Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create test-runner command for rerunning tests #6842

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ TEST_TAG_FLAG := -tags $(ALL_TEST_TAGS)
TEST_TIMEOUT ?= 20m

# Number of retries for *-coverage targets.
# NOTE: This is incompatible with TEST_ARGS which specify the `-run` flag due to how gotestsum selects which tests to
# retry.
# *WARNING*: This is disabled for now; see https://github.com/gotestyourself/gotestsum/issues/423
FAILED_TEST_RETRIES ?= 0
FAILED_TEST_RETRIES ?= 2

# Whether or not to test with the race detector. All of (1 on y yes t true) are true values.
TEST_RACE_FLAG ?= on
Expand Down Expand Up @@ -166,7 +163,7 @@ $(GOLANGCI_LINT): $(LOCALBIN)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint,$(GOLANGCI_LINT_VERSION))

# Don't get confused, there is a single linter called gci, which is a part of the mega linter we use is called golangci-lint.
GCI_VERSION := v0.13.4
GCI_VERSION := v0.13.5
GCI := $(LOCALBIN)/gci-$(GCI_VERSION)
$(GCI): $(LOCALBIN)
$(call go-install-tool,$(GCI),github.com/daixiang0/gci,$(GCI_VERSION))
Expand Down Expand Up @@ -405,13 +402,13 @@ prepare-coverage-test: $(GOTESTSUM) $(TEST_OUTPUT_ROOT)

unit-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run unit tests with coverage..."
$(GOTESTSUM) --rerun-fails=$(FAILED_TEST_RETRIES) --rerun-fails-max-failures=10 --junitfile $(NEW_REPORT) --packages $(UNIT_TEST_DIRS) -- \
go run ./cmd/tools/test-runner $(GOTESTSUM) -retries $(FAILED_TEST_RETRIES) --junitfile $(NEW_REPORT) --packages $(UNIT_TEST_DIRS) -- \
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's a way to pre-build this in our CI setup. I can look into that if anyone thinks using go run would be an issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anything you build in pre-build-functional-test-coverage will go into the per-run cache. That won't cover the final binary (I think) but the object files. I wouldn't worry about it, though, the compile+link time should be negligible.

$(COMPILED_TEST_ARGS) \
-coverprofile=$(NEW_COVER_PROFILE)

integration-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run integration tests with coverage..."
$(GOTESTSUM) --rerun-fails=$(FAILED_TEST_RETRIES) --rerun-fails-max-failures=10 --junitfile $(NEW_REPORT) --packages $(INTEGRATION_TEST_DIRS) -- \
go run ./cmd/tools/test-runner $(GOTESTSUM) -retries $(FAILED_TEST_RETRIES) --junitfile $(NEW_REPORT) --packages $(INTEGRATION_TEST_DIRS) -- \
$(COMPILED_TEST_ARGS) \
-coverprofile=$(NEW_COVER_PROFILE) $(INTEGRATION_TEST_COVERPKG)

Expand All @@ -421,21 +418,21 @@ pre-build-functional-test-coverage: prepare-coverage-test

functional-test-coverage: prepare-coverage-test
@printf $(COLOR) "Run functional tests with coverage with $(PERSISTENCE_DRIVER) driver..."
$(GOTESTSUM) --rerun-fails=$(FAILED_TEST_RETRIES) --rerun-fails-max-failures=10 --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_ROOT) -- \
go run ./cmd/tools/test-runner $(GOTESTSUM) -retries $(FAILED_TEST_RETRIES) --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_ROOT) -- \
$(COMPILED_TEST_ARGS) \
-coverprofile=$(NEW_COVER_PROFILE) $(FUNCTIONAL_TEST_COVERPKG) \
-args -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER)

functional-test-xdc-coverage: prepare-coverage-test
@printf $(COLOR) "Run functional test for cross DC with coverage with $(PERSISTENCE_DRIVER) driver..."
$(GOTESTSUM) --rerun-fails=$(FAILED_TEST_RETRIES) --rerun-fails-max-failures=10 --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_XDC_ROOT) -- \
go run ./cmd/tools/test-runner $(GOTESTSUM) -retries $(FAILED_TEST_RETRIES) --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_XDC_ROOT) -- \
$(COMPILED_TEST_ARGS) \
-coverprofile=$(NEW_COVER_PROFILE) $(FUNCTIONAL_TEST_COVERPKG) \
-args -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER)

functional-test-ndc-coverage: prepare-coverage-test
@printf $(COLOR) "Run functional test for NDC with coverage with $(PERSISTENCE_DRIVER) driver..."
$(GOTESTSUM) --rerun-fails=$(FAILED_TEST_RETRIES) --rerun-fails-max-failures=10 --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_NDC_ROOT) -- \
go run ./cmd/tools/test-runner $(GOTESTSUM) -retries $(FAILED_TEST_RETRIES) --junitfile $(NEW_REPORT) --packages $(FUNCTIONAL_TEST_NDC_ROOT) -- \
$(COMPILED_TEST_ARGS) \
-coverprofile=$(NEW_COVER_PROFILE) $(FUNCTIONAL_TEST_COVERPKG) \
-args -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER)
Expand Down
31 changes: 31 additions & 0 deletions cmd/tools/test-runner/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// The MIT License
//
// Copyright (c) 2024 Temporal Technologies Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package main

