Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/optimize-test-sharding.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
run: |
# NOTE: shard count must match shards in run-tests.yml
go run ./cmd/tools/optimize-test-sharding \
-shards 3 \
-shards 5 \
-workflow run-tests.yml \
-artifact-pattern 'junit-xml--*shard*--functional-test' \
-file "${{ env.SALT_FILE }}" \
Expand Down
24 changes: 15 additions & 9 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ env:
DOCKER_COMPOSE_FILE: ./develop/github/docker-compose.yml
TEMPORAL_VERSION_CHECK_DISABLED: 1
MAX_TEST_ATTEMPTS: 3
SHARD_COUNT: 3 # NOTE: must match shard count in optimize-test-sharding.yml
SHARD_COUNT: 5 # NOTE: must match shard count in optimize-test-sharding.yml
RUNNER_ARM: ubuntu-24.04-arm

jobs:
test-setup:
Expand Down Expand Up @@ -99,14 +100,7 @@ jobs:

- name: Configure runners
id: configure_runners
run: |
# Use 8-core runners for temporalio org, standard runners for forks
if [[ "${{ github.repository_owner }}" == "temporalio" ]]; then
runner_arm="ubuntu-24.04-arm64-8-cores"
else
runner_arm="ubuntu-24.04-arm"
fi
echo "runner_arm=$runner_arm" >> "$GITHUB_OUTPUT"
run: echo "runner_arm=$RUNNER_ARM" >> "$GITHUB_OUTPUT"

# Primary DBs always get full tests, extended DBs get smoke tests (1 job) in abridged PRs.
- name: Build job matrix
Expand Down Expand Up @@ -154,6 +148,7 @@ jobs:
test_timeout: 35m
github_timeout: 40
sharded: true
reuse_schema: true
smoke:
cmd: make functional-test-coverage
test_timeout: 5m
Expand Down Expand Up @@ -539,6 +534,15 @@ jobs:
# shellcheck disable=SC2046
docker compose -f ${{ env.DOCKER_COMPOSE_FILE }} up --wait $(docker compose -f ${{ env.DOCKER_COMPOSE_FILE }} ps --services)

- name: Install schema
if: ${{ matrix.reuse_schema }}
run: |
case "${{ matrix.persistence_driver }}" in
cassandra) make install-schema-functional-cassandra ;;
mysql8) make install-schema-functional-mysql8 ;;
postgres12*) make install-schema-functional-postgresql12 ;;
esac

- name: Run functional test
timeout-minutes: ${{ matrix.github_timeout }}
run: ./develop/github/monitor_test.sh ${{ matrix.cmd }}
Expand All @@ -548,6 +552,8 @@ jobs:
TEST_ARGS: "${{ matrix.test_args }}"
TEMPORAL_TEST_LOG_FILE: ${{ github.workspace }}/.testoutput/debug.log
TEMPORAL_TEST_LOG_LEVEL: info
GOMEMLIMIT: 5GiB
TEMPORAL_REUSE_SCHEMA: ${{ matrix.reuse_schema && 'true' || '' }}

- name: Dump container logs
if: ${{ failure() && toJson(matrix.containers) != '[]' }}
Expand Down
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,29 @@ install-schema-postgresql12: temporal-sql-tool
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) setup-schema -v 0.0
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(VISIBILITY_DB) update-schema -d ./schema/postgresql/v12/visibility/versioned

install-schema-functional-cassandra: temporal-cassandra-tool
@printf $(COLOR) "Install Cassandra functional test schema..."
./temporal-cassandra-tool drop -k $(TEMPORAL_DB) -f
./temporal-cassandra-tool create -k $(TEMPORAL_DB) --rf 1
./temporal-cassandra-tool -k $(TEMPORAL_DB) setup-schema -v 0.0
./temporal-cassandra-tool -k $(TEMPORAL_DB) update-schema -d ./schema/cassandra/temporal/versioned

install-schema-functional-mysql8: temporal-sql-tool
@printf $(COLOR) "Install MySQL functional test schema (temporal + visibility into one DB)..."
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) --pl mysql8 --db $(TEMPORAL_DB) drop -f
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) --pl mysql8 --db $(TEMPORAL_DB) create
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) --pl mysql8 --db $(TEMPORAL_DB) setup-schema -v 0.0
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) --pl mysql8 --db $(TEMPORAL_DB) update-schema -d ./schema/mysql/v8/temporal/versioned
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) --pl mysql8 --db $(TEMPORAL_DB) update-schema -d ./schema/mysql/v8/visibility/versioned

