diff --git a/Makefile b/Makefile index 35c5219f253..cba5ca1ba73 100644 --- a/Makefile +++ b/Makefile @@ -59,13 +59,6 @@ endef TEST_TIMEOUT := 20m -# TODO: INTEG_TEST should be functional tests -INTEG_TEST_ROOT := ./host -INTEG_TEST_XDC_ROOT := ./host/xdc -INTEG_TEST_NDC_ROOT := ./host/ndc - -PERSISTENCE_INTEGRATION_TEST_ROOT := ./common/persistence/tests -DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests PROTO_ROOT := proto PROTO_FILES = $(shell find ./$(PROTO_ROOT)/internal -name "*.proto") @@ -76,10 +69,15 @@ PROTO_OUT := api ALL_SRC := $(shell find . -name "*.go") ALL_SRC += go.mod ALL_SCRIPTS := $(shell find . -name "*.sh") -# TODO (jeremy): Replace below with build tags and `go test ./...` for targets + TEST_DIRS := $(sort $(dir $(filter %_test.go,$(ALL_SRC)))) -INTEG_TEST_DIRS := $(filter $(INTEG_TEST_ROOT)/ $(INTEG_TEST_NDC_ROOT)/,$(TEST_DIRS)) -UNIT_TEST_DIRS := $(filter-out $(INTEG_TEST_ROOT)% $(INTEG_TEST_XDC_ROOT)% $(INTEG_TEST_NDC_ROOT)% $(PERSISTENCE_INTEGRATION_TEST_ROOT)% $(DB_TOOL_INTEGRATION_TEST_ROOT)%,$(TEST_DIRS)) +FUNCTIONAL_TEST_ROOT := ./tests +FUNCTIONAL_TEST_XDC_ROOT := ./tests/xdc +FUNCTIONAL_TEST_NDC_ROOT := ./tests/ndc +DB_INTEGRATION_TEST_ROOT := ./common/persistence/tests +DB_TOOL_INTEGRATION_TEST_ROOT := ./tools/tests +INTEGRATION_TEST_DIRS := $(DB_INTEGRATION_TEST_ROOT) $(DB_TOOL_INTEGRATION_TEST_ROOT) +UNIT_TEST_DIRS := $(filter-out $(FUNCTIONAL_TEST_ROOT)% $(FUNCTIONAL_TEST_XDC_ROOT)% $(FUNCTIONAL_TEST_NDC_ROOT)% $(DB_INTEGRATION_TEST_ROOT)% $(DB_TOOL_INTEGRATION_TEST_ROOT)%,$(TEST_DIRS)) # go.opentelemetry.io/otel/sdk/metric@v0.31.0 - there are breaking changes in v0.32.0. # github.com/urfave/cli/v2@v2.4.0 - needs to accept comma in values before unlocking https://github.com/urfave/cli/pull/1241. @@ -89,26 +87,26 @@ PINNED_DEPENDENCIES := \ github.com/urfave/cli/v2@v2.4.0 # Code coverage output files. -COVER_ROOT := ./.coverage -UNIT_COVER_PROFILE := $(COVER_ROOT)/unit_coverprofile.out -INTEGRATION_COVER_PROFILE := $(COVER_ROOT)/integration_coverprofile.out -DB_TOOL_COVER_PROFILE := $(COVER_ROOT)/db_tool_coverprofile.out -INTEG_COVER_PROFILE := $(COVER_ROOT)/integ_$(PERSISTENCE_DRIVER)_coverprofile.out -INTEG_XDC_COVER_PROFILE := $(COVER_ROOT)/integ_xdc_$(PERSISTENCE_DRIVER)_coverprofile.out -INTEG_NDC_COVER_PROFILE := $(COVER_ROOT)/integ_ndc_$(PERSISTENCE_DRIVER)_coverprofile.out -SUMMARY_COVER_PROFILE := $(COVER_ROOT)/summary.out +COVER_ROOT := ./.coverage +UNIT_COVER_PROFILE := $(COVER_ROOT)/unit_coverprofile.out +INTEGRATION_COVER_PROFILE := $(COVER_ROOT)/integration_coverprofile.out +DB_TOOL_COVER_PROFILE := $(COVER_ROOT)/db_tool_coverprofile.out +FUNCTIONAL_COVER_PROFILE := $(COVER_ROOT)/functional_$(PERSISTENCE_DRIVER)_coverprofile.out +FUNCTIONAL_XDC_COVER_PROFILE := $(COVER_ROOT)/functional_xdc_$(PERSISTENCE_DRIVER)_coverprofile.out +FUNCTIONAL_NDC_COVER_PROFILE := $(COVER_ROOT)/functional_ndc_$(PERSISTENCE_DRIVER)_coverprofile.out +SUMMARY_COVER_PROFILE := $(COVER_ROOT)/summary.out # DB SQL_USER ?= temporal SQL_PASSWORD ?= temporal -# Need the following option to have integration tests count towards coverage. godoc below: +# Need the following option to have integration and functional tests count towards coverage. godoc below: # -coverpkg pkg1,pkg2,pkg3 # Apply coverage analysis in each test to the given list of packages. # The default is for each test to analyze only the package being tested. # Packages are specified as import paths. -INTEG_TEST_COVERPKG := -coverpkg="$(MODULE_ROOT)/client/...,$(MODULE_ROOT)/common/...,$(MODULE_ROOT)/service/..." - +INTEGRATION_TEST_COVERPKG := -coverpkg="$(MODULE_ROOT)/common/persistence/...,$(MODULE_ROOT)/tools/..." +FUNCTIONAL_TEST_COVERPKG := -coverpkg="$(MODULE_ROOT)/client/...,$(MODULE_ROOT)/common/...,$(MODULE_ROOT)/service/...,$(MODULE_ROOT)/temporal/...,$(MODULE_ROOT)/tools/..." ##### Tools ##### update-checkers: @printf $(COLOR) "Install/update check tools..." @@ -262,32 +260,31 @@ build-tests: unit-test: clean-test-results @printf $(COLOR) "Run unit tests..." - @go test $(UNIT_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log + @go test $(UNIT_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_DIRS) -race | tee -a test.log @! grep -q "^--- FAIL" test.log -db-integration-test: clean-test-results +integration-test: clean-test-results @printf $(COLOR) "Run integration tests..." - @go test $(PERSISTENCE_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log - @go test $(DB_TOOL_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log + @go test $(INTEGRATION_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log @! grep -q "^--- FAIL" test.log -# TODO: rename it to functional-test -integration-test: clean-test-results - @printf $(COLOR) "Run integration tests..." - @go test $(INTEG_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log +functional-test: clean-test-results + @printf $(COLOR) "Run functional tests..." + @go test $(FUNCTIONAL_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log + @go test $(FUNCTIONAL_TEST_NDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race | tee -a test.log # Need to run xdc tests with race detector off because of ringpop bug causing data race issue. - @go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log + @go test $(FUNCTIONAL_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) | tee -a test.log @! grep -q "^--- FAIL" test.log -# TODO: rename it to functional-test -integration-with-fault-injection-test: clean-test-results +functional-with-fault-injection-test: clean-test-results @printf $(COLOR) "Run integration tests with fault injection..." - @go test $(INTEG_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log + @go test $(FUNCTIONAL_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log + @go test $(FUNCTIONAL_TEST_NDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -race -PersistenceFaultInjectionRate=0.005 | tee -a test.log # Need to run xdc tests with race detector off because of ringpop bug causing data race issue. - @go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log + @go test $(FUNCTIONAL_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -PersistenceFaultInjectionRate=0.005 | tee -a test.log @! grep -q "^--- FAIL" test.log -test: unit-test db-integration-test integration-test integration-with-fault-injection-test +test: unit-test integration-test functional-test functional-with-fault-injection-test ##### Coverage ##### $(COVER_ROOT): @@ -296,27 +293,23 @@ $(COVER_ROOT): unit-test-coverage: $(COVER_ROOT) @printf $(COLOR) "Run unit tests with coverage..." @echo "mode: atomic" > $(UNIT_COVER_PROFILE) - @go test ./$(UNIT_TEST_DIRS) -timeout=$(TEST_TIMEOUT) -race -coverprofile=$(UNIT_COVER_PROFILE) || exit 1; + @go test ./$(UNIT_TEST_DIRS) -timeout=$(TEST_TIMEOUT) -race -tags=unittest -coverprofile=$(UNIT_COVER_PROFILE) || exit 1; -db-integration-test-coverage: $(COVER_ROOT) +integration-test-coverage: $(COVER_ROOT) @printf $(COLOR) "Run integration tests with coverage..." - @go test $(PERSISTENCE_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -coverpkg="./common/..." -coverprofile=$(INTEGRATION_COVER_PROFILE) - @go test $(DB_TOOL_INTEGRATION_TEST_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -coverpkg="./tools/..." -coverprofile=$(DB_TOOL_COVER_PROFILE) + @go test $(INTEGRATION_TEST_DIRS) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) $(INTEGRATION_TEST_COVERPKG) -coverprofile=$(INTEGRATION_COVER_PROFILE) -# TODO: rename it to functional-test -integration-test-coverage: $(COVER_ROOT) - @printf $(COLOR) "Run integration tests with coverage with $(PERSISTENCE_DRIVER) driver..." - @go test $(INTEG_TEST_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(INTEG_TEST_COVERPKG) -coverprofile=$(INTEG_COVER_PROFILE) - -# TODO: rename it to functional-test -integration-test-xdc-coverage: $(COVER_ROOT) - @printf $(COLOR) "Run integration test for cross DC with coverage with $(PERSISTENCE_DRIVER) driver..." - @go test $(INTEG_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(INTEG_TEST_COVERPKG) -coverprofile=$(INTEG_XDC_COVER_PROFILE) - -# TODO: rename it to functional-test -integration-test-ndc-coverage: $(COVER_ROOT) - @printf $(COLOR) "Run integration test for NDC with coverage with $(PERSISTENCE_DRIVER) driver..." - @go test $(INTEG_TEST_NDC_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(INTEG_TEST_COVERPKG) -coverprofile=$(INTEG_NDC_COVER_PROFILE) +functional-test-coverage: $(COVER_ROOT) + @printf $(COLOR) "Run functional tests with coverage with $(PERSISTENCE_DRIVER) driver..." + @go test $(FUNCTIONAL_TEST_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(FUNCTIONAL_COVER_PROFILE) + +functional-test-xdc-coverage: $(COVER_ROOT) + @printf $(COLOR) "Run functional test for cross DC with coverage with $(PERSISTENCE_DRIVER) driver..." + @go test $(FUNCTIONAL_TEST_XDC_ROOT) -timeout=$(TEST_TIMEOUT) $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(FUNCTIONAL_XDC_COVER_PROFILE) + +functional-test-ndc-coverage: $(COVER_ROOT) + @printf $(COLOR) "Run functional test for NDC with coverage with $(PERSISTENCE_DRIVER) driver..." + @go test $(FUNCTIONAL_TEST_NDC_ROOT) -timeout=$(TEST_TIMEOUT) -race $(TEST_TAG) -persistenceType=$(PERSISTENCE_TYPE) -persistenceDriver=$(PERSISTENCE_DRIVER) $(FUNCTIONAL_TEST_COVERPKG) -coverprofile=$(FUNCTIONAL_NDC_COVER_PROFILE) .PHONY: $(SUMMARY_COVER_PROFILE) $(SUMMARY_COVER_PROFILE): $(COVER_ROOT) diff --git a/common/archiver/filestore/historyArchiver_test.go b/common/archiver/filestore/historyArchiver_test.go index ac9211df68a..66f48ba5171 100644 --- a/common/archiver/filestore/historyArchiver_test.go +++ b/common/archiver/filestore/historyArchiver_test.go @@ -34,7 +34,7 @@ import ( enumspb "go.temporal.io/api/enums/v1" - "go.temporal.io/server/tests/testhelper" + "go.temporal.io/server/tests/testutils" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" @@ -355,7 +355,7 @@ func (s *historyArchiverSuite) TestArchive_Success() { historyIterator.EXPECT().HasNext().Return(false), ) - dir := testhelper.MkdirTemp(s.T(), "", "TestArchiveSingleRead") + dir := testutils.MkdirTemp(s.T(), "", "TestArchiveSingleRead") historyArchiver := s.newTestHistoryArchiver(historyIterator) request := &archiver.ArchiveHistoryRequest{ @@ -538,7 +538,7 @@ func (s *historyArchiverSuite) TestArchiveAndGet() { historyIterator.EXPECT().HasNext().Return(false), ) - dir := testhelper.MkdirTemp(s.T(), "", "TestArchiveAndGet") + dir := testutils.MkdirTemp(s.T(), "", "TestArchiveAndGet") historyArchiver := s.newTestHistoryArchiver(historyIterator) archiveRequest := &archiver.ArchiveHistoryRequest{ diff --git a/common/archiver/filestore/util_test.go b/common/archiver/filestore/util_test.go index 5f24ff8ecb3..410f7d9182a 100644 --- a/common/archiver/filestore/util_test.go +++ b/common/archiver/filestore/util_test.go @@ -30,8 +30,6 @@ import ( "testing" "time" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" enumspb "go.temporal.io/api/enums/v1" @@ -40,6 +38,7 @@ import ( "go.temporal.io/server/common" "go.temporal.io/server/common/archiver" "go.temporal.io/server/common/codec" + "go.temporal.io/server/tests/testutils" ) const ( @@ -61,7 +60,7 @@ func (s *UtilSuite) SetupTest() { } func (s *UtilSuite) TestFileExists() { - dir := testhelper.MkdirTemp(s.T(), "", "TestFileExists") + dir := testutils.MkdirTemp(s.T(), "", "TestFileExists") s.assertDirectoryExists(dir) exists, err := fileExists(dir) @@ -80,7 +79,7 @@ func (s *UtilSuite) TestFileExists() { } func (s *UtilSuite) TestDirectoryExists() { - dir := testhelper.MkdirTemp(s.T(), "", "TestDirectoryExists") + dir := testutils.MkdirTemp(s.T(), "", "TestDirectoryExists") s.assertDirectoryExists(dir) subdir := "subdir" @@ -97,7 +96,7 @@ func (s *UtilSuite) TestDirectoryExists() { } func (s *UtilSuite) TestMkdirAll() { - dir := testhelper.MkdirTemp(s.T(), "", "TestMkdirAll") + dir := testutils.MkdirTemp(s.T(), "", "TestMkdirAll") s.assertDirectoryExists(dir) s.NoError(mkdirAll(dir, testDirMode)) @@ -116,7 +115,7 @@ func (s *UtilSuite) TestMkdirAll() { } func (s *UtilSuite) TestWriteFile() { - dir := testhelper.MkdirTemp(s.T(), "", "TestWriteFile") + dir := testutils.MkdirTemp(s.T(), "", "TestWriteFile") s.assertDirectoryExists(dir) filename := "test-file-name" @@ -134,7 +133,7 @@ func (s *UtilSuite) TestWriteFile() { } func (s *UtilSuite) TestReadFile() { - dir := testhelper.MkdirTemp(s.T(), "", "TestReadFile") + dir := testutils.MkdirTemp(s.T(), "", "TestReadFile") s.assertDirectoryExists(dir) filename := "test-file-name" @@ -151,7 +150,7 @@ func (s *UtilSuite) TestReadFile() { } func (s *UtilSuite) TestListFilesByPrefix() { - dir := testhelper.MkdirTemp(s.T(), "", "TestListFiles") + dir := testutils.MkdirTemp(s.T(), "", "TestListFiles") s.assertDirectoryExists(dir) filename := "test-file-name" @@ -214,7 +213,7 @@ func (s *UtilSuite) TestEncodeDecodeHistoryBatches() { } func (s *UtilSuite) TestValidateDirPath() { - dir := testhelper.MkdirTemp(s.T(), "", "TestValidateDirPath") + dir := testutils.MkdirTemp(s.T(), "", "TestValidateDirPath") s.assertDirectoryExists(dir) filename := "test-file-name" s.createFile(dir, filename) diff --git a/common/archiver/filestore/visibilityArchiver_test.go b/common/archiver/filestore/visibilityArchiver_test.go index fc3dbee4253..65a38d74453 100644 --- a/common/archiver/filestore/visibilityArchiver_test.go +++ b/common/archiver/filestore/visibilityArchiver_test.go @@ -32,8 +32,6 @@ import ( "testing" "time" - "go.temporal.io/server/tests/testhelper" - "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" @@ -51,6 +49,7 @@ import ( "go.temporal.io/server/common/log" "go.temporal.io/server/common/payload" "go.temporal.io/server/common/primitives/timestamp" + "go.temporal.io/server/tests/testutils" ) const ( @@ -166,7 +165,7 @@ func (s *visibilityArchiverSuite) TestArchive_Fail_NonRetryableErrorOption() { } func (s *visibilityArchiverSuite) TestArchive_Success() { - dir := testhelper.MkdirTemp(s.T(), "", "TestVisibilityArchive") + dir := testutils.MkdirTemp(s.T(), "", "TestVisibilityArchive") visibilityArchiver := s.newTestVisibilityArchiver() closeTimestamp := timestamp.TimeNowPtrUtc() @@ -472,7 +471,7 @@ func (s *visibilityArchiverSuite) TestQuery_Success_SmallPageSize() { } func (s *visibilityArchiverSuite) TestArchiveAndQuery() { - dir := testhelper.MkdirTemp(s.T(), "", "TestArchiveAndQuery") + dir := testutils.MkdirTemp(s.T(), "", "TestArchiveAndQuery") visibilityArchiver := s.newTestVisibilityArchiver() mockParser := NewMockQueryParser(s.controller) diff --git a/common/config/loader_test.go b/common/config/loader_test.go index 41a428494ca..61dd4408fe4 100644 --- a/common/config/loader_test.go +++ b/common/config/loader_test.go @@ -28,10 +28,10 @@ import ( "os" "testing" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + + "go.temporal.io/server/tests/testutils" ) const fileMode = os.FileMode(0644) @@ -61,7 +61,7 @@ func (s *LoaderSuite) SetupTest() { } func (s *LoaderSuite) TestBaseYaml() { - dir := testhelper.MkdirTemp(s.T(), "", "loader.testBaseYaml") + dir := testutils.MkdirTemp(s.T(), "", "loader.testBaseYaml") data := buildConfig("", "") err := os.WriteFile(path(dir, "base.yaml"), []byte(data), fileMode) @@ -82,7 +82,7 @@ func (s *LoaderSuite) TestBaseYaml() { } func (s *LoaderSuite) TestHierarchy() { - dir := testhelper.MkdirTemp(s.T(), "", "loader.testHierarchy") + dir := testutils.MkdirTemp(s.T(), "", "loader.testHierarchy") s.createFile(dir, "base.yaml", "", "") s.createFile(dir, "development.yaml", "development", "") diff --git a/common/log/zap_logger_test.go b/common/log/zap_logger_test.go index b974bb70703..0ea58e52291 100644 --- a/common/log/zap_logger_test.go +++ b/common/log/zap_logger_test.go @@ -33,14 +33,13 @@ import ( "strings" "testing" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "go.uber.org/zap" "go.temporal.io/server/common/log/tag" + "go.temporal.io/server/tests/testutils" ) type LogSuite struct { @@ -68,7 +67,7 @@ func (s *LogSuite) TestParseLogLevel() { } func (s *LogSuite) TestNewLogger() { - dir := testhelper.MkdirTemp(s.T(), "", "config.testNewLogger") + dir := testutils.MkdirTemp(s.T(), "", "config.testNewLogger") cfg := Config{ Level: "info", diff --git a/common/persistence/cassandra/test.go b/common/persistence/cassandra/test.go index e6ac2d38f41..f048e25ae03 100644 --- a/common/persistence/cassandra/test.go +++ b/common/persistence/cassandra/test.go @@ -38,7 +38,7 @@ import ( "go.temporal.io/server/common/persistence/nosql/nosqlplugin/cassandra/gocql" "go.temporal.io/server/common/resolver" "go.temporal.io/server/environment" - "go.temporal.io/server/tests/testhelper" + "go.temporal.io/server/tests/testutils" ) const ( @@ -109,7 +109,7 @@ func (s *TestCluster) SetupTestDatabase() { schemaDir := s.schemaDir + "/" if !strings.HasPrefix(schemaDir, "/") && !strings.HasPrefix(schemaDir, "../") { - temporalPackageDir := testhelper.GetRepoRootDirectory() + temporalPackageDir := testutils.GetRepoRootDirectory() schemaDir = path.Join(temporalPackageDir, schemaDir) } diff --git a/common/persistence/persistence-tests/historyV2PersistenceTest.go b/common/persistence/persistence-tests/historyV2PersistenceTest.go index d10506317e8..f47be0888f3 100644 --- a/common/persistence/persistence-tests/historyV2PersistenceTest.go +++ b/common/persistence/persistence-tests/historyV2PersistenceTest.go @@ -37,6 +37,7 @@ import ( enumspb "go.temporal.io/api/enums/v1" historypb "go.temporal.io/api/history/v1" "go.temporal.io/api/serviceerror" + "go.temporal.io/server/common/persistence/serialization" persistencespb "go.temporal.io/server/api/persistence/v1" diff --git a/common/persistence/sql/sqlPersistenceTest.go b/common/persistence/sql/sqlPersistenceTest.go index a1522199be0..3a8c0c8d51a 100644 --- a/common/persistence/sql/sqlPersistenceTest.go +++ b/common/persistence/sql/sqlPersistenceTest.go @@ -38,7 +38,7 @@ import ( p "go.temporal.io/server/common/persistence" "go.temporal.io/server/common/persistence/sql/sqlplugin" "go.temporal.io/server/common/resolver" - "go.temporal.io/server/tests/testhelper" + "go.temporal.io/server/tests/testutils" ) // TestCluster allows executing cassandra operations in testing. @@ -99,7 +99,7 @@ func (s *TestCluster) SetupTestDatabase() { schemaDir := s.schemaDir + "/" if !strings.HasPrefix(schemaDir, "/") && !strings.HasPrefix(schemaDir, "../") { - temporalPackageDir := testhelper.GetRepoRootDirectory() + temporalPackageDir := testutils.GetRepoRootDirectory() schemaDir = path.Join(temporalPackageDir, schemaDir) } s.LoadSchema(path.Join(schemaDir, "temporal", "schema.sql")) diff --git a/common/persistence/tests/history_store.go b/common/persistence/tests/history_store.go index e9d2f90162c..c9fa28f4d55 100644 --- a/common/persistence/tests/history_store.go +++ b/common/persistence/tests/history_store.go @@ -36,6 +36,7 @@ import ( enumspb "go.temporal.io/api/enums/v1" historypb "go.temporal.io/api/history/v1" + persistencespb "go.temporal.io/server/api/persistence/v1" "go.temporal.io/server/common" "go.temporal.io/server/common/dynamicconfig" diff --git a/common/ringpop/ringpop_test.go b/common/ringpop/ringpop_test.go index 76d0be13183..7f14fdc12db 100644 --- a/common/ringpop/ringpop_test.go +++ b/common/ringpop/ringpop_test.go @@ -31,18 +31,18 @@ import ( "testing" "time" + "github.com/golang/mock/gomock" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "gopkg.in/yaml.v3" + "go.temporal.io/server/common/config" "go.temporal.io/server/common/dynamicconfig" "go.temporal.io/server/common/log" "go.temporal.io/server/common/metrics" "go.temporal.io/server/common/primitives" "go.temporal.io/server/common/rpc/encryption" - "go.temporal.io/server/tests/testhelper" - - "github.com/golang/mock/gomock" - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" - "gopkg.in/yaml.v3" + "go.temporal.io/server/tests/testutils" ) type ( @@ -54,7 +54,7 @@ type ( logger log.Logger internodeCertDir string - internodeChain testhelper.CertChain + internodeChain testutils.CertChain membershipConfig config.Membership internodeConfigMutualTLS config.GroupTLS @@ -99,7 +99,7 @@ func (s *RingpopSuite) SetupTest() { var err error s.internodeCertDir, err = os.MkdirTemp("", "RingpopSuiteInternode") s.NoError(err) - s.internodeChain, err = testhelper.GenerateTestChain(s.internodeCertDir, localhostIPv4) + s.internodeChain, err = testutils.GenerateTestChain(s.internodeCertDir, localhostIPv4) s.NoError(err) s.internodeConfigMutualTLS = config.GroupTLS{ @@ -116,11 +116,11 @@ func (s *RingpopSuite) SetupTest() { s.internodeConfigServerTLS = config.GroupTLS{ Server: config.ServerTLS{ - CertData: testhelper.ConvertFileToBase64(s.internodeChain.CertPubFile), - KeyData: testhelper.ConvertFileToBase64(s.internodeChain.CertKeyFile), + CertData: testutils.ConvertFileToBase64(s.internodeChain.CertPubFile), + KeyData: testutils.ConvertFileToBase64(s.internodeChain.CertKeyFile), }, Client: config.ClientTLS{ - RootCAData: []string{testhelper.ConvertFileToBase64(s.internodeChain.CaPubFile)}, + RootCAData: []string{testutils.ConvertFileToBase64(s.internodeChain.CaPubFile)}, }, } diff --git a/common/rpc/test/rpc_localstore_tls_test.go b/common/rpc/test/rpc_localstore_tls_test.go index 31dc09b01f6..b12c2e97197 100644 --- a/common/rpc/test/rpc_localstore_tls_test.go +++ b/common/rpc/test/rpc_localstore_tls_test.go @@ -42,7 +42,7 @@ import ( "go.temporal.io/server/common/metrics" "go.temporal.io/server/common/rpc" "go.temporal.io/server/common/rpc/encryption" - "go.temporal.io/server/tests/testhelper" + "go.temporal.io/server/tests/testutils" ) const ( @@ -84,17 +84,17 @@ type localStoreRPCSuite struct { internodeRefreshCertDir string frontendRefreshCertDir string - internodeChain testhelper.CertChain - frontendChain testhelper.CertChain - frontendAltChain testhelper.CertChain + internodeChain testutils.CertChain + frontendChain testutils.CertChain + frontendAltChain testutils.CertChain frontendRollingCerts []*tls.Certificate - internodeRefreshChain testhelper.CertChain + internodeRefreshChain testutils.CertChain internodeRefreshCA *tls.Certificate - frontendRefreshChain testhelper.CertChain + frontendRefreshChain testutils.CertChain frontendRefreshCA *tls.Certificate frontendClientCertDir string - frontendClientChain testhelper.CertChain + frontendClientChain testutils.CertChain membershipConfig config.Membership frontendConfigServerTLS config.GroupTLS @@ -141,37 +141,37 @@ func (s *localStoreRPCSuite) SetupSuite() { s.frontendCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteFrontend") s.NoError(err) - s.frontendChain, err = testhelper.GenerateTestChain(s.frontendCertDir, localhostIPv4) + s.frontendChain, err = testutils.GenerateTestChain(s.frontendCertDir, localhostIPv4) s.NoError(err) s.internodeCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteInternode") s.NoError(err) - s.internodeChain, err = testhelper.GenerateTestChain(s.internodeCertDir, localhostIPv4) + s.internodeChain, err = testutils.GenerateTestChain(s.internodeCertDir, localhostIPv4) s.NoError(err) s.frontendAltCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteFrontendAlt") s.NoError(err) - s.frontendAltChain, err = testhelper.GenerateTestChain(s.frontendAltCertDir, localhost) + s.frontendAltChain, err = testutils.GenerateTestChain(s.frontendAltCertDir, localhost) s.NoError(err) s.frontendClientCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteFrontendClient") s.NoError(err) - s.frontendClientChain, err = testhelper.GenerateTestChain(s.frontendClientCertDir, localhostIPv4) + s.frontendClientChain, err = testutils.GenerateTestChain(s.frontendClientCertDir, localhostIPv4) s.NoError(err) s.frontendRollingCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteFrontendRolling") s.NoError(err) - s.frontendRollingCerts, s.dynamicCACertPool, s.wrongCACertPool, err = testhelper.GenerateTestCerts(s.frontendRollingCertDir, localhostIPv4, 2) + s.frontendRollingCerts, s.dynamicCACertPool, s.wrongCACertPool, err = testutils.GenerateTestCerts(s.frontendRollingCertDir, localhostIPv4, 2) s.NoError(err) s.internodeRefreshCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteInternodeRefresh") s.NoError(err) - s.internodeRefreshChain, s.internodeRefreshCA, err = testhelper.GenerateTestChainWithSN(s.internodeRefreshCertDir, localhostIPv4, internodeServerCertSerialNumber) + s.internodeRefreshChain, s.internodeRefreshCA, err = testutils.GenerateTestChainWithSN(s.internodeRefreshCertDir, localhostIPv4, internodeServerCertSerialNumber) s.NoError(err) s.frontendRefreshCertDir, err = os.MkdirTemp("", "localStoreRPCSuiteFrontendRefresh") s.NoError(err) - s.frontendRefreshChain, s.frontendRefreshCA, err = testhelper.GenerateTestChainWithSN(s.frontendRefreshCertDir, localhostIPv4, frontendServerCertSerialNumber) + s.frontendRefreshChain, s.frontendRefreshCA, err = testutils.GenerateTestChainWithSN(s.frontendRefreshCertDir, localhostIPv4, frontendServerCertSerialNumber) s.NoError(err) s.membershipConfig = config.Membership{ @@ -204,7 +204,7 @@ func (s *localStoreRPCSuite) SetupSuite() { } s.frontendConfigRootCAOnly = config.GroupTLS{ Client: config.ClientTLS{ - RootCAData: []string{testhelper.ConvertFileToBase64(s.frontendChain.CaPubFile)}, + RootCAData: []string{testutils.ConvertFileToBase64(s.frontendChain.CaPubFile)}, }, } s.frontendConfigRootCAForceTLS = s.frontendConfigRootCAOnly @@ -215,7 +215,7 @@ func (s *localStoreRPCSuite) SetupSuite() { RequireClientAuth: true, }, Client: config.ClientTLS{ - RootCAData: []string{testhelper.ConvertFileToBase64(s.frontendAltChain.CaPubFile)}, + RootCAData: []string{testutils.ConvertFileToBase64(s.frontendAltChain.CaPubFile)}, }, } s.systemWorkerOnly = config.WorkerTLS{ @@ -240,11 +240,11 @@ func (s *localStoreRPCSuite) SetupSuite() { } s.internodeConfigServerTLS = config.GroupTLS{ Server: config.ServerTLS{ - CertData: testhelper.ConvertFileToBase64(s.internodeChain.CertPubFile), - KeyData: testhelper.ConvertFileToBase64(s.internodeChain.CertKeyFile), + CertData: testutils.ConvertFileToBase64(s.internodeChain.CertPubFile), + KeyData: testutils.ConvertFileToBase64(s.internodeChain.CertKeyFile), }, Client: config.ClientTLS{ - RootCAData: []string{testhelper.ConvertFileToBase64(s.internodeChain.CaPubFile)}, + RootCAData: []string{testutils.ConvertFileToBase64(s.internodeChain.CaPubFile)}, }, } s.internodeConfigAltMutualTLS = config.GroupTLS{ @@ -263,7 +263,7 @@ func (s *localStoreRPCSuite) SetupSuite() { s.frontendConfigMutualTLSRefresh = mutualGroupTLSFromChain(s.frontendRefreshChain) } -func mutualGroupTLSFromChain(chain testhelper.CertChain) config.GroupTLS { +func mutualGroupTLSFromChain(chain testutils.CertChain) config.GroupTLS { return config.GroupTLS{ Server: config.ServerTLS{ CertFile: chain.CertPubFile, @@ -638,7 +638,7 @@ func (s *localStoreRPCSuite) testServerTLSRefresh(factory *TestFactory, ca *tls. tlsInfo, err := dialHelloAndGetTLSInfo(s.Suite, host, factory, factory.serverUsage) s.validateTLSInfo(tlsInfo, err, serialNumber) // serial number of server cert before refresh - srvrCert, err := testhelper.GenerateServerCert(ca, localhostIPv4, serialNumber+100, testhelper.CertFilePath(certDir), testhelper.KeyFilePath(certDir)) + srvrCert, err := testutils.GenerateServerCert(ca, localhostIPv4, serialNumber+100, testutils.CertFilePath(certDir), testutils.KeyFilePath(certDir)) s.NoError(err) s.NotNil(srvrCert) diff --git a/develop/buildkite/pipeline.yml b/develop/buildkite/pipeline.yml index fa2654565a4..a5605423932 100644 --- a/develop/buildkite/pipeline.yml +++ b/develop/buildkite/pipeline.yml @@ -27,7 +27,7 @@ steps: agents: queue: "default" docker: "*" - command: "make db-integration-test-coverage" + command: "make integration-test-coverage" artifact_paths: - ".coverage/*.out" plugins: @@ -35,11 +35,11 @@ steps: run: db-integration-test config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration test with cassandra" + - label: ":golang: functional test with cassandra" agents: queue: "default" docker: "*" - command: "make integration-test-coverage" + command: "make functional-test-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -50,11 +50,11 @@ steps: run: integration-test-cassandra config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration test with cassandra (ES8)" + - label: ":golang: functional test with cassandra (ES8)" agents: queue: "default" docker: "*" - command: "make integration-test-coverage" + command: "make functional-test-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -65,11 +65,11 @@ steps: run: integration-test-cassandra config: ./develop/buildkite/docker-compose-es8.yml - - label: ":golang: integration xdc test with cassandra" + - label: ":golang: functional xdc test with cassandra" agents: queue: "default" docker: "*" - command: "make integration-test-xdc-coverage" + command: "make functional-test-xdc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -80,11 +80,11 @@ steps: run: integration-test-xdc-cassandra config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration ndc test with cassandra" + - label: ":golang: functional ndc test with cassandra" agents: queue: "default" docker: "*" - command: "make integration-test-ndc-coverage" + command: "make functional-test-ndc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -95,11 +95,11 @@ steps: run: integration-test-xdc-cassandra config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration test with mysql" + - label: ":golang: functional test with mysql" agents: queue: "default" docker: "*" - command: "make integration-test-coverage" + command: "make functional-test-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -110,11 +110,11 @@ steps: run: integration-test-mysql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration xdc test with mysql" + - label: ":golang: functional xdc test with mysql" agents: queue: "default" docker: "*" - command: "make integration-test-xdc-coverage" + command: "make functional-test-xdc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -125,11 +125,11 @@ steps: run: integration-test-xdc-mysql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration ndc test with mysql" + - label: ":golang: functional ndc test with mysql" agents: queue: "default" docker: "*" - command: "make integration-test-ndc-coverage" + command: "make functional-test-ndc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -140,11 +140,11 @@ steps: run: integration-test-xdc-mysql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration test with postgresql" + - label: ":golang: functional test with postgresql" agents: queue: "default" docker: "*" - command: "make integration-test-coverage" + command: "make functional-test-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -155,11 +155,11 @@ steps: run: integration-test-postgresql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration xdc test with postgresql" + - label: ":golang: functional xdc test with postgresql" agents: queue: "default" docker: "*" - command: "make integration-test-xdc-coverage" + command: "make functional-test-xdc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -170,11 +170,11 @@ steps: run: integration-test-xdc-postgresql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration ndc test with postgresql" + - label: ":golang: functional ndc test with postgresql" agents: queue: "default" docker: "*" - command: "make integration-test-ndc-coverage" + command: "make functional-test-ndc-coverage" artifact_paths: - ".coverage/*.out" retry: @@ -185,11 +185,11 @@ steps: run: integration-test-xdc-postgresql config: ./develop/buildkite/docker-compose.yml - - label: ":golang: integration test with sqlite" + - label: ":golang: functional test with sqlite" agents: queue: "default" docker: "*" - command: "make integration-test-coverage" + command: "make functional-test-coverage" artifact_paths: - ".coverage/*.out" retry: diff --git a/develop/buildkite/scripts/coverage-report.sh b/develop/buildkite/scripts/coverage-report.sh index 7a795f9bc11..eb3b2683ac6 100755 --- a/develop/buildkite/scripts/coverage-report.sh +++ b/develop/buildkite/scripts/coverage-report.sh @@ -5,28 +5,27 @@ set -eu # Download cover profiles from all the test containers. buildkite-agent artifact download ".coverage/unit_coverprofile.out" . --step ":golang: unit test" --build "${BUILDKITE_BUILD_ID}" buildkite-agent artifact download ".coverage/integration_coverprofile.out" . --step ":golang: integration test" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/db_tool_coverprofile.out" . --step ":golang: integration test" --build "${BUILDKITE_BUILD_ID}" # ES8. -buildkite-agent artifact download ".coverage/integ_cassandra_coverprofile.out" . --step ":golang: integration test with cassandra (ES8)" --build "${BUILDKITE_BUILD_ID}" -mv ./.coverage/integ_cassandra_coverprofile.out ./.coverage/integ_cassandra_es8_coverprofile.out +buildkite-agent artifact download ".coverage/functional_cassandra_coverprofile.out" . --step ":golang: functional test with cassandra (ES8)" --build "${BUILDKITE_BUILD_ID}" +mv ./.coverage/functional_cassandra_coverprofile.out ./.coverage/functional_cassandra_es8_coverprofile.out # Cassandra. -buildkite-agent artifact download ".coverage/integ_cassandra_coverprofile.out" . --step ":golang: integration test with cassandra" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_xdc_cassandra_coverprofile.out" . --step ":golang: integration xdc test with cassandra" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_ndc_cassandra_coverprofile.out" . --step ":golang: integration ndc test with cassandra" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_cassandra_coverprofile.out" . --step ":golang: functional test with cassandra" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_xdc_cassandra_coverprofile.out" . --step ":golang: functional xdc test with cassandra" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_ndc_cassandra_coverprofile.out" . --step ":golang: functional ndc test with cassandra" --build "${BUILDKITE_BUILD_ID}" # MySQL. -buildkite-agent artifact download ".coverage/integ_mysql_coverprofile.out" . --step ":golang: integration test with mysql" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_xdc_mysql_coverprofile.out" . --step ":golang: integration xdc test with mysql" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_ndc_mysql_coverprofile.out" . --step ":golang: integration ndc test with mysql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_mysql_coverprofile.out" . --step ":golang: functional test with mysql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_xdc_mysql_coverprofile.out" . --step ":golang: functional xdc test with mysql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_ndc_mysql_coverprofile.out" . --step ":golang: functional ndc test with mysql" --build "${BUILDKITE_BUILD_ID}" # PostgreSQL. -buildkite-agent artifact download ".coverage/integ_postgres_coverprofile.out" . --step ":golang: integration test with postgresql" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_xdc_postgres_coverprofile.out" . --step ":golang: integration xdc test with postgresql" --build "${BUILDKITE_BUILD_ID}" -buildkite-agent artifact download ".coverage/integ_ndc_postgres_coverprofile.out" . --step ":golang: integration ndc test with postgresql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_postgres_coverprofile.out" . --step ":golang: functional test with postgresql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_xdc_postgres_coverprofile.out" . --step ":golang: functional xdc test with postgresql" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_ndc_postgres_coverprofile.out" . --step ":golang: functional ndc test with postgresql" --build "${BUILDKITE_BUILD_ID}" # SQLite. -buildkite-agent artifact download ".coverage/integ_sqlite_coverprofile.out" . --step ":golang: integration test with sqlite" --build "${BUILDKITE_BUILD_ID}" +buildkite-agent artifact download ".coverage/functional_sqlite_coverprofile.out" . --step ":golang: functional test with sqlite" --build "${BUILDKITE_BUILD_ID}" make ci-coverage-report diff --git a/temporal/server_test.go b/temporal/server_test.go index 2a02b328ee1..98375fb6ada 100644 --- a/temporal/server_test.go +++ b/temporal/server_test.go @@ -34,12 +34,12 @@ import ( "go.temporal.io/server/common/config" // need to import this package to register the sqlite plugin _ "go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite" - "go.temporal.io/server/tests/testhelper" + "go.temporal.io/server/tests/testutils" ) // TestNewServer verifies that NewServer doesn't cause any fx errors func TestNewServer(t *testing.T) { - configDir := path.Join(testhelper.GetRepoRootDirectory(), "config") + configDir := path.Join(testutils.GetRepoRootDirectory(), "config") cfg, err := config.LoadConfig("development-sqlite", configDir, "") require.NoError(t, err) cfg.DynamicConfigClient.Filepath = path.Join(configDir, "dynamicconfig", "development-sql.yaml") diff --git a/host/acquire_shard_integration_test.go b/tests/acquire_shard_integration_test.go similarity index 99% rename from host/acquire_shard_integration_test.go rename to tests/acquire_shard_integration_test.go index 678bd0a42fd..dc9582f3fe8 100644 --- a/host/acquire_shard_integration_test.go +++ b/tests/acquire_shard_integration_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/activity_test.go b/tests/activity_test.go similarity index 99% rename from host/activity_test.go rename to tests/activity_test.go index b76448ef802..4a7b35617bb 100644 --- a/host/activity_test.go +++ b/tests/activity_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/admin_test.go b/tests/admin_test.go similarity index 99% rename from host/admin_test.go rename to tests/admin_test.go index 4316d73afa2..0142c10ccf4 100644 --- a/host/admin_test.go +++ b/tests/admin_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/archival_test.go b/tests/archival_test.go similarity index 99% rename from host/archival_test.go rename to tests/archival_test.go index ada7bab297b..dc5d27e8e05 100644 --- a/host/archival_test.go +++ b/tests/archival_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/cancel_workflow_test.go b/tests/cancel_workflow_test.go similarity index 99% rename from host/cancel_workflow_test.go rename to tests/cancel_workflow_test.go index 4f60733b2df..ebc35948b33 100644 --- a/host/cancel_workflow_test.go +++ b/tests/cancel_workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "errors" diff --git a/host/child_workflow_test.go b/tests/child_workflow_test.go similarity index 99% rename from host/child_workflow_test.go rename to tests/child_workflow_test.go index ad80ab60a9a..251813afed9 100644 --- a/host/child_workflow_test.go +++ b/tests/child_workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "fmt" diff --git a/host/client.go b/tests/client.go similarity index 99% rename from host/client.go rename to tests/client.go index 751b552f72e..6b1de977f29 100644 --- a/host/client.go +++ b/tests/client.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "google.golang.org/grpc" diff --git a/host/client_integration_test.go b/tests/client_integration_test.go similarity index 99% rename from host/client_integration_test.go rename to tests/client_integration_test.go index b6815eafd16..f234f67cc92 100644 --- a/host/client_integration_test.go +++ b/tests/client_integration_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/context.go b/tests/context.go similarity index 99% rename from host/context.go rename to tests/context.go index 31fa2ffd7ca..e4dd2eec990 100644 --- a/host/context.go +++ b/tests/context.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/continue_as_new_test.go b/tests/continue_as_new_test.go similarity index 99% rename from host/continue_as_new_test.go rename to tests/continue_as_new_test.go index c3ffb06b42a..ba7d9eb91ec 100644 --- a/host/continue_as_new_test.go +++ b/tests/continue_as_new_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/cron_test.go b/tests/cron_test.go similarity index 99% rename from host/cron_test.go rename to tests/cron_test.go index 90fb517ec3a..8209c5292f1 100644 --- a/host/cron_test.go +++ b/tests/cron_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/describe_test.go b/tests/describe_test.go similarity index 99% rename from host/describe_test.go rename to tests/describe_test.go index 177da2aae54..bb96784330b 100644 --- a/host/describe_test.go +++ b/tests/describe_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/dynamicconfig.go b/tests/dynamicconfig.go similarity index 99% rename from host/dynamicconfig.go rename to tests/dynamicconfig.go index 4ed32ea1dbe..b5fca93bd33 100644 --- a/host/dynamicconfig.go +++ b/tests/dynamicconfig.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "sync" diff --git a/host/elasticsearch_test.go b/tests/elasticsearch_test.go similarity index 99% rename from host/elasticsearch_test.go rename to tests/elasticsearch_test.go index e918c3d0ed9..b17096018b6 100644 --- a/host/elasticsearch_test.go +++ b/tests/elasticsearch_test.go @@ -24,7 +24,7 @@ //go:build esintegration -package host +package tests import ( "bytes" diff --git a/host/flag.go b/tests/flag.go similarity index 99% rename from host/flag.go rename to tests/flag.go index 8eb6545d1ca..d720e335938 100644 --- a/host/flag.go +++ b/tests/flag.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import "flag" diff --git a/host/gethistory_test.go b/tests/gethistory_test.go similarity index 99% rename from host/gethistory_test.go rename to tests/gethistory_test.go index a3eca8032f2..eec58d883d4 100644 --- a/host/gethistory_test.go +++ b/tests/gethistory_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/integration_test.go b/tests/integration_test.go similarity index 99% rename from host/integration_test.go rename to tests/integration_test.go index 82ed63ee6f0..3d381b877b7 100644 --- a/host/integration_test.go +++ b/tests/integration_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "flag" diff --git a/host/integrationbase.go b/tests/integrationbase.go similarity index 99% rename from host/integrationbase.go rename to tests/integrationbase.go index da7332662c8..8308f1b3593 100644 --- a/host/integrationbase.go +++ b/tests/integrationbase.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/max_buffered_event_test.go b/tests/max_buffered_event_test.go similarity index 99% rename from host/max_buffered_event_test.go rename to tests/max_buffered_event_test.go index d0d3138fbc1..8f7d57c86ed 100644 --- a/host/max_buffered_event_test.go +++ b/tests/max_buffered_event_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/namespace_delete_test.go b/tests/namespace_delete_test.go similarity index 99% rename from host/namespace_delete_test.go rename to tests/namespace_delete_test.go index 276df38142a..9076a0ba99e 100644 --- a/host/namespace_delete_test.go +++ b/tests/namespace_delete_test.go @@ -24,7 +24,7 @@ //go:build esintegration -package host +package tests import ( "errors" diff --git a/host/ndc/ndc_integration_test.go b/tests/ndc/ndc_integration_test.go similarity index 98% rename from host/ndc/ndc_integration_test.go rename to tests/ndc/ndc_integration_test.go index 47302fa6571..89292fc4a1d 100644 --- a/host/ndc/ndc_integration_test.go +++ b/tests/ndc/ndc_integration_test.go @@ -38,7 +38,6 @@ import ( enumspb "go.temporal.io/api/enums/v1" failurepb "go.temporal.io/api/failure/v1" - replicationpb "go.temporal.io/api/replication/v1" enumsspb "go.temporal.io/server/api/enums/v1" historyspb "go.temporal.io/server/api/history/v1" @@ -67,7 +66,7 @@ import ( "go.temporal.io/server/common/log/tag" test "go.temporal.io/server/common/testing" "go.temporal.io/server/environment" - "go.temporal.io/server/host" + "go.temporal.io/server/tests" ) type ( @@ -76,7 +75,7 @@ type ( // not merely log an error *require.Assertions suite.Suite - active *host.TestCluster + active *tests.TestCluster generator test.Generator serializer serialization.Serializer logger log.Logger @@ -91,15 +90,6 @@ type ( } ) -var ( - clusterName = []string{"active", "standby", "other"} - clusterReplicationConfig = []*replicationpb.ClusterReplicationConfig{ - {ClusterName: clusterName[0]}, - {ClusterName: clusterName[1]}, - {ClusterName: clusterName[2]}, - } -) - func TestNDCIntegrationTestSuite(t *testing.T) { flag.Parse() @@ -111,8 +101,8 @@ func (s *nDCIntegrationTestSuite) SetupSuite() { s.serializer = serialization.NewSerializer() fileName := "../testdata/ndc_integration_test_clusters.yaml" - if host.TestFlags.TestClusterConfigFile != "" { - fileName = host.TestFlags.TestClusterConfigFile + if tests.TestFlags.TestClusterConfigFile != "" { + fileName = tests.TestFlags.TestClusterConfigFile } environment.SetupEnv() @@ -120,10 +110,10 @@ func (s *nDCIntegrationTestSuite) SetupSuite() { s.Require().NoError(err) confContent = []byte(os.ExpandEnv(string(confContent))) - var clusterConfigs []*host.TestClusterConfig + var clusterConfigs []*tests.TestClusterConfig s.Require().NoError(yaml.Unmarshal(confContent, &clusterConfigs)) - clusterConfigs[0].WorkerConfig = &host.WorkerConfig{} - clusterConfigs[1].WorkerConfig = &host.WorkerConfig{} + clusterConfigs[0].WorkerConfig = &tests.WorkerConfig{} + clusterConfigs[1].WorkerConfig = &tests.WorkerConfig{} s.standByReplicationTasksChan = make(chan *replicationspb.ReplicationTask, 100) @@ -141,7 +131,7 @@ func (s *nDCIntegrationTestSuite) SetupSuite() { s.mockAdminClient["other"] = mockOtherClient clusterConfigs[0].MockAdminClient = s.mockAdminClient - cluster, err := host.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterName[0]))) + cluster, err := tests.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterName[0]))) s.Require().NoError(err) s.active = cluster @@ -248,7 +238,7 @@ func (s *nDCIntegrationTestSuite) verifyEventHistory( // get replicated history events from passive side passiveClient := s.active.GetFrontendClient() replicatedHistory, err := passiveClient.GetWorkflowExecutionHistory( - host.NewContext(), + tests.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: s.namespace.String(), Execution: &commonpb.WorkflowExecution{ @@ -1269,7 +1259,7 @@ func (s *nDCIntegrationTestSuite) TestAdminGetWorkflowExecutionRawHistoryV2() { WorkflowId: workflowID, RunId: runID, } - return adminClient.GetWorkflowExecutionRawHistoryV2(host.NewContext(), &adminservice.GetWorkflowExecutionRawHistoryV2Request{ + return adminClient.GetWorkflowExecutionRawHistoryV2(tests.NewContext(), &adminservice.GetWorkflowExecutionRawHistoryV2Request{ NamespaceId: nsID.String(), Execution: execution, StartEventId: startEventID, @@ -1743,7 +1733,7 @@ func (s *nDCIntegrationTestSuite) TestAdminGetWorkflowExecutionRawHistoryV2() { func (s *nDCIntegrationTestSuite) registerNamespace() { s.namespace = namespace.Name("test-simple-workflow-ndc-" + common.GenerateRandomString(5)) client1 := s.active.GetFrontendClient() // active - _, err := client1.RegisterNamespace(host.NewContext(), &workflowservice.RegisterNamespaceRequest{ + _, err := client1.RegisterNamespace(tests.NewContext(), &workflowservice.RegisterNamespaceRequest{ Namespace: s.namespace.String(), IsGlobalNamespace: true, Clusters: clusterReplicationConfig, @@ -1753,12 +1743,12 @@ func (s *nDCIntegrationTestSuite) registerNamespace() { }) s.Require().NoError(err) // Wait for namespace cache to pick the change - time.Sleep(2 * host.NamespaceCacheRefreshInterval) + time.Sleep(2 * tests.NamespaceCacheRefreshInterval) descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: s.namespace.String(), } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.Require().NoError(err) s.Require().NotNil(resp) s.namespaceID = namespace.ID(resp.GetNamespaceInfo().GetId()) @@ -1850,7 +1840,7 @@ func (s *nDCIntegrationTestSuite) applyEvents( taskqueue string, versionHistory *historyspb.VersionHistory, eventBatches []*historypb.History, - historyClient host.HistoryClient, + historyClient tests.HistoryClient, ) { for _, batch := range eventBatches { eventBlob, newRunEventBlob := s.generateEventBlobs(workflowID, runID, workflowType, taskqueue, batch) @@ -1865,10 +1855,10 @@ func (s *nDCIntegrationTestSuite) applyEvents( NewRunEvents: newRunEventBlob, } - resp, err := historyClient.ReplicateEventsV2(host.NewContext(), req) + resp, err := historyClient.ReplicateEventsV2(tests.NewContext(), req) s.NoError(err, "Failed to replicate history event") s.Equal(&historyservice.ReplicateEventsV2Response{}, resp) - resp, err = historyClient.ReplicateEventsV2(host.NewContext(), req) + resp, err = historyClient.ReplicateEventsV2(tests.NewContext(), req) s.NoError(err, "Failed to dedup replicate history event") s.Equal(&historyservice.ReplicateEventsV2Response{}, resp) } diff --git a/host/ndc/replication_integration_test.go b/tests/ndc/replication_integration_test.go similarity index 98% rename from host/ndc/replication_integration_test.go rename to tests/ndc/replication_integration_test.go index 0104bb6d490..c9fac739958 100644 --- a/host/ndc/replication_integration_test.go +++ b/tests/ndc/replication_integration_test.go @@ -34,8 +34,8 @@ import ( "go.temporal.io/server/common/persistence" test "go.temporal.io/server/common/testing" - "go.temporal.io/server/host" "go.temporal.io/server/service/history/tasks" + "go.temporal.io/server/tests" ) func (s *nDCIntegrationTestSuite) TestReplicationMessageApplication() { @@ -140,7 +140,7 @@ Loop: var token []byte for doPaging := true; doPaging; doPaging = len(token) > 0 { request.NextPageToken = token - response, err := executionManager.GetReplicationTasksFromDLQ(host.NewContext(), request) + response, err := executionManager.GetReplicationTasksFromDLQ(tests.NewContext(), request) if err != nil { continue Loop } diff --git a/tests/ndc/test_data.go b/tests/ndc/test_data.go new file mode 100644 index 00000000000..bc8c30c0a04 --- /dev/null +++ b/tests/ndc/test_data.go @@ -0,0 +1,36 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// 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 ndc + +import replicationpb "go.temporal.io/api/replication/v1" + +var ( + clusterName = []string{"active", "standby", "other"} + clusterReplicationConfig = []*replicationpb.ClusterReplicationConfig{ + {ClusterName: clusterName[0]}, + {ClusterName: clusterName[1]}, + {ClusterName: clusterName[2]}, + } +) diff --git a/host/onebox.go b/tests/onebox.go similarity index 99% rename from host/onebox.go rename to tests/onebox.go index d2c43d6bc37..7ed55b7a34b 100644 --- a/host/onebox.go +++ b/tests/onebox.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/query_workflow_test.go b/tests/query_workflow_test.go similarity index 99% rename from host/query_workflow_test.go rename to tests/query_workflow_test.go index 5c42571b4c5..364ca21b9ad 100644 --- a/host/query_workflow_test.go +++ b/tests/query_workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" @@ -35,6 +35,7 @@ import ( "go.temporal.io/sdk/temporal" "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" + "go.temporal.io/server/service/history/consts" "go.temporal.io/server/common/log/tag" diff --git a/host/relay_task_test.go b/tests/relay_task_test.go similarity index 99% rename from host/relay_task_test.go rename to tests/relay_task_test.go index 15b66cee869..a95cbd523fd 100644 --- a/host/relay_task_test.go +++ b/tests/relay_task_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "time" diff --git a/host/reset_workflow_test.go b/tests/reset_workflow_test.go similarity index 99% rename from host/reset_workflow_test.go rename to tests/reset_workflow_test.go index 943adc51a81..e1507533f7d 100644 --- a/host/reset_workflow_test.go +++ b/tests/reset_workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/schedule_test.go b/tests/schedule_test.go similarity index 99% rename from host/schedule_test.go rename to tests/schedule_test.go index 0b89eb2a723..5eed6467935 100644 --- a/host/schedule_test.go +++ b/tests/schedule_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "flag" diff --git a/host/signal_workflow_test.go b/tests/signal_workflow_test.go similarity index 99% rename from host/signal_workflow_test.go rename to tests/signal_workflow_test.go index 8ba1deedd1c..37ef4a64ced 100644 --- a/host/signal_workflow_test.go +++ b/tests/signal_workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/simpleMonitor.go b/tests/simpleMonitor.go similarity index 99% rename from host/simpleMonitor.go rename to tests/simpleMonitor.go index 886da95f905..f59ce195667 100644 --- a/host/simpleMonitor.go +++ b/tests/simpleMonitor.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "fmt" diff --git a/host/simpleServiceResolver.go b/tests/simpleServiceResolver.go similarity index 99% rename from host/simpleServiceResolver.go rename to tests/simpleServiceResolver.go index 347da9ae198..f6a1546e6e2 100644 --- a/host/simpleServiceResolver.go +++ b/tests/simpleServiceResolver.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "github.com/dgryski/go-farm" diff --git a/host/sizelimit_test.go b/tests/sizelimit_test.go similarity index 99% rename from host/sizelimit_test.go rename to tests/sizelimit_test.go index 0331fd4dc6a..51e82b15bb9 100644 --- a/host/sizelimit_test.go +++ b/tests/sizelimit_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/stickytq_test.go b/tests/stickytq_test.go similarity index 99% rename from host/stickytq_test.go rename to tests/stickytq_test.go index bbf69a37cf4..3cdf8ed5b3c 100644 --- a/host/stickytq_test.go +++ b/tests/stickytq_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "errors" diff --git a/host/taskpoller.go b/tests/taskpoller.go similarity index 99% rename from host/taskpoller.go rename to tests/taskpoller.go index 5ce4104ff00..8ff0dea8c3c 100644 --- a/host/taskpoller.go +++ b/tests/taskpoller.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "errors" diff --git a/host/test_cluster.go b/tests/test_cluster.go similarity index 99% rename from host/test_cluster.go rename to tests/test_cluster.go index 929ea313c83..5622d41adc7 100644 --- a/host/test_cluster.go +++ b/tests/test_cluster.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/test_search_attribute_mapper.go b/tests/test_search_attribute_mapper.go similarity index 99% rename from host/test_search_attribute_mapper.go rename to tests/test_search_attribute_mapper.go index cbc1fd96f32..2586855700d 100644 --- a/host/test_search_attribute_mapper.go +++ b/tests/test_search_attribute_mapper.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "fmt" diff --git a/host/testdata/acquire_shard_deadline_exceeded_error.yaml b/tests/testdata/acquire_shard_deadline_exceeded_error.yaml similarity index 100% rename from host/testdata/acquire_shard_deadline_exceeded_error.yaml rename to tests/testdata/acquire_shard_deadline_exceeded_error.yaml diff --git a/host/testdata/acquire_shard_eventual_success.yaml b/tests/testdata/acquire_shard_eventual_success.yaml similarity index 100% rename from host/testdata/acquire_shard_eventual_success.yaml rename to tests/testdata/acquire_shard_eventual_success.yaml diff --git a/host/testdata/acquire_shard_ownership_lost_error.yaml b/tests/testdata/acquire_shard_ownership_lost_error.yaml similarity index 100% rename from host/testdata/acquire_shard_ownership_lost_error.yaml rename to tests/testdata/acquire_shard_ownership_lost_error.yaml diff --git a/host/testdata/clientintegrationtestcluster.yaml b/tests/testdata/clientintegrationtestcluster.yaml similarity index 100% rename from host/testdata/clientintegrationtestcluster.yaml rename to tests/testdata/clientintegrationtestcluster.yaml diff --git a/host/testdata/es_v7_index_template.json b/tests/testdata/es_v7_index_template.json similarity index 100% rename from host/testdata/es_v7_index_template.json rename to tests/testdata/es_v7_index_template.json diff --git a/host/testdata/es_v8_index_template.json b/tests/testdata/es_v8_index_template.json similarity index 100% rename from host/testdata/es_v8_index_template.json rename to tests/testdata/es_v8_index_template.json diff --git a/host/testdata/integration_elasticsearch_cluster.yaml b/tests/testdata/integration_elasticsearch_cluster.yaml similarity index 100% rename from host/testdata/integration_elasticsearch_cluster.yaml rename to tests/testdata/integration_elasticsearch_cluster.yaml diff --git a/host/testdata/integration_namespace_cluster.yaml b/tests/testdata/integration_namespace_cluster.yaml similarity index 100% rename from host/testdata/integration_namespace_cluster.yaml rename to tests/testdata/integration_namespace_cluster.yaml diff --git a/host/testdata/integration_sizelimit_cluster.yaml b/tests/testdata/integration_sizelimit_cluster.yaml similarity index 100% rename from host/testdata/integration_sizelimit_cluster.yaml rename to tests/testdata/integration_sizelimit_cluster.yaml diff --git a/host/testdata/integration_test_cluster.yaml b/tests/testdata/integration_test_cluster.yaml similarity index 100% rename from host/testdata/integration_test_cluster.yaml rename to tests/testdata/integration_test_cluster.yaml diff --git a/host/testdata/ndc_integration_test_clusters.yaml b/tests/testdata/ndc_integration_test_clusters.yaml similarity index 100% rename from host/testdata/ndc_integration_test_clusters.yaml rename to tests/testdata/ndc_integration_test_clusters.yaml diff --git a/host/testdata/schedule_integration_test_cluster_adv_vis.yaml b/tests/testdata/schedule_integration_test_cluster_adv_vis.yaml similarity index 100% rename from host/testdata/schedule_integration_test_cluster_adv_vis.yaml rename to tests/testdata/schedule_integration_test_cluster_adv_vis.yaml diff --git a/host/testdata/schedule_integration_test_cluster_std_vis.yaml b/tests/testdata/schedule_integration_test_cluster_std_vis.yaml similarity index 100% rename from host/testdata/schedule_integration_test_cluster_std_vis.yaml rename to tests/testdata/schedule_integration_test_cluster_std_vis.yaml diff --git a/host/testdata/xdc_integration_es_clusters.yaml b/tests/testdata/xdc_integration_es_clusters.yaml similarity index 100% rename from host/testdata/xdc_integration_es_clusters.yaml rename to tests/testdata/xdc_integration_es_clusters.yaml diff --git a/host/testdata/xdc_integration_test_clusters.yaml b/tests/testdata/xdc_integration_test_clusters.yaml similarity index 100% rename from host/testdata/xdc_integration_test_clusters.yaml rename to tests/testdata/xdc_integration_test_clusters.yaml diff --git a/tests/testhelper/certificate.go b/tests/testutils/certificate.go similarity index 99% rename from tests/testhelper/certificate.go rename to tests/testutils/certificate.go index 9e132405365..0189c1bebf4 100644 --- a/tests/testhelper/certificate.go +++ b/tests/testutils/certificate.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package testhelper +package testutils import ( "crypto/rand" diff --git a/tests/testhelper/io.go b/tests/testutils/io.go similarity index 99% rename from tests/testhelper/io.go rename to tests/testutils/io.go index 136896392cd..11c226c5fe5 100644 --- a/tests/testhelper/io.go +++ b/tests/testutils/io.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package testhelper +package testutils import ( "os" diff --git a/tests/testhelper/source_root.go b/tests/testutils/source_root.go similarity index 99% rename from tests/testhelper/source_root.go rename to tests/testutils/source_root.go index f354a45b4cc..7c8413b445f 100644 --- a/tests/testhelper/source_root.go +++ b/tests/testutils/source_root.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package testhelper +package testutils import ( "os" diff --git a/tests/testhelper/source_root_test.go b/tests/testutils/source_root_test.go similarity index 98% rename from tests/testhelper/source_root_test.go rename to tests/testutils/source_root_test.go index 949afa52276..e62806f5653 100644 --- a/tests/testhelper/source_root_test.go +++ b/tests/testutils/source_root_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package testhelper +package testutils import ( "strings" diff --git a/tests/testhelper/tls.go b/tests/testutils/tls.go similarity index 99% rename from tests/testhelper/tls.go rename to tests/testutils/tls.go index e0117abd2e5..a49d5be5de3 100644 --- a/tests/testhelper/tls.go +++ b/tests/testutils/tls.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package testhelper +package testutils import ( "bytes" diff --git a/host/transient_task_test.go b/tests/transient_task_test.go similarity index 99% rename from host/transient_task_test.go rename to tests/transient_task_test.go index a7ce660cbfe..64a6e044e21 100644 --- a/host/transient_task_test.go +++ b/tests/transient_task_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "errors" diff --git a/host/user_timers_test.go b/tests/user_timers_test.go similarity index 99% rename from host/user_timers_test.go rename to tests/user_timers_test.go index 51758535bd0..f3fec7a40bb 100644 --- a/host/user_timers_test.go +++ b/tests/user_timers_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/util.go b/tests/util.go similarity index 99% rename from host/util.go rename to tests/util.go index fc2d787ac33..0a421f7ae87 100644 --- a/host/util.go +++ b/tests/util.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" diff --git a/host/versioning_test.go b/tests/versioning_test.go similarity index 99% rename from host/versioning_test.go rename to tests/versioning_test.go index 8444e1249a9..d89e8d381c9 100644 --- a/host/versioning_test.go +++ b/tests/versioning_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "context" @@ -42,6 +42,7 @@ import ( sdkclient "go.temporal.io/sdk/client" "go.temporal.io/sdk/worker" "go.temporal.io/sdk/workflow" + "go.temporal.io/server/common/dynamicconfig" "go.temporal.io/server/common/log/tag" ) diff --git a/host/workflow_buffered_events_test.go b/tests/workflow_buffered_events_test.go similarity index 99% rename from host/workflow_buffered_events_test.go rename to tests/workflow_buffered_events_test.go index 38550a8ad5a..8abe0cee566 100644 --- a/host/workflow_buffered_events_test.go +++ b/tests/workflow_buffered_events_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/workflow_delete_execution_test.go b/tests/workflow_delete_execution_test.go similarity index 99% rename from host/workflow_delete_execution_test.go rename to tests/workflow_delete_execution_test.go index bf1db09bbf9..2de9d0c546d 100644 --- a/host/workflow_delete_execution_test.go +++ b/tests/workflow_delete_execution_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "fmt" diff --git a/host/workflow_failures_test.go b/tests/workflow_failures_test.go similarity index 99% rename from host/workflow_failures_test.go rename to tests/workflow_failures_test.go index b01015f950d..0f33e8a39fb 100644 --- a/host/workflow_failures_test.go +++ b/tests/workflow_failures_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/workflow_memo_test.go b/tests/workflow_memo_test.go similarity index 99% rename from host/workflow_memo_test.go rename to tests/workflow_memo_test.go index ca2923b51d7..3e343961db3 100644 --- a/host/workflow_memo_test.go +++ b/tests/workflow_memo_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "time" diff --git a/host/workflow_task_test.go b/tests/workflow_task_test.go similarity index 99% rename from host/workflow_task_test.go rename to tests/workflow_task_test.go index 94f19770112..0dad9063b35 100644 --- a/host/workflow_task_test.go +++ b/tests/workflow_task_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "strconv" diff --git a/host/workflow_test.go b/tests/workflow_test.go similarity index 99% rename from host/workflow_test.go rename to tests/workflow_test.go index 27098616f22..92363dab57f 100644 --- a/host/workflow_test.go +++ b/tests/workflow_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "bytes" diff --git a/host/workflow_timer_test.go b/tests/workflow_timer_test.go similarity index 99% rename from host/workflow_timer_test.go rename to tests/workflow_timer_test.go index c561e263a21..f04cd62b8a2 100644 --- a/host/workflow_timer_test.go +++ b/tests/workflow_timer_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "fmt" diff --git a/host/workflow_visibility_test.go b/tests/workflow_visibility_test.go similarity index 99% rename from host/workflow_visibility_test.go rename to tests/workflow_visibility_test.go index de96b84522d..cff7b161047 100644 --- a/host/workflow_visibility_test.go +++ b/tests/workflow_visibility_test.go @@ -22,7 +22,7 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package host +package tests import ( "time" diff --git a/host/xdc/elasticsearch_test.go b/tests/xdc/elasticsearch_test.go similarity index 83% rename from host/xdc/elasticsearch_test.go rename to tests/xdc/elasticsearch_test.go index 981a8e4b831..9eafe8b3469 100644 --- a/host/xdc/elasticsearch_test.go +++ b/tests/xdc/elasticsearch_test.go @@ -57,13 +57,7 @@ import ( esclient "go.temporal.io/server/common/persistence/visibility/store/elasticsearch/client" "go.temporal.io/server/common/primitives/timestamp" "go.temporal.io/server/environment" - "go.temporal.io/server/host" -) - -const ( - numOfRetry = 100 - waitTimeInMs = 400 - waitForESToSettle = 4 * time.Second // wait es shards for some time ensure data consistent + "go.temporal.io/server/tests" ) type esCrossDCTestSuite struct { @@ -71,10 +65,10 @@ type esCrossDCTestSuite struct { // not merely log an error *require.Assertions suite.Suite - cluster1 *host.TestCluster - cluster2 *host.TestCluster + cluster1 *tests.TestCluster + cluster2 *tests.TestCluster logger log.Logger - clusterConfigs []*host.TestClusterConfig + clusterConfigs []*tests.TestClusterConfig esClient esclient.IntegrationTestsClient testSearchAttributeKey string @@ -102,8 +96,8 @@ func (s *esCrossDCTestSuite) SetupSuite() { s.logger = log.NewTestLogger() fileName := "../testdata/xdc_integration_es_clusters.yaml" - if host.TestFlags.TestClusterConfigFile != "" { - fileName = host.TestFlags.TestClusterConfigFile + if tests.TestFlags.TestClusterConfigFile != "" { + fileName = tests.TestFlags.TestClusterConfigFile } environment.SetupEnv() @@ -111,27 +105,27 @@ func (s *esCrossDCTestSuite) SetupSuite() { s.Require().NoError(err) confContent = []byte(os.ExpandEnv(string(confContent))) - var clusterConfigs []*host.TestClusterConfig + var clusterConfigs []*tests.TestClusterConfig s.Require().NoError(yaml.Unmarshal(confContent, &clusterConfigs)) s.clusterConfigs = clusterConfigs - c, err := host.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterNameES[0]))) + c, err := tests.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterNameES[0]))) s.Require().NoError(err) s.cluster1 = c - c, err = host.NewCluster(clusterConfigs[1], log.With(s.logger, tag.ClusterName(clusterNameES[1]))) + c, err = tests.NewCluster(clusterConfigs[1], log.With(s.logger, tag.ClusterName(clusterNameES[1]))) s.Require().NoError(err) s.cluster2 = c cluster1Address := clusterConfigs[0].ClusterMetadata.ClusterInformation[clusterConfigs[0].ClusterMetadata.CurrentClusterName].RPCAddress cluster2Address := clusterConfigs[1].ClusterMetadata.ClusterInformation[clusterConfigs[1].ClusterMetadata.CurrentClusterName].RPCAddress - _, err = s.cluster1.GetAdminClient().AddOrUpdateRemoteCluster(host.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ + _, err = s.cluster1.GetAdminClient().AddOrUpdateRemoteCluster(tests.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ FrontendAddress: cluster2Address, EnableRemoteClusterConnection: true, }) s.Require().NoError(err) - _, err = s.cluster2.GetAdminClient().AddOrUpdateRemoteCluster(host.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ + _, err = s.cluster2.GetAdminClient().AddOrUpdateRemoteCluster(tests.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ FrontendAddress: cluster1Address, EnableRemoteClusterConnection: true, }) @@ -139,10 +133,10 @@ func (s *esCrossDCTestSuite) SetupSuite() { // Wait for cluster metadata to refresh new added clusters time.Sleep(time.Millisecond * 200) - s.esClient = host.CreateESClient(&s.Suite, s.clusterConfigs[0].ESConfig, s.logger) - host.PutIndexTemplate(&s.Suite, s.esClient, fmt.Sprintf("../testdata/es_%s_index_template.json", s.clusterConfigs[0].ESConfig.Version), "test-visibility-template") - host.CreateIndex(&s.Suite, s.esClient, s.clusterConfigs[0].ESConfig.GetVisibilityIndex()) - host.CreateIndex(&s.Suite, s.esClient, s.clusterConfigs[1].ESConfig.GetVisibilityIndex()) + s.esClient = tests.CreateESClient(&s.Suite, s.clusterConfigs[0].ESConfig, s.logger) + tests.PutIndexTemplate(&s.Suite, s.esClient, fmt.Sprintf("../testdata/es_%s_index_template.json", s.clusterConfigs[0].ESConfig.Version), "test-visibility-template") + tests.CreateIndex(&s.Suite, s.esClient, s.clusterConfigs[0].ESConfig.GetVisibilityIndex()) + tests.CreateIndex(&s.Suite, s.esClient, s.clusterConfigs[1].ESConfig.GetVisibilityIndex()) s.testSearchAttributeKey = "CustomTextField" s.testSearchAttributeVal = "test value" @@ -156,8 +150,8 @@ func (s *esCrossDCTestSuite) SetupTest() { func (s *esCrossDCTestSuite) TearDownSuite() { s.cluster1.TearDownCluster() s.cluster2.TearDownCluster() - host.DeleteIndex(&s.Suite, s.esClient, s.clusterConfigs[0].ESConfig.GetVisibilityIndex()) - host.DeleteIndex(&s.Suite, s.esClient, s.clusterConfigs[1].ESConfig.GetVisibilityIndex()) + tests.DeleteIndex(&s.Suite, s.esClient, s.clusterConfigs[0].ESConfig.GetVisibilityIndex()) + tests.DeleteIndex(&s.Suite, s.esClient, s.clusterConfigs[1].ESConfig.GetVisibilityIndex()) } func (s *esCrossDCTestSuite) TestSearchAttributes() { @@ -170,7 +164,7 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { IsGlobalNamespace: true, WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change @@ -178,12 +172,12 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) client2 := s.cluster2.GetFrontendClient() // standby - resp2, err := client2.DescribeNamespace(host.NewContext(), descReq) + resp2, err := client2.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp2) s.Equal(resp, resp2) @@ -214,7 +208,7 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { SearchAttributes: searchAttr, } startTime := time.Now().UTC() - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -229,12 +223,12 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { Query: query, } - testListResult := func(client host.FrontendClient) { + testListResult := func(client tests.FrontendClient) { var openExecution *workflowpb.WorkflowExecutionInfo for i := 0; i < numOfRetry; i++ { startFilter.LatestTime = timestamp.TimePtr(time.Now().UTC()) - resp, err := client.ListWorkflowExecutions(host.NewContext(), listRequest) + resp, err := client.ListWorkflowExecutions(tests.NewContext(), listRequest) s.NoError(err) if len(resp.GetExecutions()) == 1 { openExecution = resp.GetExecutions()[0] @@ -272,7 +266,7 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { return []*commandpb.Command{upsertCommand}, nil } - poller := host.TaskPoller{ + poller := tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -294,10 +288,10 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { Query: fmt.Sprintf(`WorkflowType = '%s' and ExecutionStatus = 'Running'`, wt), } - testListResult = func(client host.FrontendClient) { + testListResult = func(client tests.FrontendClient) { verified := false for i := 0; i < numOfRetry; i++ { - resp, err := client.ListWorkflowExecutions(host.NewContext(), listRequest) + resp, err := client.ListWorkflowExecutions(tests.NewContext(), listRequest) s.NoError(err) if len(resp.GetExecutions()) == 1 { execution := resp.GetExecutions()[0] @@ -329,7 +323,7 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { // terminate workflow terminateReason := "force terminate to make sure standby process tasks" terminateDetails := payloads.EncodeString("terminate details") - _, err = client1.TerminateWorkflowExecution(host.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ + _, err = client1.TerminateWorkflowExecution(tests.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -350,7 +344,7 @@ func (s *esCrossDCTestSuite) TestSearchAttributes() { } GetHistoryLoop: for i := 0; i < 10; i++ { - historyResponse, err := client1.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err := client1.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) s.NoError(err) history := historyResponse.History @@ -375,7 +369,7 @@ GetHistoryLoop: eventsReplicated := false GetHistoryLoop2: for i := 0; i < numOfRetry; i++ { - historyResponse, err = client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil { history := historyResponse.History lastEvent := history.Events[len(history.Events)-1] diff --git a/host/xdc/integration_failover_test.go b/tests/xdc/integration_failover_test.go similarity index 92% rename from host/xdc/integration_failover_test.go rename to tests/xdc/integration_failover_test.go index 767b41ec4b4..bc4d6c4b3a2 100644 --- a/host/xdc/integration_failover_test.go +++ b/tests/xdc/integration_failover_test.go @@ -69,9 +69,9 @@ import ( "go.temporal.io/server/common/payloads" "go.temporal.io/server/common/primitives/timestamp" "go.temporal.io/server/environment" - "go.temporal.io/server/host" sw "go.temporal.io/server/service/worker" "go.temporal.io/server/service/worker/migration" + "go.temporal.io/server/tests" ) type ( @@ -80,16 +80,12 @@ type ( // not merely log an error *require.Assertions suite.Suite - cluster1 *host.TestCluster - cluster2 *host.TestCluster + cluster1 *tests.TestCluster + cluster2 *tests.TestCluster logger log.Logger } ) -const ( - cacheRefreshInterval = host.NamespaceCacheRefreshInterval + 5*time.Second -) - var ( clusterName = []string{"active", "standby"} clusterReplicationConfig = []*replicationpb.ClusterReplicationConfig{ @@ -111,8 +107,8 @@ func (s *integrationClustersTestSuite) SetupSuite() { s.logger = log.NewTestLogger() fileName := "../testdata/xdc_integration_test_clusters.yaml" - if host.TestFlags.TestClusterConfigFile != "" { - fileName = host.TestFlags.TestClusterConfigFile + if tests.TestFlags.TestClusterConfigFile != "" { + fileName = tests.TestFlags.TestClusterConfigFile } environment.SetupEnv() @@ -120,21 +116,21 @@ func (s *integrationClustersTestSuite) SetupSuite() { s.Require().NoError(err) confContent = []byte(os.ExpandEnv(string(confContent))) - var clusterConfigs []*host.TestClusterConfig + var clusterConfigs []*tests.TestClusterConfig s.Require().NoError(yaml.Unmarshal(confContent, &clusterConfigs)) - c, err := host.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterName[0]))) + c, err := tests.NewCluster(clusterConfigs[0], log.With(s.logger, tag.ClusterName(clusterName[0]))) s.Require().NoError(err) s.cluster1 = c - c, err = host.NewCluster(clusterConfigs[1], log.With(s.logger, tag.ClusterName(clusterName[1]))) + c, err = tests.NewCluster(clusterConfigs[1], log.With(s.logger, tag.ClusterName(clusterName[1]))) s.Require().NoError(err) s.cluster2 = c cluster1Address := clusterConfigs[0].ClusterMetadata.ClusterInformation[clusterConfigs[0].ClusterMetadata.CurrentClusterName].RPCAddress cluster2Address := clusterConfigs[1].ClusterMetadata.ClusterInformation[clusterConfigs[1].ClusterMetadata.CurrentClusterName].RPCAddress _, err = s.cluster1.GetAdminClient().AddOrUpdateRemoteCluster( - host.NewContext(), + tests.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ FrontendAddress: cluster2Address, EnableRemoteClusterConnection: true, @@ -142,7 +138,7 @@ func (s *integrationClustersTestSuite) SetupSuite() { s.Require().NoError(err) _, err = s.cluster2.GetAdminClient().AddOrUpdateRemoteCluster( - host.NewContext(), + tests.NewContext(), &adminservice.AddOrUpdateRemoteClusterRequest{ FrontendAddress: cluster1Address, EnableRemoteClusterConnection: true, @@ -177,7 +173,7 @@ func (s *integrationClustersTestSuite) TestNamespaceFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(7 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -185,12 +181,12 @@ func (s *integrationClustersTestSuite) TestNamespaceFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) client2 := s.cluster2.GetFrontendClient() // standby - resp2, err := client2.DescribeNamespace(host.NewContext(), descReq) + resp2, err := client2.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp2) s.Equal(resp, resp2) @@ -200,7 +196,7 @@ func (s *integrationClustersTestSuite) TestNamespaceFailover() { updated := false var resp3 *workflowservice.DescribeNamespaceResponse for i := 0; i < 30; i++ { - resp3, err = client2.DescribeNamespace(host.NewContext(), descReq) + resp3, err = client2.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) if resp3.ReplicationConfig.GetActiveClusterName() == clusterName[1] { updated = true @@ -232,7 +228,7 @@ func (s *integrationClustersTestSuite) TestNamespaceFailover() { } var we *workflowservice.StartWorkflowExecutionResponse for i := 0; i < 30; i++ { - we, err = client2.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client2.StartWorkflowExecution(tests.NewContext(), startReq) if err == nil { break } @@ -252,7 +248,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -260,12 +256,12 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespaceName, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) client2 := s.cluster2.GetFrontendClient() // standby - resp2, err := client2.DescribeNamespace(host.NewContext(), descReq) + resp2, err := client2.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp2) s.Equal(resp, resp2) @@ -288,7 +284,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(1 * time.Second), Identity: identity, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) rid := we.GetRunId() @@ -347,7 +343,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { return nil, errors.New("unknown-query-type") } - poller := host.TaskPoller{ + poller := tests.TaskPoller{ Engine: client1, Namespace: namespaceName, TaskQueue: taskQueue, @@ -359,7 +355,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { T: s.T(), } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespaceName, TaskQueue: taskQueue, @@ -382,7 +378,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { } queryResultCh := make(chan QueryResult) queryWorkflowFn := func(client workflowservice.WorkflowServiceClient, queryType string) { - queryResp, err := client.QueryWorkflow(host.NewContext(), &workflowservice.QueryWorkflowRequest{ + queryResp, err := client.QueryWorkflow(tests.NewContext(), &workflowservice.QueryWorkflowRequest{ Namespace: namespaceName, Execution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -449,7 +445,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { var historyResponse *workflowservice.GetWorkflowExecutionHistoryResponse eventsReplicated := false for i := 0; i < 15; i++ { - historyResponse, err = client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil && len(historyResponse.History.Events) == 5 { eventsReplicated = true break @@ -512,7 +508,7 @@ func (s *integrationClustersTestSuite) TestSimpleWorkflowFailover() { // check history replicated in cluster 1 eventsReplicated = false for i := 0; i < 15; i++ { - historyResponse, err = client1.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client1.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil && len(historyResponse.History.Events) == 11 { eventsReplicated = true break @@ -533,7 +529,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -541,7 +537,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -572,7 +568,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(60 * time.Second), Identity: identity1, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -602,7 +598,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { }}, nil } - poller1 := &host.TaskPoller{ + poller1 := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -614,7 +610,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { T: s.T(), } - poller2 := &host.TaskPoller{ + poller2 := &tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -634,7 +630,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { // Send a signal in cluster signalName := "my signal" signalInput := payloads.EncodeString("my signal input") - _, err = client1.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client1.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -653,7 +649,7 @@ func (s *integrationClustersTestSuite) TestStickyWorkflowTaskFailover() { s.NoError(err) s.True(secondCommandMade) - _, err = client2.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client2.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -683,7 +679,7 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -691,12 +687,12 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespaceName, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) client2 := s.cluster2.GetFrontendClient() // standby - resp2, err := client2.DescribeNamespace(host.NewContext(), descReq) + resp2, err := client2.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp2) s.Equal(resp, resp2) @@ -720,7 +716,7 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf Identity: identity, WorkflowIdReusePolicy: enumspb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) s.logger.Info("StartWorkflowExecution in cluster 1: ", tag.WorkflowRunID(we.GetRunId())) @@ -738,7 +734,7 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf }}, nil } - poller := host.TaskPoller{ + poller := tests.TaskPoller{ Engine: client1, Namespace: namespaceName, TaskQueue: taskQueue, @@ -749,7 +745,7 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf T: s.T(), } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespaceName, TaskQueue: taskQueue, @@ -771,21 +767,21 @@ func (s *integrationClustersTestSuite) TestStartWorkflowExecution_Failover_Workf // start the same workflow in cluster 2 is not allowed if policy is AllowDuplicateFailedOnly startReq.RequestId = uuid.New() startReq.WorkflowIdReusePolicy = enumspb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE_FAILED_ONLY - we, err = client2.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client2.StartWorkflowExecution(tests.NewContext(), startReq) s.IsType(&serviceerror.WorkflowExecutionAlreadyStarted{}, err) s.Nil(we) // start the same workflow in cluster 2 is not allowed if policy is RejectDuplicate startReq.RequestId = uuid.New() startReq.WorkflowIdReusePolicy = enumspb.WORKFLOW_ID_REUSE_POLICY_REJECT_DUPLICATE - we, err = client2.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client2.StartWorkflowExecution(tests.NewContext(), startReq) s.IsType(&serviceerror.WorkflowExecutionAlreadyStarted{}, err) s.Nil(we) // start the workflow in cluster 2 startReq.RequestId = uuid.New() startReq.WorkflowIdReusePolicy = enumspb.WORKFLOW_ID_REUSE_POLICY_ALLOW_DUPLICATE - we, err = client2.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client2.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) s.logger.Info("StartWorkflowExecution in cluster 2: ", tag.WorkflowRunID(we.GetRunId())) @@ -806,7 +802,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -814,7 +810,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -838,7 +834,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(1 * time.Second), Identity: identity, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -881,7 +877,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { return payloads.EncodeString("Activity Result"), false, nil } - poller := &host.TaskPoller{ + poller := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -902,7 +898,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { // terminate workflow at cluster 2 terminateReason := "terminate reason" terminateDetails := payloads.EncodeString("terminate details") - _, err = client2.TerminateWorkflowExecution(host.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ + _, err = client2.TerminateWorkflowExecution(tests.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -923,7 +919,7 @@ func (s *integrationClustersTestSuite) TestTerminateFailover() { } GetHistoryLoop: for i := 0; i < 10; i++ { - historyResponse, err := client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err := client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) s.NoError(err) history := historyResponse.History @@ -948,7 +944,7 @@ GetHistoryLoop: eventsReplicated := false GetHistoryLoop2: for i := 0; i < 15; i++ { - historyResponse, err = client1.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client1.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil { history := historyResponse.History lastEvent := history.Events[len(history.Events)-1] @@ -977,7 +973,7 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -985,7 +981,7 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1009,11 +1005,11 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(1 * time.Second), Identity: identity, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) - _, err = client1.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client1.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1050,7 +1046,7 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { } - poller := host.TaskPoller{ + poller := tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -1061,7 +1057,7 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { T: s.T(), } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1084,7 +1080,7 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { // 5. WorkflowTaskCompleted // Reset workflow execution - resetResp, err := client1.ResetWorkflowExecution(host.NewContext(), &workflowservice.ResetWorkflowExecutionRequest{ + resetResp, err := client1.ResetWorkflowExecution(tests.NewContext(), &workflowservice.ResetWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1113,12 +1109,12 @@ func (s *integrationClustersTestSuite) TestResetWorkflowFailover() { }, } - getHistoryResp, err := client1.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + getHistoryResp, err := client1.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) s.NoError(err) events := getHistoryResp.History.Events s.Equal(enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED, events[len(events)-1].GetEventType()) - getHistoryResp, err = client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + getHistoryResp, err = client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) s.NoError(err) events = getHistoryResp.History.Events s.Equal(enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_COMPLETED, events[len(events)-1].GetEventType()) @@ -1134,7 +1130,7 @@ func (s *integrationClustersTestSuite) TestContinueAsNewFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1142,7 +1138,7 @@ func (s *integrationClustersTestSuite) TestContinueAsNewFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1166,7 +1162,7 @@ func (s *integrationClustersTestSuite) TestContinueAsNewFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(1 * time.Second), Identity: identity, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -1205,7 +1201,7 @@ func (s *integrationClustersTestSuite) TestContinueAsNewFailover() { }}, nil } - poller := &host.TaskPoller{ + poller := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -1215,7 +1211,7 @@ func (s *integrationClustersTestSuite) TestContinueAsNewFailover() { T: s.T(), } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1258,7 +1254,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1266,7 +1262,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1290,7 +1286,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { WorkflowTaskTimeout: timestamp.DurationPtr(1 * time.Second), Identity: identity, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -1316,7 +1312,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { }}, nil } - poller := &host.TaskPoller{ + poller := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -1326,7 +1322,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { T: s.T(), } - poller2 := &host.TaskPoller{ + poller2 := &tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1339,7 +1335,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { // Send a signal in cluster 1 signalName := "my signal" signalInput := payloads.EncodeString("my signal input") - _, err = client1.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client1.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1370,7 +1366,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { var historyResponse *workflowservice.GetWorkflowExecutionHistoryResponse eventsReplicated := false for i := 0; i < 15; i++ { - historyResponse, err = client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil && len(historyResponse.History.Events) == 5 { eventsReplicated = true break @@ -1383,7 +1379,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { // Send another signal in cluster 2 signalName2 := "my signal 2" signalInput2 := payloads.EncodeString("my signal input 2") - _, err = client2.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client2.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1404,7 +1400,7 @@ func (s *integrationClustersTestSuite) TestSignalFailover() { // check history matched eventsReplicated = false for i := 0; i < 15; i++ { - historyResponse, err = client2.GetWorkflowExecutionHistory(host.NewContext(), getHistoryReq) + historyResponse, err = client2.GetWorkflowExecutionHistory(tests.NewContext(), getHistoryReq) if err == nil && len(historyResponse.History.Events) == 9 { eventsReplicated = true break @@ -1425,7 +1421,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1433,7 +1429,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1459,7 +1455,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { } var we *workflowservice.StartWorkflowExecutionResponse for i := 0; i < 10; i++ { - we, err = client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client1.StartWorkflowExecution(tests.NewContext(), startReq) if err == nil { break } @@ -1482,7 +1478,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { // Send a signal in cluster signalName := "my signal" signalInput := payloads.EncodeString("my signal input") - _, err = client1.SignalWorkflowExecution(host.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ + _, err = client1.SignalWorkflowExecution(tests.NewContext(), &workflowservice.SignalWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1503,7 +1499,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { } if !timerFired { - resp, err := client2.GetWorkflowExecutionHistory(host.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ + resp, err := client2.GetWorkflowExecutionHistory(tests.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: namespace, Execution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1530,7 +1526,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { }}, nil } - poller1 := &host.TaskPoller{ + poller1 := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -1540,7 +1536,7 @@ func (s *integrationClustersTestSuite) TestUserTimerFailover() { T: s.T(), } - poller2 := &host.TaskPoller{ + poller2 := &tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1583,7 +1579,7 @@ func (s *integrationClustersTestSuite) TestTransientWorkflowTaskFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1591,7 +1587,7 @@ func (s *integrationClustersTestSuite) TestTransientWorkflowTaskFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1617,7 +1613,7 @@ func (s *integrationClustersTestSuite) TestTransientWorkflowTaskFailover() { } var we *workflowservice.StartWorkflowExecutionResponse for i := 0; i < 10; i++ { - we, err = client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err = client1.StartWorkflowExecution(tests.NewContext(), startReq) if err == nil { break } @@ -1646,7 +1642,7 @@ func (s *integrationClustersTestSuite) TestTransientWorkflowTaskFailover() { }}, nil } - poller1 := &host.TaskPoller{ + poller1 := &tests.TaskPoller{ Engine: client1, Namespace: namespace, TaskQueue: taskQueue, @@ -1656,7 +1652,7 @@ func (s *integrationClustersTestSuite) TestTransientWorkflowTaskFailover() { T: s.T(), } - poller2 := &host.TaskPoller{ + poller2 := &tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1690,7 +1686,7 @@ func (s *integrationClustersTestSuite) TestCronWorkflowFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1698,7 +1694,7 @@ func (s *integrationClustersTestSuite) TestCronWorkflowFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1723,7 +1719,7 @@ func (s *integrationClustersTestSuite) TestCronWorkflowFailover() { Identity: identity, CronSchedule: "@every 5s", } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -1738,7 +1734,7 @@ func (s *integrationClustersTestSuite) TestCronWorkflowFailover() { }}, nil } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1756,7 +1752,7 @@ func (s *integrationClustersTestSuite) TestCronWorkflowFailover() { s.NoError(err) } - _, err = client2.TerminateWorkflowExecution(host.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ + _, err = client2.TerminateWorkflowExecution(tests.NewContext(), &workflowservice.TerminateWorkflowExecutionRequest{ Namespace: namespace, WorkflowExecution: &commonpb.WorkflowExecution{ WorkflowId: id, @@ -1775,7 +1771,7 @@ func (s *integrationClustersTestSuite) TestWorkflowRetryFailover() { ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -1783,7 +1779,7 @@ func (s *integrationClustersTestSuite) TestWorkflowRetryFailover() { descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) @@ -1814,7 +1810,7 @@ func (s *integrationClustersTestSuite) TestWorkflowRetryFailover() { BackoffCoefficient: 1, }, } - we, err := client1.StartWorkflowExecution(host.NewContext(), startReq) + we, err := client1.StartWorkflowExecution(tests.NewContext(), startReq) s.NoError(err) s.NotNil(we.GetRunId()) @@ -1831,7 +1827,7 @@ func (s *integrationClustersTestSuite) TestWorkflowRetryFailover() { }}, nil } - poller2 := host.TaskPoller{ + poller2 := tests.TaskPoller{ Engine: client2, Namespace: namespace, TaskQueue: taskQueue, @@ -1904,7 +1900,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() { // Start a workflow startTime := time.Now() workflowID := "integration-activity-heartbeat-workflow-failover-test" - run1, err := client1.ExecuteWorkflow(host.NewContext(), sdkclient.StartWorkflowOptions{ + run1, err := client1.ExecuteWorkflow(tests.NewContext(), sdkclient.StartWorkflowOptions{ ID: workflowID, TaskQueue: taskqueue, WorkflowRunTimeout: time.Second * 300, @@ -1939,7 +1935,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() { // Make sure the heartbeat details are sent to cluster2 even when the activity at cluster1 // has heartbeat timeout. Also make sure the information is recorded when the activity state // is "Scheduled" - dweResponse, err := client2.DescribeWorkflowExecution(host.NewContext(), workflowID, "") + dweResponse, err := client2.DescribeWorkflowExecution(tests.NewContext(), workflowID, "") s.NoError(err) pendingActivities := dweResponse.GetPendingActivities() s.Equal(1, len(pendingActivities)) @@ -1958,7 +1954,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() { defer worker2.Stop() // ExecuteWorkflow return existing running workflow if it already started - run2, err := client2.ExecuteWorkflow(host.NewContext(), sdkclient.StartWorkflowOptions{ + run2, err := client2.ExecuteWorkflow(tests.NewContext(), sdkclient.StartWorkflowOptions{ ID: workflowID, TaskQueue: taskqueue, WorkflowRunTimeout: time.Second * 300, @@ -1967,7 +1963,7 @@ func (s *integrationClustersTestSuite) TestActivityHeartbeatFailover() { // verify we get the same execution as in cluster1 s.Equal(run1.GetRunID(), run2.GetRunID()) - err = run2.Get(host.NewContext(), nil) + err = run2.Get(tests.NewContext(), nil) s.NoError(err) // workflow succeed s.Equal(2, lastAttemptCount) } @@ -2567,8 +2563,8 @@ func (s *integrationClustersTestSuite) TestForceMigration_ResetWorkflow() { verifyHistory(workflowID, resp.GetRunId()) } -func (s *integrationClustersTestSuite) getHistory(client host.FrontendClient, namespace string, execution *commonpb.WorkflowExecution) []*historypb.HistoryEvent { - historyResponse, err := client.GetWorkflowExecutionHistory(host.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ +func (s *integrationClustersTestSuite) getHistory(client tests.FrontendClient, namespace string, execution *commonpb.WorkflowExecution) []*historypb.HistoryEvent { + historyResponse, err := client.GetWorkflowExecutionHistory(tests.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: namespace, Execution: execution, MaximumPageSize: 5, // Use small page size to force pagination code path @@ -2577,7 +2573,7 @@ func (s *integrationClustersTestSuite) getHistory(client host.FrontendClient, na events := historyResponse.History.Events for historyResponse.NextPageToken != nil { - historyResponse, err = client.GetWorkflowExecutionHistory(host.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ + historyResponse, err = client.GetWorkflowExecutionHistory(tests.NewContext(), &workflowservice.GetWorkflowExecutionHistoryRequest{ Namespace: namespace, Execution: execution, NextPageToken: historyResponse.NextPageToken, @@ -2593,7 +2589,7 @@ func (s *integrationClustersTestSuite) failover( namespace string, targetCluster string, targetFailoverVersion int64, - client host.FrontendClient, + client tests.FrontendClient, ) { // wait for replication task propagation time.Sleep(4 * time.Second) @@ -2605,7 +2601,7 @@ func (s *integrationClustersTestSuite) failover( ActiveClusterName: targetCluster, }, } - updateResp, err := client.UpdateNamespace(host.NewContext(), updateReq) + updateResp, err := client.UpdateNamespace(tests.NewContext(), updateReq) s.NoError(err) s.Equal(targetCluster, updateResp.ReplicationConfig.GetActiveClusterName()) s.Equal(targetFailoverVersion, updateResp.GetFailoverVersion()) @@ -2627,7 +2623,7 @@ func (s *integrationClustersTestSuite) registerNamespace(namespace string, isGlo ActiveClusterName: clusterName[0], WorkflowExecutionRetentionPeriod: timestamp.DurationPtr(1 * time.Hour * 24), } - _, err := client1.RegisterNamespace(host.NewContext(), regReq) + _, err := client1.RegisterNamespace(tests.NewContext(), regReq) s.NoError(err) // Wait for namespace cache to pick the change time.Sleep(cacheRefreshInterval) @@ -2635,7 +2631,7 @@ func (s *integrationClustersTestSuite) registerNamespace(namespace string, isGlo descReq := &workflowservice.DescribeNamespaceRequest{ Namespace: namespace, } - resp, err := client1.DescribeNamespace(host.NewContext(), descReq) + resp, err := client1.DescribeNamespace(tests.NewContext(), descReq) s.NoError(err) s.NotNil(resp) s.Equal(namespace, resp.NamespaceInfo.Name) diff --git a/tests/single_dc_setup.go b/tests/xdc/test_data.go similarity index 80% rename from tests/single_dc_setup.go rename to tests/xdc/test_data.go index 64cbef14357..a6ec58a98b0 100644 --- a/tests/single_dc_setup.go +++ b/tests/xdc/test_data.go @@ -22,4 +22,17 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -package tests +package xdc + +import ( + "time" + + "go.temporal.io/server/tests" +) + +const ( + numOfRetry = 100 + waitTimeInMs = 400 + waitForESToSettle = 4 * time.Second // wait es shards for some time ensure data consistent + cacheRefreshInterval = tests.NamespaceCacheRefreshInterval + 5*time.Second +) diff --git a/tools/common/schema/test/dbtest.go b/tools/common/schema/test/dbtest.go index 5812323412b..5932ae9e33a 100644 --- a/tools/common/schema/test/dbtest.go +++ b/tools/common/schema/test/dbtest.go @@ -29,13 +29,12 @@ import ( "math/rand" "time" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "go.temporal.io/server/common/log" "go.temporal.io/server/common/log/tag" + "go.temporal.io/server/tests/testutils" "go.temporal.io/server/tools/common/schema" ) @@ -79,8 +78,8 @@ func (tb *DBTestBase) TearDownSuiteBase() { // RunParseFileTest runs a test against the ParseFile method func (tb *DBTestBase) RunParseFileTest(content string) { - rootDir := testhelper.MkdirTemp(tb.T(), "", "dbClientTestDir") - cqlFile := testhelper.CreateTemp(tb.T(), rootDir, "parseCQLTest") + rootDir := testutils.MkdirTemp(tb.T(), "", "dbClientTestDir") + cqlFile := testutils.CreateTemp(tb.T(), rootDir, "parseCQLTest") _, err := cqlFile.WriteString(content) tb.NoError(err) diff --git a/tools/common/schema/test/setuptest.go b/tools/common/schema/test/setuptest.go index dfa225e2839..b4a23233f8f 100644 --- a/tools/common/schema/test/setuptest.go +++ b/tools/common/schema/test/setuptest.go @@ -29,8 +29,6 @@ import ( "math/rand" "time" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/urfave/cli" @@ -38,6 +36,7 @@ import ( "go.temporal.io/server/common/convert" "go.temporal.io/server/common/log" "go.temporal.io/server/common/log/tag" + "go.temporal.io/server/tests/testutils" ) // SetupSchemaTestBase is the base test suite for all tests @@ -86,8 +85,8 @@ func (tb *SetupSchemaTestBase) RunSetupTest( tb.Nil(err) tb.Equal(0, len(tables)) - tmpDir := testhelper.MkdirTemp(tb.T(), "", "setupSchemaTestDir") - sqlFile := testhelper.CreateTemp(tb.T(), tmpDir, "setupSchema.cliOptionsTest") + tmpDir := testutils.MkdirTemp(tb.T(), "", "setupSchemaTestDir") + sqlFile := testutils.CreateTemp(tb.T(), tmpDir, "setupSchema.cliOptionsTest") _, err = sqlFile.WriteString(sqlFileContent) tb.NoError(err) diff --git a/tools/common/schema/test/updatetest.go b/tools/common/schema/test/updatetest.go index ae4627e2ad8..90dcc93b793 100644 --- a/tools/common/schema/test/updatetest.go +++ b/tools/common/schema/test/updatetest.go @@ -30,14 +30,13 @@ import ( "os" "time" - "go.temporal.io/server/tests/testhelper" - "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" "github.com/urfave/cli" "go.temporal.io/server/common/log" "go.temporal.io/server/common/log/tag" + "go.temporal.io/server/tests/testutils" ) // UpdateSchemaTestBase is the base test suite for all tests @@ -99,7 +98,7 @@ func (tb *UpdateSchemaTestBase) RunDryrunTest(app *cli.App, db DB, dbNameFlag st // RunUpdateSchemaTest tests schema update func (tb *UpdateSchemaTestBase) RunUpdateSchemaTest(app *cli.App, db DB, dbNameFlag string, sqlFileContent string, expectedTables []string) { - tmpDir := testhelper.MkdirTemp(tb.T(), "", "update_schema_test") + tmpDir := testutils.MkdirTemp(tb.T(), "", "update_schema_test") tb.makeSchemaVersionDirs(tmpDir, sqlFileContent) diff --git a/tools/common/schema/updatetask_test.go b/tools/common/schema/updatetask_test.go index 4cd797f55e7..780a044532e 100644 --- a/tools/common/schema/updatetask_test.go +++ b/tools/common/schema/updatetask_test.go @@ -29,14 +29,12 @@ import ( "testing" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" "go.uber.org/zap/zaptest" "go.temporal.io/server/common/log" - - "go.temporal.io/server/tests/testhelper" - - "github.com/stretchr/testify/require" - "github.com/stretchr/testify/suite" + "go.temporal.io/server/tests/testutils" ) type UpdateTaskTestSuite struct { @@ -60,13 +58,13 @@ var updateTaskTestData = struct { func (s *UpdateTaskTestSuite) SetupSuite() { s.Assertions = require.New(s.T()) - s.versionsDir = testhelper.MkdirTemp(s.T(), "", "update_schema_test") + s.versionsDir = testutils.MkdirTemp(s.T(), "", "update_schema_test") for _, d := range updateTaskTestData.versions { s.NoError(os.Mkdir(s.versionsDir+"/"+d, os.FileMode(0444))) } - s.emptyDir = testhelper.MkdirTemp(s.T(), "", "update_schema_test_empty") + s.emptyDir = testutils.MkdirTemp(s.T(), "", "update_schema_test_empty") s.logger = log.NewZapLogger(zaptest.NewLogger(s.T())) } @@ -134,7 +132,7 @@ func (s *UpdateTaskTestSuite) TestReadSchemaDirWithEmptyDir_ReturnsError() { } func (s *UpdateTaskTestSuite) TestReadManifest() { - tmpDir := testhelper.MkdirTemp(s.T(), "", "update_schema_test") + tmpDir := testutils.MkdirTemp(s.T(), "", "update_schema_test") input := `{ "CurrVersion": "0.4", diff --git a/tools/tests/mysql_cli_test.go b/tools/tests/mysql_cli_test.go index 9b21ab4a287..8956e715feb 100644 --- a/tools/tests/mysql_cli_test.go +++ b/tools/tests/mysql_cli_test.go @@ -36,47 +36,6 @@ import ( "go.temporal.io/server/tools/sql/clitest" ) -const ( - testUser = "temporal" - testPassword = "temporal" - testMySQLExecutionSchemaFile = "../../schema/mysql/v57/temporal/schema.sql" - testMySQLVisibilitySchemaFile = "../../schema/mysql/v57/visibility/schema.sql" - testMySQLExecutionSchemaVersionDir = "../../schema/mysql/v57/temporal/versioned" - testMySQLVisibilitySchemaVersionDir = "../../schema/mysql/v57/visibility/versioned" - testMySQLQuery = ` --- test sql file content - -CREATE TABLE executions( - shard_id INT NOT NULL, - namespace_id BINARY(16) NOT NULL, - workflow_id VARCHAR(255) NOT NULL, - run_id BINARY(16) NOT NULL, - -- - next_event_id BIGINT NOT NULL, - last_write_version BIGINT NOT NULL, - data BLOB NOT NULL, - data_encoding VARCHAR(16) NOT NULL, - state BLOB NOT NULL, - state_encoding VARCHAR(16) NOT NULL, - PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) -); - -CREATE TABLE current_executions( - shard_id INT NOT NULL, - namespace_id BINARY(16) NOT NULL, - workflow_id VARCHAR(255) NOT NULL, - -- - run_id BINARY(16) NOT NULL, - create_request_id VARCHAR(64) NOT NULL, - state INT NOT NULL, - status INT NOT NULL, - start_version BIGINT NOT NULL, - last_write_version BIGINT NOT NULL, - PRIMARY KEY (shard_id, namespace_id, workflow_id) -); -` -) - func TestMySQLConnTestSuite(t *testing.T) { suite.Run(t, clitest.NewSQLConnTestSuite( environment.GetMySQLAddress(), diff --git a/tools/tests/postgresql_cli_test.go b/tools/tests/postgresql_cli_test.go index 5cd590709ca..dc76165f718 100644 --- a/tools/tests/postgresql_cli_test.go +++ b/tools/tests/postgresql_cli_test.go @@ -36,44 +36,6 @@ import ( "go.temporal.io/server/tools/sql/clitest" ) -const ( - testPostgreSQLExecutionSchemaFile = "../../schema/postgresql/v96/temporal/schema.sql" - testPostgreSQLVisibilitySchemaFile = "../../schema/postgresql/v96/visibility/schema.sql" - testPostgreSQLExecutionSchemaVersionDir = "../../schema/postgresql/v96/temporal/versioned" - testPostgreSQLVisibilitySchemaVersionDir = "../../schema/postgresql/v96/visibility/versioned" - testPostgreSQLQuery = ` --- test sql file content - -CREATE TABLE executions( - shard_id INTEGER NOT NULL, - namespace_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, - run_id BYTEA NOT NULL, - -- - next_event_id BIGINT NOT NULL, - last_write_version BIGINT NOT NULL, - data BYTEA NOT NULL, - data_encoding VARCHAR(16) NOT NULL, - state BYTEA NOT NULL, - state_encoding VARCHAR(16) NOT NULL, - PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) -); - -CREATE TABLE current_executions( - shard_id INTEGER NOT NULL, - namespace_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, - -- - run_id BYTEA NOT NULL, - create_request_id VARCHAR(64) NOT NULL, - state INTEGER NOT NULL, - status INTEGER NOT NULL, - last_write_version BIGINT NOT NULL, - PRIMARY KEY (shard_id, namespace_id, workflow_id) -); -` -) - func TestPostgreSQLConnTestSuite(t *testing.T) { suite.Run(t, clitest.NewSQLConnTestSuite( environment.GetPostgreSQLAddress(), diff --git a/tools/tests/test_data.go b/tools/tests/test_data.go new file mode 100644 index 00000000000..51d3f9665a1 --- /dev/null +++ b/tools/tests/test_data.go @@ -0,0 +1,101 @@ +// The MIT License +// +// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. +// +// Copyright (c) 2020 Uber Technologies, Inc. +// +// 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 tests + +const ( + testUser = "temporal" + testPassword = "temporal" + testMySQLExecutionSchemaFile = "../../schema/mysql/v57/temporal/schema.sql" + testMySQLVisibilitySchemaFile = "../../schema/mysql/v57/visibility/schema.sql" + testMySQLExecutionSchemaVersionDir = "../../schema/mysql/v57/temporal/versioned" + testMySQLVisibilitySchemaVersionDir = "../../schema/mysql/v57/visibility/versioned" + testMySQLQuery = ` +-- test sql file content + +CREATE TABLE executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BINARY(16) NOT NULL, + -- + next_event_id BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + data BLOB NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + state BLOB NOT NULL, + state_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) +); + +CREATE TABLE current_executions( + shard_id INT NOT NULL, + namespace_id BINARY(16) NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + -- + run_id BINARY(16) NOT NULL, + create_request_id VARCHAR(64) NOT NULL, + state INT NOT NULL, + status INT NOT NULL, + start_version BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id) +); +` + testPostgreSQLExecutionSchemaFile = "../../schema/postgresql/v96/temporal/schema.sql" + testPostgreSQLVisibilitySchemaFile = "../../schema/postgresql/v96/visibility/schema.sql" + testPostgreSQLExecutionSchemaVersionDir = "../../schema/postgresql/v96/temporal/versioned" + testPostgreSQLVisibilitySchemaVersionDir = "../../schema/postgresql/v96/visibility/versioned" + testPostgreSQLQuery = ` +-- test sql file content + +CREATE TABLE executions( + shard_id INTEGER NOT NULL, + namespace_id BYTEA NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + run_id BYTEA NOT NULL, + -- + next_event_id BIGINT NOT NULL, + last_write_version BIGINT NOT NULL, + data BYTEA NOT NULL, + data_encoding VARCHAR(16) NOT NULL, + state BYTEA NOT NULL, + state_encoding VARCHAR(16) NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id, run_id) +); + +CREATE TABLE current_executions( + shard_id INTEGER NOT NULL, + namespace_id BYTEA NOT NULL, + workflow_id VARCHAR(255) NOT NULL, + -- + run_id BYTEA NOT NULL, + create_request_id VARCHAR(64) NOT NULL, + state INTEGER NOT NULL, + status INTEGER NOT NULL, + last_write_version BIGINT NOT NULL, + PRIMARY KEY (shard_id, namespace_id, workflow_id) +); +` +)