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:
@@ -43,6 +43,11 @@ jobs:
|
||||
# needed for .withReuse(true) to work
|
||||
echo "testcontainers.reuse.enable=true" > ~/.testcontainers.properties
|
||||
- checkout
|
||||
- restore_cache:
|
||||
keys:
|
||||
- spring-cloud-kubernetes-{{ .Branch }}-{{ checksum "pom.xml" }}
|
||||
- spring-cloud-kubernetes-{{ .Branch }}
|
||||
- spring-cloud-kubernetes
|
||||
- attach_workspace:
|
||||
at: /tmp/docker
|
||||
- run:
|
||||
@@ -60,19 +65,74 @@ jobs:
|
||||
###########################################################################################################################
|
||||
################################################# Build test support dependency ###########################################
|
||||
cd spring-cloud-kubernetes-test-support
|
||||
.././mvnw clean install
|
||||
.././mvnw clean install
|
||||
cd ..
|
||||
|
||||
###########################################################################################################################
|
||||
##################################################### Split and run tests #################################################
|
||||
CLASSNAMES=$(circleci tests glob "**/src/test/**/**.java" | grep -v 'Fabric8IstioIT' \
|
||||
| xargs grep -l '@Test' \
|
||||
| sed 's/.*src.test.java.//g' | sed 's@/@.@g' \
|
||||
| sed 's/.\{5\}$//' \
|
||||
| circleci tests split --split-by=timings)
|
||||
echo $CLASSNAMES
|
||||
TEST_ARG=$(echo $CLASSNAMES | sed 's/ /,/g')
|
||||
echo $TEST_ARG
|
||||
|
||||
# - 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
|
||||
|
||||
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\}$//'))
|
||||
|
||||
# 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"
|
||||
|
||||
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'"
|
||||
|
||||
# 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\}$//'"
|
||||
|
||||
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)
|
||||
|
||||
IFS=$'\n'
|
||||
SORTED_TEST_CLASSNAMES=( $(sort \<<< "${PLAIN_TEST_CLASSNAMES[*]}" | uniq -u) )
|
||||
unset IFS
|
||||
|
||||
printf "%s\n" "${SORTED_TEST_CLASSNAMES[@]}" > file.txt
|
||||
CLASSNAMES=( $(cat file.txt | circleci tests split --split-by=timings) )
|
||||
rm file.txt
|
||||
|
||||
TEST_ARG=$(echo ${CLASSNAMES[@]} | sed 's/ /,/g')
|
||||
echo '----------------------- tests ---------------------'
|
||||
echo ${TEST_ARG[@]}
|
||||
echo '---------------------------------------------------'
|
||||
|
||||
./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
|
||||
@@ -110,7 +170,7 @@ jobs:
|
||||
- run:
|
||||
name: dependencies
|
||||
command: |
|
||||
./mvnw -s .settings.xml -U dependency:resolve-plugins dependency:go-offline -B -Dservice.occurence=${_SERVICE_OCCURENCE} || true
|
||||
./mvnw -s .settings.xml -U dependency:resolve-plugins dependency:go-offline -B || true
|
||||
- run:
|
||||
name: build
|
||||
command: |
|
||||
|
||||
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
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -19,6 +19,7 @@
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
|
||||
@@ -1,107 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.client.config;
|
||||
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
/**
|
||||
* The stub data for this test is in : IncludeProfileSpecificSourcesConfigurationStub
|
||||
*
|
||||
* @author wind57
|
||||
*/
|
||||
abstract class KubernetesClientConfigMapIncludeProfileSpecificSourcesTests {
|
||||
|
||||
@Autowired
|
||||
private WebTestClient webClient;
|
||||
|
||||
@AfterEach
|
||||
public void afterEach() {
|
||||
WireMock.reset();
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
public static void afterAll() {
|
||||
WireMock.shutdownServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[0].includeProfileSpecificSources=true'
|
||||
* 'spring.cloud.kubernetes.config.sources[0].name=config-map-one'
|
||||
*
|
||||
* We do not define config-map 'config-map-one', but we do define 'config-map-one-dev'.
|
||||
*
|
||||
* As such: @ConfigurationProperties("one") must be resolved from 'config-map-one-dev'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testOne() {
|
||||
this.webClient.get().uri("/profile-specific/one").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("one"));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[1].includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[1].name=config-map-two'
|
||||
*
|
||||
* We define config-map 'config-map-two', but we also define 'config-map-two-dev'.
|
||||
* This tests proves that data will be read from 'config-map-two' _only_, even if 'config-map-two-dev'
|
||||
* also exists. This happens because of the 'includeProfileSpecificSources=false' property defined at the source level.
|
||||
* If this would be incorrect, the value we read from '/profile-specific/two' would have been 'twoDev' and _not_ 'two',
|
||||
* simply because 'config-map-two-dev' would override the property value.
|
||||
*
|
||||
* As such: @ConfigurationProperties("two") must be resolved from 'config-map-two'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testTwo() {
|
||||
this.webClient.get().uri("/profile-specific/two").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("two"));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[2].name=config-map-three'
|
||||
*
|
||||
* We define config-map 'config-map-three', but we also define 'config-map-three-dev'.
|
||||
* This tests proves that data will be read from 'config-map-three' _only_, even if 'config-map-three-dev'
|
||||
* also exists. This happens because the 'includeProfileSpecificSources' property is not defined at the source level,
|
||||
* but it is defaulted from the root level, where we set it to false.
|
||||
* If this would be incorrect, the value we read from '/profile-specific/three' would have been 'threeDev' and _not_ 'three',
|
||||
* simply because 'config-map-three-dev' would override the property value.
|
||||
*
|
||||
* As such: @ConfigurationProperties("three") must be resolved from 'config-map-three'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testThree() {
|
||||
this.webClient.get().uri("/profile-specific/three").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("three"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -66,6 +66,7 @@
|
||||
<name>${env.IMAGE}</name>
|
||||
</image>
|
||||
<goal>build-image</goal>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<name>${env.IMAGE}</name>
|
||||
</image>
|
||||
<goal>build-image</goal>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -58,6 +58,7 @@
|
||||
<name>${env.IMAGE}</name>
|
||||
</image>
|
||||
<goal>build-image</goal>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-kubernetes</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.kubernetes.fabric8.config;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
abstract class ConfigMapWithIncludeProfileSpecificSourcesTests {
|
||||
|
||||
private static KubernetesClient mockClient;
|
||||
|
||||
@Autowired
|
||||
private WebTestClient webClient;
|
||||
|
||||
public static void setUpBeforeClass(KubernetesClient mockClient) {
|
||||
ConfigMapWithIncludeProfileSpecificSourcesTests.mockClient = mockClient;
|
||||
// Configure the kubernetes master url to point to the mock server
|
||||
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, mockClient.getConfiguration().getMasterUrl());
|
||||
System.setProperty(Config.KUBERNETES_TRUST_CERT_SYSTEM_PROPERTY, "true");
|
||||
System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false");
|
||||
System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false");
|
||||
System.setProperty(Config.KUBERNETES_NAMESPACE_SYSTEM_PROPERTY, "test");
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
Map<String, String> one = new HashMap<>();
|
||||
one.put("one.property", "one");
|
||||
createConfigmap("config-map-one-dev", one);
|
||||
|
||||
Map<String, String> two = new HashMap<>();
|
||||
two.put("two.property", "two");
|
||||
createConfigmap("config-map-two", two);
|
||||
|
||||
Map<String, String> twoDev = new HashMap<>();
|
||||
twoDev.put("two.property", "twoDev");
|
||||
createConfigmap("config-map-two-dev", twoDev);
|
||||
|
||||
Map<String, String> three = new HashMap<>();
|
||||
three.put("three.property", "three");
|
||||
createConfigmap("config-map-three", three);
|
||||
|
||||
Map<String, String> threeDev = new HashMap<>();
|
||||
threeDev.put("three.property", "threeDev");
|
||||
createConfigmap("config-map-three-dev", threeDev);
|
||||
|
||||
}
|
||||
|
||||
private static void createConfigmap(String name, Map<String, String> data) {
|
||||
mockClient.configMaps().inNamespace("spring-k8s")
|
||||
.create(new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata().addToData(data).build());
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[0].includeProfileSpecificSources=true'
|
||||
* 'spring.cloud.kubernetes.config.sources[0].name=config-map-one'
|
||||
*
|
||||
* We do not define config-map 'config-map-one', but we do define 'config-map-one-dev'.
|
||||
*
|
||||
* As such: @ConfigurationProperties("one") must be resolved from 'config-map-one-dev'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testOne() {
|
||||
this.webClient.get().uri("/profile-specific/one").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("one"));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[1].includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[1].name=config-map-two'
|
||||
*
|
||||
* We define config-map 'config-map-two', but we also define 'config-map-two-dev'.
|
||||
* This tests proves that data will be read from 'config-map-two' _only_, even if 'config-map-two-dev'
|
||||
* also exists. This happens because of the 'includeProfileSpecificSources=false' property defined at the source level.
|
||||
* If this would be incorrect, the value we read from '/profile-specific/two' would have been 'twoDev' and _not_ 'two',
|
||||
* simply because 'config-map-two-dev' would override the property value.
|
||||
*
|
||||
* As such: @ConfigurationProperties("two") must be resolved from 'config-map-two'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testTwo() {
|
||||
this.webClient.get().uri("/profile-specific/two").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("two"));
|
||||
}
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 'spring.cloud.kubernetes.config.includeProfileSpecificSources=false'
|
||||
* 'spring.cloud.kubernetes.config.sources[2].name=config-map-three'
|
||||
*
|
||||
* We define config-map 'config-map-three', but we also define 'config-map-three-dev'.
|
||||
* This tests proves that data will be read from 'config-map-three' _only_, even if 'config-map-three-dev'
|
||||
* also exists. This happens because the 'includeProfileSpecificSources' property is not defined at the source level,
|
||||
* but it is defaulted from the root level, where we set it to false.
|
||||
* If this would be incorrect, the value we read from '/profile-specific/three' would have been 'threeDev' and _not_ 'three',
|
||||
* simply because 'config-map-three-dev' would override the property value.
|
||||
*
|
||||
* As such: @ConfigurationProperties("three") must be resolved from 'config-map-three'
|
||||
* </pre>
|
||||
*/
|
||||
@Test
|
||||
public void testThree() {
|
||||
this.webClient.get().uri("/profile-specific/three").exchange().expectStatus().isOk().expectBody(String.class)
|
||||
.value(Matchers.equalTo("three"));
|
||||
}
|
||||
|
||||
}
|
||||
33
spring-cloud-kubernetes-integration-tests/README
Normal file
33
spring-cloud-kubernetes-integration-tests/README
Normal file
@@ -0,0 +1,33 @@
|
||||
Writing a new integration test should be done with minor things in mind, so that
|
||||
tests are picked up by our CI/CD pipeline and work as expected. In particular when you
|
||||
define the plugin that builds the image (integrations tests have a docker image build),
|
||||
you must name the image with the same name as the module. For example:
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>build-image</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
Notice this line:
|
||||
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
|
||||
You must follow the same convention.
|
||||
|
||||
One more important part in this configuration is : "<skip>${skip.build.image}</skip>".
|
||||
We use this setting in the build pipeline where in some stages we skip the image build,
|
||||
only to have it build in some latter ones.
|
||||
@@ -91,6 +91,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -92,6 +92,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -86,6 +86,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -120,6 +120,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -132,7 +132,7 @@ class ActuatorRefreshIT {
|
||||
api.createNamespacedConfigMap(NAMESPACE, configMap, null, null, null);
|
||||
|
||||
// Wait a bit before we verify
|
||||
await().atMost(Duration.ofMillis(3400))
|
||||
await().atMost(Duration.ofSeconds(30))
|
||||
.until(() -> !findAll(postRequestedFor(urlEqualTo("/actuator/refresh"))).isEmpty());
|
||||
|
||||
verify(postRequestedFor(urlEqualTo("/actuator/refresh")));
|
||||
|
||||
@@ -152,7 +152,7 @@ class ActuatorRefreshKafkaIT {
|
||||
WebClient serviceClient = builder.baseUrl("http://localhost:80/it").build();
|
||||
|
||||
Boolean[] value = new Boolean[1];
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(90)).until(() -> {
|
||||
await().pollInterval(Duration.ofSeconds(3)).atMost(Duration.ofSeconds(240)).until(() -> {
|
||||
value[0] = serviceClient.method(HttpMethod.GET).retrieve().bodyToMono(Boolean.class).retryWhen(retrySpec())
|
||||
.block();
|
||||
return value[0];
|
||||
@@ -285,7 +285,7 @@ class ActuatorRefreshKafkaIT {
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
return Retry.fixedDelay(240, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -185,7 +185,7 @@ class ConfigMapPollingReloadIT {
|
||||
}
|
||||
|
||||
private RetryBackoffSpec retrySpec() {
|
||||
return Retry.fixedDelay(15, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
return Retry.fixedDelay(60, Duration.ofSeconds(1)).filter(Objects::nonNull);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -63,6 +63,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
@@ -61,6 +61,7 @@
|
||||
<configuration>
|
||||
<imageName>docker.io/springcloud/${project.artifactId}:${project.version}</imageName>
|
||||
<imageBuilder>paketobuildpacks/builder</imageBuilder>
|
||||
<skip>${skip.build.image}</skip>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
||||
Reference in New Issue
Block a user