Simplify Nexus stage tag tests

This commit is contained in:
Stephan Behnke
2026-08-27 15:59:53 -07:00
parent e216637afc
commit d6c867ec18
2 changed files with 4 additions and 20 deletions

View File

@@ -18,12 +18,10 @@ import (
"go.temporal.io/server/common/clock/hybrid_logical_clock"
"go.temporal.io/server/common/dynamicconfig"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/persistence"
"go.temporal.io/server/common/testing/protoassert"
"go.temporal.io/server/common/testing/protorequire"
"go.temporal.io/server/common/testing/testlogger"
"go.uber.org/mock/gomock"
"google.golang.org/protobuf/types/known/timestamppb"
)
@@ -184,32 +182,20 @@ func TestInitializationFallback(t *testing.T) {
testEndpoint := newEndpointEntry(t.Name())
mocks := newTestMocks(t)
matchingErr := serviceerror.NewUnavailable("matching unavailable test error")
mocks.matchingClient.EXPECT().ListNexusEndpoints(gomock.Any(), gomock.Any()).Return(nil, matchingErr).MinTimes(1)
mocks.matchingClient.EXPECT().ListNexusEndpoints(gomock.Any(), gomock.Any()).Return(nil, serviceerror.NewUnavailable("matching unavailable test error")).MinTimes(1)
mocks.persistence.EXPECT().ListNexusEndpoints(gomock.Any(), gomock.Any()).Return(&persistence.ListNexusEndpointsResponse{
TableVersion: int64(1),
NextPageToken: nil,
Entries: []*persistencespb.NexusEndpointEntry{testEndpoint},
}, nil)
logger := testlogger.NewTestLogger(t, testlogger.FailOnExpectedErrorOnly)
capture := logger.StartCapture()
reg := NewEndpointRegistry(mocks.config, mocks.matchingClient, mocks.persistence, log.With(logger, tag.ComponentPersistence), metrics.NoopMetricsHandler)
reg := NewEndpointRegistry(mocks.config, mocks.matchingClient, mocks.persistence, log.NewNoopLogger(), metrics.NoopMetricsHandler)
reg.StartLifecycle()
defer reg.StopLifecycle()
endpoint, err := reg.GetByID(context.Background(), testEndpoint.Id)
require.NoError(t, err)
protoassert.ProtoEqual(t, testEndpoint, endpoint)
capture.RequireContains(t, testlogger.CapturedLogPattern{
Level: testlogger.Error,
Message: "error from matching when initializing Nexus endpoint cache",
Tags: map[string]any{
"component": "persistence",
"nexus-stage": "registry",
"error": matchingErr.Error(),
},
})
reg.dataLock.RLock()
defer reg.dataLock.RUnlock()

View File

@@ -16,7 +16,7 @@ import (
)
func TestOnStateChangeNexusStage(t *testing.T) {
testCases := []struct {
for _, testCase := range []struct {
name string
taskGroup string
stage string
@@ -45,9 +45,7 @@ func TestOnStateChangeNexusStage(t *testing.T) {
name: "shared HSM callback",
taskGroup: callbacks.TaskTypeInvocation,
},
}
for _, testCase := range testCases {
} {
t.Run(testCase.name, func(t *testing.T) {
logger := testlogger.NewTestLogger(t, testlogger.FailOnExpectedErrorOnly)
capture := logger.StartCapture()