Files
tasks/service/history/queues/queue_immediate_test.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

88 lines
2.2 KiB
Go

package queues
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
"github.com/hanzoai/tasks/common/cluster"
"github.com/hanzoai/tasks/common/log"
"github.com/hanzoai/tasks/common/metrics"
"github.com/hanzoai/tasks/common/persistence"
"github.com/hanzoai/tasks/service/history/shard"
"github.com/hanzoai/tasks/service/history/tasks"
"github.com/hanzoai/tasks/service/history/tests"
"go.uber.org/mock/gomock"
)
type (
immediateQueueSuite struct {
suite.Suite
*require.Assertions
controller *gomock.Controller
mockShard *shard.ContextTest
mockExecutionManager *persistence.MockExecutionManager
immediateQueue *immediateQueue
}
)
func TestImmediateQueueSuite(t *testing.T) {
s := new(immediateQueueSuite)
suite.Run(t, s)
}
func (s *immediateQueueSuite) SetupTest() {
s.Assertions = require.New(s.T())
s.controller = gomock.NewController(s.T())
s.mockShard = shard.NewTestContext(
s.controller,
&persistencespb.ShardInfo{
ShardId: 0,
RangeId: 1,
Owner: "test-shard-owner",
},
tests.NewDynamicConfig(),
)
s.mockExecutionManager = s.mockShard.Resource.ExecutionMgr
s.mockShard.Resource.ClusterMetadata.EXPECT().GetCurrentClusterName().Return(cluster.TestCurrentClusterName).AnyTimes()
s.immediateQueue = NewImmediateQueue(
s.mockShard,
tasks.CategoryTransfer,
nil, // scheduler
nil, // rescheduler
&testQueueOptions,
NewReaderPriorityRateLimiter(
func() float64 { return 10 },
1,
),
GrouperNamespaceID{},
log.NewTestLogger(),
metrics.NoopMetricsHandler,
nil, // execuable factory
)
}
func (s *immediateQueueSuite) TearDownTest() {
s.controller.Finish()
}
func (s *immediateQueueSuite) TestPaginationFnProvider_ShardOwnershipLost() {
paginationFnProvider := s.immediateQueue.paginationFnProvider
s.mockExecutionManager.EXPECT().GetHistoryTasks(gomock.Any(), gomock.Any()).Return(nil, &persistence.ShardOwnershipLostError{
ShardID: s.mockShard.GetShardID(),
}).Times(1)
paginationFn := paginationFnProvider(NewRandomRange())
_, _, err := paginationFn(nil)
s.True(shard.IsShardOwnershipLostError(err))
// make sure shard is also marked as invalid
s.False(s.mockShard.IsValid())
}