Skip to content

E2E test for pull request #1228

E2E test for pull request

E2E test for pull request #1228

Workflow file for this run

name: E2E test for pull request
on:
workflow_run:
workflows: ["PR-CI"]
types:
- completed
env:
DOCKER_REPO: wuyfeedocker/nacos-ci
DOCKER_REPO_B: wuyfeehub/nacos-ci
TEST_REPO_NAME: nacos-group/nacos-e2e
HEADER_PARAMS: "-H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${{ secrets.ACTION_TOKEN }}\" -H \"X-GitHub-Api-Version: 2022-11-28\""
HEADER_PARAMS_WRITE_COMMENT: "-H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer ${{ secrets.ACTION_TOKEN }}\" -H \"X-GitHub-Api-Version: 2022-11-28\""
BASE_URL_NACOS: https://api.github.com/repos/${GITHUB_REPOSITORY}
BASE_URL_ROBOT: https://api.github.com/repos/wuyfee/nacos
jobs:
docker:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success'
timeout-minutes: 30
strategy:
matrix:
base-image: ["ubuntu"]
java-version: ["8"]
outputs:
version-json: ${{ steps.show_versions.outputs.version-json }}
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifactNacos = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "nacos"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifactNacos.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/nacos.zip', Buffer.from(download.data));
- run: |
unzip nacos.zip
mkdir nacos
cp -r nacos-* nacos/
- uses: actions/checkout@v3
with:
repository: nacos-group/nacos-e2e.git
ref: main
path: nacos-e2e
- name: Generate image tag
id: build-images
run: |
mv nacos-server-*.tar.gz nacos-e2e/cicd/build
cd nacos-e2e/cicd/build
version=${{ github.event.pull_request.number || github.ref_name }}-$(uuidgen)
mkdir versionlist
touch versionlist/"${version}-`echo ${{ matrix.java-version }} | sed -e "s/:/-/g"`"
ls versionlist/
echo TAG=${version}-$(echo ${{ matrix.java-version }} | sed -e "s/:/-/g") >> $GITHUB_ENV
- name: docker-login-1
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: save docker_1 images
run: |
mkdir build_backup
cp -rf nacos-e2e/cicd/build/* ./build_backup/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO}:${{ env.TAG }} .
docker push ${DOCKER_REPO}:${{ env.TAG }}
- name: docker-login-2
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USER_B }}
password: ${{ secrets.DOCKERHUB_TOKEN_B }}
- name: save docker_2 images
run: |
rm -rf nacos-e2e/cicd/build/*
mv ./build_backup/* nacos-e2e/cicd/build/
cd nacos-e2e/cicd/build
docker build --no-cache -f Dockerfile -t ${DOCKER_REPO_B}:${{ env.TAG }} .
docker push ${DOCKER_REPO_B}:${{ env.TAG }}
- name: Show versions
id: show_versions
run: |
a=(`ls nacos-e2e/cicd/build/versionlist`)
printf '%s\n' "${a[@]}" | jq -R . | jq -s .
echo version-json=`printf '%s\n' "${a[@]}" | jq -R . | jq -s .` >> $GITHUB_OUTPUT
deploy:
if: ${{ success() }}
name: Deploy nacos
needs: [docker]
runs-on: ubuntu-latest
timeout-minutes: 60
env:
REPLICA_COUNT: 3
DATABASE: mysql
NODE_PORT: 30000
AUTH_ENABLED: false
ACTUAL_MODE: cluster
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone","standalone_auth"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- name: set nodeport
run: |
echo "NODE_PORT=$(expr $(expr $(expr $(expr ${{ strategy.job-index }} + 1) * ${{ github.run_number }}) % 30000) + 30000)" >> $GITHUB_ENV
- name: set params values
run: |
if [[ ${{ matrix.mode }} == "standalone"* ]];then
if [[ ${{ matrix.mode }} = "standalone_auth" ]]; then
echo "AUTH_ENABLED=true" >> $GITHUB_ENV
fi
echo "ACTUAL_MODE=standalone" >> $GITHUB_ENV
echo "REPLICA_COUNT=1" >> $GITHUB_ENV
echo "DATABASE=embedded" >> $GITHUB_ENV
echo ${{ matrix.mode }}-nacos-${{ github.run_id }}-${{ strategy.job-index }}
fi
- name: allocate docker repo
run: |
if [[ $(expr $(expr ${{ github.run_id }} + ${{ strategy.job-index }} ) % 2 ) -eq 1 ]]; then
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO }}" >> $GITHUB_ENV
else
echo "DOCKER_REPO_ACTUAL=${{ env.DOCKER_REPO_B }}" >> $GITHUB_ENV
fi
- uses: apache/rocketmq-test-tool@java-dev
name: Deploy nacos
with:
yamlString: |
action: deploy
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
waitTimes: 2000
velaAppDescription: nacos-${{ env.GITHUB_WORKFLOW }}-${{ github.run_id }}@${{ matrix.version }}
repoName: nacos
helm:
chart: ./cicd/helm
git:
branch: main
repoType: git
retries: 3
url: https://ghproxy.com/https://github.com/nacos-group/nacos-e2e.git
values:
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
global:
mode: ${{ env.ACTUAL_MODE }}
nacos:
replicaCount: ${{ env.REPLICA_COUNT }}
image:
repository: ${{ env.DOCKER_REPO_ACTUAL }}
tag: ${{ matrix.version }}
auth:
enabled: ${{ env.AUTH_ENABLED }}
storage:
type: ${{ env.DATABASE }}
db:
port: 3306
username: nacos
password: nacos
param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
service:
nodePort: ${{ env.NODE_PORT }}
type: ClusterIP
e2e-java-test:
if: ${{ success() }}
name: Java e2e Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
env:
CODE_PATH: java/nacos-2X
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone","standalone_auth"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- name: set code path
run: |
if [[ ${{ matrix.mode }} = "standalone_auth" ]]; then
echo "CODE_PATH=java/auth" >> $GITHUB_ENV
echo ${{ matrix.mode }}-nacos-${{ github.run_id }}-${{ strategy.job-index }}
fi
- uses: apache/rocketmq-test-tool@java-dev
name: java e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: ${{ env.CODE_PATH }}
CMD: mvn clean test -B
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-java.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-go-test:
if: ${{ success() }}
name: GO E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: go e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: golang
CMD: |
cd /root/code/golang && go mod init nacos_go_test && go mod tidy
gotestsum --junitfile ./target/surefire-reports/TEST-report.xml ./nacosgotest
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-go.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-cpp-test:
if: ${{ success() }}
name: Cpp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: cpp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: cpp
CMD: |
yum-config-manager remove centos-sclo-rh
cd /root/code/cpp && make install
echo "export LD_LIBRARY_PATH=/usr/local/lib" >> ~/.bashrc && source ~/.bashrc
cd /root/code/cpp/nacoscpptest
g++ nacos_test.cpp -o nacos_test -lgtest -lpthread -I/usr/local/include/nacos/ -L/usr/local/lib/ -lnacos-cli
chmod 777 nacos_test && ./nacos_test --gtest_output="xml:../target/surefire-reports/TEST-gtestresults.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-cpp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-csharp-test:
if: ${{ success() }}
name: Csharp E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: csharp e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: csharp
CMD: |
rpm -Uvh https://packages.microsoft.com/config/centos/7/packages-microsoft-prod.rpm
yum -y install dotnet-sdk-3.1 && yum -y install aspnetcore-runtime-7.0
cd /root/code/csharp/nacos-csharp-sdk-test && dotnet restore
dotnet test --logger:"junit;LogFilePath=../target/surefire-reports/TEST-result.xml"
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-csharp.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-nodejs-test:
if: ${{ success() }}
name: Nodejs E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: nodejs e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: nodejs
CMD: |
cd /root/code/nodejs/nacosnodejstest && npm install
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=../target/surefire-reports/TEST-report.xml
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-nodejs.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
e2e-python-test:
if: ${{ success() }}
name: Python E2E Test
needs: [docker, deploy]
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: python e2e test
with:
yamlString: |
action: test
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
API_VERSION: v1
KIND: Pod
RESTART_POLICY: Never
ENV:
WAIT_TIME: 900
REPO_NAME: ${{ env.TEST_REPO_NAME }}
CODE: https://github.com/${{ env.TEST_REPO_NAME }}
BRANCH: main
CODE_PATH: python
CMD: |
cd /root/code/python
pip3 install -r requirements.txt
source ~/.bashrc
cd nacospythontest && pytest --junitxml ../target/surefire-reports/TEST-report.xml test/*_test.py --log-cli-level=DEBUG
ALL_IP: null
CONTAINER:
IMAGE: cloudnativeofalibabacloud/test-runner:v0.0.4
RESOURCE_LIMITS:
cpu: 2
memory: 2Gi
RESOURCE_REQUIRE:
cpu: 2
memory: 2Gi
- uses: actions/upload-artifact@v3
if: always()
name: Upload test log
with:
name: testlog-${{ matrix.mode }}-python.txt
path: testlog.txt
- name: add markdown
if: always()
run: |
cat result.md >> $GITHUB_STEP_SUMMARY
clean:
if: ${{ always() }}
name: Clean
needs: [docker, e2e-java-test, e2e-go-test, e2e-cpp-test, e2e-csharp-test, e2e-nodejs-test, e2e-python-test]
runs-on: ubuntu-latest
timeout-minutes: 5
strategy:
fail-fast: false
matrix:
mode: ["cluster","standalone","standalone_auth"]
version: ${{ fromJSON(needs.docker.outputs.version-json) }}
steps:
- uses: apache/rocketmq-test-tool@java-dev
name: clean
with:
yamlString: |
action: clean
namespace: nacos-${{ github.run_id }}-${{ strategy.job-index }}
askConfig: ${{ secrets.ASK_CONFIG_VIRGINA }}
write-comment:
if: ${{ always() }}
name: write comment to pr
needs: [docker, deploy, e2e-java-test, e2e-go-test, e2e-cpp-test, e2e-csharp-test, e2e-nodejs-test, e2e-python-test, clean]
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: 'Download artifact'
uses: actions/github-script@v3.1.0
with:
script: |
var artifacts = await github.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
var matchArtifactPR = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifactPR.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- name: unzip pr
run: |
unzip pr.zip
cat pr.txt
pr_number=`cat pr.txt`
echo "PR_NUMBER=${pr_number}" >> $GITHUB_ENV
- name: write issue comment
run: |
echo ${{ env.PR_NUMBER }}
job_status=""
if [ ${{ needs.docker.result }} = 'success' ] && [ ${{ needs.deploy.result }} = 'success' ] && [ ${{ needs.e2e-java-test.result }} = 'success' ] && [ ${{ needs.e2e-go-test.result }} = 'success' ] && [ ${{ needs.e2e-cpp-test.result }} = 'success' ] && [ ${{ needs.e2e-csharp-test.result }} = 'success' ] && [ ${{ needs.e2e-nodejs-test.result }} = 'success' ] && [ ${{ needs.e2e-python-test.result }} = 'success' ]; then
jobs_status='$\\color{green}{SUCCESS}$'
jobs_status+="\n[DETAILS](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }})"
else
jobs_status='$\\color{red}{FAILURE}$'
jobs_status+="\n[DETAILS](https://github.com/${GITHUB_REPOSITORY}/actions/runs/${{ github.run_id }})"
fi
echo ${jobs_status}
markdown_content="${jobs_status}"
generate_content() {
if [ $1 = "success" ];then
echo "\n ✅ $2 $1 "
else
echo "\n ❌ $2 $1 "
fi
}
markdown_content+=$(generate_content ${{ needs.docker.result }} "- docker: ")
markdown_content+=$(generate_content ${{ needs.deploy.result }} "- deploy (standalone & cluster & standalone_auth): ")
markdown_content+=$(generate_content ${{ needs.e2e-java-test.result }} "- e2e-java-test (standalone & cluster & standalone_auth): ")
markdown_content+=$(generate_content ${{ needs.e2e-go-test.result }} "- e2e-go-test (standalone & cluster): ")
markdown_content+=$(generate_content ${{ needs.e2e-cpp-test.result }} "- e2e-cpp-test (standalone & cluster): ")
markdown_content+=$(generate_content ${{ needs.e2e-csharp-test.result }} "- e2e-csharp-test (standalone & cluster): ")
markdown_content+=$(generate_content ${{ needs.e2e-nodejs-test.result }} "- e2e-nodejs-test (standalone & cluster): ")
markdown_content+=$(generate_content ${{ needs.e2e-python-test.result }} "- e2e-python-test (standalone & cluster): ")
markdown_content+=$(generate_content ${{ needs.clean.result }} "- clean (standalone & cluster & standalone_auth): ")
echo "markdown_content: \n ${markdown_content}"
payload=`echo "{\"body\": \"${markdown_content}\"}" | jq .`
curl -L -X POST ${{ env.HEADER_PARAMS_WRITE_COMMENT }} ${{ env.BASE_URL_NACOS }}/issues/${{ env.PR_NUMBER }}/comments -d "${payload}"