From 38aeb8890885fe78b9bbf62fe30ca02e2e65b3dc Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Fri, 29 Jan 2021 15:53:45 -0500 Subject: [PATCH] Start to setup enterprise tests for terminating gateway streaming events. Co-Authored-By: Kyle Havlovitz --- agent/consul/state/catalog_events.go | 13 ++++++++++--- agent/consul/state/catalog_events_test.go | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/agent/consul/state/catalog_events.go b/agent/consul/state/catalog_events.go index 9be0a9dae..2fa353d7a 100644 --- a/agent/consul/state/catalog_events.go +++ b/agent/consul/state/catalog_events.go @@ -312,7 +312,9 @@ func ServiceHealthEventsFromChanges(tx ReadTxn, changes Changes) ([]stream.Event e.Topic = topicServiceHealthConnect payload := e.Payload.(EventPayloadCheckServiceNode) payload.overrideKey = serviceName.Name - payload.overrideNamespace = serviceName.EnterpriseMeta.GetNamespace() + if gatewayName.EnterpriseMeta.GetNamespace() != serviceName.EnterpriseMeta.GetNamespace() { + payload.overrideNamespace = serviceName.EnterpriseMeta.GetNamespace() + } e.Payload = payload events = append(events, e) @@ -334,7 +336,9 @@ func ServiceHealthEventsFromChanges(tx ReadTxn, changes Changes) ([]stream.Event e.Topic = topicServiceHealthConnect payload := e.Payload.(EventPayloadCheckServiceNode) payload.overrideKey = serviceName.Name - payload.overrideNamespace = serviceName.EnterpriseMeta.GetNamespace() + if gatewayName.EnterpriseMeta.GetNamespace() != serviceName.EnterpriseMeta.GetNamespace() { + payload.overrideNamespace = serviceName.EnterpriseMeta.GetNamespace() + } e.Payload = payload events = append(events, e) @@ -450,7 +454,10 @@ func copyEventForService(event stream.Event, service structs.ServiceName) stream event.Topic = topicServiceHealthConnect payload := event.Payload.(EventPayloadCheckServiceNode) payload.overrideKey = service.Name - payload.overrideNamespace = service.EnterpriseMeta.GetNamespace() + if payload.Value.Service.EnterpriseMeta.GetNamespace() != service.EnterpriseMeta.GetNamespace() { + payload.overrideNamespace = service.EnterpriseMeta.GetNamespace() + } + event.Payload = payload return event } diff --git a/agent/consul/state/catalog_events_test.go b/agent/consul/state/catalog_events_test.go index 108f6eea7..5257e2108 100644 --- a/agent/consul/state/catalog_events_test.go +++ b/agent/consul/state/catalog_events_test.go @@ -1717,8 +1717,9 @@ func testServiceHealthEvent(t *testing.T, svc string, opts ...eventOption) strea csn.Node.Address = "10.10.10.10" for _, opt := range opts { - err := opt(&e) - require.NoError(t, err) + if err := opt(&e); err != nil { + t.Fatalf("expected no error, got %v", err) + } } return e }