-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
netstat: Update VMI interface status report unit tests #6951
netstat: Update VMI interface status report unit tests #6951
Conversation
/uncc rmohr vladikr |
/sig network |
change: Added misc test scenarios |
f5bed9b
to
1c5e61f
Compare
change: Rebase |
@@ -278,6 +278,59 @@ var _ = Describe("netstat", func() { | |||
newVMIStatusIface(networkName, nil, ifaceMAC, guestIfaceName), | |||
}), "the SR-IOV interface should be reported in the status, associated to the network") | |||
}) | |||
|
|||
Context("misc scenario", func() { |
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.
maybe worth to add in the Context that this is unrealistic scenarios ?
(misc word is too general, and usually we read the code and not going to the commit message / PR desc which does elaborate it in this case)
It is important to people won't think those are the expected flows
while we develop or even during review, it can cause noise if misunderstood
there are some tests here that should not happen at all (unless there is hot plug), so i am not sure it is good to include them, for example has interface in VMI spec but not in domain spec
IIUC (i do understand the motivation and saw the PR desc)
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.
Unrealistic to whom?
These are indeed edge cases which are the result of the unit API. We can argue that these scenarios have not been expected to occur, at least by their users. However, the unit does allow them to exist, just because the API supports them. Therefore, they should be covered to express what will happen in these cases.
Although we expect not to see these scenarios, they may occur due to bugs or changes to the callers of this unit. In the context of this unit, it has no knowledge on how it is called or by who, and it should not care.
Now that these scenarios are exposed here, a decision may be made to disallow them (e.g. raise an error) or change the output result. But this is not in the scope of this change.
Finally, regarding the name: I consider these miscellaneous scenarios and I did not find any better name for this goup of tests. I do not think they fit to the word "unrealistic" because that is in the context of a caller, not the unit itself.
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.
first pass
if !(vmiIface.Name == vmiNetwork.Name && vmiIface.Name == domainIface.Alias.GetName()) { | ||
panic("network name must be the same") | ||
} |
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.
why not simply ExpectWithOffset ?
(appears at least twice in the PR)
i understand that it is not runtime but more 'config' phase, but we aren't using panic usually,
and Expect will do the same result
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.
To differentiate between the code-under-test failing and the test writer placing an unsupported config in place.
pkg/network/setup/netstat_test.go
Outdated
newVMIStatusIface(primaryNetworkName, []string{newGaIPv4, newGaIPv6}, origMAC, ""), | ||
}), "the pod IP/s should be reported in the status") | ||
}) | ||
|
||
It("should add a new interface based on the domain spec", func() { | ||
It("should report SR-IOV interface when no guest-agent is active", func() { |
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.
Please consider adding a test with 2 interfaces (without guest agent)
- Non SR-IOV
- SR-IOV
Because the behavior would be different, as the main loop of UpdateStatus
would override the interfaces added by the snippet
https://github.com/kubevirt/kubevirt/pull/6951/files#diff-c2b23c7cf6d14c6f6a9e12f1a63d6c8004ead588e9d4d6a369aeea15701ca086R79
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.
Done
1c5e61f
to
9fc55e8
Compare
change: Rebase |
9fc55e8
to
05b3465
Compare
Change: Answered review: Added a SR-IOV test to show what happens when it is accompanied with a "regular" interface. |
change: Rebase |
@@ -244,37 +244,6 @@ var _ = Describe("netstat", func() { | |||
}), "the pod IP/s should be reported in the status") | |||
}) | |||
|
|||
It("should add a new interface based on the domain spec", func() { |
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 understand the commit message. Why such option is not supported? What if there is no GA at all?
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.
The VMI spec is not updated with any interfaces, so having only the domain defined but not the vmi spec is odd.
Later on in the PR, I re-introduces this case in a more direct manner. see here.
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 tried to express it better in the commit message.
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.
Great work!
pkg/network/setup/netstat_test.go
Outdated
ifaceFSCacheFactory *interfaceCacheFactoryStatusStub | ||
|
||
// There are two types of caches used: virt-launcher/pod filesystem & virt-handler in-memory (volatile). | ||
// volatileCache flag marks is the setup should also populate the volatile cache when a network interface is added. |
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.
"marks that the setup"?
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.
Done
}), "the SR-IOV interface should be reported in the status, associated to the network") | ||
}) | ||
|
||
It("should not report SR-IOV interface when guest-agent is inactive and a regular interface exists", func() { |
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.
This sounds like a bug. The appearance of the sriov interface shouldn't be effected by another interface existence.
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, SR-IOV reporting is buggy.
On one hand, it is reported sometimes even if there is no "proof" of it being there. On the other hand, it is not reported if at least one non-SRIOV interface is there.
None of these are correct, both represent a bug: When the guest has no guest-agent, SR-IOV interfaces are not reported correctly (either not at all, or based on false data).
But al least now we express this clearly through the tests.
I opened #7050 to track this.
Ref it also in the commit message.
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.
Can you please add the ref to #7050 to the code as well? So the next developer that will see those tests won't think it is "by design" behaviour.
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 add it to the tests.
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.
Done
In the current implementation, the domain spec is directly affected by the VMI spec (in the network interfaces scope). The scenario were the domain is configured with interfaces that do not appear in the VMI spec is no supported (or expected). Therefore, the test that checks such a scenario (in an implicit manner) is removed. Signed-off-by: Edward Haas <edwardh@redhat.com>
Tests should represent real scenarios which are to be expected. Undefined scenario have their own place, but those need to be explicit and show what may happen in such cases as exceptions. The current netstat unit tests have been updated to reflect the following expected behavior: - When regular interfaces are added, this is the expected state/input: - VMI spec interfaces and networks should be in sync with 1:1 relation. - Domain spec is expect to reflect the VMI spec, i.e. having the same interfaces. - The filesystem cache should reflect the same interfaces as the VMI spec. - The volatile cache is optional, reflecting the same interface. - The Guest Agent data is optional. - When SR-IOV interfaces are added, this is the expected state/input: - VMI spec interfaces and networks should be in sync with 1:1 relation. - The Guest Agent data is optional. Notes: Caches do not exist and the domain spec interfaces do not include the SR-IOV interfaces. These are under the hostdevice section. Signed-off-by: Edward Haas <edwardh@redhat.com>
3920609
to
5e8f178
Compare
change: Answered review feedback. |
When an SR-IOV interface is present in the VMI spec and the guest is not running the guest-agent, the interface is appearing in the status section with just the network name and no other data. On the other hand, if another non SR-IOV interface exists, the result changes and the SR-IOV interface will not appear in the report at all. The behavior observed is tracked through: kubevirt#7050 Signed-off-by: Edward Haas <edwardh@redhat.com>
The unit tests included in this change represent undefined behavior. These scenarios are explicitly represented through dedicated tests to show the expected result if such a case occurs. Future changes may suggest to change this output and replace it with something that fits better (e.g. do not show the interface entry). Signed-off-by: Edward Haas <edwardh@redhat.com>
The volatile cache needs to be populated based on the non-volatile cache. Signed-off-by: Edward Haas <edwardh@redhat.com>
5e8f178
to
0c5b65d
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: AlonaKaplan The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
2 similar comments
/retest |
/retest |
/retest |
/retest |
What this PR does / why we need it:
The existing unit tests which cover the VMI interface status report is missing some realistic overall scenarios about the existing data available.
This change unifies and tries to place some rules on what is the expected data provided to the report processing.
The current netstat unit tests have been updated to reflect the
following expected behavior:
When regular interfaces are added, this is the expected state/input:
interfaces.
spec.
When SR-IOV interfaces are added, this is the expected state/input:
Notes: Caches do not exist and the domain spec interfaces do not
include the SR-IOV interfaces. These are under the hostdevice section.
Miscellaneous scenarios are also covered to reflect what happens when such cases occur. However, these are not expected to occur in a normal system operation. Future production changes may treat these scenarios explicitly to avoid undefined and nontrivial behavior.
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #
Special notes for your reviewer:
Depends on #6926Only the last 6 commits are to be reviewed as part of this PR.Release note: