Files
tasks/service/history/workflow/context_mock.go
wxing1292andGitHub 5e7cabd712 Allow import workflow events if local cluster encountered dataloss (#4850)
<!-- Describe what has changed in this PR -->
**What changed?**
* Allow import workflow events if local cluster encountered dataloss

<!-- Tell your future self why have you made these changes -->
**Why?**
More flexibility

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

<!-- Assuming the worst case, what can be broken when deploying this
change to production? -->
**Potential risks**
N/A

<!-- Is this PR a hotfix candidate or require that a notification be
sent to the broader community? (Yes/No) -->
**Is hotfix candidate?**
N/A
2023-09-11 10:41:48 -07:00

321 lines
16 KiB
Go

// The MIT License
//
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
//
// Copyright (c) 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.
// Code generated by MockGen. DO NOT EDIT.
// Source: context.go
// Package workflow is a generated GoMock package.
package workflow
import (
context "context"
reflect "reflect"
gomock "github.com/golang/mock/gomock"
v1 "go.temporal.io/server/api/persistence/v1"
definition "go.temporal.io/server/common/definition"
persistence "go.temporal.io/server/common/persistence"
shard "go.temporal.io/server/service/history/shard"
update "go.temporal.io/server/service/history/workflow/update"
)
// MockContext is a mock of Context interface.
type MockContext struct {
ctrl *gomock.Controller
recorder *MockContextMockRecorder
}
// MockContextMockRecorder is the mock recorder for MockContext.
type MockContextMockRecorder struct {
mock *MockContext
}
// NewMockContext creates a new mock instance.
func NewMockContext(ctrl *gomock.Controller) *MockContext {
mock := &MockContext{ctrl: ctrl}
mock.recorder = &MockContextMockRecorder{mock}
return mock
}
// EXPECT returns an object that allows the caller to indicate expected use.
func (m *MockContext) EXPECT() *MockContextMockRecorder {
return m.recorder
}
// Clear mocks base method.
func (m *MockContext) Clear() {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Clear")
}
// Clear indicates an expected call of Clear.
func (mr *MockContextMockRecorder) Clear() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Clear", reflect.TypeOf((*MockContext)(nil).Clear))
}
// ConflictResolveWorkflowExecution mocks base method.
func (m *MockContext) ConflictResolveWorkflowExecution(ctx context.Context, shardContext shard.Context, conflictResolveMode persistence.ConflictResolveWorkflowMode, resetMutableState MutableState, newContext Context, newMutableState MutableState, currentContext Context, currentMutableState MutableState, resetWorkflowTransactionPolicy TransactionPolicy, newWorkflowTransactionPolicy, currentTransactionPolicy *TransactionPolicy) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ConflictResolveWorkflowExecution", ctx, shardContext, conflictResolveMode, resetMutableState, newContext, newMutableState, currentContext, currentMutableState, resetWorkflowTransactionPolicy, newWorkflowTransactionPolicy, currentTransactionPolicy)
ret0, _ := ret[0].(error)
return ret0
}
// ConflictResolveWorkflowExecution indicates an expected call of ConflictResolveWorkflowExecution.
func (mr *MockContextMockRecorder) ConflictResolveWorkflowExecution(ctx, shardContext, conflictResolveMode, resetMutableState, newContext, newMutableState, currentContext, currentMutableState, resetWorkflowTransactionPolicy, newWorkflowTransactionPolicy, currentTransactionPolicy interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ConflictResolveWorkflowExecution", reflect.TypeOf((*MockContext)(nil).ConflictResolveWorkflowExecution), ctx, shardContext, conflictResolveMode, resetMutableState, newContext, newMutableState, currentContext, currentMutableState, resetWorkflowTransactionPolicy, newWorkflowTransactionPolicy, currentTransactionPolicy)
}
// CreateWorkflowExecution mocks base method.
func (m *MockContext) CreateWorkflowExecution(ctx context.Context, shardContext shard.Context, createMode persistence.CreateWorkflowMode, prevRunID string, prevLastWriteVersion int64, newMutableState MutableState, newWorkflow *persistence.WorkflowSnapshot, newWorkflowEvents []*persistence.WorkflowEvents) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "CreateWorkflowExecution", ctx, shardContext, createMode, prevRunID, prevLastWriteVersion, newMutableState, newWorkflow, newWorkflowEvents)
ret0, _ := ret[0].(error)
return ret0
}
// CreateWorkflowExecution indicates an expected call of CreateWorkflowExecution.
func (mr *MockContextMockRecorder) CreateWorkflowExecution(ctx, shardContext, createMode, prevRunID, prevLastWriteVersion, newMutableState, newWorkflow, newWorkflowEvents interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "CreateWorkflowExecution", reflect.TypeOf((*MockContext)(nil).CreateWorkflowExecution), ctx, shardContext, createMode, prevRunID, prevLastWriteVersion, newMutableState, newWorkflow, newWorkflowEvents)
}
// GetWorkflowKey mocks base method.
func (m *MockContext) GetWorkflowKey() definition.WorkflowKey {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "GetWorkflowKey")
ret0, _ := ret[0].(definition.WorkflowKey)
return ret0
}
// GetWorkflowKey indicates an expected call of GetWorkflowKey.
func (mr *MockContextMockRecorder) GetWorkflowKey() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetWorkflowKey", reflect.TypeOf((*MockContext)(nil).GetWorkflowKey))
}
// IsDirty mocks base method.
func (m *MockContext) IsDirty() bool {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "IsDirty")
ret0, _ := ret[0].(bool)
return ret0
}
// IsDirty indicates an expected call of IsDirty.
func (mr *MockContextMockRecorder) IsDirty() *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "IsDirty", reflect.TypeOf((*MockContext)(nil).IsDirty))
}
// LoadExecutionStats mocks base method.
func (m *MockContext) LoadExecutionStats(ctx context.Context, shardContext shard.Context) (*v1.ExecutionStats, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LoadExecutionStats", ctx, shardContext)
ret0, _ := ret[0].(*v1.ExecutionStats)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LoadExecutionStats indicates an expected call of LoadExecutionStats.
func (mr *MockContextMockRecorder) LoadExecutionStats(ctx, shardContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadExecutionStats", reflect.TypeOf((*MockContext)(nil).LoadExecutionStats), ctx, shardContext)
}
// LoadMutableState mocks base method.
func (m *MockContext) LoadMutableState(ctx context.Context, shardContext shard.Context) (MutableState, error) {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "LoadMutableState", ctx, shardContext)
ret0, _ := ret[0].(MutableState)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// LoadMutableState indicates an expected call of LoadMutableState.
func (mr *MockContextMockRecorder) LoadMutableState(ctx, shardContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LoadMutableState", reflect.TypeOf((*MockContext)(nil).LoadMutableState), ctx, shardContext)
}
// Lock mocks base method.
func (m *MockContext) Lock(ctx context.Context, lockPriority LockPriority) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "Lock", ctx, lockPriority)
ret0, _ := ret[0].(error)
return ret0
}
// Lock indicates an expected call of Lock.
func (mr *MockContextMockRecorder) Lock(ctx, lockPriority interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Lock", reflect.TypeOf((*MockContext)(nil).Lock), ctx, lockPriority)
}
// PersistWorkflowEvents mocks base method.
func (m *MockContext) PersistWorkflowEvents(ctx context.Context, shardContext shard.Context, workflowEventsSlice ...*persistence.WorkflowEvents) (int64, error) {
m.ctrl.T.Helper()
varargs := []interface{}{ctx, shardContext}
for _, a := range workflowEventsSlice {
varargs = append(varargs, a)
}
ret := m.ctrl.Call(m, "PersistWorkflowEvents", varargs...)
ret0, _ := ret[0].(int64)
ret1, _ := ret[1].(error)
return ret0, ret1
}
// PersistWorkflowEvents indicates an expected call of PersistWorkflowEvents.
func (mr *MockContextMockRecorder) PersistWorkflowEvents(ctx, shardContext interface{}, workflowEventsSlice ...interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
varargs := append([]interface{}{ctx, shardContext}, workflowEventsSlice...)
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PersistWorkflowEvents", reflect.TypeOf((*MockContext)(nil).PersistWorkflowEvents), varargs...)
}
// ReapplyEvents mocks base method.
func (m *MockContext) ReapplyEvents(ctx context.Context, shardContext shard.Context, eventBatches []*persistence.WorkflowEvents) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "ReapplyEvents", ctx, shardContext, eventBatches)
ret0, _ := ret[0].(error)
return ret0
}
// ReapplyEvents indicates an expected call of ReapplyEvents.
func (mr *MockContextMockRecorder) ReapplyEvents(ctx, shardContext, eventBatches interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ReapplyEvents", reflect.TypeOf((*MockContext)(nil).ReapplyEvents), ctx, shardContext, eventBatches)
}
// SetWorkflowExecution mocks base method.
func (m *MockContext) SetWorkflowExecution(ctx context.Context, shardContext shard.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SetWorkflowExecution", ctx, shardContext)
ret0, _ := ret[0].(error)
return ret0
}
// SetWorkflowExecution indicates an expected call of SetWorkflowExecution.
func (mr *MockContextMockRecorder) SetWorkflowExecution(ctx, shardContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetWorkflowExecution", reflect.TypeOf((*MockContext)(nil).SetWorkflowExecution), ctx, shardContext)
}
// Unlock mocks base method.
func (m *MockContext) Unlock(lockPriority LockPriority) {
m.ctrl.T.Helper()
m.ctrl.Call(m, "Unlock", lockPriority)
}
// Unlock indicates an expected call of Unlock.
func (mr *MockContextMockRecorder) Unlock(lockPriority interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Unlock", reflect.TypeOf((*MockContext)(nil).Unlock), lockPriority)
}
// UpdateRegistry mocks base method.
func (m *MockContext) UpdateRegistry(ctx context.Context) update.Registry {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateRegistry", ctx)
ret0, _ := ret[0].(update.Registry)
return ret0
}
// UpdateRegistry indicates an expected call of UpdateRegistry.
func (mr *MockContextMockRecorder) UpdateRegistry(ctx interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateRegistry", reflect.TypeOf((*MockContext)(nil).UpdateRegistry), ctx)
}
// UpdateWorkflowExecutionAsActive mocks base method.
func (m *MockContext) UpdateWorkflowExecutionAsActive(ctx context.Context, shardContext shard.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateWorkflowExecutionAsActive", ctx, shardContext)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateWorkflowExecutionAsActive indicates an expected call of UpdateWorkflowExecutionAsActive.
func (mr *MockContextMockRecorder) UpdateWorkflowExecutionAsActive(ctx, shardContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowExecutionAsActive", reflect.TypeOf((*MockContext)(nil).UpdateWorkflowExecutionAsActive), ctx, shardContext)
}
// UpdateWorkflowExecutionAsPassive mocks base method.
func (m *MockContext) UpdateWorkflowExecutionAsPassive(ctx context.Context, shardContext shard.Context) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateWorkflowExecutionAsPassive", ctx, shardContext)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateWorkflowExecutionAsPassive indicates an expected call of UpdateWorkflowExecutionAsPassive.
func (mr *MockContextMockRecorder) UpdateWorkflowExecutionAsPassive(ctx, shardContext interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowExecutionAsPassive", reflect.TypeOf((*MockContext)(nil).UpdateWorkflowExecutionAsPassive), ctx, shardContext)
}
// UpdateWorkflowExecutionWithNew mocks base method.
func (m *MockContext) UpdateWorkflowExecutionWithNew(ctx context.Context, shardContext shard.Context, updateMode persistence.UpdateWorkflowMode, newContext Context, newMutableState MutableState, updateWorkflowTransactionPolicy TransactionPolicy, newWorkflowTransactionPolicy *TransactionPolicy) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateWorkflowExecutionWithNew", ctx, shardContext, updateMode, newContext, newMutableState, updateWorkflowTransactionPolicy, newWorkflowTransactionPolicy)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateWorkflowExecutionWithNew indicates an expected call of UpdateWorkflowExecutionWithNew.
func (mr *MockContextMockRecorder) UpdateWorkflowExecutionWithNew(ctx, shardContext, updateMode, newContext, newMutableState, updateWorkflowTransactionPolicy, newWorkflowTransactionPolicy interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowExecutionWithNew", reflect.TypeOf((*MockContext)(nil).UpdateWorkflowExecutionWithNew), ctx, shardContext, updateMode, newContext, newMutableState, updateWorkflowTransactionPolicy, newWorkflowTransactionPolicy)
}
// UpdateWorkflowExecutionWithNewAsActive mocks base method.
func (m *MockContext) UpdateWorkflowExecutionWithNewAsActive(ctx context.Context, shardContext shard.Context, newContext Context, newMutableState MutableState) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateWorkflowExecutionWithNewAsActive", ctx, shardContext, newContext, newMutableState)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateWorkflowExecutionWithNewAsActive indicates an expected call of UpdateWorkflowExecutionWithNewAsActive.
func (mr *MockContextMockRecorder) UpdateWorkflowExecutionWithNewAsActive(ctx, shardContext, newContext, newMutableState interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowExecutionWithNewAsActive", reflect.TypeOf((*MockContext)(nil).UpdateWorkflowExecutionWithNewAsActive), ctx, shardContext, newContext, newMutableState)
}
// UpdateWorkflowExecutionWithNewAsPassive mocks base method.
func (m *MockContext) UpdateWorkflowExecutionWithNewAsPassive(ctx context.Context, shardContext shard.Context, newContext Context, newMutableState MutableState) error {
m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "UpdateWorkflowExecutionWithNewAsPassive", ctx, shardContext, newContext, newMutableState)
ret0, _ := ret[0].(error)
return ret0
}
// UpdateWorkflowExecutionWithNewAsPassive indicates an expected call of UpdateWorkflowExecutionWithNewAsPassive.
func (mr *MockContextMockRecorder) UpdateWorkflowExecutionWithNewAsPassive(ctx, shardContext, newContext, newMutableState interface{}) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateWorkflowExecutionWithNewAsPassive", reflect.TypeOf((*MockContext)(nil).UpdateWorkflowExecutionWithNewAsPassive), ctx, shardContext, newContext, newMutableState)
}