Skip to content

Commit 8305fae

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

File tree

3 files changed

+45
-7
lines changed

3 files changed

+45
-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: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ source scripts/funcs/operator_deployment
1515

1616
check_env_var "TEST_NAME" "The 'TEST_NAME' must be specified to run the Operator single e2e test"
1717

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

1936
deploy_test_app() {
2037
printenv
@@ -33,12 +50,17 @@ deploy_test_app() {
3350
BUILD_ID="${BUILD_ID:-default_build_id}"
3451
BUILD_VARIANT="${BUILD_VARIANT:-default_build_variant}"
3552

53+
if ! test_file=$(find_test_file_by_fixture_mark "${TASK_NAME}"); then
54+
return 1
55+
fi
56+
3657
# note, that the 4 last parameters are used only for Mongodb resource testing - not for Ops Manager
3758
helm_params=(
3859
"--set" "taskId=${task_id:-'not-specified'}"
3960
"--set" "repo=${BASE_REPO_URL:=268558157000.dkr.ecr.us-east-1.amazonaws.com/dev}"
4061
"--set" "namespace=${NAMESPACE}"
4162
"--set" "taskName=${task_name}"
63+
"--set" "testFile=${test_file}"
4264
"--set" "tag=${tag}"
4365
"--set" "aws.accessKey=${AWS_ACCESS_KEY_ID}"
4466
"--set" "aws.secretAccessKey=${AWS_SECRET_ACCESS_KEY}"
@@ -128,7 +150,9 @@ deploy_test_app() {
128150

129151
helm_params+=("--set" "opsManagerVersion=${ops_manager_version}")
130152

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

133157
cat "${helm_template_file}"
134158

@@ -189,7 +213,9 @@ run_tests() {
189213

190214
prepare_operator_config_map "${operator_context}"
191215

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

194220
wait_until_pod_is_running_or_failed_or_succeeded "${test_pod_context}"
195221

0 commit comments

Comments
 (0)