Skip to content

Commit

Permalink
Replacing comparison of proto messages (networkservicemesh#601)
Browse files Browse the repository at this point in the history
* Replacing comparison of proto messages

Signed-off-by: Artem Glazychev <[email protected]>

* Add tests for network service endpoints matching by label

Signed-off-by: Artem Glazychev <[email protected]>
Signed-off-by: Sergey Ershov <[email protected]>
  • Loading branch information
glazychev-art authored and Sergey Ershov committed Dec 23, 2020
1 parent 9b16782 commit 9660a0a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/fsnotify/fsnotify v1.4.9
github.com/ghodss/yaml v1.0.0
github.com/golang/protobuf v1.4.3
github.com/google/go-cmp v0.5.2
github.com/google/uuid v1.1.2
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645
github.com/hashicorp/go-multierror v1.0.0
Expand Down
32 changes: 32 additions & 0 deletions pkg/registry/memory/nse_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,38 @@ func TestNetworkServiceEndpointRegistryServer_RegisterAndFindWatch(t *testing.T)
close(ch)
}

func TestNetworkServiceEndpointRegistryServer_RegisterAndFindByLabel(t *testing.T) {
defer goleak.VerifyNone(t, goleak.IgnoreCurrent())
s := next.NewNetworkServiceEndpointRegistryServer(memory.NewNetworkServiceEndpointRegistryServer())

_, err := s.Register(context.Background(), createLabeledNSE1())
require.NoError(t, err)

_, err = s.Register(context.Background(), createLabeledNSE2())
require.NoError(t, err)

_, err = s.Register(context.Background(), createLabeledNSE3())
require.NoError(t, err)

ctx, cancel := context.WithCancel(context.Background())
ch := make(chan *registry.NetworkServiceEndpoint, 1)
_ = s.Find(&registry.NetworkServiceEndpointQuery{
NetworkServiceEndpoint: &registry.NetworkServiceEndpoint{
NetworkServiceLabels: map[string]*registry.NetworkServiceLabels{
"Service1": {
Labels: map[string]string{
"c": "d",
},
},
},
},
}, streamchannel.NewNetworkServiceEndpointFindServer(ctx, ch))

require.Equal(t, createLabeledNSE2(), <-ch)
cancel()
close(ch)
}

func TestNetworkServiceEndpointRegistryServer_RegisterAndFindByLabelWatch(t *testing.T) {
defer goleak.VerifyNone(t, goleak.IgnoreCurrent())
s := next.NewNetworkServiceEndpointRegistryServer(memory.NewNetworkServiceEndpointRegistryServer())
Expand Down

0 comments on commit 9660a0a

Please sign in to comment.