mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.
## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
123 lines
4.3 KiB
Go
123 lines
4.3 KiB
Go
package signalworkflow
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
"go.temporal.io/api/workflowservice/v1"
|
|
"go.temporal.io/server/api/historyservice/v1"
|
|
persistencespb "go.temporal.io/server/api/persistence/v1"
|
|
"go.temporal.io/server/common/clock"
|
|
"go.temporal.io/server/common/cluster"
|
|
"go.temporal.io/server/common/cluster/clustertest"
|
|
"go.temporal.io/server/common/locks"
|
|
"go.temporal.io/server/common/log"
|
|
"go.temporal.io/server/common/metrics"
|
|
"go.temporal.io/server/common/namespace"
|
|
"go.temporal.io/server/service/history/api"
|
|
"go.temporal.io/server/service/history/consts"
|
|
historyi "go.temporal.io/server/service/history/interfaces"
|
|
"go.temporal.io/server/service/history/tests"
|
|
wcache "go.temporal.io/server/service/history/workflow/cache"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
type (
|
|
signalWorkflowSuite struct {
|
|
suite.Suite
|
|
*require.Assertions
|
|
|
|
controller *gomock.Controller
|
|
shardContext *historyi.MockShardContext
|
|
namespaceRegistry *namespace.MockRegistry
|
|
|
|
workflowCache *wcache.MockCache
|
|
workflowConsistencyChecker api.WorkflowConsistencyChecker
|
|
|
|
currentContext *historyi.MockWorkflowContext
|
|
currentMutableState *historyi.MockMutableState
|
|
}
|
|
)
|
|
|
|
func TestSignalWorkflowSuite(t *testing.T) {
|
|
s := new(signalWorkflowSuite)
|
|
suite.Run(t, s)
|
|
}
|
|
|
|
func (s *signalWorkflowSuite) SetupSuite() {
|
|
}
|
|
|
|
func (s *signalWorkflowSuite) TearDownSuite() {
|
|
}
|
|
|
|
func (s *signalWorkflowSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
|
|
s.controller = gomock.NewController(s.T())
|
|
s.namespaceRegistry = namespace.NewMockRegistry(s.controller)
|
|
s.namespaceRegistry.EXPECT().GetNamespaceByID(tests.GlobalNamespaceEntry.ID()).Return(tests.GlobalNamespaceEntry, nil).AnyTimes()
|
|
|
|
s.shardContext = historyi.NewMockShardContext(s.controller)
|
|
s.shardContext.EXPECT().GetConfig().Return(tests.NewDynamicConfig()).AnyTimes()
|
|
s.shardContext.EXPECT().GetLogger().Return(log.NewTestLogger()).AnyTimes()
|
|
s.shardContext.EXPECT().GetThrottledLogger().Return(log.NewTestLogger()).AnyTimes()
|
|
s.shardContext.EXPECT().GetMetricsHandler().Return(metrics.NoopMetricsHandler).AnyTimes()
|
|
s.shardContext.EXPECT().GetTimeSource().Return(clock.NewRealTimeSource()).AnyTimes()
|
|
s.shardContext.EXPECT().GetNamespaceRegistry().Return(s.namespaceRegistry).AnyTimes()
|
|
s.shardContext.EXPECT().GetClusterMetadata().Return(clustertest.NewMetadataForTest(cluster.NewTestClusterMetadataConfig(true, true))).AnyTimes()
|
|
|
|
s.currentMutableState = historyi.NewMockMutableState(s.controller)
|
|
s.currentMutableState.EXPECT().GetNamespaceEntry().Return(tests.GlobalNamespaceEntry).AnyTimes()
|
|
s.currentMutableState.EXPECT().GetExecutionInfo().Return(&persistencespb.WorkflowExecutionInfo{
|
|
WorkflowId: tests.WorkflowID,
|
|
}).AnyTimes()
|
|
s.currentMutableState.EXPECT().GetExecutionState().Return(&persistencespb.WorkflowExecutionState{
|
|
RunId: tests.RunID,
|
|
}).AnyTimes()
|
|
|
|
s.currentContext = historyi.NewMockWorkflowContext(s.controller)
|
|
s.currentContext.EXPECT().LoadMutableState(gomock.Any(), s.shardContext).Return(s.currentMutableState, nil).AnyTimes()
|
|
|
|
s.workflowCache = wcache.NewMockCache(s.controller)
|
|
s.workflowCache.EXPECT().GetOrCreateWorkflowExecution(gomock.Any(), gomock.Any(), gomock.Any(), gomock.Any(), locks.PriorityHigh).
|
|
Return(s.currentContext, wcache.NoopReleaseFn, nil).AnyTimes()
|
|
|
|
s.workflowConsistencyChecker = api.NewWorkflowConsistencyChecker(
|
|
s.shardContext,
|
|
s.workflowCache,
|
|
)
|
|
}
|
|
|
|
func (s *signalWorkflowSuite) TearDownTest() {
|
|
s.controller.Finish()
|
|
}
|
|
|
|
func (s *signalWorkflowSuite) TestSignalWorkflow_WorkflowCloseAttempted() {
|
|
s.currentMutableState.EXPECT().IsWorkflowExecutionRunning().Return(true)
|
|
s.currentMutableState.EXPECT().IsWorkflowCloseAttempted().Return(true)
|
|
s.currentMutableState.EXPECT().HasStartedWorkflowTask().Return(true)
|
|
|
|
resp, err := Invoke(
|
|
context.Background(),
|
|
&historyservice.SignalWorkflowExecutionRequest{
|
|
NamespaceId: tests.NamespaceID.String(),
|
|
SignalRequest: &workflowservice.SignalWorkflowExecutionRequest{
|
|
Namespace: tests.Namespace.String(),
|
|
WorkflowExecution: &commonpb.WorkflowExecution{
|
|
WorkflowId: tests.WorkflowID,
|
|
RunId: tests.RunID,
|
|
},
|
|
SignalName: "signal-name",
|
|
Input: nil,
|
|
},
|
|
},
|
|
s.shardContext,
|
|
s.workflowConsistencyChecker,
|
|
)
|
|
s.Nil(resp)
|
|
s.Error(consts.ErrWorkflowClosing, err)
|
|
}
|