Skip to content

Commit

Permalink
Assign payload from network service to the connection (#791)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Belov <artem.belov@xored.com>
  • Loading branch information
Artem Belov authored Mar 25, 2021
1 parent a9754c7 commit 8fe930c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions pkg/networkservice/common/discover/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func (d *discoverCandidatesServer) Request(ctx context.Context, request *network
return nil, err
}

request.GetConnection().Payload = ns.Payload

delay := defaultDiscoverDelay
for ctx.Err() == nil {
resp, err := next.Server(ctx).Request(WithCandidates(ctx, nses, ns), request)
Expand Down
6 changes: 4 additions & 2 deletions pkg/networkservice/common/discover/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ func TestMatchExactService(t *testing.T) {

// 3. Register NS, NSE with the right name
_, err = nsServer.Register(context.Background(), &registry.NetworkService{
Name: nsName,
Name: nsName,
Payload: payload.IP,
})
require.NoError(t, err)
_, err = nseServer.Register(context.Background(), &registry.NetworkServiceEndpoint{
Expand All @@ -428,8 +429,9 @@ func TestMatchExactService(t *testing.T) {
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Millisecond)
defer cancel()

_, err = server.Request(ctx, request.Clone())
conn, err := server.Request(ctx, request.Clone())
require.NoError(t, err)
require.Equal(t, payload.IP, conn.Payload)
}

func TestMatchExactEndpoint(t *testing.T) {
Expand Down

0 comments on commit 8fe930c

Please sign in to comment.