fix github actions build failure (#1054)
* test * add timeout * trigger * add timeout to 60 min * test * test * test * fix what tests each instance is running * github fix for abstract tests * remove file * removed echo * test circleci * escape * single? * test * bigger timeout * add a bit more debugging * fix circleci * split in half * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * circleci should work now * circleci should work now * drop splitting as it seems un-needed * remove file when done * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * trigger * trigger * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * trigger * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * test * trigger * test * test * test * test * added README * refactor load images * enable reuse * increaase timeout * increaase timeout * test * test * test * test * no return * test * test * test * test * test * test * test * test * test * test * test * test * test * disable test * pom * enable test back
This commit is contained in:
11
.github/workflows/composites/build-controllers-project/action.yaml
vendored
Normal file
11
.github/workflows/composites/build-controllers-project/action.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: build controllers project
|
||||
description: build controllers project
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: build controllers project
|
||||
shell: bash
|
||||
run: |
|
||||
cd spring-cloud-kubernetes-controllers
|
||||
.././mvnw -T 1C clean install
|
||||
cd ..
|
||||
12
.github/workflows/composites/build-integration-tests-project/action.yaml
vendored
Normal file
12
.github/workflows/composites/build-integration-tests-project/action.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: build integration tests project without tests
|
||||
description: build integration tests project without tests
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: build integration tests project without tests
|
||||
shell: bash
|
||||
run: |
|
||||
cd spring-cloud-kubernetes-integration-tests
|
||||
# build the images, but dont run the tests
|
||||
.././mvnw -T 1C clean install -DskipTests
|
||||
cd ..
|
||||
11
.github/workflows/composites/cache/action.yaml
vendored
Normal file
11
.github/workflows/composites/cache/action.yaml
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
name: cache
|
||||
description: cache
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-cache-${{ env.BRANCH_NAME }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-cache-${{ env.BRANCH_NAME }}-${{ hashFiles('**/pom.xml') }}
|
||||
15
.github/workflows/composites/download-docker-images/action.yaml
vendored
Normal file
15
.github/workflows/composites/download-docker-images/action.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# we are not going to use upload/download actions, since it is slower than cache usage
|
||||
# as key to the cache we are going to use DOCKER_IMAGES_KEY, which is the same as GITHUB_RUN_ID
|
||||
|
||||
name: download docker images
|
||||
description: download docker images
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/docker/images
|
||||
key: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}
|
||||
restore-keys: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}
|
||||
|
||||
|
||||
10
.github/workflows/composites/echo-saved-images/action.yaml
vendored
Normal file
10
.github/workflows/composites/echo-saved-images/action.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
name: echo saved images
|
||||
description: echo saved images
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: echo saved images
|
||||
shell: bash
|
||||
run: |
|
||||
VIEW=$(ls -l /tmp/docker/images)
|
||||
echo "${VIEW}"
|
||||
10
.github/workflows/composites/env-variables/action.yaml
vendored
Normal file
10
.github/workflows/composites/env-variables/action.yaml
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
name: sets environment variables
|
||||
description: sets environment variables
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: set env variables
|
||||
shell: bash
|
||||
run: |
|
||||
echo "BRANCH_NAME=$(echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV
|
||||
echo "DOCKER_IMAGES_KEY=$(echo $GITHUB_RUN_ID)" >> $GITHUB_ENV
|
||||
12
.github/workflows/composites/fabric8-istio-integration-test/action.yaml
vendored
Normal file
12
.github/workflows/composites/fabric8-istio-integration-test/action.yaml
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
name: run fabric8 istio integration test
|
||||
description: run fabric8 istio integration test
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: run fabric8 istio integration test
|
||||
shell: bash
|
||||
run: |
|
||||
docker load -i /tmp/docker/images/spring-cloud-kubernetes-fabric8-istio-it.tar
|
||||
cd spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/
|
||||
../.././mvnw clean install -Dskip.build.image=true
|
||||
cd ../..
|
||||
14
.github/workflows/composites/fabric8-istio/action.yaml
vendored
Normal file
14
.github/workflows/composites/fabric8-istio/action.yaml
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# build a lightweight project so that dependencies for the
|
||||
# maven-surefire-plugin are downloaded and thus cached also
|
||||
|
||||
name: build fabric8 istio project
|
||||
description: build fabric8 istio projects
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: build fabric8 istio project
|
||||
shell: bash
|
||||
run: |
|
||||
cd spring-cloud-kubernetes-fabric8-istio
|
||||
.././mvnw -s ../.settings.xml clean install -U
|
||||
cd ..
|
||||
22
.github/workflows/composites/load-docker-images/action.yaml
vendored
Normal file
22
.github/workflows/composites/load-docker-images/action.yaml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: install docker images
|
||||
description: load docker images from tar
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: load docker images
|
||||
shell: bash
|
||||
run: |
|
||||
|
||||
# get the name of the images to load from children of spring-cloud-kubernetes-controllers
|
||||
cd spring-cloud-kubernetes-controllers
|
||||
while read controller_image; do
|
||||
docker load -i /tmp/docker/images/${controller_image}.tar
|
||||
done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q | grep -v 'spring-cloud-kubernetes-controllers')
|
||||
cd ..
|
||||
|
||||
# get the name of the images to load from children of spring-cloud-kubernetes-integration-tests
|
||||
cd spring-cloud-kubernetes-integration-tests
|
||||
while read integration_test_image; do
|
||||
docker load -i /tmp/docker/images/${integration_test_image}.tar
|
||||
done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q | grep -v 'spring-cloud-kubernetes-integration-tests')
|
||||
cd ..
|
||||
15
.github/workflows/composites/save-controller-images/action.yaml
vendored
Normal file
15
.github/workflows/composites/save-controller-images/action.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: save controller docker images
|
||||
description: save controller docker images
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: save controller docker images
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/docker/images
|
||||
TAG=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
|
||||
cd spring-cloud-kubernetes-controllers
|
||||
while read controller_image; do
|
||||
docker save -o /tmp/docker/images/${controller_image}.tar docker.io/springcloud/${controller_image}:$TAG
|
||||
done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q | grep -v 'spring-cloud-kubernetes-controllers')
|
||||
cd ..
|
||||
15
.github/workflows/composites/save-integration-tests-images/action.yaml
vendored
Normal file
15
.github/workflows/composites/save-integration-tests-images/action.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
name: save integration tests docker images
|
||||
description: save integration tests docker images
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: save integration tests docker images
|
||||
shell: bash
|
||||
run: |
|
||||
mkdir -p /tmp/docker/images
|
||||
TAG=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
|
||||
cd spring-cloud-kubernetes-integration-tests
|
||||
while read integ_test; do
|
||||
docker save -o /tmp/docker/images/${integ_test}.tar docker.io/springcloud/${integ_test}:$TAG
|
||||
done < <(mvn -Dexec.executable='echo' -Dexec.args='${project.artifactId}' exec:exec -q | grep -v 'spring-cloud-kubernetes-integration-tests')
|
||||
cd ..
|
||||
9
.github/workflows/composites/setup/action.yaml
vendored
Normal file
9
.github/workflows/composites/setup/action.yaml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
name: setup project
|
||||
description: setup project
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
15
.github/workflows/composites/upload-docker-images/action.yaml
vendored
Normal file
15
.github/workflows/composites/upload-docker-images/action.yaml
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# we are not going to use upload/download actions, since it is slower than cache usage
|
||||
# as key to the cache we are going to use DOCKER_IMAGES_KEY, which is the same as GITHUB_RUN_ID
|
||||
|
||||
name: upload docker images
|
||||
description: upload docker images
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/docker/images
|
||||
key: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}
|
||||
restore-keys: docker-images-cache-${{ env.DOCKER_IMAGES_KEY }}
|
||||
|
||||
|
||||
315
.github/workflows/maven.yaml
vendored
315
.github/workflows/maven.yaml
vendored
@@ -7,88 +7,80 @@ on:
|
||||
branches: [ main ]
|
||||
|
||||
jobs:
|
||||
# build the project, skip tests, update snapshots
|
||||
###########################################################################################################################
|
||||
######################################## Build test support dependency and Run test #######################################
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
env:
|
||||
TESTCONTAINERS_REUSE_ENABLE: false
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Extract branch name
|
||||
id: extract_branch
|
||||
shell: bash
|
||||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_HEAD_REF})"
|
||||
- name: checkout project
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# if this is the first build, this is a NOOP and every dependency is downloaded.
|
||||
# if this is != first build, cache is restored. We then issue mvn clean install with "-U",
|
||||
# and thus update any third party snapshots; also we build the project, thus update
|
||||
# any inter-module snapshot dependencies.
|
||||
# only after that is the cache saved, which is what we want. Any subsequent restores as such
|
||||
# will have the latest versions of snapshots available.
|
||||
- name: Cache local Maven repository
|
||||
id: cache-maven-repo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: setup project
|
||||
uses: ./.github/workflows/composites/setup
|
||||
|
||||
- if: ${{ steps.cache-maven-repo.outputs.cache-hit == 'false' }}
|
||||
name: cache miss callback
|
||||
continue-on-error: false
|
||||
run: echo 'cache miss'
|
||||
- name: set env variables
|
||||
uses: ./.github/workflows/composites/env-variables
|
||||
|
||||
- if: ${{ steps.cache-maven-repo.outputs.cache-hit == 'true' }}
|
||||
name: cache hit callback
|
||||
continue-on-error: false
|
||||
run: echo 'cache hit'
|
||||
- name: cache local maven repository
|
||||
uses: ./.github/workflows/composites/cache
|
||||
|
||||
- name: Build with skip tests
|
||||
run: ./mvnw -s .settings.xml clean install -U -DskipTests
|
||||
- name: build fabric8 istio
|
||||
uses: ./.github/workflows/composites/fabric8-istio
|
||||
|
||||
- name: build with skip tests and skip images
|
||||
run: ./mvnw -T 1C -s .settings.xml clean install -U -DskipTests -Dskip.build.image=true
|
||||
|
||||
- name: build controllers project
|
||||
uses: ./.github/workflows/composites/build-controllers-project
|
||||
|
||||
- name: build integration tests project
|
||||
uses: ./.github/workflows/composites/build-integration-tests-project
|
||||
|
||||
- name: save controller docker images
|
||||
uses: ./.github/workflows/composites/save-controller-images
|
||||
|
||||
- name: save integration tests docker images
|
||||
uses: ./.github/workflows/composites/save-integration-tests-images
|
||||
|
||||
- name: echo saved images
|
||||
uses: ./.github/workflows/composites/echo-saved-images
|
||||
|
||||
- name: upload docker images
|
||||
uses: ./.github/workflows/composites/upload-docker-images
|
||||
|
||||
# we need to run some test, so that K3s container is started and then all other instances will re-use this one.
|
||||
# Otherwise, (since we use static ports) there might be two instances starting at the same time, and ports might conflict
|
||||
###########################################################################################################################
|
||||
###################################################### Fabric8 istio test #################################################
|
||||
fabric8_istio_test:
|
||||
fabric8_istio_integration_test:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: checkout project
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Cache local Maven repository
|
||||
id: cache-maven-repo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: setup project
|
||||
uses: ./.github/workflows/composites/setup
|
||||
|
||||
- name: test fabric8 istio
|
||||
run: |
|
||||
cd spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-fabric8-istio-it/
|
||||
../.././mvnw clean install
|
||||
cd ../..
|
||||
- name: set env variables
|
||||
uses: ./.github/workflows/composites/env-variables
|
||||
|
||||
- name: cache local maven repository
|
||||
uses: ./.github/workflows/composites/cache
|
||||
|
||||
- name: download docker images
|
||||
uses: ./.github/workflows/composites/download-docker-images
|
||||
|
||||
- name: echo saved images
|
||||
uses: ./.github/workflows/composites/echo-saved-images
|
||||
|
||||
- name: integration test fabric8 istio
|
||||
uses: ./.github/workflows/composites/fabric8-istio-integration-test
|
||||
|
||||
test:
|
||||
needs: build
|
||||
needs: [ build, fabric8_istio_integration_test ]
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
@@ -97,102 +89,155 @@ jobs:
|
||||
number_of_jobs: [32]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-java@v2
|
||||
name: Set up JDK
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
|
||||
- name: Cache local Maven repository
|
||||
id: cache-maven-repo
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: ${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-maven-${{ steps.extract_branch.outputs.branch }}-${{ hashFiles('**/pom.xml') }}
|
||||
- name: testcontainers reuse support
|
||||
run: echo "testcontainers.reuse.enable=true" > ~/.testcontainers.properties
|
||||
|
||||
- name: checkout project
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: setup project
|
||||
uses: ./.github/workflows/composites/setup
|
||||
|
||||
- name: set env variables
|
||||
uses: ./.github/workflows/composites/env-variables
|
||||
|
||||
- name: cache local maven repository
|
||||
uses: ./.github/workflows/composites/cache
|
||||
|
||||
- name: download docker images
|
||||
uses: ./.github/workflows/composites/download-docker-images
|
||||
|
||||
- name: load docker images into local repo
|
||||
uses: ./.github/workflows/composites/load-docker-images
|
||||
|
||||
- name: run tests
|
||||
env:
|
||||
CURRENT_INDEX: ${{ matrix.current_index }}
|
||||
NUMBER_OF_JOBS: ${{ matrix.number_of_jobs }}
|
||||
run: |
|
||||
# find all tests
|
||||
# exclude Fabric8IstionIT
|
||||
# only take classes that have @Test inside them
|
||||
# drop the "begining" xxx/src/test/java
|
||||
# replace / with .
|
||||
# drop last ".java"
|
||||
# replace newline with space
|
||||
# sort
|
||||
|
||||
CLASSNAMES=($(find . -name '*.java' \
|
||||
| grep 'src/test/java' \
|
||||
| grep -v 'Fabric8IstioIT' \
|
||||
| xargs grep -l '@Test' \
|
||||
| sed 's/.*src.test.java.//g' \
|
||||
| sed 's@/@.@g' \
|
||||
| sed 's/.\{5\}$//' \
|
||||
| sort \
|
||||
| tr '\n' ' '))
|
||||
# - find all tests
|
||||
# - exclude Fabric8IstionIT
|
||||
# - only take classes that have @Test inside them
|
||||
# - ignore the ones that have 'abstract class'. we do this because otherwise we would pass
|
||||
# to -DtestsToRun an abstract class, and it will not run anything.
|
||||
# - drop the "begining" xxx/src/test/java
|
||||
# - replace / with .
|
||||
# - drop last ".java"
|
||||
# - replace newline with space
|
||||
# - replace '\n' with ' '
|
||||
|
||||
number_of_tests=${#CLASSNAMES[@]}
|
||||
number_of_jobs=${NUMBER_OF_JOBS}
|
||||
current_index=${CURRENT_INDEX}
|
||||
PLAIN_TEST_CLASSNAMES=($(find . -name '*.java' \
|
||||
| grep 'src/test/java' \
|
||||
| grep -v 'Fabric8IstioIT' \
|
||||
| xargs grep -l '@Test' \
|
||||
| xargs grep -L 'abstract class' \
|
||||
| sed 's/.*src.test.java.//g' \
|
||||
| sed 's@/@.@g' \
|
||||
| sed 's/.\{5\}$//' \
|
||||
| tr '\n' ' '))
|
||||
|
||||
per_instance=$((number_of_tests / number_of_jobs))
|
||||
# classes that have @Test and are abstract, for example: "LabeledSecretWithPrefixTests"
|
||||
# - exclude Fabric8IstionIT
|
||||
# - only take classes that have @Test inside them
|
||||
# - only take classes that are abstract
|
||||
# - drop everything up until the last "/"
|
||||
# - drop ".java"
|
||||
|
||||
# we do not get an ideal distribution all the time, so this is needed to add one more test
|
||||
# to the first "reminder" number of instances.
|
||||
ABSTRACT_TEST_CLASSNAMES_COMMAND="find . -name '*.java' \
|
||||
| grep 'src/test/java' \
|
||||
| grep -v 'Fabric8IstioIT' \
|
||||
| xargs grep -l '@Test' \
|
||||
| xargs grep -l 'abstract class' \
|
||||
| sed 's/.*\///g' \
|
||||
| sed 's/.java//g'"
|
||||
|
||||
# consider the case when there are 10 tests, and 4 instances
|
||||
# 10/4=2 (and this is "per_instance"), at the same time "reminder" = (10 - 4 * 2) = 2
|
||||
# this means that the first instance will run (2 + 1) tests
|
||||
# second instance will run (2 + 1) tests
|
||||
# all subsequent instances will run 2 tests.
|
||||
# find classes that extend abstract test classes
|
||||
DERIVED_FROM_ABSTRACT_CLASSES_COMMAND="find . -name '*.java' \
|
||||
| grep 'src/test/java' \
|
||||
| grep -v 'Fabric8IstioIT' \
|
||||
| xargs grep -l 'extends replace_me ' \
|
||||
| sed 's/.*src.test.java.//g' \
|
||||
| sed 's@/@.@g' \
|
||||
| sed 's/.\{5\}$//' \
|
||||
| tr '\n' ' '"
|
||||
|
||||
reminder=$((number_of_tests - number_of_jobs * per_instance))
|
||||
elements_in_current_instance=$((per_instance + 1))
|
||||
while read class_name; do
|
||||
replaced=$(echo ${DERIVED_FROM_ABSTRACT_CLASSES_COMMAND/replace_me/"$class_name"})
|
||||
result=($(eval $replaced))
|
||||
PLAIN_TEST_CLASSNAMES+=(${result[@]})
|
||||
done < <(eval $ABSTRACT_TEST_CLASSNAMES_COMMAND)
|
||||
|
||||
left_bound=0
|
||||
right_bound=0
|
||||
IFS=$'\n'
|
||||
SORTED_TEST_CLASSNAMES=( $(sort <<< "${PLAIN_TEST_CLASSNAMES[*]} | uniq -u") )
|
||||
unset IFS
|
||||
|
||||
# we are in a range where we might need to add one more test to each instance
|
||||
# notice the "less then" condition here, it is important and must not change
|
||||
if [[ $current_index -lt $reminder ]]; then
|
||||
number_of_tests=${#SORTED_TEST_CLASSNAMES[@]}
|
||||
number_of_jobs=${NUMBER_OF_JOBS}
|
||||
current_index=${CURRENT_INDEX}
|
||||
|
||||
# this one is easy, the range will be [0..3] (following our example above)
|
||||
if [[ $current_index == 0 ]]; then
|
||||
left_bound=0
|
||||
right_bound=$elements_in_current_instance
|
||||
# this one will be [3..6]
|
||||
else
|
||||
left_bound=$((current_index * elements_in_current_instance))
|
||||
right_bound=$(((current_index + 1) * elements_in_current_instance))
|
||||
fi
|
||||
per_instance=$((number_of_tests / number_of_jobs))
|
||||
|
||||
echo "total tests : $number_of_tests, jobs: $number_of_jobs, current index : $current_index. will run tests in range : [$left_bound..$right_bound]"
|
||||
# we do not get an ideal distribution all the time, so this is needed to add one more test
|
||||
# to the first "reminder" number of instances.
|
||||
|
||||
else
|
||||
# consider the case when there are 10 tests, and 4 instances
|
||||
# 10/4=2 (and this is "per_instance"), at the same time "reminder" = (10 - 4 * 2) = 2
|
||||
# this means that the first instance will run (2 + 1) tests
|
||||
# second instance will run (2 + 1) tests
|
||||
# all subsequent instances will run 2 tests.
|
||||
|
||||
# reminder can be zero here (in case of a perfect distribution): in such a case, this is just "current_index * per_instance".
|
||||
# if reminder is not zero, we have two regions here, logically. the one of the left is "reminder * elements_in_current_instance",
|
||||
# basically [0..3] and [3..6]
|
||||
# and the region on the right [6..8].
|
||||
left_bound=$((reminder * elements_in_current_instance + ((current_index - reminder) * per_instance)))
|
||||
right_bound=$((left_bound + per_instance))
|
||||
reminder=$((number_of_tests - number_of_jobs * per_instance))
|
||||
elements_in_current_instance=$((per_instance + 1))
|
||||
|
||||
echo "total tests : $number_of_tests, jobs: $number_of_jobs, current index : $current_index. will run tests in range : [$left_bound..$right_bound]"
|
||||
fi
|
||||
left_bound=0
|
||||
right_bound=0
|
||||
|
||||
diff=$((right_bound - left_bound))
|
||||
sliced_array=("${CLASSNAMES[@]:$left_bound:$diff}")
|
||||
TEST_ARG=$(echo $sliced_array | sed 's/ /,/g')
|
||||
# we are in a range where we might need to add one more test to each instance
|
||||
# notice the "less then" condition here, it is important and must not change
|
||||
if [[ $current_index -lt $reminder ]]; then
|
||||
|
||||
./mvnw -s .settings.xml -DfailIfNoTests=false -DtestsToRun=$TEST_ARG -e clean org.jacoco:jacoco-maven-plugin:prepare-agent install \
|
||||
-U -P sonar -nsu --batch-mode -Dmaven.test.redirectTestOutputToFile=true \
|
||||
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
|
||||
# this one is easy, the range will be [0..3] (following our example above)
|
||||
if [[ $current_index == 0 ]]; then
|
||||
left_bound=0
|
||||
right_bound=$elements_in_current_instance
|
||||
# this one will be [3..6]
|
||||
else
|
||||
left_bound=$((current_index * elements_in_current_instance))
|
||||
right_bound=$(((current_index + 1) * elements_in_current_instance))
|
||||
fi
|
||||
|
||||
echo "total tests : $number_of_tests, jobs: $number_of_jobs, current index : $current_index. will run tests in range : [$left_bound..$right_bound]"
|
||||
|
||||
else
|
||||
|
||||
# reminder can be zero here (in case of a perfect distribution): in such a case, this is just "current_index * per_instance".
|
||||
# if reminder is not zero, we have two regions here, logically. the one of the left is "reminder * elements_in_current_instance",
|
||||
# basically [0..3] and [3..6]
|
||||
# and the region on the right [6..8].
|
||||
left_bound=$((reminder * elements_in_current_instance + ((current_index - reminder) * per_instance)))
|
||||
right_bound=$((left_bound + per_instance))
|
||||
|
||||
echo "total tests : $number_of_tests, jobs: $number_of_jobs, current index : $current_index. will run tests in range : [$left_bound..$right_bound]"
|
||||
fi
|
||||
|
||||
diff=$((right_bound - left_bound))
|
||||
sliced_array=("${SORTED_TEST_CLASSNAMES[@]:$left_bound:$diff}")
|
||||
TEST_ARG=$(echo ${sliced_array[@]} | sed 's/ /,/g')
|
||||
|
||||
echo "will run tests : ${TEST_ARG[@]}"
|
||||
|
||||
./mvnw -s .settings.xml \
|
||||
-DtestsToRun=${TEST_ARG[@]} \
|
||||
-e clean install \
|
||||
-U -P sonar -nsu --batch-mode \
|
||||
-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
|
||||
-Dhttp.keepAlive=false \
|
||||
-Dmaven.wagon.http.pool=false \
|
||||
-Dmaven.wagon.http.retryHandler.class=standard \
|
||||
-Dmaven.wagon.http.retryHandler.count=3 \
|
||||
-Dskip.build.image=true
|
||||
|
||||
- name: Publish Test Report
|
||||
uses: mikepenz/action-junit-report@v2
|
||||
|
||||
Reference in New Issue
Block a user