Skip to content

Implement WCM AWS TGW connector NSE config options and composite endpoint stub and add stub unit-tests as well #48

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

Open
wants to merge 21 commits into
base: master
Choose a base branch
from

Conversation

amberimam
Copy link

Copy link
Contributor

@CosminNechifor CosminNechifor left a comment

Choose a reason for hiding this comment

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

Nice work. LGTM and I have 2 small suggestions.

Comment on lines 16 to 21
Name string `yaml:"name"`
Labels Labels `yaml:"labels"`
NseName string `yaml:"nseName"` //TODO temporary in order to be able to run examples
NseControl *NseControl `yaml:"nseControl"`
VL3 VL3 `yaml:"vl3"`
AwsTgwEndpoint *AwsTgwEndpoint
Copy link
Contributor

Choose a reason for hiding this comment

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

Format this file. Also you could add after AwsTgwEndpoint *AwsTgwEndpoint `yaml:"awsTgwEndpoint"`

Copy link
Author

Choose a reason for hiding this comment

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

Sure, what should I format exactly? I am moving the annotations so that they all start in the same column. Should I do anything else?

Amber Imam added 2 commits December 3, 2020 09:26
@@ -70,6 +70,117 @@ type vL3ConnectComposite struct {
nseControlAddr string
}

// newVL3ConnectComposite creates a new VL3 composite
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure what happened/changed here. Is anything supposed to have changed in this file? Even if there are changes please don't move the function as it shows everything as changed in the diffs

Copy link
Author

Choose a reason for hiding this comment

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

ah sure, I'll move it back. I think I misunderstood a review comment from @CosminNechifor . I changed the function to be a var so that I could mock it during unit testing. @CosminNechifor did you just want me to declare the var near the top of the file and leave the function implementation where it is?

@@ -108,7 +108,7 @@ func (s *serviceRegistry) RegisterWorkload(ctx context.Context, workloadLabels m
logrus.Infof("Sending workload register request: %v", serviceWorkload)
_, err = s.registryClient.RegisterWorkload(ctx, serviceWorkload)
if err != nil {
logrus.Errorf("service registration not successful: %w", err)
logrus.Errorf("service registration not successful: %v", err)
Copy link
Contributor

Choose a reason for hiding this comment

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

are these golint related fixes? if there's a lot of these please add these as a separate PR

Copy link
Author

@amberimam amberimam Dec 4, 2020

Choose a reason for hiding this comment

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

When I tried running the unit tests I wrote for aws_tgw_connect.go there was a build failure for this file that was preventing my tests from running. Failure happened due to having the %w instead of %v.

Copy link
Member

@ondrej-fabry ondrej-fabry Dec 8, 2020

Choose a reason for hiding this comment

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

Just noting here for exaplanation:
This most likely a forgotten formatting directive that was probably copy-pasted from other fmt.Errorf call. The %w is a special specified for errors, read more here: https://golang.org/pkg/fmt/#Errorf Since this is logrus.Errorf that just prints log and does not create error it is incorrect in this case.

assert.Equal(t, 1, len(*got))

compositeEndpoints := *got
typeofEndpoint := fmt.Sprintf("%T", compositeEndpoints[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this test is actually validating that the AwsTgwConnector endpoint didn't get added. You should loop through the compositeEndpoints to check each element to ensure it's not AwsTgwConnector

Copy link
Author

Choose a reason for hiding this comment

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

Sure, will do.

assert.Equal(t, len(*got), 2)

compositeEndpoints := *got
awsTgwEndpoint := compositeEndpoints[1]
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment re: looping through the compositeEndpoints.

Copy link
Author

Choose a reason for hiding this comment

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

Will do

awsTgwEndpoint := compositeEndpoints[1]
typeOfEndpoint := fmt.Sprintf("%T", awsTgwEndpoint)

assert.Equal(t, "*main.AwsTgwConnector", typeOfEndpoint )
Copy link
Contributor

Choose a reason for hiding this comment

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

these 2 cases are good candidates to convert to a table driven approach

Copy link
Author

Choose a reason for hiding this comment

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

Sure will change it to a table driven test

@@ -18,6 +18,7 @@ const (
dstIpAddrClient = "192.168.22.2"
dstIpRouteClient = "192.168.0.0/16"
ifName = "endpoint0"
mechanismType = "MEMIF"
Copy link
Contributor

Choose a reason for hiding this comment

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

seems like the fixes in this file are unrelated to the WCM connector NSE work, right? Are they more appropriate in another PR ?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, I'll move these changes into a separate PR. Thanks for the review Tim!!! :)

@tiswanso
Copy link
Contributor

@amberimam -- let's push this content to a branch named feature-aws-tgw in the wwwin-github repo and we can close this PR here.

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.

5 participants