mirror of
https://github.com/hanzoai/tasks.git
synced 2026-10-04 02:04:03 +00:00
## What changed? - Use force deletion for chasm execution in namespace deletion - Add functional test for forcing deleting chasm executions - We have log for force deletion as well ## Why? - DeleteWorkflowExecution API is an async graceful deletion api that only works for Workflow, but not other CHASM archetypes. - Upon namespace deletion we need to delete chasm executions as well and we can use force deletion to do it. ## How did you test it? - [x] built - [ ] run locally and tested manually - [ ] covered by existing tests - [x] added new unit test(s) - [x] added new functional test(s)
68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
package common
|
|
|
|
import (
|
|
"strconv"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
commonpb "go.temporal.io/api/common/v1"
|
|
workflowpb "go.temporal.io/api/workflow/v1"
|
|
"go.temporal.io/server/chasm"
|
|
"go.temporal.io/server/common/payload"
|
|
"go.temporal.io/server/common/searchattribute/sadefs"
|
|
)
|
|
|
|
func TestArchetypeIDFromExecutionInfo(t *testing.T) {
|
|
t.Run("NoSearchAttributes", func(t *testing.T) {
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("NoNamespaceDivision", func(t *testing.T) {
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("Scheduler", func(t *testing.T) {
|
|
p := payload.EncodeString("TemporalScheduler")
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.WorkflowArchetypeID, id)
|
|
})
|
|
|
|
t.Run("CHASM", func(t *testing.T) {
|
|
p := payload.EncodeString(strconv.FormatUint(42, 10))
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
id, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.NoError(t, err)
|
|
require.Equal(t, chasm.ArchetypeID(42), id)
|
|
})
|
|
|
|
t.Run("ErrorOnInvalidNumber", func(t *testing.T) {
|
|
p := payload.EncodeString("1x")
|
|
|
|
execInfo := &workflowpb.WorkflowExecutionInfo{
|
|
SearchAttributes: &commonpb.SearchAttributes{IndexedFields: map[string]*commonpb.Payload{
|
|
sadefs.TemporalNamespaceDivision: p,
|
|
}},
|
|
}
|
|
_, err := ArchetypeIDFromExecutionInfo(execInfo)
|
|
require.Error(t, err)
|
|
})
|
|
}
|