Files
tasks/common/persistence/client/factory_test.go
Prathyush PVandGitHub 9d34c6c111 Optimize WorkflowTask Timeouts (#8412)
## What changed?
Optimize workflow task timeouts by completing them when the workflow
task finishes.
This optimization is enabled when the dynamic config
system.enableDeleteHistoryTasksOnUpdate is turned on.
It is disabled by default, as it can cause performance degradation in
cassandra based persistence.

## Why?
A large fraction of all timer tasks processed is workflow task timeouts.
In most of the cases, these are no-ops.
We can complete these tasks when the corresponding workflow task
finishes. This will reduce the number of timer tasks processes.

## How did you test it?
- [x] built
- [ ] run locally and tested manually
- [ ] covered by existing tests
- [x] added new unit test(s)
- [ ] added new functional test(s)
2025-10-03 18:12:59 +00:00

64 lines
1.2 KiB
Go

package client_test
import (
"errors"
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/server/common/config"
"go.temporal.io/server/common/persistence/client"
"go.temporal.io/server/common/persistence/mock"
"go.uber.org/mock/gomock"
)
func TestFactoryImpl_NewHistoryTaskQueueManager(t *testing.T) {
t.Parallel()
for _, tc := range []struct {
name string
err error
}{
{
name: "No error",
err: nil,
},
{
name: "Error",
err: errors.New("some error"),
},
} {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
ctrl := gomock.NewController(t)
dataStoreFactory := mock.NewMockDataStoreFactory(ctrl)
dataStoreFactory.EXPECT().NewQueueV2().Return(nil, tc.err).AnyTimes()
factory := client.NewFactory(
dataStoreFactory,
&config.Persistence{
NumHistoryShards: 1,
},
nil,
nil,
nil,
nil,
nil,
"",
nil,
nil,
nil,
func() bool { return false },
func() bool { return false },
)
historyTaskQueueManager, err := factory.NewHistoryTaskQueueManager()
if tc.err != nil {
require.Error(t, err)
return
}
require.NoError(t, err)
require.NotNil(t, historyTaskQueueManager)
})
}
}