Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions go.sum

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions hack/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ import (

// Needed for the storage version too.
_ "knative.dev/pkg/apiextensions/storageversion/cmd/migrate"

// For chaos testing the leaderelection stuff.
_ "knative.dev/pkg/leaderelection/chaosduck"
)
94 changes: 94 additions & 0 deletions test/config/chaosduck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Copyright 2020 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ServiceAccount
metadata:
name: chaosduck
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel

---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaosduck
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "delete"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "list"]

---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: chaosduck
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: chaosduck
subjects:
- kind: ServiceAccount
name: chaosduck
namespace: knative-eventing

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: chaosduck
namespace: knative-eventing
labels:
eventing.knative.dev/release: devel
spec:
selector:
matchLabels:
app: chaosduck
template:
metadata:
labels:
app: chaosduck
spec:
serviceAccountName: chaosduck
containers:
- name: chaosduck
# This is the Go import path for the binary that is containerized
# and substituted here.
image: ko://knative.dev/pkg/leaderelection/chaosduck

args: [
# TODO(https://github.com/knative/eventing/issues/3591): Enable once MT Broker chaos issues are fixed.
"-disable=mt-broker-controller",
# TODO(https://github.com/knative/eventing/issues/3590): Enable once IMC chaos issues are fixed.
"-disable=imc-controller", "-disable=imc-dispatcher",
]

env:
- name: SYSTEM_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace

securityContext:
allowPrivilegeEscalation: false
35 changes: 34 additions & 1 deletion test/e2e-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ readonly CONFIG_TRACING_CONFIG="test/config/config-tracing.yaml"
# PreInstall script for v0.16
readonly PRE_INSTALL_V016="config/pre-install/v0.16.0"

# The number of controlplane replicas to run.
readonly REPLICAS=3

# Should deploy a Knative Monitoring as well
readonly DEPLOY_KNATIVE_MONITORING="${DEPLOY_KNATIVE_MONITORING:-1}"

Expand Down Expand Up @@ -81,6 +84,17 @@ function knative_setup() {
install_knative_eventing
}

function scale_controlplane() {
for deployment in "$@"; do
# Make sure all pods run in leader-elected mode.
kubectl -n "${TEST_EVENTING_NAMESPACE}" scale deployment "$deployment" --replicas=0 || failed=1
# Give it time to kill the pods.
sleep 5
# Scale up components for HA tests
kubectl -n "${TEST_EVENTING_NAMESPACE}" scale deployment "$deployment" --replicas="${REPLICAS}" || failed=1
done
}

