Skip to content

Commit

Permalink
Refactor var names related to visibility mysql8 and postgres12 (tempo…
Browse files Browse the repository at this point in the history
…ralio#5464)

## What changed?
<!-- Describe what has changed in this PR -->
Rename vars related to visibility.

## Why?
<!-- Tell your future self why have you made these changes -->
Ease to read code.

## How did you test it?
<!-- How have you verified this change? Tested locally? Added a unit
test? Checked in staging env? -->
Existing unit tests.

## Potential risks
<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
No.

## Documentation
<!-- Have you made sure this change doesn't falsify anything currently
stated in `docs/`? If significant
new behavior is added, have you described that in `docs/`? -->

## Is hotfix candidate?
<!-- Is this PR a hotfix candidate or does it require a notification to
be sent to the broader community? (Yes/No) -->
No
  • Loading branch information
rodrigozhou authored Feb 29, 2024
1 parent ebda7a5 commit 849fb7b
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 107 deletions.
8 changes: 4 additions & 4 deletions common/persistence/persistence-tests/persistence_test_base.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,9 @@ func NewTestBaseWithSQL(options *TestBaseOptions) *TestBase {

if options.DBPort == 0 {
switch options.SQLDBPluginName {
case mysql.PluginNameV8:
case mysql.PluginName:
options.DBPort = environment.GetMySQLPort()
case postgresql.PluginNameV12, postgresql.PluginNameV12PGX:
case postgresql.PluginName, postgresql.PluginNamePGX:
options.DBPort = environment.GetPostgreSQLPort()
case sqlite.PluginName:
options.DBPort = 0
Expand All @@ -161,9 +161,9 @@ func NewTestBaseWithSQL(options *TestBaseOptions) *TestBase {
}
if options.DBHost == "" {
switch options.SQLDBPluginName {
case mysql.PluginNameV8:
case mysql.PluginName:
options.DBHost = environment.GetMySQLAddress()
case postgresql.PluginNameV12, postgresql.PluginNameV12PGX:
case postgresql.PluginName, postgresql.PluginNamePGX:
options.DBHost = environment.GetPostgreSQLAddress()
case sqlite.PluginName:
options.DBHost = environment.GetLocalhostIP()
Expand Down
36 changes: 18 additions & 18 deletions common/persistence/persistence-tests/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ import (
)

const (
testMySQLUser = "temporal"
testMySQLPassword = "temporal"
testMySQL8SchemaDir = "schema/mysql/v8"
testMySQLUser = "temporal"
testMySQLPassword = "temporal"
testMySQLSchemaDir = "schema/mysql/v8"

testPostgreSQLUser = "temporal"
testPostgreSQLPassword = "temporal"
testPostgreSQL12SchemaDir = "schema/postgresql/v12"
testPostgreSQLUser = "temporal"
testPostgreSQLPassword = "temporal"
testPostgreSQLSchemaDir = "schema/postgresql/v12"

testSQLiteUser = ""
testSQLitePassword = ""
Expand All @@ -48,41 +48,41 @@ const (
testSQLiteSchemaDir = "schema/sqlite/v3" // specify if mode is not "memory"
)

// GetMySQL8TestClusterOption return test options
func GetMySQL8TestClusterOption() *TestBaseOptions {
// GetMySQLTestClusterOption return test options
func GetMySQLTestClusterOption() *TestBaseOptions {
return &TestBaseOptions{
SQLDBPluginName: mysql.PluginNameV8,
SQLDBPluginName: mysql.PluginName,
DBUsername: testMySQLUser,
DBPassword: testMySQLPassword,
DBHost: environment.GetMySQLAddress(),
DBPort: environment.GetMySQLPort(),
SchemaDir: testMySQL8SchemaDir,
SchemaDir: testMySQLSchemaDir,
StoreType: config.StoreTypeSQL,
}
}

// GetPostgreSQL12TestClusterOption return test options
func GetPostgreSQL12TestClusterOption() *TestBaseOptions {
// GetPostgreSQLTestClusterOption return test options
func GetPostgreSQLTestClusterOption() *TestBaseOptions {
return &TestBaseOptions{
SQLDBPluginName: postgresql.PluginNameV12,
SQLDBPluginName: postgresql.PluginName,
DBUsername: testPostgreSQLUser,
DBPassword: testPostgreSQLPassword,
DBHost: environment.GetPostgreSQLAddress(),
DBPort: environment.GetPostgreSQLPort(),
SchemaDir: testPostgreSQL12SchemaDir,
SchemaDir: testPostgreSQLSchemaDir,
StoreType: config.StoreTypeSQL,
}
}

// GetPostgreSQL12PGXTestClusterOption return test options
func GetPostgreSQL12PGXTestClusterOption() *TestBaseOptions {
// GetPostgreSQLPGXTestClusterOption return test options
func GetPostgreSQLPGXTestClusterOption() *TestBaseOptions {
return &TestBaseOptions{
SQLDBPluginName: postgresql.PluginNameV12PGX,
SQLDBPluginName: postgresql.PluginNamePGX,
DBUsername: testPostgreSQLUser,
DBPassword: testPostgreSQLPassword,
DBHost: environment.GetPostgreSQLAddress(),
DBPort: environment.GetPostgreSQLPort(),
SchemaDir: testPostgreSQL12SchemaDir,
SchemaDir: testPostgreSQLSchemaDir,
StoreType: config.StoreTypeSQL,
}
}
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/sql/sqlplugin/mysql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (mdb *db) Close() error {

// PluginName returns the name of the mysql plugin
func (mdb *db) PluginName() string {
return PluginNameV8
return PluginName
}

// DbName returns the name of the database
Expand Down
4 changes: 2 additions & 2 deletions common/persistence/sql/sqlplugin/mysql/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ import (

const (
// PluginName is the name of the plugin
PluginNameV8 = "mysql8"
PluginName = "mysql8"
)

type plugin struct{}

var _ sqlplugin.Plugin = (*plugin)(nil)

func init() {
sql.RegisterPlugin(PluginNameV8, &plugin{})
sql.RegisterPlugin(PluginName, &plugin{})
}

// CreateDB initialize the db object
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/sql/sqlplugin/postgresql/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func (pdb *db) Close() error {

// PluginName returns the name of the mysql plugin
func (pdb *db) PluginName() string {
return PluginNameV12
return PluginName
}

// DbName returns the name of the database
Expand Down
8 changes: 4 additions & 4 deletions common/persistence/sql/sqlplugin/postgresql/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ import (

const (
// PluginName is the name of the plugin
PluginNameV12 = "postgres12"
PluginNameV12PGX = "postgres12_pgx"
PluginName = "postgres12"
PluginNamePGX = "postgres12_pgx"
)

var (
Expand All @@ -59,8 +59,8 @@ type plugin struct {
var _ sqlplugin.Plugin = (*plugin)(nil)

func init() {
sql.RegisterPlugin(PluginNameV12, &plugin{&driver.PQDriver{}})
sql.RegisterPlugin(PluginNameV12PGX, &plugin{&driver.PGXDriver{}})
sql.RegisterPlugin(PluginName, &plugin{&driver.PQDriver{}})
sql.RegisterPlugin(PluginNamePGX, &plugin{&driver.PGXDriver{}})

}

Expand Down
20 changes: 10 additions & 10 deletions common/persistence/tests/mysql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,39 +145,39 @@ func TestMySQLTaskQueueTaskSuite(t *testing.T) {
suite.Run(t, s)
}

func TestMySQL8VisibilityPersistenceSuite(t *testing.T) {
func TestMySQLVisibilityPersistenceSuite(t *testing.T) {
s := &VisibilityPersistenceSuite{
TestBase: persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQL8TestClusterOption()),
TestBase: persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQLTestClusterOption()),
}
suite.Run(t, s)
}

// TODO: Merge persistence-tests into the tests directory.

func TestMySQL8HistoryV2PersistenceSuite(t *testing.T) {
func TestMySQLHistoryV2PersistenceSuite(t *testing.T) {
s := new(persistencetests.HistoryV2PersistenceSuite)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQL8TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(t, s)
}

func TestMySQL8MetadataPersistenceSuiteV2(t *testing.T) {
func TestMySQLMetadataPersistenceSuiteV2(t *testing.T) {
s := new(persistencetests.MetadataPersistenceSuiteV2)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQL8TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(t, s)
}

func TestMySQL8QueuePersistence(t *testing.T) {
func TestMySQLQueuePersistence(t *testing.T) {
s := new(persistencetests.QueuePersistenceSuite)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQL8TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(t, s)
}

func TestMySQL8ClusterMetadataPersistence(t *testing.T) {
func TestMySQLClusterMetadataPersistence(t *testing.T) {
s := new(persistencetests.ClusterMetadataManagerSuite)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQL8TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetMySQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(t, s)
}
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/tests/mysql_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewMySQLConfig() *config.SQL {
strconv.Itoa(environment.GetMySQLPort()),
),
ConnectProtocol: testMySQLConnectionProtocol,
PluginName: mysql.PluginNameV8,
PluginName: mysql.PluginName,
DatabaseName: testMySQLDatabaseNamePrefix + shuffle.String(testMySQLDatabaseNameSuffix),
}
}
Expand Down
20 changes: 10 additions & 10 deletions common/persistence/tests/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,32 +146,32 @@ func (p *PostgreSQLSuite) TestPostgreSQLTaskQueueTaskSuite() {
suite.Run(p.T(), s)
}

func (p *PostgreSQLSuite) TestPostgreSQL12VisibilityPersistenceSuite() {
func (p *PostgreSQLSuite) TestPostgreSQLVisibilityPersistenceSuite() {
s := &VisibilityPersistenceSuite{
TestBase: persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQL12TestClusterOption()),
TestBase: persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQLTestClusterOption()),
}
suite.Run(p.T(), s)
}

// TODO: Merge persistence-tests into the tests directory.

func (p *PostgreSQLSuite) TestPostgreSQL12HistoryV2PersistenceSuite() {
func (p *PostgreSQLSuite) TestPostgreSQLHistoryV2PersistenceSuite() {
s := new(persistencetests.HistoryV2PersistenceSuite)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQL12TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(p.T(), s)
}

func (p *PostgreSQLSuite) TestPostgreSQL12MetadataPersistenceSuiteV2() {
func (p *PostgreSQLSuite) TestPostgreSQLMetadataPersistenceSuiteV2() {
s := new(persistencetests.MetadataPersistenceSuiteV2)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQL12TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(p.T(), s)
}

func (p *PostgreSQLSuite) TestPostgreSQL12ClusterMetadataPersistence() {
func (p *PostgreSQLSuite) TestPostgreSQLClusterMetadataPersistence() {
s := new(persistencetests.ClusterMetadataManagerSuite)
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQL12TestClusterOption())
s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQLTestClusterOption())
s.TestBase.Setup(nil)
suite.Run(p.T(), s)
}
Expand All @@ -187,9 +187,9 @@ FAIL: TestPostgreSQLQueuePersistence/TestNamespaceReplicationQueue (0.26s)
actual : 98
Test: TestPostgreSQLQueuePersistence/TestNamespaceReplicationQueue
*/
// func (p *PostgreSQLSuite) TestPostgreSQL12QueuePersistence() {
// func (p *PostgreSQLSuite) TestPostgreSQLQueuePersistence() {
// s := new(persistencetests.QueuePersistenceSuite)
// s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQL12TestClusterOption())
// s.TestBase = persistencetests.NewTestBaseWithSQL(persistencetests.GetPostgreSQLTestClusterOption())
// s.TestBase.Setup(nil)
// suite.Run(p.T(), s)
// }
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/visibility/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func AllowListForValidation(
}

switch storeNames[0] {
case mysql.PluginNameV8, postgresql.PluginNameV12, postgresql.PluginNameV12PGX, sqlite.PluginName:
case mysql.PluginName, postgresql.PluginName, postgresql.PluginNamePGX, sqlite.PluginName:
// Advanced visibility with SQL DB don't support list of values
return dynamicconfig.GetBoolPropertyFnFilteredByNamespace(false)
default:
Expand Down
4 changes: 2 additions & 2 deletions common/persistence/visibility/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ func NewManager(
isPrimaryAdvancedSQL := false
isSecondaryAdvancedSQL := false
switch visibilityManager.GetStoreNames()[0] {
case mysql.PluginNameV8, postgresql.PluginNameV12, postgresql.PluginNameV12PGX, sqlite.PluginName:
case mysql.PluginName, postgresql.PluginName, postgresql.PluginNamePGX, sqlite.PluginName:
isPrimaryAdvancedSQL = true
}
switch secondaryVisibilityManager.GetStoreNames()[0] {
case mysql.PluginNameV8, postgresql.PluginNameV12, postgresql.PluginNameV12PGX, sqlite.PluginName:
case mysql.PluginName, postgresql.PluginName, postgresql.PluginNamePGX, sqlite.PluginName:
isSecondaryAdvancedSQL = true
}
if isPrimaryAdvancedSQL && !isSecondaryAdvancedSQL {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ func NewQueryConverter(
queryString string,
) *QueryConverter {
switch pluginName {
case mysql.PluginNameV8:
case mysql.PluginName:
return newMySQLQueryConverter(namespaceName, namespaceID, saTypeMap, saMapper, queryString)
case postgresql.PluginNameV12, postgresql.PluginNameV12PGX:
case postgresql.PluginName, postgresql.PluginNamePGX:
return newPostgreSQLQueryConverter(namespaceName, namespaceID, saTypeMap, saMapper, queryString)
case sqlite.PluginName:
return newSqliteQueryConverter(namespaceName, namespaceID, saTypeMap, saMapper, queryString)
Expand Down
2 changes: 1 addition & 1 deletion common/persistence/visibility/visibility_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *VisibilityManagerSuite) SetupTest() {

s.controller = gomock.NewController(s.T())
s.visibilityStore = store.NewMockVisibilityStore(s.controller)
s.visibilityStore.EXPECT().GetName().Return(mysql.PluginNameV8).AnyTimes()
s.visibilityStore.EXPECT().GetName().Return(mysql.PluginName).AnyTimes()
s.visibilityStore.EXPECT().GetIndexName().Return("test-index-name").AnyTimes()
s.metricsHandler = metrics.NewMockHandler(s.controller)
s.visibilityManager = newVisibilityManager(
Expand Down
10 changes: 5 additions & 5 deletions service/frontend/operator_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributes_DualVisibility() {

mockVisManager1.EXPECT().GetStoreNames().Return([]string{elasticsearch.PersistenceName}).AnyTimes()
mockVisManager1.EXPECT().GetIndexName().Return(testIndexName).AnyTimes()
mockVisManager2.EXPECT().GetStoreNames().Return([]string{mysql.PluginNameV8}).AnyTimes()
mockVisManager2.EXPECT().GetStoreNames().Return([]string{mysql.PluginName}).AnyTimes()
mockVisManager2.EXPECT().GetIndexName().Return(testIndexName).AnyTimes()

s.mockResource.SearchAttributesManager.EXPECT().
Expand Down Expand Up @@ -291,7 +291,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributes_DualVisibility() {
addVisManager2Err: errors.New("mock error add vis manager 2"),
expectedErrMsg: fmt.Sprintf(
"Failed to add search attributes to store %s",
mysql.PluginNameV8,
mysql.PluginName,
),
},
}
Expand Down Expand Up @@ -374,7 +374,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributesInternal() {
"CustomAttr": enumspb.INDEXED_VALUE_TYPE_KEYWORD,
},
},
storeName: mysql.PluginNameV8,
storeName: mysql.PluginName,
expectedErrMsg: "",
},
{
Expand Down Expand Up @@ -422,7 +422,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributesInternal() {
},
Namespace: testNamespace,
},
storeName: mysql.PluginNameV8,
storeName: mysql.PluginName,
indexName: testIndexName,
addSqlCalled: true,
addSqlErr: errors.New("mock error add sql wf"),
Expand All @@ -436,7 +436,7 @@ func (s *operatorHandlerSuite) Test_AddSearchAttributesInternal() {
},
Namespace: testNamespace,
},
storeName: mysql.PluginNameV8,
storeName: mysql.PluginName,
indexName: testIndexName,
addSqlCalled: true,
expectedErrMsg: "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func NewLocalActivities(

func (a *LocalActivities) IsAdvancedVisibilityActivity(_ context.Context, nsName namespace.Name) (bool, error) {
switch a.visibilityManager.GetReadStoreName(nsName) {
case elasticsearch.PersistenceName, mysql.PluginNameV8, postgresql.PluginNameV12, postgresql.PluginNameV12PGX, sqlite.PluginName:
case elasticsearch.PersistenceName, mysql.PluginName, postgresql.PluginName, postgresql.PluginNamePGX, sqlite.PluginName:
return true, nil
default:
return false, nil
Expand Down
2 changes: 1 addition & 1 deletion tests/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func init() {

func UsingSQLAdvancedVisibility() bool {
switch TestFlags.PersistenceDriver {
case mysql.PluginNameV8, postgresql.PluginNameV12, postgresql.PluginNameV12PGX, sqlite.PluginName:
case mysql.PluginName, postgresql.PluginName, postgresql.PluginNamePGX, sqlite.PluginName:
return true
default:
return false
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ func (f *defaultPersistenceTestBaseFactory) NewTestBase(options *persistencetest
case config.StoreTypeSQL:
var ops *persistencetests.TestBaseOptions
switch TestFlags.PersistenceDriver {
case mysql.PluginNameV8:
ops = persistencetests.GetMySQL8TestClusterOption()
case postgresql.PluginNameV12:
ops = persistencetests.GetPostgreSQL12TestClusterOption()
case postgresql.PluginNameV12PGX:
ops = persistencetests.GetPostgreSQL12PGXTestClusterOption()
case mysql.PluginName:
ops = persistencetests.GetMySQLTestClusterOption()
case postgresql.PluginName:
ops = persistencetests.GetPostgreSQLTestClusterOption()
case postgresql.PluginNamePGX:
ops = persistencetests.GetPostgreSQLPGXTestClusterOption()
case sqlite.PluginName:
ops = persistencetests.GetSQLiteMemoryTestClusterOption()
default:
Expand Down
Loading

0 comments on commit 849fb7b

Please sign in to comment.