Skip to content

Commit 066f401

Browse files
committed
Run e2e test by file name instead of mark
1 parent 9a76e72 commit 066f401

File tree

3 files changed

+46
-7
lines changed

3 files changed

+46
-7
lines changed

scripts/evergreen/deployments/test-app/templates/mongodb-enterprise-tests.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,19 @@ spec:
192192
image: {{ .Values.repo }}/mongodb-kubernetes-tests:{{ .Values.tag }}
193193
# Options to pytest command should go in the pytest.ini file.
194194
command: ["pytest"]
195-
{{ if .Values.otel_endpoint }}
196-
args: ["-vv", "-m", "{{ .Values.taskName }}", "--trace-parent", "00-{{ .Values.otel_trace_id }}-{{ .Values.otel_parent_id }}-01", "--export-traces"]
197-
{{ else }}
198-
args: ["-vv", "-m", "{{ .Values.taskName }}"]
199-
{{ end }}
195+
args:
196+
- "-vv"
197+
{{- if .Values.testFile }}
198+
- "{{ .Values.testFile }}"
199+
{{- else }}
200+
- "-m"
201+
- "{{ .Values.taskName }}"
202+
{{- end }}
203+
{{- if .Values.otel_endpoint }}
204+
- "--trace-parent"
205+
- "00-{{ .Values.otel_trace_id }}-{{ .Values.otel_parent_id }}-01"
206+
- "--export-traces"
207+
{{- end }}
200208
imagePullPolicy: Always
201209
volumeMounts:
202210
- name: results

scripts/evergreen/deployments/test-app/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ apiKey: omApiKey
88
orgId: ""
99
projectId: omProjectId
1010
tag:
11+
12+
# if testFile is specified, then test is executed as pytest <testFile>
13+
testFile:
14+
# if testFile is empty, executes the test by fixture mark: pytest -m <taskName>
1115
taskName: ${TASK_NAME}
1216

1317
pytest:

scripts/evergreen/e2e/single_e2e.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
set -Eeou pipefail
44

5+
test "${MDB_BASH_DEBUG:-0}" -eq 1 && set -x
56
##
67
## The script deploys a single test application and waits until it finishes.
78
## All the Operator deployment, configuration and teardown work is done in 'e2e' script
@@ -15,6 +16,23 @@ source scripts/funcs/operator_deployment
1516

1617
check_env_var "TEST_NAME" "The 'TEST_NAME' must be specified to run the Operator single e2e test"
1718

19+
find_test_file_by_fixture_mark() {
20+
fixture_mark="$1"
21+
22+
cd docker/mongodb-kubernetes-tests
23+
if ! test_files="$(grep -l -R "mark.${fixture_mark}$" --include '*.py')"; then
24+
>&2 echo "Cannot find any test file containing a pytest fixture mark: ${fixture_mark}"
25+
return 1
26+
fi
27+
number_of_files_matched=$(wc -l <<< "${test_files}")
28+
if [[ ${number_of_files_matched} -gt 1 ]]; then
29+
>&2 echo "Found more than one file with the same pytest fixture mark ${fixture_mark}:"
30+
grep --color=auto --line-number --recursive -C2 "mark.${fixture_mark}$" --include '*.py' .
31+
return 1
32+
fi
33+
34+
echo -n "${test_files}"
35+
}
1836

1937
deploy_test_app() {
2038
printenv
@@ -33,12 +51,17 @@ deploy_test_app() {
3351
BUILD_ID="${BUILD_ID:-default_build_id}"
3452
BUILD_VARIANT="${BUILD_VARIANT:-default_build_variant}"
3553

54+
if ! test_file=$(find_test_file_by_fixture_mark "${TASK_NAME}"); then
55+
return 1
56+
fi
57+
3658
# note, that the 4 last parameters are used only for Mongodb resource testing - not for Ops Manager
3759
helm_params=(
3860
"--set" "taskId=${task_id:-'not-specified'}"
3961
"--set" "repo=${BASE_REPO_URL:=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev}"
4062
"--set" "namespace=${NAMESPACE}"
4163
"--set" "taskName=${task_name}"
64+
"--set" "testFile=${test_file}"
4265
"--set" "tag=${tag}"
4366
"--set" "aws.accessKey=${AWS_ACCESS_KEY_ID}"
4467
"--set" "aws.secretAccessKey=${AWS_SECRET_ACCESS_KEY}"
@@ -128,7 +151,9 @@ deploy_test_app() {
128151

129152
helm_params+=("--set" "opsManagerVersion=${ops_manager_version}")
130153

131-
helm template "scripts/evergreen/deployments/test-app" "${helm_params[@]}" > "${helm_template_file}" || exit 1
154+
echo "Executing helm template:"
155+
echo "helm template scripts/evergreen/deployments/test-app ${helm_params[*]}"
156+
helm template "scripts/evergreen/deployments/test-app" "${helm_params[@]}" > "${helm_template_file}" || return 1
132157

133158
cat "${helm_template_file}"
134159

@@ -189,7 +214,9 @@ run_tests() {
189214

190215
prepare_operator_config_map "${operator_context}"
191216

192-
deploy_test_app "${test_pod_context}"
217+
if ! deploy_test_app "${test_pod_context}"; then
218+
return 1
219+
fi
193220

194221
wait_until_pod_is_running_or_failed_or_succeeded "${test_pod_context}"
195222

0 commit comments

Comments
 (0)