go.temporal.io/server@v1.23.0/common/persistence/persistence-tests/setup.go (about) 1 // The MIT License 2 // 3 // Copyright (c) 2020 Temporal Technologies Inc. All rights reserved. 4 // 5 // Copyright (c) 2020 Uber Technologies, Inc. 6 // 7 // Permission is hereby granted, free of charge, to any person obtaining a copy 8 // of this software and associated documentation files (the "Software"), to deal 9 // in the Software without restriction, including without limitation the rights 10 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 // copies of the Software, and to permit persons to whom the Software is 12 // furnished to do so, subject to the following conditions: 13 // 14 // The above copyright notice and this permission notice shall be included in 15 // all copies or substantial portions of the Software. 16 // 17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 // THE SOFTWARE. 24 25 package persistencetests 26 27 import ( 28 "go.temporal.io/server/common/config" 29 "go.temporal.io/server/common/persistence/sql/sqlplugin/mysql" 30 "go.temporal.io/server/common/persistence/sql/sqlplugin/postgresql" 31 "go.temporal.io/server/common/persistence/sql/sqlplugin/sqlite" 32 "go.temporal.io/server/environment" 33 ) 34 35 const ( 36 testMySQLUser = "temporal" 37 testMySQLPassword = "temporal" 38 testMySQLSchemaDir = "schema/mysql/v57" 39 testMySQL8SchemaDir = "schema/mysql/v8" 40 41 testPostgreSQLUser = "temporal" 42 testPostgreSQLPassword = "temporal" 43 testPostgreSQLSchemaDir = "schema/postgresql/v96" 44 testPostgreSQL12SchemaDir = "schema/postgresql/v12" 45 46 testSQLiteUser = "" 47 testSQLitePassword = "" 48 testSQLiteMode = "memory" 49 testSQLiteCache = "private" 50 testSQLiteSchemaDir = "schema/sqlite/v3" // specify if mode is not "memory" 51 ) 52 53 // GetMySQLTestClusterOption return test options 54 func GetMySQLTestClusterOption() *TestBaseOptions { 55 return &TestBaseOptions{ 56 SQLDBPluginName: mysql.PluginName, 57 DBUsername: testMySQLUser, 58 DBPassword: testMySQLPassword, 59 DBHost: environment.GetMySQLAddress(), 60 DBPort: environment.GetMySQLPort(), 61 SchemaDir: testMySQLSchemaDir, 62 StoreType: config.StoreTypeSQL, 63 } 64 } 65 66 // GetMySQL8TestClusterOption return test options 67 func GetMySQL8TestClusterOption() *TestBaseOptions { 68 return &TestBaseOptions{ 69 SQLDBPluginName: mysql.PluginNameV8, 70 DBUsername: testMySQLUser, 71 DBPassword: testMySQLPassword, 72 DBHost: environment.GetMySQLAddress(), 73 DBPort: environment.GetMySQLPort(), 74 SchemaDir: testMySQL8SchemaDir, 75 StoreType: config.StoreTypeSQL, 76 } 77 } 78 79 // GetPostgreSQLTestClusterOption return test options 80 func GetPostgreSQLTestClusterOption() *TestBaseOptions { 81 return &TestBaseOptions{ 82 SQLDBPluginName: postgresql.PluginName, 83 DBUsername: testPostgreSQLUser, 84 DBPassword: testPostgreSQLPassword, 85 DBHost: environment.GetPostgreSQLAddress(), 86 DBPort: environment.GetPostgreSQLPort(), 87 SchemaDir: testPostgreSQLSchemaDir, 88 StoreType: config.StoreTypeSQL, 89 } 90 } 91 92 // GetPostgreSQLPGXTestClusterOption return test options 93 func GetPostgreSQLPGXTestClusterOption() *TestBaseOptions { 94 return &TestBaseOptions{ 95 SQLDBPluginName: postgresql.PluginNamePGX, 96 DBUsername: testPostgreSQLUser, 97 DBPassword: testPostgreSQLPassword, 98 DBHost: environment.GetPostgreSQLAddress(), 99 DBPort: environment.GetPostgreSQLPort(), 100 SchemaDir: testPostgreSQLSchemaDir, 101 StoreType: config.StoreTypeSQL, 102 } 103 } 104 105 // GetPostgreSQL12TestClusterOption return test options 106 func GetPostgreSQL12TestClusterOption() *TestBaseOptions { 107 return &TestBaseOptions{ 108 SQLDBPluginName: postgresql.PluginNameV12, 109 DBUsername: testPostgreSQLUser, 110 DBPassword: testPostgreSQLPassword, 111 DBHost: environment.GetPostgreSQLAddress(), 112 DBPort: environment.GetPostgreSQLPort(), 113 SchemaDir: testPostgreSQL12SchemaDir, 114 StoreType: config.StoreTypeSQL, 115 } 116 } 117 118 // GetPostgreSQL12PGXTestClusterOption return test options 119 func GetPostgreSQL12PGXTestClusterOption() *TestBaseOptions { 120 return &TestBaseOptions{ 121 SQLDBPluginName: postgresql.PluginNameV12PGX, 122 DBUsername: testPostgreSQLUser, 123 DBPassword: testPostgreSQLPassword, 124 DBHost: environment.GetPostgreSQLAddress(), 125 DBPort: environment.GetPostgreSQLPort(), 126 SchemaDir: testPostgreSQL12SchemaDir, 127 StoreType: config.StoreTypeSQL, 128 } 129 } 130 131 // GetSQLiteTestClusterOption return test options 132 func GetSQLiteFileTestClusterOption() *TestBaseOptions { 133 return &TestBaseOptions{ 134 SQLDBPluginName: sqlite.PluginName, 135 DBUsername: testSQLiteUser, 136 DBPassword: testSQLitePassword, 137 DBHost: environment.GetLocalhostIP(), 138 DBPort: 0, 139 SchemaDir: testSQLiteSchemaDir, 140 StoreType: config.StoreTypeSQL, 141 ConnectAttributes: map[string]string{"cache": testSQLiteCache}, 142 } 143 } 144 145 // GetSQLiteTestClusterOption return test options 146 func GetSQLiteMemoryTestClusterOption() *TestBaseOptions { 147 return &TestBaseOptions{ 148 SQLDBPluginName: sqlite.PluginName, 149 DBUsername: testSQLiteUser, 150 DBPassword: testSQLitePassword, 151 DBHost: environment.GetLocalhostIP(), 152 DBPort: 0, 153 SchemaDir: "", 154 StoreType: config.StoreTypeSQL, 155 ConnectAttributes: map[string]string{"mode": testSQLiteMode, "cache": testSQLiteCache}, 156 } 157 }