-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15230a8
commit f81cbb9
Showing
19 changed files
with
1,099 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,8 +29,8 @@ concurrency: | |
cancel-in-progress: ${{ github.event_name == 'pull_request' }} | ||
|
||
jobs: | ||
test-go: | ||
name: "test/go" | ||
test-go-enterprise: | ||
name: "test/go-enterprise" | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
steps: | ||
|
@@ -57,59 +57,5 @@ jobs: | |
path: ${{ steps.go-cache-paths.outputs.go-mod }} | ||
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }} | ||
|
||
- name: Install gotestsum | ||
uses: jaxxstorm/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
repo: gotestyourself/gotestsum | ||
tag: v1.10.1 | ||
|
||
- name: Test | ||
shell: bash | ||
run: | | ||
set +e | ||
gotestsum \ | ||
--junitfile="gotests.xml" \ | ||
--jsonfile="gotestsum.json" \ | ||
--packages="./..." \ | ||
--debug \ | ||
-- \ | ||
-exec sudo \ | ||
-parallel=8 \ | ||
-timeout=5m \ | ||
-short \ | ||
-failfast \ | ||
-covermode=atomic \ | ||
-coverprofile="gotests.coverage" \ | ||
-coverpkg=./... | ||
ret=$? | ||
set -e | ||
if ((ret)); then | ||
# Eternalize test timeout logs because "re-run failed" erases | ||
# artifacts and gotestsum doesn't always capture it: | ||
# https://github.com/gotestyourself/gotestsum/issues/292 | ||
# Multiple test packages could've failed, each one may or may | ||
# not run into the edge case. PS. Don't summon ShellCheck here. | ||
for testWithStack in $(grep 'panic: test timed out' gotestsum.json | grep -E -o '("Test":[^,}]*)'); do | ||
if [ -n "$testWithStack" ] && grep -q "${testWithStack}.*PASS" gotestsum.json; then | ||
echo "Conditions met for gotestsum stack trace missing bug, outputting panic trace:" | ||
grep -A 999999 "${testWithStack}.*panic: test timed out" gotestsum.json | ||
fi | ||
done | ||
fi | ||
exit $ret | ||
- uses: actions/upload-artifact@v3 | ||
if: success() || failure() | ||
with: | ||
name: gotestsum-debug.json | ||
path: ./gotestsum.json | ||
retention-days: 7 | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: success() || failure() | ||
with: | ||
name: gotests.xml | ||
path: ./gotests.xml | ||
retention-days: 30 | ||
run: make test/go-enterprise |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/bash | ||
|
||
# Runs go benchmarks in a new PID namespace. Depends on `go` and `unshare`. | ||
# | ||
# Usage: COUNT=10000 ./bench.sh | ||
# Runs `go test -bench=. -run="^#" -count 1 -benchtime "${COUNT:-1000}x"` ./ | ||
# | ||
# Usage: ./bench.sh -bench=... ... | ||
# Runs `go test "$@"`. COUNT is ignored. | ||
|
||
set -euo pipefail | ||
|
||
cd "$(dirname "$0")" | ||
|
||
args=("$@") | ||
if [[ "${#args[@]}" -eq 0 ]]; then | ||
args=('-bench=.' '-run="^#"' '-count=1' "-benchtime=${COUNT:-1000}x" ./) | ||
fi | ||
|
||
# Start the go test process in a new PID namespace and exec with sudo. | ||
go_binary=$(command -v go) | ||
set -x | ||
exec sudo -E unshare --pid --fork --setuid "$(id -u)" --setgid "$(id -g)" -- "$go_binary" test -exec sudo "${args[@]}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
module github.com/coder/exectrace/bench | ||
|
||
go 1.21.0 | ||
|
||
require ( | ||
github.com/DataDog/ebpfbench v0.0.0-20230731170724-14eabe1f3e9a | ||
github.com/coder/exectrace v0.2.4 | ||
github.com/stretchr/testify v1.9.0 | ||
) | ||
|
||
require ( | ||
github.com/cilium/ebpf v0.10.0 // indirect | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/hashicorp/errwrap v1.1.0 // indirect | ||
github.com/hashicorp/go-multierror v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
golang.org/x/sys v0.4.0 // indirect | ||
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
Oops, something went wrong.