# This installs everything from the config dir but then removes the Channel Based Broker.
# TODO: This should only install the core.
# Args:
Expand Down Expand Up @@ -118,6 +132,8 @@ function install_knative_eventing() {
sed "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${TEST_EVENTING_NAMESPACE}/g" ${CONFIG_TRACING_CONFIG} > ${TMP_CONFIG_TRACING_CONFIG}
kubectl replace -f ${TMP_CONFIG_TRACING_CONFIG}

scale_controlplane eventing-webhook eventing-controller

wait_until_pods_running ${TEST_EVENTING_NAMESPACE} || fail_test "Knative Eventing did not come up"

echo "check the config map"
Expand Down Expand Up @@ -173,7 +189,10 @@ function install_mt_broker() {
cp -r ${MT_CHANNEL_BASED_BROKER_CONFIG_DIR}/* ${TMP_MT_CHANNEL_BASED_BROKER_CONFIG_DIR}
find ${TMP_MT_CHANNEL_BASED_BROKER_CONFIG_DIR} -type f -name "*.yaml" -exec sed -i "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${TEST_EVENTING_NAMESPACE}/g" {} +
ko apply --strict -f ${TMP_MT_CHANNEL_BASED_BROKER_CONFIG_DIR} || return 1
wait_until_pods_running ${TEST_EVENTING_NAMESPACE} || return 1

# TODO(https://github.com/knative/eventing/issues/3591): Enable once MT Broker chaos issues are fixed.
# scale_controlplane mt-broker-controller

wait_until_pods_running ${TEST_EVENTING_NAMESPACE} || fail_test "Knative Eventing with MT Broker did not come up"
}

Expand All @@ -184,9 +203,19 @@ function install_sugar() {
find ${TMP_SUGAR_CONTROLLER_CONFIG_DIR} -type f -name "*.yaml" -exec sed -i "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${TEST_EVENTING_NAMESPACE}/g" {} +
ko apply --strict -f ${TMP_SUGAR_CONTROLLER_CONFIG_DIR} || return 1
kubectl -n ${TEST_EVENTING_NAMESPACE} set env deployment/sugar-controller BROKER_INJECTION_DEFAULT=true || return 1

scale_controlplane sugar-controller

wait_until_pods_running ${TEST_EVENTING_NAMESPACE} || fail_test "Knative Eventing Sugar Controller did not come up"
}

function unleash_duck() {
echo "unleash the duck"
cat test/config/chaosduck.yaml | \
sed "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${TEST_EVENTING_NAMESPACE}/g" | \
ko apply --strict -f - || return $?
}

# Teardown the Knative environment after tests finish.
function knative_teardown() {
echo ">> Stopping Knative Eventing"
Expand Down Expand Up @@ -258,6 +287,10 @@ function install_channel_crds() {
cp -r ${IN_MEMORY_CHANNEL_CRD_CONFIG_DIR}/* ${TMP_IN_MEMORY_CHANNEL_CONFIG_DIR}
find ${TMP_IN_MEMORY_CHANNEL_CONFIG_DIR} -type f -name "*.yaml" -exec sed -i "s/namespace: ${KNATIVE_DEFAULT_NAMESPACE}/namespace: ${TEST_EVENTING_NAMESPACE}/g" {} +
ko apply --strict -f ${TMP_IN_MEMORY_CHANNEL_CONFIG_DIR} || return 1

# TODO(https://github.com/knative/eventing/issues/3590): Enable once IMC chaos issues are fixed.
# scale_controlplane imc-controller imc-dispatcher

wait_until_pods_running ${TEST_EVENTING_NAMESPACE} || fail_test "Failed to install the In-Memory Channel CRD"
}

Expand Down
2 changes: 2 additions & 0 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ install_mt_broker || fail_test "Could not install MT Channel Based Broker"

install_sugar || fail_test "Could not install Sugar Controller"

unleash_duck || fail_test "Could not unleash the chaos duck"

echo "Running tests with Multi Tenant Channel Based Broker"
go_test_e2e -timeout=30m -parallel=12 ./test/e2e ./test/conformance -brokerclass=MTChannelBasedBroker -channels=messaging.knative.dev/v1beta1:Channel,messaging.knative.dev/v1beta1:InMemoryChannel,messaging.knative.dev/v1:Channel,messaging.knative.dev/v1:InMemoryChannel -sources=sources.knative.dev/v1alpha2:ApiServerSource,sources.knative.dev/v1alpha2:ContainerSource,sources.knative.dev/v1alpha2:PingSource || fail_test

Expand Down
18 changes: 18 additions & 0 deletions vendor/knative.dev/pkg/kflag/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package kflag contains a variety of non-standard command-line flag types
package kflag
42 changes: 42 additions & 0 deletions vendor/knative.dev/pkg/kflag/set.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2020 The Knative Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package kflag

import (
"flag"
"fmt"

"k8s.io/apimachinery/pkg/util/sets"
)

type StringSet struct {
Value sets.String
}

var _ flag.Value = (*StringSet)(nil)

func (i *StringSet) String() string {
return fmt.Sprintf("%v", i.Value)
}

func (i *StringSet) Set(value string) error {
if i.Value == nil {
i.Value = make(sets.String, 1)
}
i.Value.Insert(value)
return nil
}
Loading