From 6561ee05521b63077811eb1bfc4a6735c819d642 Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Wed, 7 Sep 2022 11:39:06 +0800 Subject: [PATCH 1/2] chore: only generate test result on specific branches (#27591) * chore: only generate test result on specific branches * lint (cherry picked from commit 8c1093534ee31f861a49f4ad5e47645349f42ca7) # Conflicts: # .buildkite/hooks/post-command # ci/test-stable.sh --- .buildkite/hooks/post-command | 15 +++++ ci/test-stable.sh | 111 ++++++++++++++++++++++++++++++++++ 2 files changed, 126 insertions(+) diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index 513b1b1f89b1a0..fe009f42ddd5c3 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -20,6 +20,21 @@ else SUCCESS=false fi +<<<<<<< HEAD +======= + if [[ -n $BUILDKITE && -f "results.json" ]]; then + # prepare result file + awk '/{ "type": .* }/' results.json > sanitized-results.json + + # upload to buildkite + buildkite-test-collector < sanitized-results.json + + # upload to datadog + cargo2junit > results.xml < sanitized-results.json + datadog-ci junit upload --service solana results.xml + fi + +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) point_tags="pipeline=$BUILDKITE_PIPELINE_SLUG,job=$CI_LABEL,pr=$PR,success=$SUCCESS" point_tags="${point_tags// /\\ }" # Escape spaces diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 7bf8695c2170ce..17c06b75b37c2f 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -12,6 +12,15 @@ annotate() { } } +<<<<<<< HEAD +======= +exit_if_error() { + if [[ "$1" -ne 0 ]]; then + exit "$1" + fi +} + +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) # Run the appropriate test based on entrypoint testName=$(basename "$0" .sh) @@ -27,10 +36,39 @@ NPROC=$(nproc) JOBS=$((JOBS>NPROC ? NPROC : JOBS)) +# get channel info +eval "$(ci/channel-info.sh)" + +need_to_generate_test_result() { + local branches=( + "$EDGE_CHANNEL" + "$BETA_CHANNEL" + "$STABLE_CHANNEL" + ) + + for n in "${branches[@]}"; + do + if [[ "$CI_BRANCH" == "$n" ]]; then + return 0 + fi + done + + return 1 +} + echo "Executing $testName" case $testName in test-stable) +<<<<<<< HEAD _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) ;; test-stable-bpf) # Clear the C dependency files, if dependency moves these files are not regenerated @@ -52,9 +90,22 @@ test-stable-bpf) # BPF C program system tests _ make -C programs/bpf/c tests +<<<<<<< HEAD _ "$cargo" stable test \ --manifest-path programs/bpf/Cargo.toml \ --no-default-features --features=bpf_c,bpf_rust -- --nocapture +======= + if need_to_generate_test_result; then + _ "$cargo" stable test \ + --manifest-path programs/bpf/Cargo.toml \ + --no-default-features --features=bpf_c,bpf_rust -- -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test \ + --manifest-path programs/bpf/Cargo.toml \ + --no-default-features --features=bpf_c,bpf_rust -- --nocapture + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) # BPF Rust program unit tests for bpf_test in programs/bpf/rust/*; do @@ -71,10 +122,25 @@ test-stable-bpf) # BPF program instruction count assertion bpf_target_path=programs/bpf/target +<<<<<<< HEAD _ "$cargo" stable test \ --manifest-path programs/bpf/Cargo.toml \ --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ -- --nocapture &> "${bpf_target_path}"/deploy/instuction_counts.txt +======= + if need_to_generate_test_result; then + _ "$cargo" stable test \ + --manifest-path programs/bpf/Cargo.toml \ + --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ + -- -Z unstable-options --format json --report-time |& tee results.json + awk '!/{ "type": .* }/' results.json >"${bpf_target_path}"/deploy/instuction_counts.txt + else + _ "$cargo" stable test \ + --manifest-path programs/bpf/Cargo.toml \ + --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ + -- --nocapture &> "${bpf_target_path}"/deploy/instuction_counts.txt + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) bpf_dump_archive="bpf-dumps.tar.bz2" rm -f "$bpf_dump_archive" @@ -99,27 +165,72 @@ test-stable-perf) fi _ "$cargo" stable build --bins ${V:+--verbose} +<<<<<<< HEAD _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) _ "$cargo" stable run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10 ;; test-local-cluster) _ "$cargo" stable build --release --bins ${V:+--verbose} +<<<<<<< HEAD _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1 +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1 + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-flakey) _ "$cargo" stable build --release --bins ${V:+--verbose} +<<<<<<< HEAD _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1 +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1 + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-slow-1) _ "$cargo" stable build --release --bins ${V:+--verbose} +<<<<<<< HEAD _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1 +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1 + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-slow-2) _ "$cargo" stable build --release --bins ${V:+--verbose} +<<<<<<< HEAD _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1 +======= + if need_to_generate_test_result; then + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json + exit_if_error "${PIPESTATUS[0]}" + else + _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1 + fi +>>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-wasm) From 3a4832af6c20831690caa3c22ca6563a1870e024 Mon Sep 17 00:00:00 2001 From: Yihau Chen Date: Wed, 7 Sep 2022 16:41:10 +0800 Subject: [PATCH 2/2] fix conflict --- .buildkite/hooks/post-command | 3 --- ci/test-stable.sh | 40 ----------------------------------- 2 files changed, 43 deletions(-) diff --git a/.buildkite/hooks/post-command b/.buildkite/hooks/post-command index fe009f42ddd5c3..a5b86ec1c2f1c8 100644 --- a/.buildkite/hooks/post-command +++ b/.buildkite/hooks/post-command @@ -20,8 +20,6 @@ else SUCCESS=false fi -<<<<<<< HEAD -======= if [[ -n $BUILDKITE && -f "results.json" ]]; then # prepare result file awk '/{ "type": .* }/' results.json > sanitized-results.json @@ -34,7 +32,6 @@ else datadog-ci junit upload --service solana results.xml fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) point_tags="pipeline=$BUILDKITE_PIPELINE_SLUG,job=$CI_LABEL,pr=$PR,success=$SUCCESS" point_tags="${point_tags// /\\ }" # Escape spaces diff --git a/ci/test-stable.sh b/ci/test-stable.sh index 17c06b75b37c2f..cee800815757f2 100755 --- a/ci/test-stable.sh +++ b/ci/test-stable.sh @@ -12,15 +12,12 @@ annotate() { } } -<<<<<<< HEAD -======= exit_if_error() { if [[ "$1" -ne 0 ]]; then exit "$1" fi } ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) # Run the appropriate test based on entrypoint testName=$(basename "$0" .sh) @@ -59,16 +56,12 @@ need_to_generate_test_result() { echo "Executing $testName" case $testName in test-stable) -<<<<<<< HEAD - _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture -======= if need_to_generate_test_result; then _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --jobs "$JOBS" --all --tests --exclude solana-local-cluster ${V:+--verbose} -- --nocapture fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) ;; test-stable-bpf) # Clear the C dependency files, if dependency moves these files are not regenerated @@ -90,11 +83,6 @@ test-stable-bpf) # BPF C program system tests _ make -C programs/bpf/c tests -<<<<<<< HEAD - _ "$cargo" stable test \ - --manifest-path programs/bpf/Cargo.toml \ - --no-default-features --features=bpf_c,bpf_rust -- --nocapture -======= if need_to_generate_test_result; then _ "$cargo" stable test \ --manifest-path programs/bpf/Cargo.toml \ @@ -105,7 +93,6 @@ test-stable-bpf) --manifest-path programs/bpf/Cargo.toml \ --no-default-features --features=bpf_c,bpf_rust -- --nocapture fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) # BPF Rust program unit tests for bpf_test in programs/bpf/rust/*; do @@ -122,12 +109,6 @@ test-stable-bpf) # BPF program instruction count assertion bpf_target_path=programs/bpf/target -<<<<<<< HEAD - _ "$cargo" stable test \ - --manifest-path programs/bpf/Cargo.toml \ - --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ - -- --nocapture &> "${bpf_target_path}"/deploy/instuction_counts.txt -======= if need_to_generate_test_result; then _ "$cargo" stable test \ --manifest-path programs/bpf/Cargo.toml \ @@ -140,7 +121,6 @@ test-stable-bpf) --no-default-features --features=bpf_c,bpf_rust assert_instruction_count \ -- --nocapture &> "${bpf_target_path}"/deploy/instuction_counts.txt fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) bpf_dump_archive="bpf-dumps.tar.bz2" rm -f "$bpf_dump_archive" @@ -165,72 +145,52 @@ test-stable-perf) fi _ "$cargo" stable build --bins ${V:+--verbose} -<<<<<<< HEAD - _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture -======= if need_to_generate_test_result; then _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --package solana-perf --package solana-ledger --package solana-core --lib ${V:+--verbose} -- --nocapture fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) _ "$cargo" stable run --manifest-path poh-bench/Cargo.toml ${V:+--verbose} -- --hashes-per-tick 10 ;; test-local-cluster) _ "$cargo" stable build --release --bins ${V:+--verbose} -<<<<<<< HEAD - _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1 -======= if need_to_generate_test_result; then _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster ${V:+--verbose} -- --nocapture --test-threads=1 fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-flakey) _ "$cargo" stable build --release --bins ${V:+--verbose} -<<<<<<< HEAD - _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1 -======= if need_to_generate_test_result; then _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_flakey ${V:+--verbose} -- --nocapture --test-threads=1 fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-slow-1) _ "$cargo" stable build --release --bins ${V:+--verbose} -<<<<<<< HEAD - _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1 -======= if need_to_generate_test_result; then _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_1 ${V:+--verbose} -- --nocapture --test-threads=1 fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-local-cluster-slow-2) _ "$cargo" stable build --release --bins ${V:+--verbose} -<<<<<<< HEAD - _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1 -======= if need_to_generate_test_result; then _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --test-threads=1 -Z unstable-options --format json --report-time | tee results.json exit_if_error "${PIPESTATUS[0]}" else _ "$cargo" stable test --release --package solana-local-cluster --test local_cluster_slow_2 ${V:+--verbose} -- --nocapture --test-threads=1 fi ->>>>>>> 8c1093534 (chore: only generate test result on specific branches (#27591)) exit 0 ;; test-wasm)