Skip to content

Commit

Permalink
ci: Djanicek/infraeng 487/circle test runner (#8977)
Browse files Browse the repository at this point in the history
* use circle test runner instead of splitter

* fix xargs syntax
  • Loading branch information
djanicekpach authored Mar 13, 2024
1 parent 4730d76 commit 978a02e
Showing 1 changed file with 12 additions and 29 deletions.
41 changes: 12 additions & 29 deletions .circleci/real_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -567,39 +567,22 @@ commands:
port: <<parameters.master-port>>

- run:
name: Split tests
name: Run e2e tests
working_directory: ~/project/e2e_tests
no_output_timeout: 30m
command: |
# Preselect the files that contain any matching tests to minimize how wrong CircleCI's
# splitting can get things. (The presence of files with no tests can cause the files
# with tests to be bunched up incorrectly, making the split suboptimal.)
# `--setup-plan` tells pytest to not run any tests but instead print out a description
# of the tests that would be run, along with some other stuff. Each file containing
# any selected tests is printed on a line by itself, except for (for some reason) a
# single trailing space.
pytest --setup-plan -m '<<parameters.mark>>' | egrep '\.py s*$' | sed 's/\.py.*$/.py/' > /tmp/all-relevant-files
echo 'All files with tests matching mark "<<parameters.mark>>":'
sed 's/^/- /' </tmp/all-relevant-files
circleci tests split --split-by=timings < /tmp/all-relevant-files > /tmp/tests-to-run
echo "Running tests from these files:"
sed 's/^/- /' </tmp/tests-to-run
if [ ! -s /tmp/tests-to-run ]; then
if [ ! -s /tmp/all-relevant-files ]; then
echo 'No test files found!'
exit 1
fi
- run:
name: Run e2e tests
working_directory: ~/project/e2e_tests
no_output_timeout: 30m
command: |
DD_CIVISIBILITY_AGENTLESS_ENABLED=true DD_SITE='datadoghq.com' DD_ENV=ci DD_SERVICE='pytest-<<parameters.mark>>' \
DET_MASTER_CERT_FILE=<<parameters.master-cert>> DET_MASTER_CERT_NAME=<<parameters.master-cert-name>> \
pytest -vv -s \
cat /tmp/all-relevant-files | circleci tests run --command="DD_CIVISIBILITY_AGENTLESS_ENABLED=true \
DD_SITE='datadoghq.com' \
DD_ENV=ci DD_SERVICE='pytest-<<parameters.mark>>' \
DET_MASTER_CERT_FILE=<<parameters.master-cert>> \
DET_MASTER_CERT_NAME=<<parameters.master-cert-name>> \
xargs pytest -vv -s \
-m '<<parameters.mark>>' \
--durations=0 \
--ddtrace \
Expand All @@ -608,8 +591,8 @@ commands:
--master-port="<<parameters.master-port>>" \
-o junit_family=xunit1 \
--junit-xml="<<parameters.junit-path>>" \
<<parameters.extra-pytest-flags>> \
$(< /tmp/tests-to-run)
<<parameters.extra-pytest-flags>>" \
--verbose --split-by=timings
- upload-test-job:
only_on_branch: main
test_results_path: <<parameters.junit-path>>
Expand Down

0 comments on commit 978a02e

Please sign in to comment.