From f9e8453fb7e23cb6f3afc14344e6f12974570855 Mon Sep 17 00:00:00 2001 From: Shaddoll Date: Mon, 7 Oct 2024 13:59:27 -0700 Subject: [PATCH] Add unit test for history config (#6334) --- common/dynamicconfig/constants.go | 253 ------------------ service/history/config/config.go | 59 +---- service/history/config/config_test.go | 356 ++++++++++++++++++++++++++ service/history/service.go | 1 - 4 files changed, 359 insertions(+), 310 deletions(-) create mode 100644 service/history/config/config_test.go diff --git a/common/dynamicconfig/constants.go b/common/dynamicconfig/constants.go index 0a3fcb03221..c232ad6c0fb 100644 --- a/common/dynamicconfig/constants.go +++ b/common/dynamicconfig/constants.go @@ -1034,72 +1034,6 @@ const ( // Default value: 10000 // Allowed filters: N/A TransferProcessorMaxRedispatchQueueSize - // CrossClusterTaskBatchSize is the batch size for loading cross cluster tasks from persistence in crossClusterQueueProcessor - // KeyName: history.crossClusterTaskBatchSize - // Value type: Int - // Default value: 100 - // Allowed filters: N/A - CrossClusterTaskBatchSize - // CrossClusterTaskDeleteBatchSize is the batch size for deleting cross cluster tasks from persistence in crossClusterQueueProcessor - // KeyName: history.crossClusterTaskDeleteBatchSize - // Value type: Int - // Default value: 4000 - // Allowed filters: N/A - CrossClusterTaskDeleteBatchSize - // CrossClusterTaskFetchBatchSize is batch size for dispatching cross cluster tasks to target cluster in crossClusterQueueProcessor - // KeyName: history.crossClusterTaskFetchBatchSize - // Value type: Int - // Default value: 100 - // Allowed filters: ShardID - CrossClusterTaskFetchBatchSize - // CrossClusterSourceProcessorMaxPollRPS is max poll rate per second for crossClusterQueueProcessor - // KeyName: history.crossClusterProcessorMaxPollRPS - // Value type: Int - // Default value: 20 - // Allowed filters: N/A - CrossClusterSourceProcessorMaxPollRPS - // CrossClusterSourceProcessorCompleteTaskFailureRetryCount is times of retry for failure - // KeyName: history.crossClusterProcessorCompleteTaskFailureRetryCount - // Value type: Int - // Default value: 10 - // Allowed filters: N/A - CrossClusterSourceProcessorCompleteTaskFailureRetryCount // TODO - // CrossClusterSourceProcessorMaxRedispatchQueueSize is the threshold of the number of tasks in the redispatch queue for crossClusterQueueProcessor - // KeyName: history.crossClusterProcessorMaxRedispatchQueueSize - // Value type: Int - // Default value: 10000 - // Allowed filters: N/A - CrossClusterSourceProcessorMaxRedispatchQueueSize - // CrossClusterSourceProcessorMaxPendingTaskSize is the threshold of the number of ready for polling tasks in crossClusterQueueProcessor, - // task loading will be stopped when the number is reached - // KeyName: history.crossClusterSourceProcessorMaxPendingTaskSize - // Value type: Int - // Default value: 500 - // Allowed filters: N/A - CrossClusterSourceProcessorMaxPendingTaskSize - - // CrossClusterTargetProcessorMaxPendingTasks is the max number of pending tasks in cross cluster task processor - // note there's one cross cluster task processor per shard per source cluster - // KeyName: history.crossClusterTargetProcessorMaxPendingTasks - // Value type: Int - // Default value: 200 - // Allowed filters: N/A - CrossClusterTargetProcessorMaxPendingTasks - // CrossClusterTargetProcessorMaxRetryCount is the max number of retries when executing a cross-cluster task in target cluster - // KeyName: history.crossClusterTargetProcessorMaxRetryCount - // Value type: Int - // Default value: 20 - // Allowed filters: N/A - CrossClusterTargetProcessorMaxRetryCount - - // CrossClusterFetcherParallelism is the number of go routines each cross cluster fetcher use - // note there's one cross cluster task fetcher per host per source cluster - // KeyName: history.crossClusterFetcherParallelism - // Value type: Int - // Default value: 1 - // Allowed filters: N/A - CrossClusterFetcherParallelism - // ReplicatorTaskBatchSize is batch size for ReplicatorProcessor // KeyName: history.replicatorTaskBatchSize // Value type: Int @@ -1802,13 +1736,6 @@ const ( // Default value: false // Allowed filters: DomainName EnableContextHeaderInVisibility - // EnableCrossClusterEngine is used as an overall switch for the cross-cluster feature, a feature which, if not enabled - // can be quite expensive in terms of resources - // KeyName: history.enableCrossClusterEngine - // Value type: Bool - // Default value: false - // Allowed filters: DomainName - EnableCrossClusterEngine // EnableCrossClusterOperationsForDomain indicates if cross cluster operations can be scheduled for a domain // KeyName: history.enableCrossClusterOperations // Value type: Bool @@ -2236,30 +2163,6 @@ const ( // Default value: 0.15 // Allowed filters: N/A TransferProcessorUpdateAckIntervalJitterCoefficient - // CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient is the max poll interval jitter coefficient - // KeyName: history.crossClusterProcessorMaxPollIntervalJitterCoefficient - // Value type: Float64 - // Default value: 0.15 - // Allowed filters: N/A - CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient - // CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient is the update interval jitter coefficient - // KeyName: history.crossClusterProcessorUpdateAckIntervalJitterCoefficient - // Value type: Float64 - // Default value: 0.15 - // Allowed filters: N/A - CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient - // CrossClusterTargetProcessorJitterCoefficient is the jitter coefficient used in cross cluster task processor - // KeyName: history.crossClusterTargetProcessorJitterCoefficient - // Value type: Float64 - // Default value: 0.15 - // Allowed filters: N/A - CrossClusterTargetProcessorJitterCoefficient - // CrossClusterFetcherJitterCoefficient is the jitter coefficient used in cross cluster task fetcher - // KeyName: history.crossClusterFetcherJitterCoefficient - // Value type: Float64 - // Default value: 0.15 - // Allowed filters: N/A - CrossClusterFetcherJitterCoefficient // ReplicationTaskProcessorCleanupJitterCoefficient is the jitter for cleanup timer // KeyName: history.ReplicationTaskProcessorCleanupJitterCoefficient // Value type: Float64 @@ -2676,51 +2579,6 @@ const ( // Default value: 400ms (400*time.Millisecond) // Allowed filters: N/A TransferProcessorVisibilityArchivalTimeLimit - // CrossClusterSourceProcessorMaxPollInterval is max poll interval for crossClusterQueueProcessor - // KeyName: history.crossClusterProcessorMaxPollInterval - // Value type: Duration - // Default value: 1m (1*time.Minute) - // Allowed filters: N/A - CrossClusterSourceProcessorMaxPollInterval - // CrossClusterSourceProcessorUpdateAckInterval is update interval for crossClusterQueueProcessor - // KeyName: history.crossClusterProcessorUpdateAckInterval - // Value type: Duration - // Default value: 30s (30*time.Second) - // Allowed filters: N/A - CrossClusterSourceProcessorUpdateAckInterval - // CrossClusterTargetProcessorTaskWaitInterval is the duration for waiting a cross-cluster task response before responding to source - // KeyName: history.crossClusterTargetProcessorTaskWaitInterval - // Value type: Duration - // Default value: 3s (3*time.Second) - // Allowed filters: N/A - CrossClusterTargetProcessorTaskWaitInterval - // CrossClusterTargetProcessorServiceBusyBackoffInterval is the backoff duration for cross cluster task processor when getting - // a service busy error when calling source cluster - // KeyName: history.crossClusterTargetProcessorServiceBusyBackoffInterval - // Value type: Duration - // Default value: 5s (5*time.Second) - // Allowed filters: N/A - CrossClusterTargetProcessorServiceBusyBackoffInterval - // CrossClusterFetcherAggregationInterval determines how frequently the fetch requests are sent - // KeyName: history.crossClusterFetcherAggregationInterval - // Value type: Duration - // Default value: 2s (2*time.Second) - // Allowed filters: N/A - CrossClusterFetcherAggregationInterval - // CrossClusterFetcherServiceBusyBackoffInterval is the backoff duration for cross cluster task fetcher when getting - // a service busy error when calling source cluster - // KeyName: history.crossClusterFetcherServiceBusyBackoffInterval - // Value type: Duration - // Default value: 5s (5*time.Second) - // Allowed filters: N/A - CrossClusterFetcherServiceBusyBackoffInterval - // CrossClusterFetcherServiceBusyBackoffInterval is the backoff duration for cross cluster task fetcher when getting - // a non-service busy error when calling source cluster - // KeyName: history.crossClusterFetcherErrorBackoffInterval - // Value type: Duration - // Default value: 1s (time.Second) - // Allowed filters: N/A - CrossClusterFetcherErrorBackoffInterval // ReplicatorUpperLatency indicates the max allowed replication latency between clusters // KeyName: history.replicatorUpperLatency // Value type: Duration @@ -3593,57 +3451,6 @@ var IntKeys = map[IntKey]DynamicInt{ Description: "TransferProcessorMaxRedispatchQueueSize is the threshold of the number of tasks in the redispatch queue for transferQueueProcessor", DefaultValue: 10000, }, - CrossClusterTaskBatchSize: { - KeyName: "history.crossClusterTaskBatchSize", - Description: "CrossClusterTaskBatchSize is the batch size for loading cross cluster tasks from persistence in crossClusterQueueProcessor", - DefaultValue: 100, - }, - CrossClusterTaskDeleteBatchSize: { - KeyName: "history.crossClusterTaskDeleteBatchSize", - Description: "CrossClusterTaskDeleteBatchSize is the batch size for deleting cross cluster tasks from persistence in crossClusterQueueProcessor", - DefaultValue: 4000, - }, - CrossClusterTaskFetchBatchSize: { - KeyName: "history.crossClusterTaskFetchBatchSize", - Filters: []Filter{ShardID}, - Description: "CrossClusterTaskFetchBatchSize is batch size for dispatching cross cluster tasks to target cluster in crossClusterQueueProcessor", - DefaultValue: 100, - }, - CrossClusterSourceProcessorMaxPollRPS: { - KeyName: "history.crossClusterSourceProcessorMaxPollRPS", - Description: "CrossClusterSourceProcessorMaxPollRPS is max poll rate per second for crossClusterQueueProcessor", - DefaultValue: 20, - }, - CrossClusterSourceProcessorCompleteTaskFailureRetryCount: { - KeyName: "history.crossClusterSourceProcessorCompleteTaskFailureRetryCount", - Description: "CrossClusterSourceProcessorCompleteTaskFailureRetryCount is times of retry for failure", - DefaultValue: 10, - }, - CrossClusterSourceProcessorMaxRedispatchQueueSize: { - KeyName: "history.crossClusterSourceProcessorMaxRedispatchQueueSize", - Description: "CrossClusterSourceProcessorMaxRedispatchQueueSize is the threshold of the number of tasks in the redispatch queue for crossClusterQueueProcessor", - DefaultValue: 10000, - }, - CrossClusterSourceProcessorMaxPendingTaskSize: { - KeyName: "history.crossClusterSourceProcessorMaxPendingTaskSize", - Description: "CrossClusterSourceProcessorMaxPendingTaskSize is the threshold of the number of ready for polling tasks in crossClusterQueueProcessor, task loading will be stopped when the number is reached", - DefaultValue: 500, - }, - CrossClusterTargetProcessorMaxPendingTasks: { - KeyName: "history.crossClusterTargetProcessorMaxPendingTasks", - Description: "CrossClusterTargetProcessorMaxPendingTasks is the max number of pending tasks in cross cluster task processor", - DefaultValue: 200, - }, - CrossClusterTargetProcessorMaxRetryCount: { - KeyName: "history.crossClusterTargetProcessorMaxRetryCount", - Description: "CrossClusterTargetProcessorMaxRetryCount is the max number of retries when executing a cross-cluster task in target cluster", - DefaultValue: 20, - }, - CrossClusterFetcherParallelism: { - KeyName: "history.crossClusterFetcherParallelism", - Description: "CrossClusterFetcherParallelism is the number of go routines each cross cluster fetcher use, note there's one cross cluster task fetcher per host per source cluster", - DefaultValue: 1, - }, ReplicatorTaskBatchSize: { KeyName: "history.replicatorTaskBatchSize", Description: "ReplicatorTaskBatchSize is batch size for ReplicatorProcessor", @@ -4269,11 +4076,6 @@ var BoolKeys = map[BoolKey]DynamicBool{ Description: "EnableContextHeaderInVisibility is key for enable context header in visibility", DefaultValue: false, }, - EnableCrossClusterEngine: { - KeyName: "history.enableCrossClusterEngine", - Description: "an overall toggle for the cross-cluster domain feature", - DefaultValue: false, - }, EnableCrossClusterOperationsForDomain: { KeyName: "history.enableCrossClusterOperations", Filters: []Filter{DomainName}, @@ -4640,26 +4442,6 @@ var FloatKeys = map[FloatKey]DynamicFloat{ Description: "TransferProcessorUpdateAckIntervalJitterCoefficient is the update interval jitter coefficient", DefaultValue: 0.15, }, - CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient: { - KeyName: "history.crossClusterSourceProcessorMaxPollIntervalJitterCoefficient", - Description: "CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient is the max poll interval jitter coefficient", - DefaultValue: 0.15, - }, - CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient: { - KeyName: "history.crossClusterSourceProcessorUpdateAckIntervalJitterCoefficient", - Description: "CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient is the update interval jitter coefficient", - DefaultValue: 0.15, - }, - CrossClusterTargetProcessorJitterCoefficient: { - KeyName: "history.crossClusterTargetProcessorJitterCoefficient", - Description: "CrossClusterTargetProcessorJitterCoefficient is the jitter coefficient used in cross cluster task processor", - DefaultValue: 0.15, - }, - CrossClusterFetcherJitterCoefficient: { - KeyName: "history.crossClusterFetcherJitterCoefficient", - Description: "CrossClusterFetcherJitterCoefficient is the jitter coefficient used in cross cluster task fetcher", - DefaultValue: 0.15, - }, ReplicationTaskProcessorCleanupJitterCoefficient: { KeyName: "history.ReplicationTaskProcessorCleanupJitterCoefficient", Filters: []Filter{ShardID}, @@ -5034,41 +4816,6 @@ var DurationKeys = map[DurationKey]DynamicDuration{ Description: "TransferProcessorVisibilityArchivalTimeLimit is the upper time limit for archiving visibility records", DefaultValue: time.Millisecond * 400, }, - CrossClusterSourceProcessorMaxPollInterval: { - KeyName: "history.crossClusterSourceProcessorMaxPollInterval", - Description: "CrossClusterSourceProcessorMaxPollInterval is max poll interval for crossClusterQueueProcessor", - DefaultValue: time.Minute, - }, - CrossClusterSourceProcessorUpdateAckInterval: { - KeyName: "history.crossClusterSourceProcessorUpdateAckInterval", - Description: "CrossClusterSourceProcessorUpdateAckInterval is update interval for crossClusterQueueProcessor", - DefaultValue: time.Second * 30, - }, - CrossClusterTargetProcessorTaskWaitInterval: { - KeyName: "history.crossClusterTargetProcessorTaskWaitInterval", - Description: "CrossClusterTargetProcessorTaskWaitInterval is the duration for waiting a cross-cluster task response before responding to source", - DefaultValue: time.Second * 3, - }, - CrossClusterTargetProcessorServiceBusyBackoffInterval: { - KeyName: "history.crossClusterTargetProcessorServiceBusyBackoffInterval", - Description: "CrossClusterTargetProcessorServiceBusyBackoffInterval is the backoff duration for cross cluster task processor when getting a service busy error when calling source cluster", - DefaultValue: time.Second * 5, - }, - CrossClusterFetcherAggregationInterval: { - KeyName: "history.crossClusterFetcherAggregationInterval", - Description: "CrossClusterFetcherAggregationInterval determines how frequently the fetch requests are sent", - DefaultValue: time.Second * 2, - }, - CrossClusterFetcherServiceBusyBackoffInterval: { - KeyName: "history.crossClusterFetcherServiceBusyBackoffInterval", - Description: "CrossClusterFetcherServiceBusyBackoffInterval is the backoff duration for cross cluster task fetcher when getting", - DefaultValue: time.Second * 5, - }, - CrossClusterFetcherErrorBackoffInterval: { - KeyName: "history.crossClusterFetcherErrorBackoffInterval", - Description: "", - DefaultValue: time.Second, - }, ReplicatorUpperLatency: { KeyName: "history.replicatorUpperLatency", Description: "ReplicatorUpperLatency indicates the max allowed replication latency between clusters", diff --git a/service/history/config/config.go b/service/history/config/config.go index 6b7fb306e15..8a7f3a9b91d 100644 --- a/service/history/config/config.go +++ b/service/history/config/config.go @@ -24,7 +24,6 @@ import ( "time" "github.com/uber/cadence/common" - "github.com/uber/cadence/common/config" "github.com/uber/cadence/common/dynamicconfig" "github.com/uber/cadence/common/log" ) @@ -161,32 +160,6 @@ type Config struct { TransferProcessorValidationInterval dynamicconfig.DurationPropertyFn TransferProcessorVisibilityArchivalTimeLimit dynamicconfig.DurationPropertyFn - // CrossClusterQueueProcessor settings - CrossClusterTaskBatchSize dynamicconfig.IntPropertyFn - CrossClusterTaskDeleteBatchSize dynamicconfig.IntPropertyFn - CrossClusterTaskFetchBatchSize dynamicconfig.IntPropertyFnWithShardIDFilter - CrossClusterSourceProcessorMaxPollRPS dynamicconfig.IntPropertyFn - CrossClusterSourceProcessorMaxPollInterval dynamicconfig.DurationPropertyFn - CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient dynamicconfig.FloatPropertyFn - CrossClusterSourceProcessorUpdateAckInterval dynamicconfig.DurationPropertyFn - CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient dynamicconfig.FloatPropertyFn - CrossClusterSourceProcessorMaxRedispatchQueueSize dynamicconfig.IntPropertyFn - CrossClusterSourceProcessorMaxPendingTaskSize dynamicconfig.IntPropertyFn - - // CrossClusterTargetTaskProcessor settings - CrossClusterTargetProcessorMaxPendingTasks dynamicconfig.IntPropertyFn - CrossClusterTargetProcessorMaxRetryCount dynamicconfig.IntPropertyFn - CrossClusterTargetProcessorTaskWaitInterval dynamicconfig.DurationPropertyFn - CrossClusterTargetProcessorServiceBusyBackoffInterval dynamicconfig.DurationPropertyFn - CrossClusterTargetProcessorJitterCoefficient dynamicconfig.FloatPropertyFn - - // CrossClusterTaskFetcher settings - CrossClusterFetcherParallelism dynamicconfig.IntPropertyFn - CrossClusterFetcherAggregationInterval dynamicconfig.DurationPropertyFn - CrossClusterFetcherServiceBusyBackoffInterval dynamicconfig.DurationPropertyFn - CrossClusterFetcherErrorBackoffInterval dynamicconfig.DurationPropertyFn - CrossClusterFetcherJitterCoefficient dynamicconfig.FloatPropertyFn - // ReplicatorQueueProcessor settings ReplicatorTaskDeleteBatchSize dynamicconfig.IntPropertyFn ReplicatorReadTaskMaxRetryCount dynamicconfig.IntPropertyFn @@ -218,8 +191,6 @@ type Config struct { EnableParentClosePolicy dynamicconfig.BoolPropertyFnWithDomainFilter // whether or not enable system workers for processing parent close policy task EnableParentClosePolicyWorker dynamicconfig.BoolPropertyFn - // whether to enable system workers for processing ElasticSearch Analyzer - EnableESAnalyzer dynamicconfig.BoolPropertyFn // parent close policy will be processed by sys workers(if enabled) if // the number of children greater than or equal to this threshold ParentClosePolicyThreshold dynamicconfig.IntPropertyFnWithDomainFilter @@ -308,7 +279,6 @@ type Config struct { // EnableContextHeaderInVisibility whether to enable indexing context header in visibility EnableContextHeaderInVisibility dynamicconfig.BoolPropertyFnWithDomainFilter - EnableCrossClusterEngine dynamicconfig.BoolPropertyFn EnableCrossClusterOperationsForDomain dynamicconfig.BoolPropertyFnWithDomainFilter // Data integrity check related config knobs @@ -358,7 +328,7 @@ type Config struct { } // New returns new service config with default values -func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, storeType string, isAdvancedVisConfigExist bool, hostname string) *Config { +func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, isAdvancedVisConfigExist bool, hostname string) *Config { cfg := &Config{ NumberOfShards: numberOfShards, IsAdvancedVisConfigExist: isAdvancedVisConfigExist, @@ -475,29 +445,6 @@ func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, s TransferProcessorValidationInterval: dc.GetDurationProperty(dynamicconfig.TransferProcessorValidationInterval), TransferProcessorVisibilityArchivalTimeLimit: dc.GetDurationProperty(dynamicconfig.TransferProcessorVisibilityArchivalTimeLimit), - CrossClusterTaskBatchSize: dc.GetIntProperty(dynamicconfig.CrossClusterTaskBatchSize), - CrossClusterTaskDeleteBatchSize: dc.GetIntProperty(dynamicconfig.CrossClusterTaskDeleteBatchSize), - CrossClusterTaskFetchBatchSize: dc.GetIntPropertyFilteredByShardID(dynamicconfig.CrossClusterTaskFetchBatchSize), - CrossClusterSourceProcessorMaxPollRPS: dc.GetIntProperty(dynamicconfig.CrossClusterSourceProcessorMaxPollRPS), - CrossClusterSourceProcessorMaxPollInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterSourceProcessorMaxPollInterval), - CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient: dc.GetFloat64Property(dynamicconfig.CrossClusterSourceProcessorMaxPollIntervalJitterCoefficient), - CrossClusterSourceProcessorUpdateAckInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterSourceProcessorUpdateAckInterval), - CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient: dc.GetFloat64Property(dynamicconfig.CrossClusterSourceProcessorUpdateAckIntervalJitterCoefficient), - CrossClusterSourceProcessorMaxRedispatchQueueSize: dc.GetIntProperty(dynamicconfig.CrossClusterSourceProcessorMaxRedispatchQueueSize), - CrossClusterSourceProcessorMaxPendingTaskSize: dc.GetIntProperty(dynamicconfig.CrossClusterSourceProcessorMaxPendingTaskSize), - - CrossClusterTargetProcessorMaxPendingTasks: dc.GetIntProperty(dynamicconfig.CrossClusterTargetProcessorMaxPendingTasks), - CrossClusterTargetProcessorMaxRetryCount: dc.GetIntProperty(dynamicconfig.CrossClusterTargetProcessorMaxRetryCount), - CrossClusterTargetProcessorTaskWaitInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterTargetProcessorTaskWaitInterval), - CrossClusterTargetProcessorServiceBusyBackoffInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterTargetProcessorServiceBusyBackoffInterval), - CrossClusterTargetProcessorJitterCoefficient: dc.GetFloat64Property(dynamicconfig.CrossClusterTargetProcessorJitterCoefficient), - - CrossClusterFetcherParallelism: dc.GetIntProperty(dynamicconfig.CrossClusterFetcherParallelism), - CrossClusterFetcherAggregationInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterFetcherAggregationInterval), - CrossClusterFetcherServiceBusyBackoffInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterFetcherServiceBusyBackoffInterval), - CrossClusterFetcherErrorBackoffInterval: dc.GetDurationProperty(dynamicconfig.CrossClusterFetcherErrorBackoffInterval), - CrossClusterFetcherJitterCoefficient: dc.GetFloat64Property(dynamicconfig.CrossClusterFetcherJitterCoefficient), - ReplicatorTaskDeleteBatchSize: dc.GetIntProperty(dynamicconfig.ReplicatorTaskDeleteBatchSize), ReplicatorReadTaskMaxRetryCount: dc.GetIntProperty(dynamicconfig.ReplicatorReadTaskMaxRetryCount), ReplicatorProcessorFetchTasksBatchSize: dc.GetIntPropertyFilteredByShardID(dynamicconfig.ReplicatorTaskBatchSize), @@ -542,6 +489,7 @@ func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, s ThrottledLogRPS: dc.GetIntProperty(dynamicconfig.HistoryThrottledLogRPS), EnableStickyQuery: dc.GetBoolPropertyFilteredByDomain(dynamicconfig.EnableStickyQuery), + EnableQueryAttributeValidation: dc.GetBoolProperty(dynamicconfig.EnableQueryAttributeValidation), ValidSearchAttributes: dc.GetMapProperty(dynamicconfig.ValidSearchAttributes), SearchAttributesNumberOfKeysLimit: dc.GetIntPropertyFilteredByDomain(dynamicconfig.SearchAttributesNumberOfKeysLimit), SearchAttributesSizeOfValueLimit: dc.GetIntPropertyFilteredByDomain(dynamicconfig.SearchAttributesSizeOfValueLimit), @@ -585,7 +533,6 @@ func New(dc *dynamicconfig.Collection, numberOfShards int, maxMessageSize int, s EnableConsistentQuery: dc.GetBoolProperty(dynamicconfig.EnableConsistentQuery), EnableConsistentQueryByDomain: dc.GetBoolPropertyFilteredByDomain(dynamicconfig.EnableConsistentQueryByDomain), EnableContextHeaderInVisibility: dc.GetBoolPropertyFilteredByDomain(dynamicconfig.EnableContextHeaderInVisibility), - EnableCrossClusterEngine: dc.GetBoolProperty(dynamicconfig.EnableCrossClusterEngine), EnableCrossClusterOperationsForDomain: dc.GetBoolPropertyFilteredByDomain(dynamicconfig.EnableCrossClusterOperationsForDomain), MaxBufferedQueryCount: dc.GetIntProperty(dynamicconfig.MaxBufferedQueryCount), MutableStateChecksumGenProbability: dc.GetIntPropertyFilteredByDomain(dynamicconfig.MutableStateChecksumGenProbability), @@ -669,7 +616,7 @@ func NewForTestByShardNumber(shardNumber int) *Config { panicIfErr(inMem.UpdateValue(dynamicconfig.EnableStrongIdempotency, true)) dc := dynamicconfig.NewCollection(inMem, log.NewNoop()) - config := New(dc, shardNumber, 1024*1024, config.StoreTypeCassandra, false, "") + config := New(dc, shardNumber, 1024*1024, false, "") // reduce the duration of long poll to increase test speed config.LongPollExpirationInterval = dc.GetDurationPropertyFilteredByDomain(dynamicconfig.HistoryLongPollExpirationInterval) config.EnableConsistentQueryByDomain = dc.GetBoolPropertyFilteredByDomain(dynamicconfig.EnableConsistentQueryByDomain) diff --git a/service/history/config/config_test.go b/service/history/config/config_test.go new file mode 100644 index 00000000000..1ee35a684e7 --- /dev/null +++ b/service/history/config/config_test.go @@ -0,0 +1,356 @@ +// The MIT License (MIT) + +// Copyright (c) 2017-2020 Uber Technologies Inc. + +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. + +package config + +import ( + "reflect" + "testing" + "time" + + "github.com/stretchr/testify/assert" + + "github.com/uber/cadence/common/dynamicconfig" + "github.com/uber/cadence/common/log/testlogger" + "github.com/uber/cadence/common/types" +) + +type configTestCase struct { + key dynamicconfig.Key + value interface{} +} + +func TestNewConfig(t *testing.T) { + hostname := "hostname" + numberOfShards := 8192 + maxMessageSize := 1024 + isAdvancedVisConfigExist := true + fields := map[string]configTestCase{ + "NumberOfShards": {nil, numberOfShards}, + "IsAdvancedVisConfigExist": {nil, isAdvancedVisConfigExist}, + "RPS": {dynamicconfig.HistoryRPS, 100}, + "MaxIDLengthWarnLimit": {dynamicconfig.MaxIDLengthWarnLimit, 100}, + "DomainNameMaxLength": {dynamicconfig.DomainNameMaxLength, 100}, + "IdentityMaxLength": {dynamicconfig.IdentityMaxLength, 100}, + "WorkflowIDMaxLength": {dynamicconfig.WorkflowIDMaxLength, 100}, + "SignalNameMaxLength": {dynamicconfig.SignalNameMaxLength, 100}, + "WorkflowTypeMaxLength": {dynamicconfig.WorkflowTypeMaxLength, 100}, + "RequestIDMaxLength": {dynamicconfig.RequestIDMaxLength, 100}, + "TaskListNameMaxLength": {dynamicconfig.TaskListNameMaxLength, 100}, + "ActivityIDMaxLength": {dynamicconfig.ActivityIDMaxLength, 100}, + "ActivityTypeMaxLength": {dynamicconfig.ActivityTypeMaxLength, 100}, + "MarkerNameMaxLength": {dynamicconfig.MarkerNameMaxLength, 100}, + "TimerIDMaxLength": {dynamicconfig.TimerIDMaxLength, 100}, + "PersistenceMaxQPS": {dynamicconfig.HistoryPersistenceMaxQPS, 100}, + "PersistenceGlobalMaxQPS": {dynamicconfig.HistoryPersistenceGlobalMaxQPS, 100}, + "EnableVisibilitySampling": {dynamicconfig.EnableVisibilitySampling, true}, + "EnableReadFromClosedExecutionV2": {dynamicconfig.EnableReadFromClosedExecutionV2, true}, + "VisibilityOpenMaxQPS": {dynamicconfig.HistoryVisibilityOpenMaxQPS, 100}, + "VisibilityClosedMaxQPS": {dynamicconfig.HistoryVisibilityClosedMaxQPS, 100}, + "AdvancedVisibilityWritingMode": {dynamicconfig.AdvancedVisibilityWritingMode, "dual"}, + "AdvancedVisibilityMigrationWritingMode": {dynamicconfig.AdvancedVisibilityMigrationWritingMode, "dual"}, + "EmitShardDiffLog": {dynamicconfig.EmitShardDiffLog, true}, + "MaxAutoResetPoints": {dynamicconfig.HistoryMaxAutoResetPoints, 100}, + "ThrottledLogRPS": {dynamicconfig.HistoryThrottledLogRPS, 100}, + "EnableStickyQuery": {dynamicconfig.EnableStickyQuery, true}, + "ShutdownDrainDuration": {dynamicconfig.HistoryShutdownDrainDuration, time.Second}, + "WorkflowDeletionJitterRange": {dynamicconfig.WorkflowDeletionJitterRange, 1}, + "DeleteHistoryEventContextTimeout": {dynamicconfig.DeleteHistoryEventContextTimeout, 1}, + "MaxResponseSize": {nil, maxMessageSize}, + "HistoryCacheInitialSize": {dynamicconfig.HistoryCacheInitialSize, 100}, + "HistoryCacheMaxSize": {dynamicconfig.HistoryCacheMaxSize, 100}, + "HistoryCacheTTL": {dynamicconfig.HistoryCacheTTL, time.Second}, + "EventsCacheInitialCount": {dynamicconfig.EventsCacheInitialCount, 100}, + "EventsCacheMaxCount": {dynamicconfig.EventsCacheMaxCount, 100}, + "EventsCacheMaxSize": {dynamicconfig.EventsCacheMaxSize, 100}, + "EventsCacheTTL": {dynamicconfig.EventsCacheTTL, time.Second}, + "EventsCacheGlobalEnable": {dynamicconfig.EventsCacheGlobalEnable, true}, + "EventsCacheGlobalInitialCount": {dynamicconfig.EventsCacheGlobalInitialCount, 100}, + "EventsCacheGlobalMaxCount": {dynamicconfig.EventsCacheGlobalMaxCount, 100}, + "RangeSizeBits": {nil, uint(20)}, + "AcquireShardInterval": {dynamicconfig.AcquireShardInterval, time.Second}, + "AcquireShardConcurrency": {dynamicconfig.AcquireShardConcurrency, 100}, + "StandbyClusterDelay": {dynamicconfig.StandbyClusterDelay, time.Second}, + "StandbyTaskMissingEventsResendDelay": {dynamicconfig.StandbyTaskMissingEventsResendDelay, time.Second}, + "StandbyTaskMissingEventsDiscardDelay": {dynamicconfig.StandbyTaskMissingEventsDiscardDelay, time.Second}, + "TaskProcessRPS": {dynamicconfig.TaskProcessRPS, 100}, + "TaskSchedulerType": {dynamicconfig.TaskSchedulerType, 1}, + "TaskSchedulerWorkerCount": {dynamicconfig.TaskSchedulerWorkerCount, 100}, + "TaskSchedulerShardWorkerCount": {dynamicconfig.TaskSchedulerShardWorkerCount, 100}, + "TaskSchedulerQueueSize": {dynamicconfig.TaskSchedulerQueueSize, 100}, + "TaskSchedulerDispatcherCount": {dynamicconfig.TaskSchedulerDispatcherCount, 100}, + "TaskSchedulerRoundRobinWeights": {dynamicconfig.TaskSchedulerRoundRobinWeights, map[string]interface{}{"key": 1}}, + "TaskSchedulerShardQueueSize": {dynamicconfig.TaskSchedulerShardQueueSize, 100}, + "TaskCriticalRetryCount": {dynamicconfig.TaskCriticalRetryCount, 100}, + "ActiveTaskRedispatchInterval": {dynamicconfig.ActiveTaskRedispatchInterval, time.Second}, + "StandbyTaskRedispatchInterval": {dynamicconfig.StandbyTaskRedispatchInterval, time.Second}, + "TaskRedispatchIntervalJitterCoefficient": {dynamicconfig.TaskRedispatchIntervalJitterCoefficient, 1.0}, + "StandbyTaskReReplicationContextTimeout": {dynamicconfig.StandbyTaskReReplicationContextTimeout, time.Second}, + "EnableDropStuckTaskByDomainID": {dynamicconfig.EnableDropStuckTaskByDomainID, true}, + "ResurrectionCheckMinDelay": {dynamicconfig.ResurrectionCheckMinDelay, time.Second}, + "QueueProcessorEnableSplit": {dynamicconfig.QueueProcessorEnableSplit, true}, + "QueueProcessorSplitMaxLevel": {dynamicconfig.QueueProcessorSplitMaxLevel, 100}, + "QueueProcessorEnableRandomSplitByDomainID": {dynamicconfig.QueueProcessorEnableRandomSplitByDomainID, true}, + "QueueProcessorRandomSplitProbability": {dynamicconfig.QueueProcessorRandomSplitProbability, 1.0}, + "QueueProcessorEnablePendingTaskSplitByDomainID": {dynamicconfig.QueueProcessorEnablePendingTaskSplitByDomainID, true}, + "QueueProcessorPendingTaskSplitThreshold": {dynamicconfig.QueueProcessorPendingTaskSplitThreshold, map[string]interface{}{"a": 100}}, + "QueueProcessorEnableStuckTaskSplitByDomainID": {dynamicconfig.QueueProcessorEnableStuckTaskSplitByDomainID, true}, + "QueueProcessorStuckTaskSplitThreshold": {dynamicconfig.QueueProcessorStuckTaskSplitThreshold, map[string]interface{}{"b": 1}}, + "QueueProcessorSplitLookAheadDurationByDomainID": {dynamicconfig.QueueProcessorSplitLookAheadDurationByDomainID, time.Second}, + "QueueProcessorPollBackoffInterval": {dynamicconfig.QueueProcessorPollBackoffInterval, time.Second}, + "QueueProcessorPollBackoffIntervalJitterCoefficient": {dynamicconfig.QueueProcessorPollBackoffIntervalJitterCoefficient, 1.0}, + "QueueProcessorEnableLoadQueueStates": {dynamicconfig.QueueProcessorEnableLoadQueueStates, true}, + "QueueProcessorEnableGracefulSyncShutdown": {dynamicconfig.QueueProcessorEnableGracefulSyncShutdown, true}, + "QueueProcessorEnablePersistQueueStates": {dynamicconfig.QueueProcessorEnablePersistQueueStates, true}, + "TimerTaskBatchSize": {dynamicconfig.TimerTaskBatchSize, 100}, + "TimerTaskDeleteBatchSize": {dynamicconfig.TimerTaskDeleteBatchSize, 100}, + "TimerProcessorGetFailureRetryCount": {dynamicconfig.TimerProcessorGetFailureRetryCount, 100}, + "TimerProcessorCompleteTimerFailureRetryCount": {dynamicconfig.TimerProcessorCompleteTimerFailureRetryCount, 100}, + "TimerProcessorUpdateAckInterval": {dynamicconfig.TimerProcessorUpdateAckInterval, time.Second}, + "TimerProcessorUpdateAckIntervalJitterCoefficient": {dynamicconfig.TimerProcessorUpdateAckIntervalJitterCoefficient, 1.0}, + "TimerProcessorCompleteTimerInterval": {dynamicconfig.TimerProcessorCompleteTimerInterval, time.Second}, + "TimerProcessorFailoverMaxStartJitterInterval": {dynamicconfig.TimerProcessorFailoverMaxStartJitterInterval, time.Second}, + "TimerProcessorFailoverMaxPollRPS": {dynamicconfig.TimerProcessorFailoverMaxPollRPS, 100}, + "TimerProcessorMaxPollRPS": {dynamicconfig.TimerProcessorMaxPollRPS, 100}, + "TimerProcessorMaxPollInterval": {dynamicconfig.TimerProcessorMaxPollInterval, time.Second}, + "TimerProcessorMaxPollIntervalJitterCoefficient": {dynamicconfig.TimerProcessorMaxPollIntervalJitterCoefficient, 1.0}, + "TimerProcessorSplitQueueInterval": {dynamicconfig.TimerProcessorSplitQueueInterval, time.Second}, + "TimerProcessorSplitQueueIntervalJitterCoefficient": {dynamicconfig.TimerProcessorSplitQueueIntervalJitterCoefficient, 1.0}, + "TimerProcessorMaxRedispatchQueueSize": {dynamicconfig.TimerProcessorMaxRedispatchQueueSize, 100}, + "TimerProcessorMaxTimeShift": {dynamicconfig.TimerProcessorMaxTimeShift, time.Second}, + "TimerProcessorHistoryArchivalSizeLimit": {dynamicconfig.TimerProcessorHistoryArchivalSizeLimit, 100}, + "TimerProcessorArchivalTimeLimit": {dynamicconfig.TimerProcessorArchivalTimeLimit, time.Second}, + "TransferTaskBatchSize": {dynamicconfig.TransferTaskBatchSize, 100}, + "TransferTaskDeleteBatchSize": {dynamicconfig.TransferTaskDeleteBatchSize, 100}, + "TransferProcessorCompleteTransferFailureRetryCount": {dynamicconfig.TransferProcessorCompleteTransferFailureRetryCount, 100}, + "TransferProcessorFailoverMaxStartJitterInterval": {dynamicconfig.TransferProcessorFailoverMaxStartJitterInterval, time.Second}, + "TransferProcessorFailoverMaxPollRPS": {dynamicconfig.TransferProcessorFailoverMaxPollRPS, 100}, + "TransferProcessorMaxPollRPS": {dynamicconfig.TransferProcessorMaxPollRPS, 100}, + "TransferProcessorMaxPollInterval": {dynamicconfig.TransferProcessorMaxPollInterval, time.Second}, + "TransferProcessorMaxPollIntervalJitterCoefficient": {dynamicconfig.TransferProcessorMaxPollIntervalJitterCoefficient, 1.0}, + "TransferProcessorSplitQueueInterval": {dynamicconfig.TransferProcessorSplitQueueInterval, time.Second}, + "TransferProcessorSplitQueueIntervalJitterCoefficient": {dynamicconfig.TransferProcessorSplitQueueIntervalJitterCoefficient, 1.0}, + "TransferProcessorUpdateAckInterval": {dynamicconfig.TransferProcessorUpdateAckInterval, time.Second}, + "TransferProcessorUpdateAckIntervalJitterCoefficient": {dynamicconfig.TransferProcessorUpdateAckIntervalJitterCoefficient, 1.0}, + "TransferProcessorCompleteTransferInterval": {dynamicconfig.TransferProcessorCompleteTransferInterval, time.Second}, + "TransferProcessorMaxRedispatchQueueSize": {dynamicconfig.TransferProcessorMaxRedispatchQueueSize, 100}, + "TransferProcessorEnableValidator": {dynamicconfig.TransferProcessorEnableValidator, true}, + "TransferProcessorValidationInterval": {dynamicconfig.TransferProcessorValidationInterval, time.Second}, + "TransferProcessorVisibilityArchivalTimeLimit": {dynamicconfig.TransferProcessorVisibilityArchivalTimeLimit, time.Second}, + "ReplicatorTaskDeleteBatchSize": {dynamicconfig.ReplicatorTaskDeleteBatchSize, 100}, + "ReplicatorReadTaskMaxRetryCount": {dynamicconfig.ReplicatorReadTaskMaxRetryCount, 100}, + "ReplicatorProcessorFetchTasksBatchSize": {dynamicconfig.ReplicatorTaskBatchSize, 100}, + "ReplicatorUpperLatency": {dynamicconfig.ReplicatorUpperLatency, time.Second}, + "ReplicatorCacheCapacity": {dynamicconfig.ReplicatorCacheCapacity, 100}, + "ExecutionMgrNumConns": {dynamicconfig.ExecutionMgrNumConns, 100}, + "HistoryMgrNumConns": {dynamicconfig.HistoryMgrNumConns, 100}, + "MaximumBufferedEventsBatch": {dynamicconfig.MaximumBufferedEventsBatch, 100}, + "MaximumSignalsPerExecution": {dynamicconfig.MaximumSignalsPerExecution, 100}, + "ShardUpdateMinInterval": {dynamicconfig.ShardUpdateMinInterval, time.Second}, + "ShardSyncMinInterval": {dynamicconfig.ShardSyncMinInterval, time.Second}, + "ShardSyncTimerJitterCoefficient": {dynamicconfig.TransferProcessorMaxPollIntervalJitterCoefficient, 1.0}, + "LongPollExpirationInterval": {dynamicconfig.HistoryLongPollExpirationInterval, time.Second}, + "EventEncodingType": {dynamicconfig.DefaultEventEncoding, "eventEncodingType"}, + "EnableParentClosePolicy": {dynamicconfig.EnableParentClosePolicy, true}, + "EnableParentClosePolicyWorker": {dynamicconfig.EnableParentClosePolicyWorker, true}, + "ParentClosePolicyThreshold": {dynamicconfig.ParentClosePolicyThreshold, 100}, + "ParentClosePolicyBatchSize": {dynamicconfig.ParentClosePolicyBatchSize, 100}, + "NumParentClosePolicySystemWorkflows": {dynamicconfig.NumParentClosePolicySystemWorkflows, 100}, + "NumArchiveSystemWorkflows": {dynamicconfig.NumArchiveSystemWorkflows, 100}, + "ArchiveRequestRPS": {dynamicconfig.ArchiveRequestRPS, 100}, + "ArchiveInlineHistoryRPS": {dynamicconfig.ArchiveInlineHistoryRPS, 100}, + "ArchiveInlineHistoryGlobalRPS": {dynamicconfig.ArchiveInlineHistoryGlobalRPS, 100}, + "ArchiveInlineVisibilityRPS": {dynamicconfig.ArchiveInlineVisibilityRPS, 100}, + "ArchiveInlineVisibilityGlobalRPS": {dynamicconfig.ArchiveInlineVisibilityGlobalRPS, 100}, + "AllowArchivingIncompleteHistory": {dynamicconfig.AllowArchivingIncompleteHistory, true}, + "BlobSizeLimitError": {dynamicconfig.BlobSizeLimitError, 100}, + "BlobSizeLimitWarn": {dynamicconfig.BlobSizeLimitWarn, 100}, + "HistorySizeLimitError": {dynamicconfig.HistorySizeLimitError, 100}, + "HistorySizeLimitWarn": {dynamicconfig.HistorySizeLimitWarn, 100}, + "HistoryCountLimitError": {dynamicconfig.HistoryCountLimitError, 100}, + "HistoryCountLimitWarn": {dynamicconfig.HistoryCountLimitWarn, 100}, + "PendingActivitiesCountLimitError": {dynamicconfig.PendingActivitiesCountLimitError, 100}, + "PendingActivitiesCountLimitWarn": {dynamicconfig.PendingActivitiesCountLimitWarn, 100}, + "PendingActivityValidationEnabled": {dynamicconfig.EnablePendingActivityValidation, true}, + "EnableQueryAttributeValidation": {dynamicconfig.EnableQueryAttributeValidation, true}, + "ValidSearchAttributes": {dynamicconfig.ValidSearchAttributes, map[string]interface{}{"key": 1}}, + "SearchAttributesNumberOfKeysLimit": {dynamicconfig.SearchAttributesNumberOfKeysLimit, 100}, + "SearchAttributesSizeOfValueLimit": {dynamicconfig.SearchAttributesSizeOfValueLimit, 100}, + "SearchAttributesTotalSizeLimit": {dynamicconfig.SearchAttributesTotalSizeLimit, 100}, + "StickyTTL": {dynamicconfig.StickyTTL, time.Second}, + "DecisionHeartbeatTimeout": {dynamicconfig.DecisionHeartbeatTimeout, time.Second}, + "MaxDecisionStartToCloseSeconds": {dynamicconfig.MaxDecisionStartToCloseSeconds, 100}, + "DecisionRetryCriticalAttempts": {dynamicconfig.DecisionRetryCriticalAttempts, 100}, + "DecisionRetryMaxAttempts": {dynamicconfig.DecisionRetryMaxAttempts, 100}, + "NormalDecisionScheduleToStartMaxAttempts": {dynamicconfig.NormalDecisionScheduleToStartMaxAttempts, 100}, + "NormalDecisionScheduleToStartTimeout": {dynamicconfig.NormalDecisionScheduleToStartTimeout, time.Second}, + "ReplicationTaskFetcherParallelism": {dynamicconfig.ReplicationTaskFetcherParallelism, 100}, + "ReplicationTaskFetcherAggregationInterval": {dynamicconfig.ReplicationTaskFetcherAggregationInterval, time.Second}, + "ReplicationTaskFetcherTimerJitterCoefficient": {dynamicconfig.ReplicationTaskFetcherTimerJitterCoefficient, 1.0}, + "ReplicationTaskFetcherErrorRetryWait": {dynamicconfig.ReplicationTaskFetcherErrorRetryWait, time.Second}, + "ReplicationTaskFetcherServiceBusyWait": {dynamicconfig.ReplicationTaskFetcherServiceBusyWait, time.Second}, + "ReplicationTaskFetcherEnableGracefulSyncShutdown": {dynamicconfig.ReplicationTaskFetcherEnableGracefulSyncShutdown, true}, + "ReplicationTaskProcessorErrorRetryWait": {dynamicconfig.ReplicationTaskProcessorErrorRetryWait, time.Second}, + "ReplicationTaskProcessorErrorRetryMaxAttempts": {dynamicconfig.ReplicationTaskProcessorErrorRetryMaxAttempts, 100}, + "ReplicationTaskProcessorErrorSecondRetryWait": {dynamicconfig.ReplicationTaskProcessorErrorSecondRetryWait, time.Second}, + "ReplicationTaskProcessorErrorSecondRetryExpiration": {dynamicconfig.ReplicationTaskProcessorErrorSecondRetryExpiration, time.Second}, + "ReplicationTaskProcessorErrorSecondRetryMaxWait": {dynamicconfig.ReplicationTaskProcessorErrorSecondRetryMaxWait, time.Second}, + "ReplicationTaskProcessorNoTaskRetryWait": {dynamicconfig.ReplicationTaskProcessorNoTaskInitialWait, time.Second}, + "ReplicationTaskProcessorCleanupInterval": {dynamicconfig.ReplicationTaskProcessorCleanupInterval, time.Second}, + "ReplicationTaskProcessorCleanupJitterCoefficient": {dynamicconfig.ReplicationTaskProcessorCleanupJitterCoefficient, 1.0}, + "ReplicationTaskProcessorStartWait": {dynamicconfig.ReplicationTaskProcessorStartWait, time.Second}, + "ReplicationTaskProcessorStartWaitJitterCoefficient": {dynamicconfig.ReplicationTaskProcessorStartWaitJitterCoefficient, 1.0}, + "ReplicationTaskProcessorHostQPS": {dynamicconfig.ReplicationTaskProcessorHostQPS, 100.0}, + "ReplicationTaskProcessorShardQPS": {dynamicconfig.ReplicationTaskProcessorShardQPS, 100.0}, + "ReplicationTaskGenerationQPS": {dynamicconfig.ReplicationTaskGenerationQPS, 100.0}, + "EnableReplicationTaskGeneration": {dynamicconfig.EnableReplicationTaskGeneration, true}, + "EnableRecordWorkflowExecutionUninitialized": {dynamicconfig.EnableRecordWorkflowExecutionUninitialized, true}, + "WorkflowIDCacheExternalEnabled": {dynamicconfig.WorkflowIDCacheExternalEnabled, true}, + "WorkflowIDCacheInternalEnabled": {dynamicconfig.WorkflowIDCacheInternalEnabled, true}, + "WorkflowIDExternalRateLimitEnabled": {dynamicconfig.WorkflowIDExternalRateLimitEnabled, true}, + "WorkflowIDInternalRateLimitEnabled": {dynamicconfig.WorkflowIDInternalRateLimitEnabled, true}, + "WorkflowIDExternalRPS": {dynamicconfig.WorkflowIDExternalRPS, 100}, + "WorkflowIDInternalRPS": {dynamicconfig.WorkflowIDInternalRPS, 100}, + "EnableConsistentQuery": {dynamicconfig.EnableConsistentQuery, true}, + "EnableConsistentQueryByDomain": {dynamicconfig.EnableConsistentQueryByDomain, true}, + "MaxBufferedQueryCount": {dynamicconfig.MaxBufferedQueryCount, 100}, + "EnableContextHeaderInVisibility": {dynamicconfig.EnableContextHeaderInVisibility, true}, + "EnableCrossClusterOperationsForDomain": {dynamicconfig.EnableCrossClusterOperationsForDomain, true}, + "MutableStateChecksumGenProbability": {dynamicconfig.MutableStateChecksumGenProbability, 10}, + "MutableStateChecksumVerifyProbability": {dynamicconfig.MutableStateChecksumVerifyProbability, 10}, + "MutableStateChecksumInvalidateBefore": {dynamicconfig.MutableStateChecksumInvalidateBefore, 10.0}, + "EnableRetryForChecksumFailure": {dynamicconfig.EnableRetryForChecksumFailure, true}, + "EnableHistoryCorruptionCheck": {dynamicconfig.EnableHistoryCorruptionCheck, true}, + "NotifyFailoverMarkerInterval": {dynamicconfig.NotifyFailoverMarkerInterval, time.Second}, + "NotifyFailoverMarkerTimerJitterCoefficient": {dynamicconfig.NotifyFailoverMarkerTimerJitterCoefficient, 1.0}, + "EnableGracefulFailover": {dynamicconfig.EnableGracefulFailover, true}, + "EnableActivityLocalDispatchByDomain": {dynamicconfig.EnableActivityLocalDispatchByDomain, true}, + "MaxActivityCountDispatchByDomain": {dynamicconfig.MaxActivityCountDispatchByDomain, 100}, + "ActivityMaxScheduleToStartTimeoutForRetry": {dynamicconfig.ActivityMaxScheduleToStartTimeoutForRetry, time.Second}, + "EnableDebugMode": {dynamicconfig.EnableDebugMode, true}, + "EnableTaskInfoLogByDomainID": {dynamicconfig.HistoryEnableTaskInfoLogByDomainID, true}, + "EnableTimerDebugLogByDomainID": {dynamicconfig.EnableTimerDebugLogByDomainID, true}, + "SampleLoggingRate": {dynamicconfig.SampleLoggingRate, 100}, + "EnableShardIDMetrics": {dynamicconfig.EnableShardIDMetrics, true}, + "LargeShardHistorySizeMetricThreshold": {dynamicconfig.LargeShardHistorySizeMetricThreshold, 100}, + "LargeShardHistoryEventMetricThreshold": {dynamicconfig.LargeShardHistoryEventMetricThreshold, 100}, + "LargeShardHistoryBlobMetricThreshold": {dynamicconfig.LargeShardHistoryBlobMetricThreshold, 100}, + "EnableStrongIdempotency": {dynamicconfig.EnableStrongIdempotency, true}, + "EnableStrongIdempotencySanityCheck": {dynamicconfig.EnableStrongIdempotencySanityCheck, true}, + "GlobalRatelimiterNewDataWeight": {dynamicconfig.HistoryGlobalRatelimiterNewDataWeight, 1.0}, + "GlobalRatelimiterUpdateInterval": {dynamicconfig.GlobalRatelimiterUpdateInterval, time.Second}, + "GlobalRatelimiterDecayAfter": {dynamicconfig.HistoryGlobalRatelimiterDecayAfter, time.Second}, + "GlobalRatelimiterGCAfter": {dynamicconfig.HistoryGlobalRatelimiterGCAfter, time.Second}, + "HostName": {nil, hostname}, + } + client := dynamicconfig.NewInMemoryClient() + for fieldName, expected := range fields { + if expected.key != nil { + err := client.UpdateValue(expected.key, expected.value) + if err != nil { + t.Errorf("Failed to update config for %s: %s", fieldName, err) + } + } + } + dc := dynamicconfig.NewCollection(client, testlogger.New(t)) + + config := New(dc, numberOfShards, maxMessageSize, isAdvancedVisConfigExist, hostname) + + assertFieldsMatch(t, *config, fields) +} + +func assertFieldsMatch(t *testing.T, config interface{}, fields map[string]configTestCase) { + configType := reflect.ValueOf(config) + + for i := 0; i < configType.NumField(); i++ { + f := configType.Field(i) + fieldName := configType.Type().Field(i).Name + + if expected, ok := fields[fieldName]; ok { + actual := getValue(&f) + if f.Kind() == reflect.Slice { + assert.ElementsMatch(t, expected.value, actual, "Incorrect value for field: %s", fieldName) + } else { + assert.Equal(t, expected.value, actual, "Incorrect value for field: %s", fieldName) + } + + } else { + t.Errorf("Unknown property on Config: %s", fieldName) + } + } +} + +func getValue(f *reflect.Value) interface{} { + switch f.Kind() { + case reflect.Func: + switch fn := f.Interface().(type) { + case dynamicconfig.IntPropertyFn: + return fn() + case dynamicconfig.IntPropertyFnWithDomainFilter: + return fn("domain") + case dynamicconfig.IntPropertyFnWithTaskListInfoFilters: + return fn("domain", "tasklist", int(types.TaskListTypeDecision)) + case dynamicconfig.BoolPropertyFn: + return fn() + case dynamicconfig.BoolPropertyFnWithDomainFilter: + return fn("domain") + case dynamicconfig.BoolPropertyFnWithDomainIDFilter: + return fn("domain") + case dynamicconfig.BoolPropertyFnWithTaskListInfoFilters: + return fn("domain", "tasklist", int(types.TaskListTypeDecision)) + case dynamicconfig.DurationPropertyFn: + return fn() + case dynamicconfig.DurationPropertyFnWithDomainFilter: + return fn("domain") + case dynamicconfig.DurationPropertyFnWithTaskListInfoFilters: + return fn("domain", "tasklist", int(types.TaskListTypeDecision)) + case dynamicconfig.FloatPropertyFn: + return fn() + case dynamicconfig.MapPropertyFn: + return fn() + case dynamicconfig.StringPropertyFn: + return fn() + case dynamicconfig.DurationPropertyFnWithDomainIDFilter: + return fn("domain") + case dynamicconfig.IntPropertyFnWithShardIDFilter: + return fn(0) + case dynamicconfig.StringPropertyFnWithDomainFilter: + return fn("domain") + case dynamicconfig.DurationPropertyFnWithShardIDFilter: + return fn(0) + case dynamicconfig.FloatPropertyFnWithShardIDFilter: + return fn(0) + case dynamicconfig.BoolPropertyFnWithDomainIDAndWorkflowIDFilter: + return fn("domain", "workflowID") + case func() []string: + return fn() + default: + panic("Unable to handle type: " + f.Type().Name()) + } + default: + return f.Interface() + } +} + +func isolationGroupsHelper() []string { + return []string{"zone-1", "zone-2"} +} diff --git a/service/history/service.go b/service/history/service.go index 93c0d8630f0..3e86ec092e4 100644 --- a/service/history/service.go +++ b/service/history/service.go @@ -67,7 +67,6 @@ func NewService( ), params.PersistenceConfig.NumHistoryShards, params.RPCFactory.GetMaxMessageSize(), - params.PersistenceConfig.DefaultStoreType(), params.PersistenceConfig.IsAdvancedVisibilityConfigExist(), params.HostName)