-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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.
pkg/nseconfig/config.go
Outdated
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 |
There was a problem hiding this comment.
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"`
There was a problem hiding this comment.
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?
…) and BuildVppIfName() functions
…oint stub and add stub unit-tests as well
* test: Introduce e2e testing Signed-off-by: Ondrej Fabry <[email protected]> * Update docs for end-2-end tests Signed-off-by: Ondrej Fabry <[email protected]>
…nce I changed it to a var so that it would be easier to override it for unit testing
…) and BuildVppIfName() functions
…oint stub and add stub unit-tests as well
…nce I changed it to a var so that it would be easier to override it for unit testing
@@ -70,6 +70,117 @@ type vL3ConnectComposite struct { | |||
nseControlAddr string | |||
} | |||
|
|||
// newVL3ConnectComposite creates a new VL3 composite |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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]) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 ) |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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!!! :)
@amberimam -- let's push this content to a branch named |
https://jira-eng-sjc4.cisco.com/jira/browse/NSMNSE-44