-
Notifications
You must be signed in to change notification settings - Fork 880
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
Showing
6 changed files
with
131 additions
and
31 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 |
---|---|---|
|
@@ -258,13 +258,21 @@ jobs: | |
key: go-${{ runner.os }}${{ runner.arch }}-build-${{ env.COMMIT }} | ||
|
||
- name: Run unit tests | ||
id: test_run | ||
timeout-minutes: 15 | ||
run: make unit-test-coverage | ||
run: | | ||
trap 'echo "exit_code=$?" >> "$GITHUB_OUTPUT"' EXIT | ||
make unit-test-coverage | ||
env: | ||
UNIT_TEST_DIRS: ${{ inputs.unit_test_directory }} | ||
TEST_ARGS: ${{ needs.set-up-single-test.outputs.single_test_args }} | ||
TEST_TIMEOUT: ${{ needs.set-up-single-test.outputs.test_timeout }} | ||
|
||
- name: Highlight test timeout | ||
if: ${{ steps.test_run.outcome == 'failure' && steps.test_run.outputs.exit_code == 124 }} | ||
run: | | ||
echo "::error::Test Test timed out" | ||
- name: Generate test summary | ||
uses: mikepenz/[email protected] | ||
if: failure() | ||
|
@@ -341,8 +349,16 @@ jobs: | |
key: go-${{ runner.os }}${{ runner.arch }}-build-${{ env.COMMIT }} | ||
|
||
- name: Run integration test | ||
id: test_run | ||
timeout-minutes: 15 | ||
run: make integration-test-coverage | ||
run: | | ||
trap 'echo "exit_code=$?" >> "$GITHUB_OUTPUT"' EXIT | ||
make integration-test-coverage | ||
- name: Highlight test timeout | ||
if: ${{ steps.test_run.outcome == 'failure' && steps.test_run.outputs.exit_code == 124 }} | ||
run: | | ||
echo "::error::Test Test timed out" | ||
- name: Generate test summary | ||
uses: mikepenz/[email protected] | ||
|
@@ -488,12 +504,20 @@ jobs: | |
echo "JOB_ID=${job_id:-unknown}" >> "$GITHUB_OUTPUT" | ||
- name: Run functional test | ||
id: test_run | ||
if: ${{ inputs.run_single_functional_test != true || (inputs.run_single_functional_test == true && contains(fromJSON(needs.set-up-single-test.outputs.dbs), env.PERSISTENCE_DRIVER)) }} | ||
timeout-minutes: ${{ fromJSON(needs.set-up-single-test.outputs.github_timeout) }} # make sure this is larger than the test timeout in the Makefile | ||
run: make functional-test-coverage | ||
run: | | ||
trap 'echo "exit_code=$?" >> "$GITHUB_OUTPUT"' EXIT | ||
make functional-test-coverage | ||
env: | ||
TEST_ARGS: ${{ needs.set-up-single-test.outputs.single_test_args }} | ||
|
||
- name: Highlight test timeout | ||
if: ${{ steps.test_run.outcome == 'failure' && steps.test_run.outputs.exit_code == 124 }} | ||
run: | | ||
echo "::error::Test Test timed out" | ||
- name: Generate test summary | ||
uses: mikepenz/[email protected] | ||
if: failure() | ||
|
@@ -615,18 +639,16 @@ jobs: | |
echo "JOB_ID=${job_id-unknown}" >> "$GITHUB_OUTPUT" | ||
- name: Run functional test xdc | ||
id: test_run | ||
timeout-minutes: 25 # update this to TEST_TIMEOUT+5 if you update the Makefile | ||
run: make functional-test-xdc-coverage | ||
run: | | ||
trap 'echo "exit_code=$?" >> "$GITHUB_OUTPUT"' EXIT | ||
make functional-test-xdc-coverage | ||
- name: Generate test summary | ||
uses: mikepenz/[email protected] | ||
if: failure() | ||
with: | ||
report_paths: ./.testoutput/*.junit.xml | ||
detailed_summary: true | ||
check_annotations: false | ||
annotate_only: true | ||
skip_annotations: true | ||
- name: Highlight test timeout | ||
if: ${{ steps.test_run.outcome == 'failure' && steps.test_run.outputs.exit_code == 124 }} | ||
run: | | ||
echo "::error::Test Test timed out" | ||
- name: Upload test results | ||
# Can't pin to major because the action linter doesn't recognize the include-hidden-files flag. | ||
|
@@ -740,8 +762,16 @@ jobs: | |
echo "JOB_ID=${job_id:-unknown}" >> "$GITHUB_OUTPUT" | ||
- name: Run functional test ndc | ||
id: test_run | ||
timeout-minutes: 15 | ||
run: make functional-test-ndc-coverage | ||
run: | | ||
trap 'echo "exit_code=$?" >> "$GITHUB_OUTPUT"' EXIT | ||
make functional-test-ndc-coverage | ||
- name: Highlight test timeout | ||
if: ${{ steps.test_run.outcome == 'failure' && steps.test_run.outputs.exit_code == 124 }} | ||
run: | | ||
echo "::error::Test Test timed out" | ||
- name: Upload test results | ||
# Can't pin to major because the action linter doesn't recognize the include-hidden-files flag. | ||
|
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
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,58 @@ | ||
package testcore | ||
|
||
import ( | ||
"bytes" | ||
"os" | ||
"runtime/debug" | ||
"testing" | ||
"time" | ||
|
||
"github.com/maruel/panicparse/v2/stack" | ||
) | ||
|
||
type testTimeout struct { | ||
updateCh chan time.Duration | ||
closeCh chan struct{} | ||
} | ||
|
||
func newTestTimeout(t *testing.T, after time.Duration) *testTimeout { | ||
res := &testTimeout{closeCh: make(chan struct{})} | ||
go func() { | ||
startedAt := time.Now() | ||
for { | ||
tick := time.NewTimer(time.Second) | ||
detonateAt := startedAt.Add(after) | ||
select { | ||
case after = <-res.updateCh: | ||
case <-res.closeCh: | ||
return | ||
case <-tick.C: | ||
if time.Now().After(detonateAt) { | ||
// Cannot use t.Fatalf since it will wait until the test completes. | ||
t.Logf("test took more than %v to complete, exiting now", after) | ||
|
||
// Print stack trace to help debugging. | ||
rawStack := append(debug.Stack(), '\n', '\n') | ||
_, _, err := stack.ScanSnapshot(bytes.NewReader(rawStack), os.Stdout, stack.DefaultOpts()) | ||
if err != nil { | ||
t.Logf("failed to parse stack trace: %v", err) | ||
} | ||
|
||
// `timeout` exits with code 124 to indicate a timeout - might as well do that here. | ||
// GitHub Actions will mark this test when it sees this exit code. | ||
//revive:disable-next-line:deep-exit | ||
os.Exit(124) | ||
} | ||
} | ||
} | ||
}() | ||
return res | ||
} | ||
|
||
func (b testTimeout) set(d time.Duration) { | ||
b.updateCh <- d | ||
} | ||
|
||
func (b testTimeout) cancel() { | ||
b.closeCh <- struct{}{} | ||
} |
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