import (
"go.temporal.io/server/tools/testrunner"
)

func main() {
testrunner.Main()
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ require (
github.com/iancoleman/strcase v0.3.0
github.com/jackc/pgx/v5 v5.6.0
github.com/jmoiron/sqlx v1.3.4
github.com/jstemmer/go-junit-report/v2 v2.1.0
github.com/lib/pq v1.10.9
github.com/mitchellh/mapstructure v1.5.0
github.com/nexus-rpc/sdk-go v0.0.11
Expand Down
3 changes: 3 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian/v3 v3.3.3 h1:DIhPTQrbPkgs2yJYdXU/eNACCG5DVQjySNRNlflZ9Fc=
Expand Down Expand Up @@ -170,6 +171,8 @@ github.com/jmoiron/sqlx v1.3.4 h1:wv+0IJZfL5z0uZoUjlpKgHkgaFSYD+r9CfrXjEXsO7w=
github.com/jmoiron/sqlx v1.3.4/go.mod h1:2BljVx/86SuTyjE+aPYlHCTNvZrnJXghYGpNiXLBMCQ=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jstemmer/go-junit-report/v2 v2.1.0 h1:X3+hPYlSczH9IMIpSC9CQSZA0L+BipYafciZUWHEmsc=
github.com/jstemmer/go-junit-report/v2 v2.1.0/go.mod h1:mgHVr7VUo5Tn8OLVr1cKnLuEy0M92wdRntM99h7RkgQ=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
Expand Down
30 changes: 30 additions & 0 deletions tools/testrunner/testdata/junit-attempt-1.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<testsuites time="14.760843" tests="7" failures="2">
<testsuite name="go.temporal.io/server/tests" tests="7" failures="2" errors="0" id="0" time="9.426000" timestamp="2024-11-18T14:05:44-08:00">
<properties>
<property name="go.version" value="go1.23.2 darwin/arm64"></property>
</properties>
<testcase name="TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument" classname="go.temporal.io/server/tests" time="0.000000">
<failure message="Failed"><![CDATA[=== RUN TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument
callbacks_test.go:99:
Error Trace: /Users/me/temporal/temporal/tests/callbacks_test.go:99
Error: Not equal:
expected: 1
actual : 2
Test: TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument
--- FAIL: TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument (0.00s)
]]></failure>
</testcase>
<testcase name="TestCallbacksSuite" classname="go.temporal.io/server/tests" time="8.330000">
<failure message="Failed"><![CDATA[=== RUN TestCallbacksSuite
=== PAUSE TestCallbacksSuite
=== CONT TestCallbacksSuite
--- FAIL: TestCallbacksSuite (8.33s)
]]></failure>
</testcase>
<testcase name="TestCallbacksSuite/TestNexusResetWorkflowWithCallback" classname="go.temporal.io/server/tests" time="0.020000"></testcase>
<testcase name="TestCallbacksSuite/TestWorkflowNexusCallbacks_CarriedOver/ContinueAsNew" classname="go.temporal.io/server/tests" time="2.029000"></testcase>
<testcase name="TestCallbacksSuite/TestWorkflowNexusCallbacks_CarriedOver/WorkflowRunTimeout" classname="go.temporal.io/server/tests" time="3.030000"></testcase>
<testcase name="TestCallbacksSuite/TestWorkflowNexusCallbacks_CarriedOver/WorkflowFailureRetry" classname="go.temporal.io/server/tests" time="2.040000"></testcase>
<testcase name="TestCallbacksSuite/TestWorkflowNexusCallbacks_CarriedOver" classname="go.temporal.io/server/tests" time="7.100000"></testcase>
</testsuite>
</testsuites>
26 changes: 26 additions & 0 deletions tools/testrunner/testdata/junit-attempt-2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuites tests="2" failures="2" errors="0" time="2.244000">
<testsuite name="go.temporal.io/server/tests" tests="2" failures="2" errors="0" id="0" time="2.244000" timestamp="2024-11-18T13:57:56-08:00">
<properties>
<property name="go.version" value="go1.23.2 darwin/arm64"></property>
</properties>
<testcase name="TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument" classname="go.temporal.io/server/tests" time="0.000000">
<failure message="Failed"><![CDATA[=== RUN TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument
callbacks_test.go:99:
Error Trace: /Users/me/temporal/temporal/tests/callbacks_test.go:99
Error: Not equal:
expected: 1
actual : 2
Test: TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument
--- FAIL: TestCallbacksSuite/TestWorkflowCallbacks_InvalidArgument (0.00s)
]]></failure>
</testcase>
<testcase name="TestCallbacksSuite" classname="go.temporal.io/server/tests" time="1.200000">
<failure message="Failed"><![CDATA[=== RUN TestCallbacksSuite
=== PAUSE TestCallbacksSuite
=== CONT TestCallbacksSuite
--- FAIL: TestCallbacksSuite (1.20s)
]]></failure>
</testcase>
</testsuite>
</testsuites>
Loading
Loading