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

qfix: Manually update to latest sdk changes #383

Merged
merged 10 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ COPY . .
RUN go build -o /bin/forwarder .

FROM build as test
CMD go test -test.v ./...
CMD go test -test.v ./... -timeout 2m

FROM test as debug
WORKDIR /build/internal/tests/
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ require (
github.com/networkservicemesh/sdk v0.5.1-0.20211108225443-65796945d24d
github.com/networkservicemesh/sdk-k8s v0.0.0-20211103091718-33b5af79cf03
github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108233028-6925316542f1
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108235351-e35775c814d4
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.7.0
github.com/spiffe/go-spiffe/v2 v2.0.0-beta.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,8 @@ github.com/networkservicemesh/sdk-kernel v0.0.0-20211108225859-2db0822a1c14 h1:t
github.com/networkservicemesh/sdk-kernel v0.0.0-20211108225859-2db0822a1c14/go.mod h1:u7vQCgUUT0DzW0xVFadc8p8ItGmgDB5Ho2qke3ewdnQ=
github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6 h1:WsnwJeTDbTVJc8FuCYIUt6y9QnYaRrEyH3TCycQGDRo=
github.com/networkservicemesh/sdk-sriov v0.0.0-20211103092011-23a720ab62a6/go.mod h1:Sx4W7rd93sUhpCPT92FvhDXAbbfshVcB4IX4CgTrFos=
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108233028-6925316542f1 h1:QI9RJKNFh8LQ+Q2ZFjOIbmvaD74+Rpv88X6jKgK+8q4=
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108233028-6925316542f1/go.mod h1:ypHVrxveXzME4bHL61nwwRXUPfwWL0vNQT6/yMI9J3w=
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108235351-e35775c814d4 h1:eb2HFbut/ax4x1JkpKvg+2q8EWOrMh+2AIArXaCw1Oc=
github.com/networkservicemesh/sdk-vpp v0.0.0-20211108235351-e35775c814d4/go.mod h1:ypHVrxveXzME4bHL61nwwRXUPfwWL0vNQT6/yMI9J3w=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
13 changes: 7 additions & 6 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import (

// Config - configuration for cmd-forwarder-vpp
type Config struct {
Name string `default:"forwarder" desc:"Name of Endpoint"`
NSName string `default:"xconnectns" desc:"Name of Network Service to Register with Registry"`
ConnectTo url.URL `default:"unix:///connect.to.socket" desc:"url to connect to" split_words:"true"`
ListenOn url.URL `default:"unix:///listen.on.socket" desc:"url to listen on" split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`
Name string `default:"forwarder" desc:"Name of Endpoint"`
Labels map[string]string `desc:"Labels related to this forwarder-vpp instance"`
NSName string `default:"forwarder" desc:"Name of Network Service to Register with Registry"`
ConnectTo url.URL `default:"unix:///connect.to.socket" desc:"url to connect to" split_words:"true"`
ListenOn url.URL `default:"unix:///listen.on.socket" desc:"url to listen on" split_words:"true"`
MaxTokenLifetime time.Duration `default:"10m" desc:"maximum lifetime of tokens" split_words:"true"`
LogLevel string `default:"INFO" desc:"Log level" split_words:"true"`

TunnelIP net.IP `desc:"IP to use for tunnels" split_words:"true"`
VxlanPort uint16 `default:"0" desc:"VXLAN port to use" split_words:"true"`
Expand Down
2 changes: 1 addition & 1 deletion internal/imports/imports_linux.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 18 additions & 4 deletions internal/tests/suite_combinatronics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import (
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/wireguard"
"github.com/networkservicemesh/api/pkg/api/registry"

"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/kernel"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/memif"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/vxlan"
"github.com/networkservicemesh/api/pkg/api/networkservice/mechanisms/wireguard"
"github.com/networkservicemesh/api/pkg/api/networkservice/payload"
"github.com/networkservicemesh/api/pkg/api/registry"
"github.com/networkservicemesh/sdk/pkg/registry/core/adapters"

"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/tools/log"
Expand Down Expand Up @@ -134,7 +134,20 @@ func (f *ForwarderTestSuite) TestCombinations() {
ctx = log.WithFields(ctx, map[string]interface{}{"test": t.Name()})
ctx = log.WithLog(ctx, logruslogger.New(ctx))
networkserviceName := "ns"
// Create testRequest

_, err = adapters.NetworkServiceEndpointServerToClient(f.registryServer).Register(ctx, &registry.NetworkServiceEndpoint{
Name: "nse",
NetworkServiceNames: []string{"ns"},
Url: f.listenOn,
})
f.Require().NoError(err)

_, err = adapters.NetworkServiceServerToClient(f.registryNSServer).Register(ctx, &registry.NetworkService{
Name: "ns",
Payload: payloadName,
})
f.Require().NoError(err)

testRequest := &networkservice.NetworkServiceRequest{
Connection: &networkservice.Connection{
NetworkService: networkserviceName,
Expand All @@ -152,6 +165,7 @@ func (f *ForwarderTestSuite) TestCombinations() {
networkservice.RegisterNetworkServiceServer(server, ep)
networkservice.RegisterMonitorConnectionServer(server, ep)
registry.RegisterNetworkServiceEndpointRegistryServer(server, f.registryServer)
registry.RegisterNetworkServiceRegistryServer(server, f.registryNSServer)
serverErrCh := f.ListenAndServe(ctx, server)
log.FromContext(ctx).Infof("Launching %s test server (took : %s)", t.Name(), time.Since(now))

Expand Down
7 changes: 6 additions & 1 deletion internal/tests/suite_setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (f *ForwarderTestSuite) SetupSuite() {
logrus.SetFormatter(&nested.Formatter{})
logrus.SetLevel(logrus.DebugLevel)
log.EnableTracing(true)
f.ctx, f.cancel = context.WithCancel(context.Background())
f.ctx, f.cancel = context.WithTimeout(context.Background(), time.Minute)
f.ctx = log.WithLog(f.ctx, logruslogger.New(f.ctx))

starttime := time.Now()
Expand Down Expand Up @@ -135,6 +135,8 @@ func (f *ForwarderTestSuite) SetupSuite() {
memrg,
)

f.registryNSServer = memory.NewNetworkServiceRegistryServer()

// ********************************************************************************
log.FromContext(f.ctx).Infof("Get the regEndpoint from SUT (time since start: %s)", time.Since(starttime))
// ********************************************************************************
Expand All @@ -143,6 +145,8 @@ func (f *ForwarderTestSuite) SetupSuite() {
server := grpc.NewServer(grpc.Creds(serverCreds))

registry.RegisterNetworkServiceEndpointRegistryServer(server, f.registryServer)
registry.RegisterNetworkServiceRegistryServer(server, f.registryNSServer)

ctx, cancel := context.WithCancel(f.ctx)
defer func(cancel context.CancelFunc, serverErrCh <-chan error) {
cancel()
Expand All @@ -162,6 +166,7 @@ func (f *ForwarderTestSuite) SetupSuite() {
f.Require().NoError(err)
log.FromContext(ctx).Infof("Received regEndpoint: %+v (time since start: %s)", regEndpoint, time.Since(starttime))

f.listenOn = regEndpoint.GetNetworkServiceEndpoint().GetUrl()
// ********************************************************************************
log.FromContext(f.ctx).Infof("Creating grpc.ClientConn to SUT (time since start: %s)", time.Since(starttime))
// ********************************************************************************
Expand Down
4 changes: 3 additions & 1 deletion internal/tests/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type ForwarderTestSuite struct {
spireErrCh <-chan error
x509source x509svid.Source
x509bundle x509bundle.Source
listenOn string

// vppServer stuff
vppServerConn vpphelper.Connection
Expand All @@ -58,7 +59,8 @@ type ForwarderTestSuite struct {
vppClientErrCh <-chan error

// registry server stuff
registryServer registry.NetworkServiceEndpointRegistryServer
registryServer registry.NetworkServiceEndpointRegistryServer
registryNSServer registry.NetworkServiceRegistryServer
}

func TestForwarderTestSuite(t *testing.T) {
Expand Down
6 changes: 3 additions & 3 deletions internal/xconnectns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
"github.com/networkservicemesh/sdk-sriov/pkg/networkservice/common/resourcepool"
sriovconfig "github.com/networkservicemesh/sdk-sriov/pkg/sriov/config"
sriovtokens "github.com/networkservicemesh/sdk-sriov/pkg/tools/tokens"
vppxconnectns "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/chains/xconnectns"
vppforwarder "github.com/networkservicemesh/sdk-vpp/pkg/networkservice/chains/forwarder"
"github.com/networkservicemesh/sdk/pkg/networkservice/chains/endpoint"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/mechanisms"
"github.com/networkservicemesh/sdk/pkg/networkservice/common/switchcase"
Expand All @@ -50,7 +50,7 @@ func NewServer(
name string,
authzServer networkservice.NetworkServiceServer,
tokenGenerator token.GeneratorFunc,
vppConn vppxconnectns.Connection,
vppConn vppforwarder.Connection,
tunnelIP net.IP,
tunnelPort uint16,
pciPool resourcepool.PCIPool,
Expand All @@ -60,7 +60,7 @@ func NewServer(
clientURL *url.URL,
clientDialOptions ...grpc.DialOption,
) endpoint.Endpoint {
vppForwarder := vppxconnectns.NewServer(ctx, name, authzServer, tokenGenerator, clientURL, vppConn, tunnelIP, tunnelPort, clientDialOptions...)
vppForwarder := vppforwarder.NewServer(ctx, name, authzServer, tokenGenerator, clientURL, vppConn, tunnelIP, tunnelPort, clientDialOptions...)
if sriovConfig == nil {
return vppForwarder
}
Expand Down
7 changes: 6 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ func main() {

registryClient := registryclient.NewNetworkServiceEndpointRegistryClient(ctx, &cfg.ConnectTo, registryclient.WithDialOptions(clientOptions...))
_, err = registryClient.Register(ctx, &registryapi.NetworkServiceEndpoint{
Name: cfg.Name,
Name: cfg.Name,
NetworkServiceLabels: map[string]*registryapi.NetworkServiceLabels{
cfg.NSName: {
Labels: cfg.Labels,
},
},
NetworkServiceNames: []string{cfg.NSName},
Url: cfg.ListenOn.String(),
})
Expand Down