mirror of
https://github.com/hanzoai/tasks.git
synced 2026-11-03 03:56:04 +00:00
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).
73 lines
2.1 KiB
Go
73 lines
2.1 KiB
Go
package history
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/hanzoai/tasks/api/historyservice/v1"
|
|
persistencespb "github.com/hanzoai/tasks/api/persistence/v1"
|
|
"github.com/hanzoai/tasks/common/log"
|
|
"github.com/hanzoai/tasks/common/membership"
|
|
"github.com/hanzoai/tasks/common/metrics"
|
|
"github.com/hanzoai/tasks/common/namespace"
|
|
"github.com/hanzoai/tasks/common/serviceerror"
|
|
"github.com/hanzoai/tasks/service/history/configs"
|
|
"github.com/hanzoai/tasks/service/history/shard"
|
|
"github.com/hanzoai/tasks/service/history/tests"
|
|
"go.uber.org/mock/gomock"
|
|
)
|
|
|
|
func TestDescribeHistoryHost(t *testing.T) {
|
|
ctrl := gomock.NewController(t)
|
|
defer ctrl.Finish()
|
|
controller := shard.NewMockController(ctrl)
|
|
namespaceRegistry := namespace.NewMockRegistry(ctrl)
|
|
hostInfoProvider := membership.NewMockHostInfoProvider(ctrl)
|
|
h := Handler{
|
|
config: &configs.Config{
|
|
NumberOfShards: 10,
|
|
},
|
|
metricsHandler: metrics.NoopMetricsHandler,
|
|
logger: log.NewNoopLogger(),
|
|
controller: controller,
|
|
namespaceRegistry: namespaceRegistry,
|
|
hostInfoProvider: hostInfoProvider,
|
|
}
|
|
|
|
mockShard1 := shard.NewTestContext(
|
|
ctrl,
|
|
&persistencespb.ShardInfo{
|
|
ShardId: 1,
|
|
RangeId: 1,
|
|
},
|
|
tests.NewDynamicConfig(),
|
|
)
|
|
controller.EXPECT().GetShardByID(int32(1)).Return(mockShard1, serviceerror.NewShardOwnershipLost("", ""))
|
|
|
|
_, err := h.DescribeHistoryHost(context.Background(), &historyservice.DescribeHistoryHostRequest{
|
|
ShardId: 1,
|
|
})
|
|
assert.Error(t, err)
|
|
var sol *serviceerror.ShardOwnershipLost
|
|
assert.True(t, errors.As(err, &sol))
|
|
|
|
mockShard2 := shard.NewTestContext(
|
|
ctrl,
|
|
&persistencespb.ShardInfo{
|
|
ShardId: 2,
|
|
RangeId: 1,
|
|
},
|
|
tests.NewDynamicConfig(),
|
|
)
|
|
controller.EXPECT().GetShardByID(int32(2)).Return(mockShard2, nil)
|
|
controller.EXPECT().ShardIDs().Return([]int32{2})
|
|
namespaceRegistry.EXPECT().GetRegistrySize().Return(int64(0), int64(0))
|
|
hostInfoProvider.EXPECT().HostInfo().Return(membership.NewHostInfoFromAddress("0.0.0.0"))
|
|
_, err = h.DescribeHistoryHost(context.Background(), &historyservice.DescribeHistoryHostRequest{
|
|
ShardId: 2,
|
|
})
|
|
assert.NoError(t, err)
|
|
}
|