Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Integrate testcontainers into the current test environment #2524

Open
wants to merge 26 commits into
base: 2021.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
7d20332
接入ci以及初始化项目
kaori-seasons May 2, 2022
fa0a109
删除多余测试执行命令
kaori-seasons May 2, 2022
629f70e
整理集成测试环境 编写nacos接入testcontainer用例
kaori-seasons May 2, 2022
2846b05
删除多余类
kaori-seasons May 2, 2022
3e8e1d3
删除多余生成文件
kaori-seasons May 3, 2022
b93ce60
移动接入ci文件夹
kaori-seasons May 3, 2022
bd9d64e
删除多余注释
kaori-seasons May 3, 2022
6f4be1f
clean code
kaori-seasons May 3, 2022
9b349f5
Remove redundant scripts
kaori-seasons May 3, 2022
cd5fd5b
Re-divide unit test modules
kaori-seasons May 15, 2022
8d16b4d
remove pipline
kaori-seasons May 15, 2022
9ddb22b
remove deps
kaori-seasons May 15, 2022
f572889
添加ITcase标准
kaori-seasons Jun 5, 2022
106b11a
添加docker构建以及推送镜像
kaori-seasons Jun 23, 2022
1c39390
fix ci and deploy docker
kaori-seasons Jun 23, 2022
b7465bc
add maven profile and assembly plugin
kaori-seasons Jun 23, 2022
00fa8cf
update cache maven repo
kaori-seasons Jun 23, 2022
223b4b2
update maven command
kaori-seasons Jun 23, 2022
fb412d6
fix Syntax
kaori-seasons Jun 23, 2022
40d3f2e
update version
kaori-seasons Jun 23, 2022
4fe712e
enhance integration test
kaori-seasons Jun 23, 2022
ea9b730
add module && update docker upload repo
kaori-seasons Jun 25, 2022
bbacb01
remove intergration module and move tests
kaori-seasons Jun 25, 2022
3555b45
fix checkstyle && add assembly
kaori-seasons Jun 26, 2022
27f0a02
fix checkstyle
kaori-seasons Jul 17, 2022
3738832
fix NacosAsyncRestTemplateITCase startup error
kaori-seasons Jul 29, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Deploy Docker Image

on:
push:
branches:
- 2021.x
paths:
- '**/pom.xml'
- '**/src/main/**'
pull_request:
branches:
- 2021.x
paths:
- '**/pom.xml'
- '**/src/main/**'
release:
types:
- published
workflow_dispatch:

env:
MAVEN_OPTS: -Dhttp.keepAlive=false -Dmaven.wagon.http.pool=false -Dmaven.wagon.http.retryHandler.count=3 -Dmaven.wagon.httpconnectionManager.ttlSeconds=30 -DskipTests

jobs:
deploy-docker-iamge:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- uses: actions/checkout@v2

# setup docker
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# build target with maven
- name: Cache Maven Repos
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-

- name: Set up JDK 8
uses: actions/setup-java@v1
with:
java-version: 8

- name: set environment
run: export MAVEN_OPTS=' -Dmaven.javadoc.skip=true -Drat.skip=true -Djacoco.skip=true $MAVEN_OPTS'
- name: Build Project
run: |
./mvnw -B -Prelease,docker -DskipTests clean install
docker image ls --format "{{.ID}} {{.Repository}} {{.Tag}}" | grep alibaba| sed 's/apache\//${{ secrets.DOCKERHUB_USERNAME }}\//' |tr A-Z a-z |awk '{system("docker tag "$1" "$2":latest;docker tag "$1" "$2":"$3";")}'

- name: Push Docker Image
run: |
echo Docker Images:
echo `docker image ls|grep -i ${{ secrets.DOCKERHUB_USERNAME }}|awk '{print $1":"$2}'`
docker image ls|grep -i ${{ secrets.DOCKERHUB_USERNAME }}|awk '{print $1":"$2}'|xargs -i docker push {}
53 changes: 53 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,49 @@ on:
push:
branches:
- 2021.x
paths:
- '.github/workflows/integration-test.yml'
- '**/pom.xml'
- '**/src/main/**'
pull_request:
branches:
- 2021.x
paths:
- '.github/workflows/integration-test.yml'
- '**/pom.xml'
- '**/src/main/**'
jobs:
build-it-image:
name: build-it-image
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v2
- name: Maven resolve ranges
run: ./mvnw versions:resolve-ranges -ntp -Dincludes='org.springframework:*,org.springframework.boot:*'
- name: Cache Maven Repos
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: spring-cloud-alibaba-it-cache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
distribution: 'temurin'
java-version: 8
- name: Build IT image
run: ./mvnw -B clean install -am -pl spring-cloud-alibaba-tests/spring-cloud-alibaba-testcontainers -Pit.env.docker -DskipTests -Dspotless.apply.skip=true
- name: Save IT image
run: docker save -o /tmp/spring-cloud-alibaba-testcontainers.tar apache/spring-cloud-alibaba-testcontainers:latest
- name: Upload IT image
uses: actions/upload-artifact@v3
with:
name: it-image
path: /tmp/spring-cloud-alibaba-testcontainers.tar
retention-days: 1

integration-testing:
name: Integration Testing
runs-on: ubuntu-latest
Expand All @@ -29,4 +68,18 @@ jobs:
- name: Testing
run: mvn clean test
# run: mvn clean -Dit.enabled=true test
- name: Download IT image
uses: actions/download-artifact@v3
with:
name: it-image
path: /tmp/
- name: Load IT image
run: docker load -i /tmp/spring-cloud-alibaba-testcontainers.tar
- name: "run install by skip tests"
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: mvn -q -B -ntp clean install -DskipTests
- name: run integration tests
if: ${{ steps.check_changes.outputs.docs_only != 'true' }}
run: ./build/run_integration_group.sh CLI


2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.5.2/apache-maven-3.5.2-bin.zip
distributionUrl=https://repo1.maven.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip
25 changes: 25 additions & 0 deletions build/retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

function fail {
echo $1 >&2
exit 1
}

function retry {
local n=1
local max=3
local delay=10
while true; do
"$@" && break || {
if [[ $n -lt $max ]]; then
((n++))
echo "Command failed. Attempt $n/$max:"
sleep $delay;
else
fail "The command has failed after $n attempts."
fi
}
done
}

retry "$@"
36 changes: 36 additions & 0 deletions build/run_integration_group.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

set -e
set -o pipefail
set -o errexit

TEST_GROUP=$1
if [ -z "$TEST_GROUP" ]; then
echo "usage: $0 [test_group]"
exit 1
fi
shift

# runs integration tests
mvn_run_integration_test() {
(
RETRY=""
# wrap with retry.sh script if next parameter is "--retry"
if [[ "$1" == "--retry" ]]; then
RETRY="./build/retry.sh"
shift
fi
# skip wrapping with retry.sh script if next parameter is "--no-retry"
if [[ "$1" == "--no-retry" ]]; then
RETRY=""
shift
fi
set -x


# run the integration tests
$RETRY ./mvnw -nsu -B install -f spring-cloud-alibaba-tests/spring-cloud-alibaba-testcontainers/pom.xml -Pit.env.docker test "$@"
)
}
Loading