Skip to content

Commit

Permalink
persistenceTestBase: re-expose dbport/schemaDir options for internal …
Browse files Browse the repository at this point in the history
…integration test (cadence-workflow#1675)
  • Loading branch information
venkat1109 authored Apr 8, 2019
1 parent ad28117 commit fe12d70
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
12 changes: 9 additions & 3 deletions common/persistence/cassandra/cassandraPersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,21 @@ type TestCluster struct {
}

// NewTestCluster returns a new cassandra test cluster
func NewTestCluster(keyspace string) *TestCluster {
func NewTestCluster(keyspace string, port int, schemaDir string) *TestCluster {
var result TestCluster
result.keyspace = keyspace
result.schemaDir = testSchemaDir
if port == 0 {
port = environment.GetCassandraPort()
}
if schemaDir == "" {
schemaDir = testSchemaDir
}
result.schemaDir = schemaDir
result.cfg = config.Cassandra{
User: testUser,
Password: testPassword,
Hosts: environment.GetCassandraAddress(),
Port: environment.GetCassandraPort(),
Port: port,
MaxConns: 2,
Keyspace: keyspace,
}
Expand Down
6 changes: 4 additions & 2 deletions common/persistence/persistence-tests/persistenceTestBase.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ type (
// TestBaseOptions options to configure workflow test base.
TestBaseOptions struct {
DBName string
DBPort int `yaml:"-"`
StoreType string `yaml:"-"`
SchemaDir string `yaml:"-"`
ClusterMetadata cluster.Metadata `yaml:"-"`
}

Expand Down Expand Up @@ -105,7 +107,7 @@ func NewTestBaseWithCassandra(options *TestBaseOptions) TestBase {
if options.DBName == "" {
options.DBName = "test_" + GenerateRandomDBName(10)
}
testCluster := cassandra.NewTestCluster(options.DBName)
testCluster := cassandra.NewTestCluster(options.DBName, options.DBPort, options.SchemaDir)
return newTestBase(options, testCluster)
}

Expand All @@ -114,7 +116,7 @@ func NewTestBaseWithSQL(options *TestBaseOptions) TestBase {
if options.DBName == "" {
options.DBName = GenerateRandomDBName(10)
}
testCluster := sql.NewTestCluster(options.DBName)
testCluster := sql.NewTestCluster(options.DBName, options.DBPort, options.SchemaDir)
return newTestBase(options, testCluster)
}

Expand Down
20 changes: 12 additions & 8 deletions common/persistence/sql/sqlPersistenceTest.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ import (
)

const (
testWorkflowClusterHosts = "127.0.0.1"
testPort = 3306
testUser = "uber"
testPassword = "uber"
testSchemaDir = "schema/mysql/v57"
testUser = "uber"
testPassword = "uber"
testSchemaDir = "schema/mysql/v57"
)

// TestCluster allows executing cassandra operations in testing.
Expand All @@ -50,14 +48,20 @@ type TestCluster struct {
}

// NewTestCluster returns a new SQL test cluster
func NewTestCluster(dbName string) *TestCluster {
func NewTestCluster(dbName string, port int, schemaDir string) *TestCluster {
var result TestCluster
result.dbName = dbName
result.schemaDir = testSchemaDir
if port == 0 {
port = environment.GetMySQLPort()
}
if schemaDir == "" {
schemaDir = testSchemaDir
}
result.schemaDir = schemaDir
result.cfg = config.SQL{
User: testUser,
Password: testPassword,
ConnectAddr: fmt.Sprintf("%v:%v", environment.GetMySQLAddress(), environment.GetMySQLPort()),
ConnectAddr: fmt.Sprintf("%v:%v", environment.GetMySQLAddress(), port),
ConnectProtocol: "tcp",
DriverName: defaultDriverName,
DatabaseName: dbName,
Expand Down

0 comments on commit fe12d70

Please sign in to comment.