This commit is contained in:
Stephan Behnke
2026-08-24 13:20:33 -07:00
parent 90104bec9f
commit 48fd023284
6 changed files with 8 additions and 212 deletions

View File

@@ -135,15 +135,14 @@ var (
ComponentPersistence = component("persistence")
ComponentWorkflowUpdate = component("workflow-update")
ComponentTaskScheduler = component("task-scheduler")
// Nexus components follow the server-side observability taxonomy.
ComponentNexusCaller = component("nexus-caller")
ComponentNexusOutbound = component("nexus-outbound")
ComponentNexusInbound = component("nexus-inbound")
ComponentNexusCompletion = component("nexus-completion")
ComponentNexusProtocol = component("nexus-protocol")
ComponentNexusRegistry = component("nexus-registry")
ComponentNexusTaskDelivery = component("nexus-task-delivery") // Reserved pending the task delivery audit.
VersionChecker = component("version-checker")
ComponentNexusCaller = component("nexus-caller")
ComponentNexusOutbound = component("nexus-outbound")
ComponentNexusInbound = component("nexus-inbound")
ComponentNexusCompletion = component("nexus-completion")
ComponentNexusProtocol = component("nexus-protocol")
ComponentNexusRegistry = component("nexus-registry")
ComponentNexusTaskDelivery = component("nexus-task-delivery") // Reserved pending the task delivery audit.
VersionChecker = component("version-checker")
)
// Pre-defined values for scope tag

View File

@@ -1,44 +0,0 @@
package nexus
import (
"testing"
"github.com/stretchr/testify/require"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/testing/testlogger"
)
func TestLoggedHTTPClientTraceUsesProtocolComponent(t *testing.T) {
t.Parallel()
provider := &LoggedHTTPClientTraceProvider{
Config: func() HTTPClientTraceConfig {
return HTTPClientTraceConfig{
Enabled: true,
ForwardingEnabled: true,
Hooks: []string{"GetConn"},
}
},
}
for name, newTrace := range map[string]func(*testlogger.TestLogger) func(string){
"operation": func(logger *testlogger.TestLogger) func(string) {
return provider.NewTrace(1, logger).GetConn
},
"forwarding": func(logger *testlogger.TestLogger) func(string) {
return provider.NewForwardingTrace(logger).GetConn
},
} {
t.Run(name, func(t *testing.T) {
t.Parallel()
logger := testlogger.NewTestLogger(t, testlogger.FailOnExpectedErrorOnly)
capture := logger.StartCapture()
newTrace(logger)("localhost:7233")
records := capture.Snapshot()
require.Len(t, records, 1)
require.Contains(t, records[0].Tags, tag.NewStringTag("component", "nexus-protocol"))
})
}
}

View File

