Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple bugfixes #823

Merged
merged 3 commits into from
Jun 10, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions service/history/historyCache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ import (
"github.com/uber-go/tally"
workflow "github.com/uber/cadence/.gen/go/shared"
"github.com/uber/cadence/common"
"github.com/uber/cadence/common/messaging"
"github.com/uber/cadence/common/metrics"
"github.com/uber/cadence/common/mocks"
"github.com/uber/cadence/common/persistence"
"github.com/uber/cadence/common/service"
"github.com/uber/cadence/common/service/dynamicconfig"
)

Expand All @@ -48,10 +50,14 @@ type (
// override suite.Suite.Assertions with require.Assertions; this means that s.NotNil(nil) will stop the test,
// not merely log an error
*require.Assertions
logger bark.Logger
mockExecutionMgr *mocks.ExecutionManager
mockShard *shardContextImpl
cache *historyCache
logger bark.Logger
mockExecutionMgr *mocks.ExecutionManager
mockClusterMetadata *mocks.ClusterMetadata
mockProducer *mocks.KafkaProducer
mockMessagingClient messaging.Client
mockService service.Service
mockShard *shardContextImpl
cache *historyCache
}
)

Expand All @@ -75,7 +81,13 @@ func (s *historyCacheSuite) SetupTest() {
// Have to define our overridden assertions in the test setup. If we did it earlier, s.T() will return nil
s.Assertions = require.New(s.T())
s.mockExecutionMgr = &mocks.ExecutionManager{}
s.mockClusterMetadata = &mocks.ClusterMetadata{}
s.mockProducer = &mocks.KafkaProducer{}
s.mockMessagingClient = mocks.NewMockMessagingClient(s.mockProducer, nil)
metricsClient := metrics.NewClient(tally.NoopScope, metrics.History)
s.mockService = service.NewTestService(s.mockClusterMetadata, s.mockMessagingClient, metricsClient, s.logger)
s.mockShard = &shardContextImpl{
service: s.mockService,
shardInfo: &persistence.ShardInfo{ShardID: 0, RangeID: 1, TransferAckLevel: 0},
transferSequenceNumber: 1,
executionManager: s.mockExecutionMgr,
Expand All @@ -87,6 +99,8 @@ func (s *historyCacheSuite) SetupTest() {
metricsClient: metrics.NewClient(tally.NoopScope, metrics.History),
}
s.cache = newHistoryCache(s.mockShard, s.logger)

s.mockClusterMetadata.On("IsGlobalDomainEnabled").Return(false)
}

func (s *historyCacheSuite) TearDownTest() {
Expand Down
4 changes: 3 additions & 1 deletion service/history/mutableStateBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ func (e *mutableStateBuilder) GetLastWriteVersion() int64 {
}

func (e *mutableStateBuilder) updateReplicationStateVersion(version int64) {
e.replicationState.CurrentVersion = version
if version > e.replicationState.CurrentVersion {
e.replicationState.CurrentVersion = version
}
}

// Assumption: It is expected CurrentVersion on replication state is updated at the start of transaction when
Expand Down
3 changes: 2 additions & 1 deletion service/history/stateBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,9 @@ func (b *stateBuilder) scheduleDeleteHistoryTimerTask(event *shared.HistoryEvent
if _, ok := err.(*shared.EntityNotExistsError); !ok {
return nil, err
}
} else {
retentionInDays = domainEntry.GetConfig().Retention
}
retentionInDays = domainEntry.GetConfig().Retention
return b.getTimerBuilder(event).createDeleteHistoryEventTimerTask(time.Duration(retentionInDays) * time.Hour * 24), nil
}

Expand Down
Loading