Skip to content

Commit

Permalink
[Fix] update bash scripts for E2E tests run to propagate failures (#433)
Browse files Browse the repository at this point in the history
* [Fix] update bash scripts for E2E tests run to propagate failures

We haven't been propagating the test failures in our E2E CI jobs because
we weren't checking for the return codes of the commands run in the bash
scripts.

Also, this fixes setup* targets in Makefile so that expected images are
deployed to the testing cluster.

* asdf
  • Loading branch information
jstourac authored Nov 25, 2024
1 parent 30afc15 commit 9294927
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 40 deletions.
15 changes: 5 additions & 10 deletions components/odh-notebook-controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,13 @@ endif
setup-kf: kustomize ## Replace Kustomize manifests with your environment configuration.
sed -i'' -e 's,namespace: .*,namespace: '"${K8S_NAMESPACE}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${KF_IMG}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${KF_TAG}"',' \
../notebook-controller/config/overlays/openshift/kustomization.yaml
sed -i'' -e "s,odh-kf-notebook-controller-image=.*,odh-kf-notebook-controller-image=${KF_IMG}:${KF_TAG}," \
../notebook-controller/config/overlays/openshift/params.env

.PHONY: setup
setup: manifests kustomize ## Replace Kustomize manifests with your environment configuration.
sed -i'' -e 's,namespace: .*,namespace: '"${K8S_NAMESPACE}"',' ./config/default/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${IMG}"',' ./config/base/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${TAG}"',' ./config/base/kustomization.yaml
sed -i'' -e "s,odh-notebook-controller-image=.*,odh-notebook-controller-image=${IMG}:${TAG}," ./config/base/params.env

.PHONY: setup-service-mesh
setup-service-mesh: kustomize ## Replace Kustomize manifests with your environment configuration.
Expand All @@ -153,10 +150,8 @@ setup-service-mesh: kustomize ## Replace Kustomize manifests with your environme
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,ISTIO_GATEWAY=.*,ISTIO_GATEWAY='"${K8S_NAMESPACE}/odh-gateway"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,newName: .*,newName: '"${KF_IMG}"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e 's,newTag: .*,newTag: '"${KF_TAG}"',' \
../notebook-controller/config/overlays/standalone-service-mesh/kustomization.yaml
sed -i'' -e "s,odh-kf-notebook-controller-image=.*,odh-kf-notebook-controller-image=${KF_IMG}:${KF_TAG}," \
../notebook-controller/config/overlays/openshift/params.env
sed -i'' -e 's,host: .*,host: opendatahub.'"$(shell kubectl get ingress.config.openshift.io cluster -o 'jsonpath={.spec.domain}')"',' \
../notebook-controller/config/overlays/standalone-service-mesh/gateway-route.yaml

Expand Down
51 changes: 36 additions & 15 deletions components/odh-notebook-controller/run-e2e-test-service-mesh.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
#!/usr/bin/env bash

# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuxo pipefail

echo "Running the ${0} setup"

TEST_NAMESPACE="odh-notebook-controller-system"

# setup and deploy the controller
oc new-project $TEST_NAMESPACE -n $TEST_NAMESPACE --skip-config-write
# Following variables are optional - if not set, the default values in relevant params.env
# will be used for both images. As such, if you want to run tests against your custom changes,
# be sure to perform a docker build and set these variables accordingly!
ODH_NOTEBOOK_CONTROLLER_IMAGE="${ODH_NOTEBOOK_CONTROLLER_IMAGE:-}"
KF_NOTEBOOK_CONTROLLER="${KF_NOTEBOOK_CONTROLLER:-}"

IFS=':' read -r -a CTRL_IMG <<< "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"
export IMG="${CTRL_IMG[0]}"
export TAG="${CTRL_IMG[1]}"
IFS=':' read -r -a KF_NBC_IMG <<< "${KF_NOTEBOOK_CONTROLLER}"
export KF_IMG="${KF_NBC_IMG[0]}"
export KF_TAG="${KF_NBC_IMG[1]}"
export K8S_NAMESPACE=$TEST_NAMESPACE

make deploy-service-mesh deploy-with-mesh
if test -n "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"; then
IFS=':' read -r -a CTRL_IMG <<< "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"
export IMG="${CTRL_IMG[0]}"
export TAG="${CTRL_IMG[1]}"
fi

# run e2e tests
make e2e-test-service-mesh
if test -n "${KF_NOTEBOOK_CONTROLLER}"; then
IFS=':' read -r -a KF_NBC_IMG <<< "${KF_NOTEBOOK_CONTROLLER}"
export KF_IMG="${KF_NBC_IMG[0]}"
export KF_TAG="${KF_NBC_IMG[1]}"
fi

export K8S_NAMESPACE="${TEST_NAMESPACE}"

# cleanup deployment
make undeploy-with-mesh undeploy-service-mesh
oc delete project $TEST_NAMESPACE -n $TEST_NAMESPACE
# From now on we want to be sure that undeploy and testing project deletion are called

function cleanup() {
echo "Performing deployment cleanup of the ${0}"
make undeploy-with-mesh undeploy-service-mesh && oc delete project "${TEST_NAMESPACE}"
}
trap cleanup EXIT

# setup and deploy the controller
oc new-project "${TEST_NAMESPACE}" --skip-config-write

# deploy and run e2e tests
make deploy-service-mesh deploy-with-mesh
make e2e-test-service-mesh
51 changes: 36 additions & 15 deletions components/odh-notebook-controller/run-e2e-test.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,44 @@
#!/usr/bin/env bash

# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/
set -Eeuxo pipefail

echo "Running the ${0} setup"

TEST_NAMESPACE="odh-notebook-controller-system"

# setup and deploy the controller
oc new-project $TEST_NAMESPACE -n $TEST_NAMESPACE --skip-config-write
# Following variables are optional - if not set, the default values in relevant params.env
# will be used for both images. As such, if you want to run tests against your custom changes,
# be sure to perform a docker build and set these variables accordingly!
ODH_NOTEBOOK_CONTROLLER_IMAGE="${ODH_NOTEBOOK_CONTROLLER_IMAGE:-}"
KF_NOTEBOOK_CONTROLLER="${KF_NOTEBOOK_CONTROLLER:-}"

IFS=':' read -r -a CTRL_IMG <<< "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"
export IMG="${CTRL_IMG[0]}"
export TAG="${CTRL_IMG[1]}"
IFS=':' read -r -a KF_NBC_IMG <<< "${KF_NOTEBOOK_CONTROLLER}"
export KF_IMG="${KF_NBC_IMG[0]}"
export KF_TAG="${KF_NBC_IMG[1]}"
export K8S_NAMESPACE=$TEST_NAMESPACE

make deploy
if test -n "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"; then
IFS=':' read -r -a CTRL_IMG <<< "${ODH_NOTEBOOK_CONTROLLER_IMAGE}"
export IMG="${CTRL_IMG[0]}"
export TAG="${CTRL_IMG[1]}"
fi

# run e2e tests
make e2e-test
if test -n "${KF_NOTEBOOK_CONTROLLER}"; then
IFS=':' read -r -a KF_NBC_IMG <<< "${KF_NOTEBOOK_CONTROLLER}"
export KF_IMG="${KF_NBC_IMG[0]}"
export KF_TAG="${KF_NBC_IMG[1]}"
fi

export K8S_NAMESPACE="${TEST_NAMESPACE}"

# cleanup deployment
make undeploy
oc delete project $TEST_NAMESPACE -n $TEST_NAMESPACE
# From now on we want to be sure that undeploy and testing project deletion are called

function cleanup() {
echo "Performing deployment cleanup of the ${0}"
make undeploy && oc delete project "${TEST_NAMESPACE}"
}
trap cleanup EXIT

# setup and deploy the controller
oc new-project "${TEST_NAMESPACE}"

# deploy and run e2e tests
make deploy
make e2e-test

0 comments on commit 9294927

Please sign in to comment.