From 56ecc083705cf2db214ea00cfa1bb4829f6d804e Mon Sep 17 00:00:00 2001 From: wangxiaobin Date: Fri, 24 May 2024 14:56:59 +0800 Subject: [PATCH 1/5] fix --- .../workflows/trigger-sample-benchmark.yml | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 .github/workflows/trigger-sample-benchmark.yml diff --git a/.github/workflows/trigger-sample-benchmark.yml b/.github/workflows/trigger-sample-benchmark.yml new file mode 100644 index 0000000000..3de693c3a3 --- /dev/null +++ b/.github/workflows/trigger-sample-benchmark.yml @@ -0,0 +1,231 @@ +name: Manually Triggered benchmark for Dubbo Samples + +on: + repository_dispatch: + types: [ manual-trigger ] + +permissions: + contents: read + +env: + FORK_COUNT: 0 + FAIL_FAST: 1 + SHOW_ERROR_DETAIL: 1 + #multi-version size limit + VERSIONS_LIMIT: 1 + CANDIDATE_VERSIONS: ' + spring.version:5.3.24; + spring-boot.version:2.7.6; + ' + +jobs: + check-benchmark-path: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + repository: 'apache/dubbo-samples' + ref: master + - name: Check if directory exists + run: | + #!/bin/bash + cd test + PATH_TO_CHECK="../10-task/dubbo-samples-benchmark/" + if [ ! -d "$PATH_TO_CHECK" ]; then + exit 1 + fi + + build-source: + name: "Build Dubbo" + needs: check-benchmark-path + runs-on: ubuntu-latest + outputs: + version: ${{ steps.dubbo-version.outputs.version }} + steps: + - uses: actions/checkout@v4 + with: + repository: 'apache/dubbo' + ref: 3.3 + - name: "Dubbo cache" + id: dubbo-cache + uses: actions/cache@v4 + with: + path: ~/.m2/repository/org/apache/dubbo + key: ${{ runner.os }}-dubbo-snapshot-${{ github.sha }} + - name: "Cache local Maven repository" + if: steps.dubbo-cache.outputs.cache-hit != 'true' + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: "Set up JDK 17" + if: steps.dubbo-cache.outputs.cache-hit != 'true' + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 17 + - name: "Build Dubbo with Maven" + if: steps.dubbo-cache.outputs.cache-hit != 'true' + run: | + cd ./dubbo + ./mvnw --batch-mode --no-snapshot-updates --no-transfer-progress clean install -Dmaven.test.skip=true -Dmaven.test.skip.exec=true + - name: "Calculate Dubbo Version" + id: dubbo-version + run: | + REVISION=`awk '/[^<]+<\/revision>/{gsub(/|<\/revision>/,"",$1);print $1;exit;}' ./dubbo/pom.xml` + echo "version=$REVISION" >> $GITHUB_OUTPUT + echo "dubbo version: $REVISION" + echo "commit_id: ${{ github.sha }}" + + samples-test-job: + needs: [ build-source ] + name: "Samples benchmark test on ubuntu-latest" + runs-on: ubuntu-latest + timeout-minutes: 90 + env: + JAVA_VER: 8 + strategy: + matrix: + job_id: [ 1 ] + fail-fast: false + steps: + - uses: actions/checkout@v4 + with: + repository: 'apache/dubbo-samples' + ref: bh-test + - name: "Cache local Maven repository" + uses: actions/cache@v4 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: "Restore Dubbo cache" + uses: actions/cache@v4 + with: + path: ~/.m2/repository/org/apache/dubbo + key: ${{ runner.os }}-dubbo-snapshot-${{ github.sha }} + - name: "Cache Skywalking Agent" + id: cache-skywalking-agent + uses: actions/cache@v4 + with: + path: /tmp/skywalking-agent + key: ${{ runner.os }}-skywalking-agent-9.0.0 + - name: "Cache MySQL Driver" + id: cache-mysql-driver + uses: actions/cache@v4 + with: + path: /tmp/mysql-connector-java-8.0.23.jar + key: ${{ runner.os }}-mysql-driver-8.0.23 + - name: "Download Skywalking Agent and MySQL Driver" + if: steps.cache-skywalking-agent.outputs.cache-hit != 'true' || steps.cache-mysql-driver.outputs.cache-hit != 'true' + run: | + wget -c https://archive.apache.org/dist/skywalking/java-agent/9.0.0/apache-skywalking-java-agent-9.0.0.tgz --no-check-certificate + tar -zxvf apache-skywalking-java-agent-9.0.0.tgz -C /tmp + wget -c https://repo1.maven.org/maven2/mysql/mysql-connector-java/8.0.23/mysql-connector-java-8.0.23.jar + mv mysql-connector-java-8.0.23.jar /tmp/ + - name: "Mvn Benchmark Skywalking Plugin" + run: | + rm /tmp/skywalking-agent/plugins/* + cd 10-task/dubbo-samples-benchmark/dubbo-samples-benchmark-agent && mvn --batch-mode --no-snapshot-updates -e --no-transfer-progress clean package -Dmaven.test.skip=true -Dmaven.test.skip.exec=true + cp -f ./target/dubbo-samples-benchmark-agent.jar /tmp/skywalking-agent/plugins/ + - name: "Set up JDK 8" + uses: actions/setup-java@v4 + with: + distribution: 'zulu' + java-version: 8 + - name: "Init Candidate Versions" + run: | + DUBBO_VERSION="${{needs.build-source.outputs.version}}" + CANDIDATE_VERSIONS="dubbo.version:$DUBBO_VERSION;compiler.version:$DUBBO_VERSION;$CANDIDATE_VERSIONS;dubbo.compiler.version:$DUBBO_VERSION" + echo "CANDIDATE_VERSIONS=$CANDIDATE_VERSIONS" >> $GITHUB_ENV + - name: "Replace runtime parameter" + run: | + RUNTIME_CONFIG_PATH=./10-task/dubbo-samples-benchmark/case-runtime-parameter.conf + rm -rf $RUNTIME_CONFIG_PATH + runtime_para_pairs="${{ github.event.client_payload.prop}}" + IFS='@' read -ra groups <<< "$runtime_para_pairs" + for group in "${groups[@]}"; do + IFS='|' read -ra prop_array <<< "$group" + config_line="" + for ((i=0; i<${#prop_array[@]}; i+=2)); do + config_line+="-D${prop_array[i]}=${prop_array[i+1]} " + done + echo "${config_line% }" >> "$RUNTIME_CONFIG_PATH" + done + - name: "Build test image" + run: | + cd test && bash ./build-test-image.sh + - name: "Run tests" + run: cd test && bash ./run-tests.sh ../10-task/dubbo-samples-benchmark/ + - name: "Upload docker log" + uses: actions/upload-artifact@v4 + with: + name: samples-docker-log + path: | + ./10-task/dubbo-samples-benchmark/target/logs/*.log + /tmp/skywalking-agent/logs/*.log + - name: "Upload jmh output result" + uses: actions/upload-artifact@v4 + with: + name: samples-jmh-result + path: /tmp/jmh*.json + - name: "Push results to results repository" + run: | + RESULTS_REPO_OWNER="${{ github.event.client_payload.PUSH_NAME}}" + RESULTS_REPO_BRANCH="${{ github.event.client_payload.RESULTS_REPO_BRANCH}}" + RESULTS_REPO_NAME="${{ github.event.client_payload.REPO_NAME}}" + GITHUB_TOKEN="${{ github.event.client_payload.PUSH_TOKEN}}" + + if ! ls /tmp/jmh_result_prop*.json -1q &> /dev/null; then + echo "No file matching /tmp/jmh_result_prop*.json exists. Exiting..." + exit 0 + fi + + git clone --depth 1 --branch ${RESULTS_REPO_BRANCH} https://github.com/${RESULTS_REPO_OWNER}/${RESULTS_REPO_NAME}.git jmh_result + cd jmh_result + git config user.name 'github-actions[bot]' + git config user.email 'github-actions[bot]@users.noreply.github.com' + + WORK_DIR="$(pwd)" + echo "WorkDir: $WORK_DIR" + + DIRECTORY_PATH="$WORK_DIR/test-results/scenario" + if [ ! -d ${DIRECTORY_PATH} ];then + mkdir -p $DIRECTORY_PATH;else + rm $DIRECTORY_PATH/* + fi + + cp /tmp/jmh_result*.json "$DIRECTORY_PATH" + cp /tmp/jmh_trace*.json "$DIRECTORY_PATH" + + merged_file="merged_prop_results.json" + merged_trace_file="merged_prop_traces.json" + + json_array=() + for file in $(ls -t1 "$DIRECTORY_PATH"/jmh_result*.json); do + if [ -f "$file" ]; then + echo "fileName=$file" + json_array+=( "$(cat "$file")" ) + fi + done + + merged_json=$(echo "${json_array[@]}" | jq -s add) + echo "$merged_json" > "$DIRECTORY_PATH/$merged_file" + + json_array=() + for file in $(ls -t1 "$DIRECTORY_PATH"/jmh_trace*.json); do + if [ -f "$file" ]; then + json_array+=( "$(cat "$file")" ) + fi + done + + merged_json=$(echo "${json_array[@]}" | jq -s add) + echo "$merged_json" > "$DIRECTORY_PATH/$merged_trace_file" + + git add $DIRECTORY_PATH + git commit -m "Compare prop in $(date +'%Y-%m-%d %H:%M:%S')" + git pull --rebase + git push https://${GITHUB_TOKEN}@github.com/${RESULTS_REPO_OWNER}/${RESULTS_REPO_NAME}.git ${RESULTS_REPO_BRANCH} From 2df5dbc247aa00ba5644186b43ad5e14d77ca19e Mon Sep 17 00:00:00 2001 From: wangxiaobin Date: Fri, 24 May 2024 15:32:46 +0800 Subject: [PATCH 2/5] log --- .github/workflows/trigger-sample-benchmark.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/trigger-sample-benchmark.yml b/.github/workflows/trigger-sample-benchmark.yml index 3de693c3a3..a6a90f1570 100644 --- a/.github/workflows/trigger-sample-benchmark.yml +++ b/.github/workflows/trigger-sample-benchmark.yml @@ -69,6 +69,8 @@ jobs: - name: "Build Dubbo with Maven" if: steps.dubbo-cache.outputs.cache-hit != 'true' run: | + echo $(pwd) + echo $(ls) cd ./dubbo ./mvnw --batch-mode --no-snapshot-updates --no-transfer-progress clean install -Dmaven.test.skip=true -Dmaven.test.skip.exec=true - name: "Calculate Dubbo Version" @@ -94,7 +96,7 @@ jobs: - uses: actions/checkout@v4 with: repository: 'apache/dubbo-samples' - ref: bh-test + ref: master - name: "Cache local Maven repository" uses: actions/cache@v4 with: From d4b4968567a4b627fe3937ef936abb69988b0124 Mon Sep 17 00:00:00 2001 From: wangxiaobin Date: Fri, 24 May 2024 15:35:35 +0800 Subject: [PATCH 3/5] log --- .github/workflows/trigger-sample-benchmark.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/trigger-sample-benchmark.yml b/.github/workflows/trigger-sample-benchmark.yml index a6a90f1570..7b1423e094 100644 --- a/.github/workflows/trigger-sample-benchmark.yml +++ b/.github/workflows/trigger-sample-benchmark.yml @@ -69,9 +69,6 @@ jobs: - name: "Build Dubbo with Maven" if: steps.dubbo-cache.outputs.cache-hit != 'true' run: | - echo $(pwd) - echo $(ls) - cd ./dubbo ./mvnw --batch-mode --no-snapshot-updates --no-transfer-progress clean install -Dmaven.test.skip=true -Dmaven.test.skip.exec=true - name: "Calculate Dubbo Version" id: dubbo-version From 4f98ba789bca94ef6e18281c898a0befe8c4170a Mon Sep 17 00:00:00 2001 From: wangxiaobin Date: Fri, 24 May 2024 15:43:23 +0800 Subject: [PATCH 4/5] fix path --- .github/workflows/trigger-sample-benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-sample-benchmark.yml b/.github/workflows/trigger-sample-benchmark.yml index 7b1423e094..bdcf695c24 100644 --- a/.github/workflows/trigger-sample-benchmark.yml +++ b/.github/workflows/trigger-sample-benchmark.yml @@ -73,7 +73,7 @@ jobs: - name: "Calculate Dubbo Version" id: dubbo-version run: | - REVISION=`awk '/[^<]+<\/revision>/{gsub(/|<\/revision>/,"",$1);print $1;exit;}' ./dubbo/pom.xml` + REVISION=`awk '/[^<]+<\/revision>/{gsub(/|<\/revision>/,"",$1);print $1;exit;}' pom.xml` echo "version=$REVISION" >> $GITHUB_OUTPUT echo "dubbo version: $REVISION" echo "commit_id: ${{ github.sha }}" From c5d0d4ac4ec61bdff584f3d2b2e84ed864bff4fb Mon Sep 17 00:00:00 2001 From: wangxiaobin Date: Fri, 24 May 2024 15:54:57 +0800 Subject: [PATCH 5/5] specfy benchmark target --- .github/workflows/trigger-sample-benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/trigger-sample-benchmark.yml b/.github/workflows/trigger-sample-benchmark.yml index bdcf695c24..180322ac68 100644 --- a/.github/workflows/trigger-sample-benchmark.yml +++ b/.github/workflows/trigger-sample-benchmark.yml @@ -138,7 +138,7 @@ jobs: - name: "Init Candidate Versions" run: | DUBBO_VERSION="${{needs.build-source.outputs.version}}" - CANDIDATE_VERSIONS="dubbo.version:$DUBBO_VERSION;compiler.version:$DUBBO_VERSION;$CANDIDATE_VERSIONS;dubbo.compiler.version:$DUBBO_VERSION" + CANDIDATE_VERSIONS="dubbo.version:$DUBBO_VERSION;compiler.version:$DUBBO_VERSION;$CANDIDATE_VERSIONS;dubbo.benchmark:1.0.0;dubbo.compiler.version:$DUBBO_VERSION" echo "CANDIDATE_VERSIONS=$CANDIDATE_VERSIONS" >> $GITHUB_ENV - name: "Replace runtime parameter" run: |