diff --git a/.github/workflows/codeql_analysis.yml b/.github/workflows/codeql_analysis.yml index 27c4a26a6a8..8e6a0a267a5 100644 --- a/.github/workflows/codeql_analysis.yml +++ b/.github/workflows/codeql_analysis.yml @@ -63,12 +63,9 @@ jobs: # Install everything else we need, and configure sudo apt-get install -y make unzip g++ etcd-client etcd-server curl git wget - + sudo service etcd stop - - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - + - name: Building binaries timeout-minutes: 30 run: | diff --git a/.github/workflows/unit_race.yml b/.github/workflows/unit_race.yml index 453b642b6f6..812246fd3ba 100644 --- a/.github/workflows/unit_race.yml +++ b/.github/workflows/unit_race.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql80" - make unit_test_race | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test_race - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_race_evalengine.yml b/.github/workflows/unit_race_evalengine.yml index 78f37a41a6a..fa20c2f2e2d 100644 --- a/.github/workflows/unit_race_evalengine.yml +++ b/.github/workflows/unit_race_evalengine.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql80" - make unit_test_race | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test_race - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_evalengine_mysql57.yml b/.github/workflows/unit_test_evalengine_mysql57.yml index 2f744a8bc5a..36f72617554 100644 --- a/.github/workflows/unit_test_evalengine_mysql57.yml +++ b/.github/workflows/unit_test_evalengine_mysql57.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql57" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_evalengine_mysql80.yml b/.github/workflows/unit_test_evalengine_mysql80.yml index a8a44c063e5..0ee5822c1e8 100644 --- a/.github/workflows/unit_test_evalengine_mysql80.yml +++ b/.github/workflows/unit_test_evalengine_mysql80.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql80" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_evalengine_mysql84.yml b/.github/workflows/unit_test_evalengine_mysql84.yml index b85f24e8e3b..b1c501e971c 100644 --- a/.github/workflows/unit_test_evalengine_mysql84.yml +++ b/.github/workflows/unit_test_evalengine_mysql84.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql84" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_mysql57.yml b/.github/workflows/unit_test_mysql57.yml index 3bd54059024..6924e267b59 100644 --- a/.github/workflows/unit_test_mysql57.yml +++ b/.github/workflows/unit_test_mysql57.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql57" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_mysql80.yml b/.github/workflows/unit_test_mysql80.yml index 7325bc902b9..8158099c9cf 100644 --- a/.github/workflows/unit_test_mysql80.yml +++ b/.github/workflows/unit_test_mysql80.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql80" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/unit_test_mysql84.yml b/.github/workflows/unit_test_mysql84.yml index 45b31fb61ca..ab987c325e2 100644 --- a/.github/workflows/unit_test_mysql84.yml +++ b/.github/workflows/unit_test_mysql84.yml @@ -91,9 +91,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@034e59c473362f8f2be47694d98fd3f12a1ad497 # v0.39.0 - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@99fa7f0daf16db969f54a49139a14471e633e6e8 # HEAD - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -127,7 +124,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="mysql84" - make unit_test | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make unit_test - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -135,15 +132,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/go.mod b/go.mod index c438516adfe..0cee85073b1 100644 --- a/go.mod +++ b/go.mod @@ -125,10 +125,12 @@ require ( github.com/DataDog/go-runtime-metrics-internal v0.0.4-0.20250721125240-fdf1ef85b633 // indirect github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.29.1 // indirect github.com/Masterminds/semver/v3 v3.4.0 // indirect + github.com/bitfield/gotestdox v0.2.2 // indirect github.com/cihub/seelog v0.0.0-20170130134532-f561c5e57575 // indirect github.com/cilium/ebpf v0.19.0 // indirect github.com/clipperhouse/uax29/v2 v2.2.0 // indirect github.com/containerd/log v0.1.0 // indirect + github.com/dnephin/pflag v1.0.7 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/godbus/dbus/v5 v5.1.0 // indirect github.com/google/btree v1.1.3 // indirect @@ -150,6 +152,7 @@ require ( go.opentelemetry.io/otel/log v0.14.0 // indirect go.yaml.in/yaml/v2 v2.4.3 // indirect go.yaml.in/yaml/v3 v3.0.4 // indirect + gotest.tools/gotestsum v1.13.0 // indirect k8s.io/apimachinery v0.33.4 // indirect ) @@ -269,3 +272,5 @@ require ( ) exclude github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes v0.33.0 + +tool gotest.tools/gotestsum diff --git a/go.sum b/go.sum index c4fdefdd6fe..749f9c722ad 100644 --- a/go.sum +++ b/go.sum @@ -149,6 +149,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bitfield/gotestdox v0.2.2 h1:x6RcPAbBbErKLnapz1QeAlf3ospg8efBsedU93CDsnE= +github.com/bitfield/gotestdox v0.2.2/go.mod h1:D+gwtS0urjBrzguAkTM2wodsTQYFHdpx8eqRJ3N+9pY= github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= @@ -195,6 +197,8 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8Yc github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da h1:aIftn67I1fkbMa512G+w+Pxci9hJPB8oMnkcP3iZF38= github.com/dgryski/go-farm v0.0.0-20240924180020-3414d57e47da/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw= +github.com/dnephin/pflag v1.0.7 h1:oxONGlWxhmUct0YzKTgrpQv9AUA1wtPBn7zuSjJqptk= +github.com/dnephin/pflag v1.0.7/go.mod h1:uxE91IoWURlOiTUIA8Mq5ZZkAv3dPUfZNaT80Zm7OQE= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -916,6 +920,10 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gotest.tools/gotestsum v1.13.0 h1:+Lh454O9mu9AMG1APV4o0y7oDYKyik/3kBOiCqiEpRo= +gotest.tools/gotestsum v1.13.0/go.mod h1:7f0NS5hFb0dWr4NtcsAsF0y1kzjEFfAil0HiBQJE03Q= +gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q= +gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= k8s.io/apimachinery v0.33.4 h1:SOf/JW33TP0eppJMkIgQ+L6atlDiP/090oaX0y9pd9s= diff --git a/test/templates/unit_test.tpl b/test/templates/unit_test.tpl index 23e53b3816e..572c0d95233 100644 --- a/test/templates/unit_test.tpl +++ b/test/templates/unit_test.tpl @@ -104,9 +104,6 @@ jobs: go mod download go install golang.org/x/tools/cmd/goimports@{{.Goimports.SHA}} # {{.Goimports.Comment}} - # install JUnit report formatter - go install github.com/vitessio/go-junit-report@{{.GoJunitReport.SHA}} # {{.GoJunitReport.Comment}} - - name: Run make tools if: steps.changes.outputs.unit_tests == 'true' run: | @@ -140,7 +137,7 @@ jobs: # testing, e.g. MySQL 5.7 vs 8.0. export CI_DB_PLATFORM="{{.Platform}}" - make {{if .Race}}unit_test_race{{else}}unit_test{{end}} | tee -a output.txt | go-junit-report -set-exit-code > report.xml + JUNIT_OUTPUT=report.xml JSON_OUTPUT=report.json make {{if .Race}}unit_test_race{{else}}unit_test{{end}} - name: Record test results in launchable if PR is not a draft if: github.event_name == 'pull_request' && github.event.pull_request.draft == 'false' && steps.changes.outputs.unit_tests == 'true' && github.base_ref == 'main' && !cancelled() @@ -148,15 +145,17 @@ jobs: # send recorded tests to launchable launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - name: Print test output - if: steps.changes.outputs.unit_tests == 'true' && !cancelled() - run: | - # print test output - cat output.txt - - name: Test Summary if: steps.changes.outputs.unit_tests == 'true' && !cancelled() uses: test-summary/action@31493c76ec9e7aa675f1585d3ed6f1da69269a86 # v2.4 with: paths: "report.xml" show: "fail" + + - name: Slowest Tests + if: steps.changes.outputs.unit_tests == 'true' && !cancelled() + run: | + echo '## Slowest Tests' >> "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" + go tool gotestsum tool slowest --num 20 --jsonfile report.json | tee -a "$GITHUB_STEP_SUMMARY" + echo '```' >> "$GITHUB_STEP_SUMMARY" diff --git a/tools/e2e_go_test.sh b/tools/e2e_go_test.sh index bc4964ffb12..d55ec2c0553 100755 --- a/tools/e2e_go_test.sh +++ b/tools/e2e_go_test.sh @@ -1,4 +1,4 @@ #!/bin/bash source build.env echo "running tests for " "$@" -go test -v "$@" -alsologtostderr -count=1 \ No newline at end of file +go test -v "$@" -alsologtostderr -count=1 diff --git a/tools/e2e_test_runner.sh b/tools/e2e_test_runner.sh index 1fc5c2cb558..8d97a89bbb4 100755 --- a/tools/e2e_test_runner.sh +++ b/tools/e2e_test_runner.sh @@ -33,7 +33,7 @@ source build.env if [[ -z $VT_GO_PARALLEL && -n $VT_GO_PARALLEL_VALUE ]]; then - VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" + VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" fi # All Go packages with test files. @@ -41,29 +41,29 @@ fi packages_with_tests=$(go list -f '{{if len .TestGoFiles}}{{.ImportPath}} {{join .TestGoFiles " "}}{{end}}{{if len .XTestGoFiles}}{{.ImportPath}} {{join .XTestGoFiles " "}}{{end}}' ./go/.../endtoend/... | sort) # Flaky tests have the suffix "_flaky_test.go". -all_except_flaky_and_cluster_tests=$(echo "$packages_with_tests" | grep -vE ".+ .+_flaky_test\.go" | grep -vE "go/test/endtoend" | cut -d" " -f1) +all_except_flaky_and_cluster_tests=$(echo "$packages_with_tests" | grep -vE ".+ .+_flaky_test\.go" | grep -vE "go/test/endtoend" | cut -d" " -f1) flaky_tests=$(echo "$packages_with_tests" | grep -E ".+ .+_flaky_test\.go" | grep -vE "go/test/endtoend" | cut -d" " -f1) # Run non-flaky tests. echo "$all_except_flaky_and_cluster_tests" | xargs go test -count=1 $VT_GO_PARALLEL if [ $? -ne 0 ]; then - echo "ERROR: Go unit tests failed. See above for errors." - echo - echo "This should NOT happen. Did you introduce a flaky unit test?" - echo "If so, please rename it to the suffix _flaky_test.go." - exit 1 + echo "ERROR: Go unit tests failed. See above for errors." + echo + echo "This should NOT happen. Did you introduce a flaky unit test?" + echo "If so, please rename it to the suffix _flaky_test.go." + exit 1 fi # Run flaky tests sequentially. Retry when necessary. for pkg in $flaky_tests; do - max_attempts=3 - attempt=1 - # Set a timeout because some tests may deadlock when they flake. - until go test -timeout 30s $VT_GO_PARALLEL $pkg; do - echo "FAILED (try $attempt/$max_attempts) in $pkg (return code $?). See above for errors." - if [ $((++attempt)) -gt $max_attempts ]; then - echo "ERROR: Flaky Go unit tests in package $pkg failed too often (after $max_attempts retries). Please reduce the flakiness." - exit 1 - fi - done + max_attempts=3 + attempt=1 + # Set a timeout because some tests may deadlock when they flake. + until go test -timeout 30s $VT_GO_PARALLEL $pkg; do + echo "FAILED (try $attempt/$max_attempts) in $pkg (return code $?). See above for errors." + if [ $((++attempt)) -gt $max_attempts ]; then + echo "ERROR: Flaky Go unit tests in package $pkg failed too often (after $max_attempts retries). Please reduce the flakiness." + exit 1 + fi + done done diff --git a/tools/unit_test_runner.sh b/tools/unit_test_runner.sh index 78a852e2cca..89bf18f91f1 100755 --- a/tools/unit_test_runner.sh +++ b/tools/unit_test_runner.sh @@ -1,30 +1,21 @@ #!/bin/bash # Copyright 2019 The Vitess 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 -# +# # http://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. -# Custom Go unit test runner which runs all unit tests in parallel except for -# known flaky unit tests. -# Flaky unit tests are run sequentially in the second phase and retried up to -# three times. - -# Why are there flaky unit tests? -# -# Some of the Go unit tests are inherently flaky e.g. because they use the -# real timer implementation and might fail when things take longer as usual. -# In particular, this happens when the system is under load and threads do not -# get scheduled as fast as usual. Then, the expected timings do not match. +# Custom Go unit test runner which runs all unit tests using gotestsum. Failed tests are +# automatically retried up to 3 times to handle flaky tests. # Set VT_GO_PARALLEL variable in the same way as the Makefile does. # We repeat this here because this script is called directly by test.go @@ -33,67 +24,48 @@ source build.env if [[ -z $VT_GO_PARALLEL && -n $VT_GO_PARALLEL_VALUE ]]; then - VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" + VT_GO_PARALLEL="-p $VT_GO_PARALLEL_VALUE" fi # Enable race detector if RACE=1 RACE_FLAG="" if [[ "$RACE" == "1" ]]; then - RACE_FLAG="-race" + RACE_FLAG="-race" fi # Mac makes long temp directories for os.TempDir(). MySQL can't connect to # sockets in those directories. Tell Golang to use /tmp/vttest_XXXXXX instead. kernel="$(uname -s)" case "$kernel" in - darwin|Darwin) - TMPDIR=${TMPDIR:-} - if [ -z "$TMPDIR" ]; then - TMPDIR="$(mktemp -d /tmp/vttest_XXXXXX)" - export TMPDIR - fi - echo "Using temporary directory for tests: $TMPDIR" - ;; +darwin | Darwin) + TMPDIR=${TMPDIR:-} + if [ -z "$TMPDIR" ]; then + TMPDIR="$(mktemp -d /tmp/vttest_XXXXXX)" + export TMPDIR + fi + echo "Using temporary directory for tests: $TMPDIR" + ;; esac -# All Go packages with test files. -# Output per line: * -packages_with_tests=$(go list -f '{{if len .TestGoFiles}}{{.ImportPath}} {{join .TestGoFiles " "}}{{end}}{{if len .XTestGoFiles}}{{.ImportPath}} {{join .XTestGoFiles " "}}{{end}}' ./go/... | sort) +# All Go packages with test files, excluding endtoend tests. +packages_with_tests=$(go list ./go/... | grep -v endtoend) if [[ "$VTEVALENGINETEST" == "1" ]]; then - packages_with_tests=$(echo "$packages_with_tests" | grep "evalengine") + packages_with_tests=$(echo "$packages_with_tests" | grep "evalengine") fi if [[ "$VTEVALENGINETEST" == "0" ]]; then - packages_with_tests=$(echo "$packages_with_tests" | grep -v "evalengine") + packages_with_tests=$(echo "$packages_with_tests" | grep -v "evalengine") fi -# Flaky tests have the suffix "_flaky_test.go". -# Exclude endtoend tests -all_except_flaky_tests=$(echo "$packages_with_tests" | grep -vE ".+ .+_flaky_test\.go" | cut -d" " -f1 | grep -v "endtoend") -flaky_tests=$(echo "$packages_with_tests" | grep -E ".+ .+_flaky_test\.go" | cut -d" " -f1) - -go test $VT_GO_PARALLEL $RACE_FLAG -v -count=1 $all_except_flaky_tests -if [ $? -ne 0 ]; then - echo "ERROR: Go unit tests failed. See above for errors." - echo - echo "This should NOT happen. Did you introduce a flaky unit test?" - echo "If so, please rename it to the suffix _flaky_test.go." - exit 1 +# Build gotestsum args. Failed tests are retried up to 3 times, but if more than 10 tests fail +# initially we skip retries to avoid wasting time on a real widespread failure. +GOTESTSUM_ARGS="--format github-actions --rerun-fails=3 --rerun-fails-max-failures=10 --rerun-fails-run-root-test --format-hide-empty-pkg --hide-summary=skipped" +if [[ -n "${JUNIT_OUTPUT:-}" ]]; then + GOTESTSUM_ARGS="$GOTESTSUM_ARGS --junitfile $JUNIT_OUTPUT" +fi +if [[ -n "${JSON_OUTPUT:-}" ]]; then + GOTESTSUM_ARGS="$GOTESTSUM_ARGS --jsonfile $JSON_OUTPUT" fi -echo '# Flaky tests (3 attempts permitted)' - -# Run flaky tests sequentially. Retry when necessary. -for pkg in $flaky_tests; do - max_attempts=3 - attempt=1 - # Set a timeout because some tests may deadlock when they flake. - until go test -timeout 5m $VT_GO_PARALLEL $RACE_FLAG $pkg -v -count=1; do - echo "FAILED (try $attempt/$max_attempts) in $pkg (return code $?). See above for errors." - if [ $((++attempt)) -gt $max_attempts ]; then - echo "ERROR: Flaky Go unit tests in package $pkg failed too often (after $max_attempts retries). Please reduce the flakiness." - exit 1 - fi - done -done +go tool gotestsum $GOTESTSUM_ARGS --packages="$packages_with_tests" -- $VT_GO_PARALLEL $RACE_FLAG -count=1