@@ -2,7 +2,6 @@ package frontend
import (
"context"
"net/http"
"testing"
"github.com/nexus-rpc/sdk-go/nexus"
@@ -14,10 +13,7 @@ import (
persistencespb "go.temporal.io/server/api/persistence/v1"
tokenspb "go.temporal.io/server/api/token/v1"
"go.temporal.io/server/common/log"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/metrics"
"go.temporal.io/server/common/nexus/nexusrpc"
"go.temporal.io/server/common/testing/testlogger"
"go.temporal.io/server/components/nexusoperations"
"go.temporal.io/server/nexusworkflowref"
"go.uber.org/mock/gomock"
@@ -26,47 +22,6 @@ import (
const convTestRequestID = "request-id"
func TestNewNexusCompletionHandlerUsesCompletionComponent(t *testing.T) {
t.Parallel()
logger := testlogger.NewTestLogger(t, testlogger.FailOnAnyUnexpectedError)
logger.Expect(testlogger.Error, "failed to decode callback token")
capture := logger.StartCapture()
handler := newNexusCompletionHandler(
nil,
nil,
logger,
metrics.NoopMetricsHandler,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
)
err := handler.CompleteOperation(context.Background(), &nexusrpc.CompletionRequest{
HTTPRequest: &http.Request{Header: http.Header{}},
})
require.Error(t, err)
capture.RequireContains(t, testlogger.CapturedLogPattern{
Level: testlogger.Error,
Message: "failed to decode callback token",
Tags: map[string]any{
tag.ComponentNexusCompletion.Key(): "nexus-completion",
"error": testlogger.AnyTagValue,
},
})
}
// hsmCompletionToken builds the HSM token used by these conversion tests.
func hsmCompletionToken() *tokenspb.NexusOperationCompletion {
return &tokenspb.NexusOperationCompletion{

View File

@@ -12,15 +12,12 @@ import (
"github.com/stretchr/testify/require"
"go.temporal.io/api/serviceerror"
persistencespb "go.temporal.io/server/api/persistence/v1"
"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/namespace"
commonnexus "go.temporal.io/server/common/nexus"
"go.temporal.io/server/common/nexus/nexusrpc"
"go.temporal.io/server/common/nexus/nexustest"
"go.temporal.io/server/common/testing/testlogger"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
@@ -43,44 +40,6 @@ type fakeNamespaceRegistry struct {
getNamespaceName func(id namespace.ID) (namespace.Name, error)
}
func TestNewNexusOperationHTTPHandlerUsesInboundComponent(t *testing.T) {
t.Parallel()
logger := testlogger.NewTestLogger(t, testlogger.FailOnAnyUnexpectedError)
logger.Expect(testlogger.Error, "failure")
capture := logger.StartCapture()
handler := NewNexusOperationHTTPHandler(
NewConfig(dynamicconfig.NewNoopCollection(), 1),
nil,
metrics.NoopMetricsHandler,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
nil,
logger,
nil,
nil,
)
handler.logger.Error("failure")
capture.RequireContains(t, testlogger.CapturedLogPattern{
Level: testlogger.Error,
Message: "failure",
Tags: map[string]any{
tag.ComponentNexusInbound.Key(): "nexus-inbound",
},
})
}
func (f *fakeNamespaceRegistry) GetNamespaceName(id namespace.ID) (namespace.Name, error) {
return f.getNamespaceName(id)
}

View File

@@ -1,49 +0,0 @@
package circuitbreakerpool
import (
"testing"
"github.com/sony/gobreaker"
"github.com/stretchr/testify/require"
"go.temporal.io/server/common/log/tag"
"go.temporal.io/server/common/testing/testlogger"
"go.temporal.io/server/service/history/tasks"
)
func TestOnStateChangeTagsOnlyNexusTaskGroups(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
taskGroup string
wantComponent bool
}{
{name: "HSM invocation", taskGroup: "nexusoperations.Invocation", wantComponent: true},
{name: "HSM cancellation", taskGroup: "nexusoperations.Cancelation", wantComponent: true},
{name: "CHASM operation", taskGroup: "nexus", wantComponent: true},
{name: "callback", taskGroup: "callbacks.Invocation"},
{name: "unknown", taskGroup: "unknown"},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
logger := testlogger.NewTestLogger(t, testlogger.FailOnExpectedErrorOnly)
capture := logger.StartCapture()
onStateChange(tasks.TaskGroupNamespaceIDAndDestination{
TaskGroup: tc.taskGroup,
NamespaceID: "namespace-id",
Destination: "destination",
}, "namespace", logger)("ignored", gobreaker.StateClosed, gobreaker.StateOpen)
records := capture.Snapshot()
require.Len(t, records, 1)
if tc.wantComponent {
require.Contains(t, records[0].Tags, tag.NewStringTag("component", "nexus-outbound"))
} else {
require.NotContains(t, records[0].Tags, tag.NewStringTag("component", "nexus-outbound"))
}
})
}
}

View File

@@ -256,7 +256,6 @@ func newMatchingEngine(
},
queryResults: collection.NewSyncMap[string, chan *queryResult](),
logger: logger,
nexusEndpointLogger: log.With(logger, tag.ComponentNexusRegistry),
throttledLogger: log.ThrottledLogger(logger),
metricsHandler: metrics.NoopMetricsHandler,
matchingRawClient: mockMatchingClient,
@@ -4079,29 +4078,6 @@ func (s *matchingEngineSuite) TestCheckNexusEndpointsOwnership() {
s.False(isOwner)
}
func (s *matchingEngineSuite) TestCreateNexusEndpointLogsRegistryComponent() {
const endpointName = "test-endpoint"
createErr := errors.New("create failed")
s.mockNexusEndpointManager.EXPECT().CreateOrUpdateNexusEndpoint(gomock.Any(), gomock.Any()).Return(nil, createErr)
s.logger.Expect(testlogger.Error, "Failed to create Nexus endpoint")
capture := s.logger.StartCapture()
_, err := s.matchingEngine.CreateNexusEndpoint(context.Background(), &matchingservice.CreateNexusEndpointRequest{
Spec: &persistencespb.NexusEndpointSpec{Name: endpointName},
})
s.ErrorIs(err, createErr)
capture.RequireContains(s.T(), testlogger.CapturedLogPattern{
Level: testlogger.Error,
Message: "Failed to create Nexus endpoint",
Tags: map[string]any{
tag.ComponentNexusRegistry.Key(): "nexus-registry",
tag.Error(createErr).Key(): createErr,
tag.Endpoint(endpointName).Key(): endpointName,
},
})
}
func (s *matchingEngineSuite) TestNotifyNexusEndpointsOwnershipLost() {
ch := s.matchingEngine.nexusEndpointsOwnershipLostCh.Load().(chan struct{}) //nolint:revive // type is always chan struct{}
s.matchingEngine.notifyNexusEndpointsOwnershipChange()