提问者:小点点

具有并行性的Circleci-每个容器执行所有测试


我希望我的集成测试在Circleci上并行运行。我https://circleci.com/blog/how-to-boost-build-time-with-test-parallelism/阅读了这个文档,并像这样设置我的工作

platform_component_test:
  working_directory: *workspace_root
  executor: ubuntu-machine
  parallelism: 16
  steps:
    - prepare_workspace
    - run:
        name: 'Run Platform Component tests'
        command:
          ./gradlew platform:componentTest -PtestFilter="`circleci tests glob "platform/src/componentTest/java/**/*.java"|circleci tests split`"

通过查看UI,我看到生成的16个容器中的每一个都执行所有测试。我错过了什么吗?


共1个答案

匿名用户

我最后稍微修改了一下,并结合了我从这里和这里学到的东西来构建这个:

      - run:
          name: Run tests in parallel
          # Use "./gradlew test" instead if tests are not run in parallel
          command: |
            cd module-with-tests-to-run/src/test/kotlin
            # Get list of classnames of tests that should run on this node
            CLASSNAMES=$(circleci tests glob "**/**Test.kt" \
              | cut -c 1- | sed 's@/@.@g' \
              | sed 's/.\{3\}$//' \
              | circleci tests split --split-by=timings --timings-type=classname)
            cd ../../../..
            # Format the arguments to "./gradlew test"
            GRADLE_ARGS=$(echo $CLASSNAMES | awk '{for (i=1; i<=NF; i++) print "--tests",$i}')
            echo "Prepared arguments for Gradle: $GRADLE_ARGS"
            ./gradlew clean module-with-tests-to-run:test $GRADLE_ARGS

注意:我试图得到正确的格式,但我可能会出错。