-
Notifications
You must be signed in to change notification settings - Fork 630
Enable e2e testing for NATSS #1126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
1493fa7
9279b80
3c23fa5
450b20b
6f343c0
2c1219c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,21 +30,24 @@ source $(dirname $0)/../vendor/github.com/knative/test-infra/scripts/e2e-tests.s | |
|
|
||
| readonly EVENTING_CONFIG="config/" | ||
|
|
||
| # In-memory provisioner config. | ||
| readonly IN_MEMORY_CHANNEL_CONFIG="config/provisioners/in-memory-channel/in-memory-channel.yaml" | ||
|
|
||
| # GCP PubSub config template. | ||
| # GCP PubSub provisioner config template. | ||
| readonly GCP_PUBSUB_CONFIG_TEMPLATE="contrib/gcppubsub/config/gcppubsub.yaml" | ||
| # Real GCP PubSub config, generated from the template. | ||
| # Real GCP PubSub provisioner config, generated from the template. | ||
| readonly GCP_PUBSUB_CONFIG="$(mktemp)" | ||
|
|
||
| # TODO(Fredy-Z): delete this flag after https://github.com/knative/test-infra/pull/692 is merged and updated | ||
| E2E_PROJECT_ID="" | ||
|
|
||
| # Constants used for creating ServiceAccount for GCP PubSub provisioner setup if it's not running on Prow. | ||
| readonly PUBSUB_SERVICE_ACCOUNT="eventing_pubsub_test" | ||
| readonly PUBSUB_SERVICE_ACCOUNT="eventing-pubsub-test" | ||
| readonly PUBSUB_SERVICE_ACCOUNT_KEY="$(mktemp)" | ||
| readonly PUBSUB_SECRET_NAME="gcppubsub-channel-key" | ||
|
|
||
| # NATS Streaming installation config. | ||
| readonly NATSS_INSTALLATION_CONFIG="contrib/natss/config/broker/natss.yaml" | ||
| # NATSS provisioner config. | ||
| readonly NATSS_CONFIG="contrib/natss/config/provisioner.yaml" | ||
|
|
||
| # Setup the Knative environment for running tests. | ||
| function knative_setup() { | ||
| # Install the latest stable Knative/serving in the current cluster. | ||
|
|
@@ -55,40 +58,53 @@ function knative_setup() { | |
| echo "Installing Knative Eventing" | ||
| ko apply -f ${EVENTING_CONFIG} || return 1 | ||
| wait_until_pods_running knative-eventing || fail_test "Knative Eventing did not come up" | ||
| } | ||
|
|
||
| # Teardown the Knative environment after tests finish. | ||
| function knative_teardown() { | ||
| echo ">> Stopping Knative Eventing" | ||
| echo "Uninstalling Knative Eventing" | ||
| ko delete --ignore-not-found=true --now --timeout 60s -f ${EVENTING_CONFIG} | ||
| } | ||
|
|
||
| # Setup resources common to all eventing tests. | ||
| function test_setup() { | ||
| # Install provisioners used by the tests. | ||
| echo "Installing In-Memory ClusterChannelProvisioner" | ||
| ko apply -f ${IN_MEMORY_CHANNEL_CONFIG} || return 1 | ||
| wait_until_pods_running knative-eventing || fail_test "Failed to install the In-Memory ClusterChannelProvisioner" | ||
|
|
||
| E2E_PROJECT_ID="$(gcloud config get-value project)" | ||
| echo "Installing GCPPubSub ClusterChannelProvisioner" | ||
| gcppubsub_setup | ||
| gcppubsub_setup || return 1 | ||
| sed "s/REPLACE_WITH_GCP_PROJECT/${E2E_PROJECT_ID}/" ${GCP_PUBSUB_CONFIG_TEMPLATE} > ${GCP_PUBSUB_CONFIG} | ||
| ko apply -f ${GCP_PUBSUB_CONFIG} | ||
| ko apply -f ${GCP_PUBSUB_CONFIG} || return 1 | ||
| wait_until_pods_running knative-eventing || fail_test "Failed to install the GCPPubSub ClusterChannelProvisioner" | ||
| } | ||
|
|
||
| # Teardown the Knative environment after tests finish. | ||
| function knative_teardown() { | ||
| echo ">> Stopping Knative Eventing" | ||
| echo "Uninstalling Knative Eventing" | ||
| ko delete --ignore-not-found=true --now --timeout 60s -f ${EVENTING_CONFIG} | ||
| echo "Installing NATSS ClusterChannelProvisioner" | ||
| natss_setup || return 1 | ||
| ko apply -f ${NATSS_CONFIG} || return 1 | ||
| wait_until_pods_running knative-eventing || fail_test "Failed to install the NATSS ClusterChannelProvisioner" | ||
|
|
||
| # Publish test images. | ||
| echo ">> Publishing test images" | ||
| $(dirname $0)/upload-test-images.sh e2e || fail_test "Error uploading test images" | ||
| } | ||
|
|
||
| # Tear down resources used in the eventing tests. | ||
| function test_teardown() { | ||
| # Uninstall provisioners used by the tests. | ||
| echo "Uninstalling In-Memory ClusterChannelProvisioner" | ||
| ko delete --ignore-not-found=true --now --timeout 60s -f ${IN_MEMORY_CHANNEL_CONFIG} | ||
|
|
||
| echo "Uninstalling GCPPubSub ClusterChannelProvisioner" | ||
| gcppubsub_teardown | ||
| ko delete --ignore-not-found=true --now --timeout 60s -f ${GCP_PUBSUB_CONFIG} | ||
|
|
||
| wait_until_object_does_not_exist namespaces knative-eventing | ||
| } | ||
| echo "Uninstalling NATSS ClusterChannelProvisioner" | ||
| natss_teardown | ||
| ko delete --ignore-not-found=true --now --timeout 60s -f ${NATSS_CONFIG} | ||
|
|
||
| # Setup resources common to all eventing tests. | ||
| function test_setup() { | ||
| # Publish test images. | ||
| echo ">> Publishing test images" | ||
| $(dirname $0)/upload-test-images.sh e2e || fail_test "Error uploading test images" | ||
| wait_until_object_does_not_exist namespaces knative-eventing | ||
| } | ||
|
|
||
| # Create resources required for GCP PubSub provisioner setup | ||
|
|
@@ -124,19 +140,33 @@ function gcppubsub_teardown() { | |
| kubectl -n knative-eventing delete secret ${PUBSUB_SECRET_NAME} | ||
| } | ||
|
|
||
| # Create resources required for NATSS provisioner setup | ||
| function natss_setup() { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this be in a separate script ? I assume this file can become messy w/ future addons, like for Kafka.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 for moving support functions to a separate file. But this can be done in a separate PR IMO. |
||
| echo "Installing NATS Streaming" | ||
| kubectl create namespace natss || return 1 | ||
| kubectl label namespace natss istio-injection=enabled || return 1 | ||
| kubectl apply -n natss -f ${NATSS_INSTALLATION_CONFIG} || return 1 | ||
| } | ||
|
|
||
| # Delete resources used for NATSS provisioner setup | ||
| function natss_teardown() { | ||
| echo "Uninstalling NATS Streaming" | ||
| kubectl delete -f ${NATSS_INSTALLATION_CONFIG} | ||
| kubectl delete namespace natss | ||
| } | ||
|
|
||
| function dump_extra_cluster_state() { | ||
| # Collecting logs from all knative's eventing pods. | ||
| echo "============================================================" | ||
| for namespace in "knative-eventing" "e2etestfn3"; do | ||
| for pod in $(kubectl get pod -n $namespace | grep Running | awk '{print $1}' ); do | ||
| for container in $(kubectl get pod "${pod}" -n $namespace -ojsonpath='{.spec.containers[*].name}'); do | ||
| echo "Namespace, Pod, Container: ${namespace}, ${pod}, ${container}" | ||
| kubectl logs -n $namespace "${pod}" -c "${container}" || true | ||
| echo "----------------------------------------------------------" | ||
| echo "Namespace, Pod, Container (Previous instance): ${namespace}, ${pod}, ${container}" | ||
| kubectl logs -p -n $namespace "${pod}" -c "${container}" || true | ||
| echo "============================================================" | ||
| done | ||
| local namespace="knative-eventing" | ||
| for pod in $(kubectl get pod -n $namespace | grep Running | awk '{print $1}' ); do | ||
| for container in $(kubectl get pod "${pod}" -n $namespace -ojsonpath='{.spec.containers[*].name}'); do | ||
| echo "Namespace, Pod, Container: ${namespace}, ${pod}, ${container}" | ||
| kubectl logs -n $namespace "${pod}" -c "${container}" || true | ||
| echo "----------------------------------------------------------" | ||
| echo "Namespace, Pod, Container (Previous instance): ${namespace}, ${pod}, ${container}" | ||
| kubectl logs -p -n $namespace "${pod}" -c "${container}" || true | ||
| echo "============================================================" | ||
| done | ||
| done | ||
| } | ||
|
|
@@ -145,6 +175,6 @@ function dump_extra_cluster_state() { | |
|
|
||
| initialize $@ | ||
|
|
||
| go_test_e2e -timeout=20m ./test/e2e -run ^TestMain$ -runFromMain=true -clusterChannelProvisioners=in-memory-channel,in-memory || fail_test | ||
| go_test_e2e -timeout=20m ./test/e2e -run ^TestMain$ -runFromMain=true -clusterChannelProvisioners=in-memory-channel,in-memory,natss || fail_test | ||
|
|
||
| success | ||
Uh oh!
There was an error while loading. Please reload this page.