test(opennebula): validate gen_conf() output against network-config-v2 schema - #6855
Conversation
977fe0c to
eb4adea
Compare
|
Unit tests fails precisely because this new test shows a bug that #6856 fixes |
eb4adea to
9c03944
Compare
9c03944 to
35b7dc2
Compare
There was a problem hiding this comment.
Pull request overview
Adds schema validation to OpenNebula network unit tests to ensure OpenNebulaNetwork.gen_conf() continues to emit a Netplan v2 config that conforms to cloud-init’s schema-network-config-v2.json.
Changes:
- Import
jsonschemaand cloud-init schema helpers in the OpenNebula unit tests. - Add an
autousepytest fixture onTestOpenNebulaNetworkthat monkeypatchesgen_conf()to validate its return value against the NETWORK_CONFIG_V2 schema on every call.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…2 schema Add an autouse fixture to TestOpenNebulaNetwork that wraps gen_conf() and runs jsonschema validation against schema-network-config-v2.json on every call, so all existing tests implicitly assert schema conformance.
35b7dc2 to
439c113
Compare
blackboxsw
left a comment
There was a problem hiding this comment.
This is a good utility fixture. Thank you for this @mcanevet. I could see something like this being adapted to be useful for any DataSource*.network_config unittest test as well.
| system_nics = ("eth0", "ens3") | ||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def _validate_gen_conf_schema(self, monkeypatch): |
There was a problem hiding this comment.
I appreciate this wrapper which validates each gen_conf return value called. This definitely can help raise awareness about invalid net config responses returned by changes OpenNebula gen_conf in subsequent PRs.
Proposed Commit Message
```
test(opennebula): validate gen_conf() output against network-config-v2 schema
Add an autouse fixture to TestOpenNebulaNetwork that wraps gen_conf() and
runs jsonschema validation against schema-network-config-v2.json on every
call, so all existing tests implicitly assert schema conformance without
requiring dedicated per-field type checks.
```
Additional Context
OpenNebula's
gen_conf()directly produces a Netplan v2 dict. Previously,no test validated the output against the network-config-v2 JSON schema, so
type errors (e.g. a field being a string when the schema requires an integer)
could go undetected. The autouse fixture catches any such regression across
all existing and future tests in the class for free.
Test Steps
Merge type