go.temporal.io/server@v1.23.0/common/cluster/metadata_test_config.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 cluster 26 27 const ( 28 // TestCurrentClusterInitialFailoverVersion is initial failover version for current cluster 29 TestCurrentClusterInitialFailoverVersion = int64(1) 30 // TestAlternativeClusterInitialFailoverVersion is initial failover version for alternative cluster 31 TestAlternativeClusterInitialFailoverVersion = int64(2) 32 // TestFailoverVersionIncrement is failover version increment used for test 33 TestFailoverVersionIncrement = int64(10) 34 // TestCurrentClusterName is current cluster used for test 35 TestCurrentClusterName = "active" 36 // TestAlternativeClusterName is alternative cluster used for test 37 TestAlternativeClusterName = "standby" 38 // TestCurrentClusterFrontendAddress is the ip port address of current cluster 39 TestCurrentClusterFrontendAddress = "127.0.0.1:7134" 40 // TestAlternativeClusterFrontendAddress is the ip port address of alternative cluster 41 TestAlternativeClusterFrontendAddress = "127.0.0.1:8134" 42 ) 43 44 var ( 45 // TestAllClusterNames is the all cluster names used for test 46 TestAllClusterNames = []string{TestCurrentClusterName, TestAlternativeClusterName} 47 // TestAllClusterInfo is the same as above, just convenient for test mocking 48 TestAllClusterInfo = map[string]ClusterInformation{ 49 TestCurrentClusterName: { 50 Enabled: true, 51 InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion, 52 RPCAddress: TestCurrentClusterFrontendAddress, 53 ShardCount: 8, 54 }, 55 TestAlternativeClusterName: { 56 Enabled: true, 57 InitialFailoverVersion: TestAlternativeClusterInitialFailoverVersion, 58 RPCAddress: TestAlternativeClusterFrontendAddress, 59 ShardCount: 4, 60 }, 61 } 62 63 // TestSingleDCAllClusterNames is the all cluster names used for test 64 TestSingleDCAllClusterNames = []string{TestCurrentClusterName} 65 // TestSingleDCClusterInfo is the same as above, just convenient for test mocking 66 TestSingleDCClusterInfo = map[string]ClusterInformation{ 67 TestCurrentClusterName: { 68 Enabled: true, 69 InitialFailoverVersion: TestCurrentClusterInitialFailoverVersion, 70 RPCAddress: TestCurrentClusterFrontendAddress, 71 }, 72 } 73 ) 74 75 // NewTestClusterMetadataConfig return an cluster metadata config 76 func NewTestClusterMetadataConfig(enableGlobalNamespace bool, isMasterCluster bool) *Config { 77 masterClusterName := TestCurrentClusterName 78 if !isMasterCluster { 79 masterClusterName = TestAlternativeClusterName 80 } 81 82 if enableGlobalNamespace { 83 return &Config{ 84 EnableGlobalNamespace: true, 85 FailoverVersionIncrement: TestFailoverVersionIncrement, 86 MasterClusterName: masterClusterName, 87 CurrentClusterName: TestCurrentClusterName, 88 ClusterInformation: TestAllClusterInfo, 89 } 90 } 91 92 return &Config{ 93 EnableGlobalNamespace: false, 94 FailoverVersionIncrement: TestFailoverVersionIncrement, 95 MasterClusterName: TestCurrentClusterName, 96 CurrentClusterName: TestCurrentClusterName, 97 ClusterInformation: TestSingleDCClusterInfo, 98 } 99 }