Python Django tests not being split correctly

When I split tests all the tests 532 of them go to one test container and the other containers don’t get anything.

Configuration:

  test-parallel:
    <<: *python-postgres
    parallelism: 4

    steps:
      - checkout
      - run: echo $(circleci tests glob "ff/mods/**/tests/**/*.py" "ff/**/tests.py" "ff/**/test_*.py" "ff/**/*_test.py" "ff/tests/*.py")
      - run: echo $(circleci tests glob "ff/mods/**/tests/**/*.py" "ff/**/tests.py" "ff/**/test_*.py" "ff/**/*_test.py" "ff/tests/*.py" | tr ' ' '\n' | wc -l)
      - run:
          name: test
          command: |
            # get test files while ignoring __init__ files
            TESTFILES=$(circleci tests glob "ff/mods/**/tests/**/*.py" "ff/**/tests.py" "ff/**/test_*.py" "ff/**/*_test.py" "ff/tests/*.py"  | sed 's/\S\+__init__.py//g')
            # reformat to remove duplicates, remove dups, reformat back
            echo $TESTFILES | tr ' ' '\n' | sort | uniq | tr '\n' ' ' > circleci_test_files.txt
            cat circleci_test_files.txt
            cat circleci_test_files.txt | tr ' ' '\n' | wc -l
            # split test files into seperate sets depending on parallel container
            TESTFILES=$(circleci tests split circleci_test_files.txt)
            # massage filepaths into format manage.py test accepts
            TESTFILES=$(echo $TESTFILES | tr "/" "." | sed 's/.py//g')
            echo $TESTFILES
            echo $TESTFILES | tr ' ' '\n' | wc -l

https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/0?filterBy=ALL

ff/core/permissions/tests.py ... output truncated ... ff/tests/test_sanitize.py ff/tests/test_serializers.py ff/tests/test_user.py 532
ff.core.permissions.tests ...output truncated... ff.tests.test_user
532
CircleCI received exit code 0

https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/1?filterBy=ALL

ff/core/permissions/tests.py ... output truncated ... ff/tests/test_serializers.py ff/tests/test_user.py 532

1
CircleCI received exit code 0

I also tried with echoing $TESTFILES directly into circleci tests split but that didn’t work either

Fixed - I just removed | tr '\n' ' ' from echo $TESTFILES | tr ' ' '\n' | sort | uniq | tr '\n' ' ' > circleci_test_files.txt and it worked

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.