install-schema-functional-postgresql12: temporal-sql-tool
@printf $(COLOR) "Install Postgres functional test schema (temporal + visibility into one DB)..."
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) drop -f
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) create
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) setup-schema -v 0.0
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) update-schema -d ./schema/postgresql/v12/temporal/versioned
./temporal-sql-tool -u $(SQL_USER) --pw $(SQL_PASSWORD) -p 5432 --pl postgres12 --db $(TEMPORAL_DB) update-schema -d ./schema/postgresql/v12/visibility/versioned

install-schema-es: temporal-elasticsearch-tool
@printf $(COLOR) "Install Elasticsearch schema..."
./temporal-elasticsearch-tool -ep http://127.0.0.1:9200 setup-schema
Expand Down
24 changes: 16 additions & 8 deletions common/persistence/cassandra/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,17 @@ const (

// TestCluster allows executing cassandra operations in testing.
type TestCluster struct {
keyspace string
schemaDir string
session commongocql.Session
cfg config.Cassandra
faultInjection *config.FaultInjection
logger log.Logger
keyspace string
schemaDir string
session commongocql.Session
cfg config.Cassandra
faultInjection *config.FaultInjection
skipSchemaSetup bool
logger log.Logger
}

// NewTestCluster returns a new cassandra test cluster
func NewTestCluster(keyspace, username, password, host string, port int, schemaDir string, faultInjection *config.FaultInjection, logger log.Logger) *TestCluster {
func NewTestCluster(keyspace, username, password, host string, port int, schemaDir string, faultInjection *config.FaultInjection, skipSchemaSetup bool, logger log.Logger) *TestCluster {
var result TestCluster
result.logger = logger
result.keyspace = keyspace
Expand All @@ -60,6 +61,7 @@ func NewTestCluster(keyspace, username, password, host string, port int, schemaD
Keyspace: keyspace,
}
result.faultInjection = faultInjection
result.skipSchemaSetup = skipSchemaSetup
return &result
}

Expand All @@ -82,6 +84,10 @@ func (s *TestCluster) DatabaseName() string {

// SetupTestDatabase from PersistenceTestCluster interface
func (s *TestCluster) SetupTestDatabase() {
if s.skipSchemaSetup {
s.CreateSession(s.DatabaseName())
return
}
s.CreateSession("system")
s.CreateDatabase()
s.CreateSession(s.DatabaseName())
Expand All @@ -97,7 +103,9 @@ func (s *TestCluster) SetupTestDatabase() {

// TearDownTestDatabase from PersistenceTestCluster interface
func (s *TestCluster) TearDownTestDatabase() {
s.DropDatabase()
if !s.skipSchemaSetup {
s.DropDatabase()
}
s.session.Close()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ type (
SchemaDir string `yaml:"-"`
FaultInjection *config.FaultInjection
Logger log.Logger `yaml:"-"`
// SkipSchemaSetup skips database creation, schema loading, and teardown.
// Use when the database and schema are pre-created externally (e.g. in CI).
SkipSchemaSetup bool `yaml:"-"`
}
)

Expand Down Expand Up @@ -131,7 +134,7 @@ func NewTestClusterForCassandra(options *TestBaseOptions, logger log.Logger) *ca
if options.DBName == "" {
options.DBName = "test_" + GenerateRandomDBName(3)
}
testCluster := cassandra.NewTestCluster(options.DBName, options.DBUsername, options.DBPassword, options.DBHost, options.DBPort, options.SchemaDir, options.FaultInjection, logger)
testCluster := cassandra.NewTestCluster(options.DBName, options.DBUsername, options.DBPassword, options.DBHost, options.DBPort, options.SchemaDir, options.FaultInjection, options.SkipSchemaSetup, logger)
return testCluster
}

Expand Down Expand Up @@ -166,7 +169,7 @@ func NewTestBaseWithSQL(options *TestBaseOptions) *TestBase {
panic(fmt.Sprintf("unknown sql store driver: %v", options.SQLDBPluginName))
}
}
testCluster := sql.NewTestCluster(options.SQLDBPluginName, options.DBName, options.DBUsername, options.DBPassword, options.DBHost, options.DBPort, options.ConnectAttributes, options.SchemaDir, options.FaultInjection, logger)
testCluster := sql.NewTestCluster(options.SQLDBPluginName, options.DBName, options.DBUsername, options.DBPassword, options.DBHost, options.DBPort, options.ConnectAttributes, options.SchemaDir, options.FaultInjection, options.SkipSchemaSetup, logger)
return NewTestBaseForCluster(testCluster, logger)
}

Expand Down
Loading
Loading