Add traffic rules tests - #394
Conversation
136ec08 to
fbad09b
Compare
38e4a18 to
b07bf94
Compare
|
To properly integrate this PR, the following PR should be merged first: |
e73de29 to
f6f16eb
Compare
a18123b to
ec9468f
Compare
2d17182 to
15ff2e8
Compare
|
rebased to get the |
15ff2e8 to
ea14d95
Compare
|
last push : support running on hosts using VLANs. need xcp-ng-xapi-plugins#68 |
ea14d95 to
adbb6db
Compare
|
Last push:
|
adbb6db to
dddd48f
Compare
|
last push:
|
|
Last push:
Marking ready for review as all components are published with 8.3-20260818 |
glehmann
left a comment
There was a problem hiding this comment.
Some minor comments: I clearly don't have the network knowledge to evaluate the tests.
| # Special requirements for some tests: | ||
| # - TestVLAN needs at least 1 free NICs (see HOST_FREE_NICS in data.py) | ||
| # - TestMigrate needs second XCP-ng host in the same pool | ||
| # - TestTunnel will create encrypted tunnel (and only one could be created at a time) |
There was a problem hiding this comment.
So it requires no encrypted tunnel already configured?
There was a problem hiding this comment.
no. the test will setup a tunnel itself. it is created by the tunnel fixture.
| # - TestMigrate needs second XCP-ng host in the same pool | ||
| # - TestTunnel will create encrypted tunnel (and only one could be created at a time) | ||
|
|
||
| CACHE_ovs_vsctl_bridge_to_parent: dict[str, str] = {} |
There was a problem hiding this comment.
Consider renaming this to cache_ovs_vsctl_bridge_to_parent (lowercase snake_case).
Since this dictionary represents mutable state rather than an immutable module-level constant, PEP 8 recommends standard lowercase naming.
Also, don't we risk leaking data between tests with a module-level cache?
There was a problem hiding this comment.
from generic point of view, I agree that module-level cache is not optimal.
I changed it a bit to have a key linked to the host and to the current test. this way, it should still cache data (and avoid too much ssh to the host) and don't be shared between tests.
| finally: | ||
| # delete networkRule | ||
| logging.info("sdnController.deleteNetworkRule") | ||
| xo_cli('sdnController.deleteNetworkRule', { |
There was a problem hiding this comment.
it can't go in defer() because it is also part of the test and things are tested after running it.
so if I put it in defer(), it means we can't test that the delete was properly done.
There was a problem hiding this comment.
It can still go in a defer, but it needs to be guarded, to make sure it's not already deleted:
xo_cli('sdnController.addNetworkRule', {
'networkId': networkId,
'ipRange': '10.0.0.1',
'direction': 'to',
'protocol': 'icmp',
'allow': 'false',
})
fn delete_rule():
xo_cli('sdnController.deleteNetworkRule', {
'networkId': networkId,
'ipRange': '10.0.0.1',
'direction': 'to',
'protocol': 'icmp',
})
return True
deleted = False
defer(lambda: delete_rule() if not deleted else None)
# do some stuff
deleted = delete_rule()
assert …This is more convoluted than the try/finally, but in case of problem, it prevents the rule from being deleted before reaching the debugger.
Just pick the version you prefer :)
|
Last push:
|
|
Last push:
|
|
Last push:
|
stormi
left a comment
There was a problem hiding this comment.
I'm trying to review the PR, which deserves reaching a point where we can merge it and have it running in CI, but right now most commits are lacking an explanation about the rationale behind them (see https://docs.xcp-ng.org/project/development-process/commit-message-conventions/), and there are important implementation choices made without any explanation that I can find, such as delaying the moment we start checking for rules to apply. Fixed delays are something we avoid, so they must be justified explicitly, and if there's a way to check differently without a delay, this must be preferred.
|
Last push:
|
|
last push:
|
|
Last push:
|
| "A pool with at least 1 host (if more, with same network configuration).", | ||
| "At least 2 free NICs on every host.", | ||
| "A small VM that can be imported on the SRs.", |
There was a problem hiding this comment.
It is important to mention here that xo_cli is necessary. This PR changes a situation where only one job used to require XO, and now we have another job that requires XO (unless XO was already required by this job previously but not mentioned at the time in the requirements).
Let's add it here to the list of requirements, and I'll make sure it's clear to the team managing CI that this job has such as requirement.
I don't expect any issue, but they need to know.
There was a problem hiding this comment.
I sent the message. Only remains the need to update the list of requirements.
There was a problem hiding this comment.
I added XO mention to the jobs entry (in the last commit I pushed).
in order to have a way to parse rpm version, add rpm-version dependency. it will be used by traffic rules tests for checking xcp-ng-xapi-plugins package version. Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
For several tests related to network (mostly traffic rules for now), we need more classes and functions to manipulate xapi objects. - create and manipulate Tunnel - create and manipulate VLAN - additional properties on Network, PIF, VIF - additional function on Host to get service status Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
tests: - simple VIF rule (add/delete with simple vm.start/destroy cycle) - simple Network rule (add/delete with simple vm.start/destroy cycle) - migrate with simple VIF rule - migrate with Network rule rule - VLAN with simple VIF rule - VLAN with simple Network rule - Tunnel with simple VIF rule - Tunnel with simple Network rule on each tests: - a traffic rule to block some traffic is added and after that removed - VM lifecycle is tested with the rule applied - each step is verified (is the traffic blocked as expected ?) - the initial state is verified (to ensure no currently active traffic rule will pertubate the test) - the final state is verified (to ensure no rules are left) the traffic check is done using low-level debug cli tool from OVS. It permits to test the openflow rule application without sending any packet. a check is done for each port plugged on the virtual switch. the two first "simple" rules are the more complexes: - interleaving two rules addition/removal is tested - VM is started, stopped, restarted (rules are managed dynamically and on the fly by XO) fixtures: - add Tunnel fixture: returns a configured Tunnel network (Private Network in XO) - add VLAN fixture: returns a configured VLAN network Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
|
Last push:
|
| from typing import Callable | ||
|
|
||
| # Requirements: | ||
| # xo-cli (on the host running the test) is expected to be usable |
There was a problem hiding this comment.
As discussed together, we don't want to add this requirement to the main job, so we'll have to move all traffic rules tests, even the simple ones, to the network-advanced job.
We discussed a possible implementation for that: make xo_cli a fixture and create a marker named the same, automatically set when the fixture is used. Then use the marker to exclude or include tests in jobs.py.
There was a problem hiding this comment.
I used the existing hosts_with_xo fixture for automatically add a hosts_with_xo mark and exclude it from 'main' jobs.
|
Last push:
|
|
Tip for reviewers: by running |
With traffic rules tests, we are adding more tests depending on XO (traffic rules are managed by XO). In order to avoid this strong dependency in 'main' jobs, automatically mark tests using 'hosts_with_xo' fixture with 'hosts_with_xo' mark. It permits to avoid running them in 'main' jobs, and run them in 'advanced-network' jobs instead of (for networks tests). Additionally, restrict the use of xo_cli() function to tests that are using 'hosts_with_xo' fixture. It is done by modifying a global in lib.xo module, and checking it at xo_cli() beginning. Based on idea from @stormi Signed-off-by: Sebastien Rodot <sebastien.rodot@vates.tech>
|
Last push:
|
Uh oh!
There was an error while loading. Please reload this page.