From 8c017fb31ed7a099c6ac446fa636d95aff0c7f79 Mon Sep 17 00:00:00 2001 From: Clemens Hoffmann Date: Thu, 12 Dec 2024 14:43:35 +0100 Subject: [PATCH] Fix tests --- metrics/metricsreporter_test.go | 10 +++++----- proxy/round_tripper/proxy_round_tripper_test.go | 16 ++++++++-------- registry/registry_test.go | 8 ++++---- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/metrics/metricsreporter_test.go b/metrics/metricsreporter_test.go index 102f4536..0eb5972b 100644 --- a/metrics/metricsreporter_test.go +++ b/metrics/metricsreporter_test.go @@ -462,8 +462,8 @@ var _ = Describe("MetricsReporter", func() { metricReporter.CaptureRegistryMessage(endpoint, "some-action") Expect(batcher.BatchIncrementCounterCallCount()).To(Equal(2)) - Expect(batcher.BatchIncrementCounterArgsForCall(0)).To(Equal("registry_message.uaa.some-action")) - Expect(batcher.BatchIncrementCounterArgsForCall(1)).To(Equal("registry_message.route-emitter.some-action")) + Expect(batcher.BatchIncrementCounterArgsForCall(0)).To(Equal("registry_message.some-action.uaa")) + Expect(batcher.BatchIncrementCounterArgsForCall(1)).To(Equal("registry_message.some-action.route-emitter")) }) It("sends the total routes", func() { @@ -522,7 +522,7 @@ var _ = Describe("MetricsReporter", func() { It("increments the counter metric", func() { Expect(sender.IncrementCounterCallCount()).To(Equal(1)) - Expect(sender.IncrementCounterArgsForCall(0)).To(Equal("unregistry_message.oauth-server.some-action")) + Expect(sender.IncrementCounterArgsForCall(0)).To(Equal("unregistry_message.some-action.oauth-server")) }) It("increments the counter metric for each component unregistered", func() { @@ -531,8 +531,8 @@ var _ = Describe("MetricsReporter", func() { metricReporter.CaptureUnregistryMessage(endpointTwo, "some-action") Expect(sender.IncrementCounterCallCount()).To(Equal(2)) - Expect(sender.IncrementCounterArgsForCall(0)).To(Equal("unregistry_message.oauth-server.some-action")) - Expect(sender.IncrementCounterArgsForCall(1)).To(Equal("unregistry_message.api-server.some-action")) + Expect(sender.IncrementCounterArgsForCall(0)).To(Equal("unregistry_message.some-action.oauth-server")) + Expect(sender.IncrementCounterArgsForCall(1)).To(Equal("unregistry_message.some-action.api-server")) }) }) Context("when unregister msg with empty component name is incremented", func() { diff --git a/proxy/round_tripper/proxy_round_tripper_test.go b/proxy/round_tripper/proxy_round_tripper_test.go index 4d0df3be..53b1a4d8 100644 --- a/proxy/round_tripper/proxy_round_tripper_test.go +++ b/proxy/round_tripper/proxy_round_tripper_test.go @@ -655,7 +655,7 @@ var _ = Describe("ProxyRoundTripper", func() { Context("when there are no more endpoints available", func() { JustBeforeEach(func() { removed := routePool.Remove(endpoint) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) }) It("returns a 502 Bad Gateway response", func() { @@ -1147,7 +1147,7 @@ var _ = Describe("ProxyRoundTripper", func() { added = routePool.Put(endpoint2) Expect(added).To(Equal(route.Added)) removed := routePool.Remove(endpoint) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) }) Context("when there are no cookies on the request", func() { @@ -1439,10 +1439,10 @@ var _ = Describe("ProxyRoundTripper", func() { JustBeforeEach(func() { removed := routePool.Remove(endpoint1) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) removed = routePool.Remove(endpoint2) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) new_endpoint := route.NewEndpoint(&route.EndpointOpts{PrivateInstanceId: "id-5"}) added := routePool.Put(new_endpoint) @@ -1502,10 +1502,10 @@ var _ = Describe("ProxyRoundTripper", func() { JustBeforeEach(func() { removed := routePool.Remove(endpoint1) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) removed = routePool.Remove(endpoint2) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) new_endpoint := route.NewEndpoint(&route.EndpointOpts{PrivateInstanceId: "id-5"}) added := routePool.Put(new_endpoint) @@ -1568,10 +1568,10 @@ var _ = Describe("ProxyRoundTripper", func() { JustBeforeEach(func() { removed := routePool.Remove(endpoint1) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) removed = routePool.Remove(endpoint2) - Expect(removed).To(BeTrue()) + Expect(removed).To(Equal(route.EndpointUnregistered)) new_endpoint := route.NewEndpoint(&route.EndpointOpts{PrivateInstanceId: "id-5"}) added := routePool.Put(new_endpoint) diff --git a/registry/registry_test.go b/registry/registry_test.go index 982604ca..c3163db3 100644 --- a/registry/registry_test.go +++ b/registry/registry_test.go @@ -76,7 +76,7 @@ var _ = Describe("RouteRegistry", func() { Expect(reporter.CaptureRegistryMessageCallCount()).To(Equal(1)) endpoint1, action1 := reporter.CaptureRegistryMessageArgsForCall(0) Expect(endpoint1).To(Equal(fooEndpoint)) - Expect(action1).To(Equal("endpoint-registered")) + Expect(action1).To(Equal("endpoint-added")) }) }) @@ -91,7 +91,7 @@ var _ = Describe("RouteRegistry", func() { Expect(reporter.CaptureRegistryMessageCallCount()).To(Equal(2)) endpointR1, action1 := reporter.CaptureRegistryMessageArgsForCall(0) Expect(endpointR1).To(Equal(endpoint1)) - Expect(action1).To(Equal("endpoint-registered")) + Expect(action1).To(Equal("endpoint-added")) endpointR2, action2 := reporter.CaptureRegistryMessageArgsForCall(1) Expect(endpointR2).To(Equal(endpoint2)) Expect(action2).To(Equal("endpoint-updated")) @@ -109,7 +109,7 @@ var _ = Describe("RouteRegistry", func() { Expect(reporter.CaptureRegistryMessageCallCount()).To(Equal(2)) endpointR1, action1 := reporter.CaptureRegistryMessageArgsForCall(0) Expect(endpointR1).To(Equal(endpoint1)) - Expect(action1).To(Equal("endpoint-registered")) + Expect(action1).To(Equal("endpoint-added")) endpointR2, action2 := reporter.CaptureRegistryMessageArgsForCall(1) Expect(endpointR2).To(Equal(endpoint2)) Expect(action2).To(Equal("endpoint-not-updated")) @@ -278,7 +278,7 @@ var _ = Describe("RouteRegistry", func() { r.Register("a.route", fooEndpoint) Eventually(logger).Should(gbytes.Say(`"log_level":1.*route-registered.*a\.route`)) - Eventually(logger).Should(gbytes.Say(`"log_level":1.*endpoint-registered.*a\.route.*192\.168\.1\.1`)) + Eventually(logger).Should(gbytes.Say(`"log_level":1.*endpoint-added.*a\.route.*192\.168\.1\.1`)) }) It("logs 'uri-added' at debug level for backward compatibility", func() {