From ad46ebbbdbc322d685957d5ba866fee570e476ab Mon Sep 17 00:00:00 2001 From: denis-tingajkin Date: Wed, 14 Jul 2021 11:35:06 +0700 Subject: [PATCH 1/2] qfix: stabilize SwapIPNSERegistry tests Signed-off-by: denis-tingajkin --- pkg/registry/common/swapip/nse_registry_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/pkg/registry/common/swapip/nse_registry_test.go b/pkg/registry/common/swapip/nse_registry_test.go index 80a63abe4..9d1826dc0 100644 --- a/pkg/registry/common/swapip/nse_registry_test.go +++ b/pkg/registry/common/swapip/nse_registry_test.go @@ -46,6 +46,10 @@ func TestSwapIPNSERegistryServer_Register(t *testing.T) { }), ) + ipMapCh <- map[string]string{ + "127.0.0.1": "8.8.8.8", + "8.8.8.8": "127.0.0.1", + } ipMapCh <- map[string]string{ "127.0.0.1": "8.8.8.8", "8.8.8.8": "127.0.0.1", @@ -81,6 +85,11 @@ func TestSwapIPNSERegistryServer_Unregister(t *testing.T) { "8.8.8.8": "127.0.0.1", } + ipMapCh <- map[string]string{ + "127.0.0.1": "8.8.8.8", + "8.8.8.8": "127.0.0.1", + } + _, err := s.Unregister(ctx, ®istry.NetworkServiceEndpoint{ Url: "tcp://127.0.0.1:5001", }) @@ -116,6 +125,11 @@ func TestSwapIPNSERegistryServer_Find(t *testing.T) { "8.8.8.8": "127.0.0.1", } + ipMapCh <- map[string]string{ + "127.0.0.1": "8.8.8.8", + "8.8.8.8": "127.0.0.1", + } + stream, err := adapters.NetworkServiceEndpointServerToClient(s).Find(ctx, ®istry.NetworkServiceEndpointQuery{ NetworkServiceEndpoint: ®istry.NetworkServiceEndpoint{ Url: "tcp://127.0.0.1:5001", From 6c7a2574c8d51ff09f78f55ce6d68e81b424f9db Mon Sep 17 00:00:00 2001 From: denis-tingajkin Date: Wed, 14 Jul 2021 23:59:23 +0700 Subject: [PATCH 2/2] apply review comments Signed-off-by: denis-tingajkin --- .../common/swapip/nse_registry_test.go | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/pkg/registry/common/swapip/nse_registry_test.go b/pkg/registry/common/swapip/nse_registry_test.go index 9d1826dc0..d035e4065 100644 --- a/pkg/registry/common/swapip/nse_registry_test.go +++ b/pkg/registry/common/swapip/nse_registry_test.go @@ -46,15 +46,14 @@ func TestSwapIPNSERegistryServer_Register(t *testing.T) { }), ) - ipMapCh <- map[string]string{ - "127.0.0.1": "8.8.8.8", - "8.8.8.8": "127.0.0.1", - } - ipMapCh <- map[string]string{ + event := map[string]string{ "127.0.0.1": "8.8.8.8", "8.8.8.8": "127.0.0.1", } + ipMapCh <- event + ipMapCh <- event + defer close(ipMapCh) resp, err := s.Register(ctx, ®istry.NetworkServiceEndpoint{ @@ -80,15 +79,13 @@ func TestSwapIPNSERegistryServer_Unregister(t *testing.T) { ) defer close(ipMapCh) - ipMapCh <- map[string]string{ + event := map[string]string{ "127.0.0.1": "8.8.8.8", "8.8.8.8": "127.0.0.1", } - ipMapCh <- map[string]string{ - "127.0.0.1": "8.8.8.8", - "8.8.8.8": "127.0.0.1", - } + ipMapCh <- event + ipMapCh <- event _, err := s.Unregister(ctx, ®istry.NetworkServiceEndpoint{ Url: "tcp://127.0.0.1:5001", @@ -120,15 +117,13 @@ func TestSwapIPNSERegistryServer_Find(t *testing.T) { ) defer close(ipMapCh) - ipMapCh <- map[string]string{ + event := map[string]string{ "127.0.0.1": "8.8.8.8", "8.8.8.8": "127.0.0.1", } - ipMapCh <- map[string]string{ - "127.0.0.1": "8.8.8.8", - "8.8.8.8": "127.0.0.1", - } + ipMapCh <- event + ipMapCh <- event stream, err := adapters.NetworkServiceEndpointServerToClient(s).Find(ctx, ®istry.NetworkServiceEndpointQuery{ NetworkServiceEndpoint: ®istry.NetworkServiceEndpoint{