@@ -28,6 +28,42 @@ run_e2e_mco_tests() {
28
28
return ${test_results}
29
29
}
30
30
31
+ dump_cluster_information () {
32
+ # Dump information from all clusters.
33
+ # TODO: ensure cluster name is included in log files so there is no overwriting of cross cluster files.
34
+ # shellcheck disable=SC2154
35
+ if [[ " ${KUBE_ENVIRONMENT_NAME:- } " = " multi" ]]; then
36
+ echo " Dumping diagnostics for context ${CENTRAL_CLUSTER} "
37
+ dump_all " ${CENTRAL_CLUSTER} " || true
38
+
39
+ for member_cluster in ${MEMBER_CLUSTERS} ; do
40
+ echo " Dumping diagnostics for context ${member_cluster} "
41
+ dump_all " ${member_cluster} " || true
42
+ done
43
+ else
44
+ # Dump all the information we can from this namespace
45
+ dump_all || true
46
+ fi
47
+ }
48
+
49
+ delete_operator () {
50
+ local context=" ${1} "
51
+ timeout 5s helm uninstall --kube-context=" ${context} " mongodb-kubernetes-operator || true
52
+ }
53
+
54
+ cleanup_openshift_cluster (){
55
+ if [[ " ${TEST_RESULTS} " -ne 0 ]]; then
56
+ # Mark namespace as failed to be cleaned later
57
+ kubectl label " namespace/${NAMESPACE} " " evg/state=failed" --overwrite=true
58
+
59
+ if [ " ${ALWAYS_REMOVE_TESTING_NAMESPACE-} " = " true" ]; then
60
+ # Failed namespaces might cascade into more failures if the namespaces
61
+ # are not being removed soon enough.
62
+ reset_namespace " $( kubectl config current-context) " " ${NAMESPACE} " || true
63
+ fi
64
+ fi
65
+ }
66
+
31
67
if [[ -n " ${KUBECONFIG:- } " && ! -f " ${KUBECONFIG} " ]]; then
32
68
echo " Kube configuration: ${KUBECONFIG} file does not exist!"
33
69
exit 1
@@ -102,48 +138,26 @@ else
102
138
timeout --foreground " ${timeout_sec} " scripts/evergreen/e2e/single_e2e.sh || TEST_RESULTS=$?
103
139
fi
104
140
105
- # Dump information from all clusters.
106
- # TODO: ensure cluster name is included in log files so there is no overwriting of cross cluster files.
107
- # shellcheck disable=SC2154
108
- if [[ " ${KUBE_ENVIRONMENT_NAME:- } " = " multi" ]]; then
109
- echo " Dumping diagnostics for context ${CENTRAL_CLUSTER} "
110
- dump_all " ${CENTRAL_CLUSTER} " || true
111
-
112
- for member_cluster in ${MEMBER_CLUSTERS} ; do
113
- echo " Dumping diagnostics for context ${member_cluster} "
114
- dump_all " ${member_cluster} " || true
115
- done
116
- else
117
- # Dump all the information we can from this namespace
118
- dump_all || true
119
- fi
120
-
121
- # we only have static cluster in openshift, otherwise there is no need to mark and clean them up here
122
- if [[ ${CLUSTER_TYPE} == " openshift" ]]; then
123
- if [[ " ${TEST_RESULTS} " -ne 0 ]]; then
124
- # Mark namespace as failed to be cleaned later
125
- kubectl label " namespace/${NAMESPACE} " " evg/state=failed" --overwrite=true
141
+ dump_cluster_information
126
142
127
- if [ " ${ALWAYS_REMOVE_TESTING_NAMESPACE-} " = " true" ]; then
128
- # Failed namespaces might cascade into more failures if the namespaces
129
- # are not being removed soon enough.
130
- reset_namespace " $( kubectl config current-context) " " ${NAMESPACE} " || true
131
- fi
143
+ # We only have static clusters in OpenShift; otherwise, there's no need to mark and clean them up here.
144
+ if [[ " ${CLUSTER_TYPE} " == " openshift" ]]; then
145
+ cleanup_openshift_cluster
146
+ else
147
+ if [[ " ${KUBE_ENVIRONMENT_NAME} " == " multi" ]]; then
148
+ echo " Tearing down cluster ${CENTRAL_CLUSTER} "
149
+ reset_namespace " ${CENTRAL_CLUSTER} " " ${NAMESPACE} " || true
150
+
151
+ for member_cluster in ${MEMBER_CLUSTERS} ; do
152
+ echo " Tearing down cluster ${member_cluster} "
153
+ reset_namespace " ${member_cluster} " " ${NAMESPACE} " || true
154
+ done
132
155
else
133
- if [[ " ${KUBE_ENVIRONMENT_NAME} " = " multi" ]]; then
134
- echo " Tearing down cluster ${CENTRAL_CLUSTER} "
135
- reset_namespace " ${CENTRAL_CLUSTER} " " ${NAMESPACE} " || true
136
-
137
- for member_cluster in ${MEMBER_CLUSTERS} ; do
138
- echo " Tearing down cluster ${member_cluster} "
139
- reset_namespace " ${member_cluster} " " ${NAMESPACE} " || true
140
- done
141
- else
142
- # If the test pass, then the namespace is removed
143
- reset_namespace " $( kubectl config current-context) " " ${NAMESPACE} " || true
144
- fi
156
+ # If the test passed, then the namespace is removed
157
+ reset_namespace " $( kubectl config current-context) " " ${NAMESPACE} " || true
145
158
fi
146
159
fi
147
160
161
+
148
162
# We exit with the test result to surface status to Evergreen.
149
163
exit ${TEST_RESULTS}
0 commit comments