-
Notifications
You must be signed in to change notification settings - Fork 22
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
add check that vnic with same name doesn't has the same network #109
Changes from 2 commits
d1442f1
8f13077
9f00269
0fbd0c1
8d94d81
75a3fdd
40ad8ec
7633789
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ func assertCanCreateNIC( | |
return nic | ||
} | ||
|
||
func assertCannotCreateNIC( | ||
func assertCannotCreateNICWithSameName( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This name change is misleading. The error message below should also be changed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about -("create 2 NICs with same name %s (%v)", name, err) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @janosdebugs , we have some functions for create nic:
regarding 2 and 3 what do you suggest? if I change 2 as it was assertCannotCreateNIC, what is the differerent from 3? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would personally prefer having two functions: |
||
t *testing.T, | ||
helper ovirtclient.TestHelper, | ||
vm ovirtclient.VM, | ||
|
@@ -47,6 +47,19 @@ func assertCannotCreateNIC( | |
} | ||
} | ||
|
||
func assertCannotCreateNICWithSameNameDiffNetwork( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would suggest renaming this to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WDYT about assertCannotCreateNICWithSameVNICProfile? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could do that, however, we are trying to keep the assert functions reusable in other test cases. The naming should convey what the assert functions are doing rather than the current use case so future contributors feel that they can safely reuse the assert function. If the assert function alone does not convey the logic in the test case using the assert function we can always add comments explaining what's happening. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NP |
||
t *testing.T, | ||
vm ovirtclient.VM, | ||
name string, | ||
diffVNICProfile string, | ||
params ovirtclient.BuildableNICParameters, | ||
) { | ||
nic, _ := vm.CreateNIC(name, diffVNICProfile, params) | ||
if nic != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is preferable from a readability perspective to check the error, not the returned object. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
t.Fatalf("create 2 NICs with same name %s", name) | ||
mgold1234 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
func assertCanRemoveNIC(t *testing.T, nic ovirtclient.NIC) { | ||
if err := nic.Remove(); err != nil { | ||
t.Fatalf("failed to remove NIC %s (%v)", nic.ID(), 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.
What happens if there is no second vnic profile? We cannot assume there is a secondary profile available. Can we create a second profile? What if the secondary profile is on the same network as the primary? Does it still work?
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.
@janosdebugs , so I will change the function to catch the case that if there is no secondary profile then we will check the assertCannotCreateNICWithSameName and if we have more then 1 profile we will check this -assertCannotCreateNICWithVNICProfile.
WDYT?
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.
Yes. Ideally, we'll skip the test if there is no secondary profile available. Later we can create a secondary profile to test.