Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve registry chains testing with sandbox #668

Merged
merged 10 commits into from
Feb 8, 2021

Conversation

Bolodya1997
Copy link

Issues

  1. Existing sandbox doesn't use registry client chain to register endpoints, so we can't use it for registry testing.
  2. Existing sandbox doesn't allow to start a node without forwarder or with multiple forwarders, so we can't use it for testing interpose chain elements.

Solution

Rework sandbox to the node API:

// Node is a NSMgr with resources
type Node struct {
	NSMgr     *NSMgrEntry
	...
}

// NewForwarder starts a new forwarder and registers it on the node NSMgr
func (n *Node) NewForwarder(
	ctx context.Context,
	nse *registry.NetworkServiceEndpoint,
	generatorFunc token.GeneratorFunc,
	additionalFunctionality ...networkservice.NetworkServiceServer,
) (*EndpointEntry, error) {
	...
}

// NewEndpoint starts a new endpoint and registers it on the node NSMgr
func (n *Node) NewEndpoint(
	ctx context.Context,
	nse *registry.NetworkServiceEndpoint,
	generatorFunc token.GeneratorFunc,
	additionalFunctionality ...networkservice.NetworkServiceServer,
) (*EndpointEntry, error) {
	...
}

// NewClient starts a new client and connects it to the node NSMgr
func (n *Node) NewClient(
	ctx context.Context,
	generatorFunc token.GeneratorFunc,
	additionalFunctionality ...networkservice.NetworkServiceClient,
) networkservice.NetworkServiceClient {
	...
}

Usage:

domain := sandbox.NewBuilder(t).
	SetNodesCount(nodesCount).
	SetRegistryProxySupplier(nil).
	SetContext(ctx).
	Build()

for _, node := range domain.Nodes {
	_, err := node.NewForwarder(ctx, new(registry.NetworkServiceEndpoint), sandbox.GenerateTestToken)
	require.NoError(t, err)
}

_, err := node.NewEndpoint(ctx, &registry.NetworkServiceEndpoint{...}, sandbox.GenerateTestTokent, ...endpointChain)
require.NoError(t, err)

client := node.NewClient(ctx, sandbox.GenerateTestTokent, ...clientChain)

conn, err := client.Request(...)
require.NoError(t, err)
validateConnection(t, conn)

_, err := client.Close(ctx, conn)
require.NoError(t, err)

@denis-tingaikin
Copy link
Member

Existing sandbox doesn't use registry client chain to register endpoints, so we can't use it for registry testing.

It is not fully correct. You are able to create a registry client using nsmgr url.

@denis-tingaikin
Copy link
Member

Existing sandbox doesn't allow to start a node without forwarder or with multiple forwarders, so we can't use it for testing interpose chain elements.

We can add this, but need to think about how to not add more complexity :)

@denis-tingaikin denis-tingaikin changed the title Rework sandbox Add to sandbox a possible to test multi forwarders Jan 25, 2021
@Bolodya1997
Copy link
Author

Existing sandbox doesn't use registry client chain to register endpoints, so we can't use it for registry testing.

It is not fully correct. You are able to create a registry client using nsmgr url.

You are right, it is not making it possible - it reworks general sandbox way to add endpoint to use registry chain :)

@Bolodya1997 Bolodya1997 marked this pull request as draft January 26, 2021 07:21
@Bolodya1997 Bolodya1997 changed the title Add to sandbox a possible to test multi forwarders Improve registry chains testing with sandbox Jan 28, 2021
@Bolodya1997 Bolodya1997 force-pushed the rework-sandbox branch 3 times, most recently from c82fd07 to 1afc43c Compare February 1, 2021 06:08
@Bolodya1997 Bolodya1997 marked this pull request as ready for review February 1, 2021 06:08
pkg/tools/sandbox/node.go Outdated Show resolved Hide resolved
pkg/tools/sandbox/registry_client.go Outdated Show resolved Hide resolved
@Bolodya1997 Bolodya1997 force-pushed the rework-sandbox branch 4 times, most recently from 54956d7 to 1a3743d Compare February 1, 2021 13:17
@Bolodya1997 Bolodya1997 marked this pull request as draft February 4, 2021 04:27
@Bolodya1997 Bolodya1997 force-pushed the rework-sandbox branch 5 times, most recently from c11e038 to 9b71b6d Compare February 5, 2021 08:58
Vladimir Popov added 2 commits February 8, 2021 11:02

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Vladimir Popov added 5 commits February 8, 2021 11:02
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
@Bolodya1997 Bolodya1997 marked this pull request as ready for review February 8, 2021 04:43
Copy link
Member

@denis-tingaikin denis-tingaikin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@@ -223,7 +223,7 @@ func TestInterdomainFloatingNetworkServiceEndpointRegistry(t *testing.T) {

domain3 := sandbox.NewBuilder(t).
SetNodesCount(0).
SetRegistrySupplier(func(context.Context, *url.URL, ...grpc.DialOption) registry2.Registry {
SetRegistrySupplier(func(context.Context, time.Duration, *url.URL, ...grpc.DialOption) registry2.Registry {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we fix the artifact registry2 ? :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, fixed with registryapi for github.com/networkservicemesh/api/pkg/api/registry and no alias for github.com/networkservicemesh/sdk/pkg/registry.

Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
@denis-tingaikin denis-tingaikin merged commit 64f6aa2 into networkservicemesh:master Feb 8, 2021
nsmbot pushed a commit to networkservicemesh/cmd-registry-memory that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-kernel that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-registry-proxy-dns that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nsmgr-proxy that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-vfio that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/cmd-nse-icmp-responder that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-vpp that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
nsmbot pushed a commit to networkservicemesh/sdk-k8s that referenced this pull request Feb 8, 2021
…k@master networkservicemesh/sdk#668

networkservicemesh/sdk PR link: networkservicemesh/sdk#668

networkservicemesh/sdk commit message:
commit 64f6aa269f6321844fa3b536ed4793840e918505
Author: Vladimir Popov <vladimir.popov@xored.com>
Date:   Mon Feb 8 16:28:44 2021 +0700

    Improve registry chains testing with sandbox (#668)

    * Rework sandbox to node API

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework tests to the new sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add Builder.setupNode

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Cleanup NSEs on context close

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Add sandbox registry client, rework endpoint Register/Unregister

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Rework endpoint registration in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Increase default registry expiration

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Use NSE registry client in sandbox

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * NSE should be registered after all NS registered

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

    * Fix imports aliaces

    Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>

Signed-off-by: NSMBot <nsmbot@networkservicmesh.io>
@Bolodya1997 Bolodya1997 deleted the rework-sandbox branch February 12, 2021 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants