1+ #! /bin/bash
2+
3+ # cleanup on EXIT regardles of error
4+
5+ # Inputs to this file as environment variables
6+ # SERVICE
7+ # SERVICE_REGION
8+ # CLUSTER_REGION
9+ # CLUSTER_NAME
10+ # SERVICE_REPO_PATH
11+ # NAMESPACE
12+
13+ set -euo pipefail
14+ export NAMESPACE=${NAMESPACE:- " ack-system" }
15+ export AWS_DEFAULT_REGION=$SERVICE_REGION
16+ export E2E_DIR=$SERVICE_REPO_PATH /test/e2e/
17+ SCRIPTS_DIR=${SERVICE_REPO_PATH} /test/canary/scripts
18+
19+ source $SCRIPTS_DIR /setup_oidc.sh
20+ source $SCRIPTS_DIR /install_controller_helm.sh
21+
22+ function print_controller_logs() {
23+ pod_id=$( kubectl get pods -n $NAMESPACE --field-selector=" status.phase=Running" \
24+ --sort-by=.metadata.creationTimestamp \
25+ | grep ack-sagemaker-controller | awk ' {print $1}' 2> /dev/null )
26+
27+ kubectl -n $NAMESPACE logs " $pod_id "
28+ }
29+
30+ function cleanup {
31+ echo " Cleaning up resources"
32+ set +e
33+ kubectl delete endpoints.sagemaker --all
34+ kubectl delete endpointconfigs --all
35+ kubectl delete models --all
36+ kubectl delete trainingjobs --all
37+ kubectl delete processingjobs --all
38+ kubectl delete transformjobs --all
39+ kubectl delete hyperparametertuningjobs --all
40+ kubectl delete dataqualityjobdefinitions --all
41+ kubectl delete modelbiasjobdefinitions --all
42+ kubectl delete modelexplainabilityjobdefinitions --all
43+ kubectl delete modelqualityjobdefinitions --all
44+ kubectl delete monitoringschedules --all
45+ kubectl delete adoptedresources --all
46+
47+ print_controller_logs
48+
49+ helm delete -n $NAMESPACE ack-$SERVICE -controller
50+ kubectl delete namespace $NAMESPACE
51+
52+ cd $E2E_DIR
53+ export PYTHONPATH=..
54+ python service_cleanup.py
55+
56+ }
57+ trap cleanup EXIT
58+
59+ # Update kubeconfig
60+ aws --region $CLUSTER_REGION eks update-kubeconfig --name $CLUSTER_NAME
61+
62+ # Setup OIDC
63+ create_oidc_role " $CLUSTER_NAME " " $CLUSTER_REGION " " $NAMESPACE "
64+
65+ # Install service helm chart
66+ install_helm_chart $SERVICE $OIDC_ROLE_ARN $SERVICE_REGION $NAMESPACE
67+
68+ echo " Log helm charts are deployed properly"
69+ kubectl -n $NAMESPACE get pods
70+ kubectl get crds
71+
72+ pushd $E2E_DIR
73+ export PYTHONPATH=..
74+ # create resources for test
75+ python service_bootstrap.py
76+ sleep 5m
77+
78+ # run tests
79+ echo " Run Tests"
80+ pytest -n 10 --dist loadfile --log-cli-level INFO -m canary
81+ popd
0 commit comments