Skip to content

Commit

Permalink
Add node.URL()
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Jun 22, 2021
1 parent 8469f30 commit f3edfb7
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
4 changes: 2 additions & 2 deletions pkg/networkservice/chains/nsmgr/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (s *nsmgrSuite) Test_SelectsRestartingEndpointUsecase() {
})
require.NoError(t, err)

nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, s.domain.Nodes[0].NSMgr.URL,
nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, s.domain.Nodes[0].URL(),
registryclient.WithDialOptions(sandbox.DefaultDialOptions(sandbox.GenerateTestToken)...))

nseReg, err = nseRegistryClient.Register(ctx, nseReg)
Expand Down Expand Up @@ -725,7 +725,7 @@ func newPassThroughEndpoint(

var additionalFunctionality []networkservice.NetworkServiceServer
if hasClientFunctionality {
additionalFunctionality = additionalFunctionalityChain(ctx, node.NSMgr.URL, name, labels)
additionalFunctionality = additionalFunctionalityChain(ctx, node.URL(), name, labels)
}

if counter != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/chains/nsmgrproxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ func Test_Interdomain_PassThroughUsecase(t *testing.T) {
// Passtrough to the node i-1
additionalFunctionality = []networkservice.NetworkServiceServer{
chain.NewNetworkServiceServer(
clienturl.NewServer(clusters[i].Nodes[0].NSMgr.URL),
clienturl.NewServer(clusters[i].Nodes[0].URL()),
connect.NewServer(ctx,
client.NewClientFactory(client.WithAdditionalFunctionality(
newPassTroughClient(fmt.Sprintf("my-service-remote-%v@cluster%v", i-1, i-1)),
Expand Down
2 changes: 1 addition & 1 deletion pkg/networkservice/common/connect/server_cancel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func TestConnect_CancelDuringRequest(t *testing.T) {
}
domain.Nodes[0].NewEndpoint(ctx, nseReg2, sandbox.GenerateTestToken,
chain.NewNetworkServiceServer(
clienturl.NewServer(domain.Nodes[0].NSMgr.URL),
clienturl.NewServer(domain.Nodes[0].URL()),
connect.NewServer(ctx,
clientFactory,
connect.WithDialTimeout(sandbox.DialTimeout),
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/common/heal/find_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func TestHealClient_FindTest(t *testing.T) {
// 1. Create NS, NSE find clients
findCtx, findCancel := context.WithCancel(ctx)

nsRegistryClient := registryclient.NewNetworkServiceRegistryClient(ctx, domain.Nodes[0].NSMgr.URL,
nsRegistryClient := registryclient.NewNetworkServiceRegistryClient(ctx, domain.Nodes[0].URL(),
registryclient.WithDialOptions(sandbox.DefaultDialOptions(sandbox.GenerateTestToken)...))

nsStream, err := nsRegistryClient.Find(findCtx, &registry.NetworkServiceQuery{
Expand All @@ -64,7 +64,7 @@ func TestHealClient_FindTest(t *testing.T) {
})
require.NoError(t, err)

nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, domain.Nodes[0].NSMgr.URL,
nseRegistryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, domain.Nodes[0].URL(),
registryclient.WithDialOptions(sandbox.DefaultDialOptions(sandbox.GenerateTestToken)...))

nseStream, err := nseRegistryClient.Find(findCtx, &registry.NetworkServiceEndpointQuery{
Expand Down
15 changes: 11 additions & 4 deletions pkg/tools/sandbox/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ type Node struct {
NSMgr *NSMgrEntry
}

// URL returns node NSMgr URL
func (n *Node) URL() *url.URL {
u := new(url.URL)
*u = *n.NSMgr.URL
return u
}

// NewNSMgr creates a new NSMgr
func (n *Node) NewNSMgr(
ctx context.Context,
Expand Down Expand Up @@ -108,7 +115,7 @@ func (n *Node) NewForwarder(

entry := new(EndpointEntry)
additionalFunctionality = append(additionalFunctionality,
clienturl.NewServer(n.NSMgr.URL),
clienturl.NewServer(n.URL()),
heal.NewServer(ctx,
heal.WithOnHeal(addressof.NetworkServiceClient(adapters.NewServerToClient(entry))),
heal.WithOnRestore(heal.OnRestoreIgnore)),
Expand All @@ -128,7 +135,7 @@ func (n *Node) NewForwarder(
ctx,
nse,
generatorFunc,
registryclient.NewNetworkServiceEndpointRegistryInterposeClient(ctx, n.NSMgr.URL,
registryclient.NewNetworkServiceEndpointRegistryInterposeClient(ctx, n.URL(),
registryclient.WithDialOptions(dialOptions...)),
additionalFunctionality...,
)
Expand All @@ -151,7 +158,7 @@ func (n *Node) NewEndpoint(
ctx,
nse,
generatorFunc,
registryclient.NewNetworkServiceEndpointRegistryClient(ctx, n.NSMgr.URL,
registryclient.NewNetworkServiceEndpointRegistryClient(ctx, n.URL(),
registryclient.WithDialOptions(DefaultDialOptions(generatorFunc)...)),
additionalFunctionality...,
)
Expand Down Expand Up @@ -200,7 +207,7 @@ func (n *Node) NewClient(
) networkservice.NetworkServiceClient {
return client.NewClient(
ctx,
n.NSMgr.URL,
n.URL(),
client.WithDialOptions(DefaultDialOptions(generatorFunc)...),
client.WithDialTimeout(DialTimeout),
client.WithAuthorizeClient(authorize.NewClient(authorize.Any())),
Expand Down
2 changes: 1 addition & 1 deletion pkg/tools/sandbox/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (d *Domain) NewNSRegistryClient(ctx context.Context, generatorFunc token.Ge
case d.Registry != nil:
registryURL = d.Registry.URL
case len(d.Nodes) != 0:
registryURL = d.Nodes[0].NSMgr.URL
registryURL = d.Nodes[0].URL()
default:
return nil
}
Expand Down

0 comments on commit f3edfb7

Please sign in to comment.