cloud-init: T9172: add userdata command regression tests - #116
cloud-init: T9172: add userdata command regression tests#116jeleel-muibi wants to merge 2 commits into
Conversation
Add focused regression coverage for the VyOS-specific vyos_config_commands handler. Exercise template discovery, supported set/delete parsing, ordinary, multi, and nested tag-node updates, both delete paths, and malformed-command skipping. Use temporary template trees and a mocked ConfigTree interface so the tests run without a VyOS image or installed template hierarchy.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🔗 Linked repositories identifiedCodeRabbit considers these linked repositories for cross-repo context during reviews:
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout. (2)
|
| Layer / File(s) | Summary |
|---|---|
Discovery and command parsing tests/unittests/config/test_cc_vyos_userdata.py |
Tests template path discovery, multi-node detection, parsing of set and delete commands, and rejection of malformed input. |
Command application and deletion tests/unittests/config/test_cc_vyos_userdata.py |
Tests ordinary-node replacement, multi-node value appending, nested tag-node preservation, and deletion by value or path. |
Command routing tests/unittests/config/test_cc_vyos_userdata.py |
Tests application of valid commands and skipping of malformed commands. |
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly identifies the cloud-init component, task, and primary change: adding VyOS userdata command regression tests. |
| Description check | ✅ Passed | The description directly explains the VyOS regression tests, covered cases, test-only scope, and validation results. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
- Create stacked PR
- Commit on current branch
✨ Simplify code
- Create PR with simplified code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
There was a problem hiding this comment.
Pull request overview
Adds a new unit test module to provide regression coverage for the VyOS-specific cloudinit.config.cc_vyos_userdata handler logic (template-node discovery, command parsing, and command application) without requiring a VyOS runtime environment.
Changes:
- Introduces
tests/unittests/config/test_cc_vyos_userdata.pywith focused unit tests for tag-node and multi-node template discovery. - Adds coverage for
string_to_command,apply_command_set,apply_command_delete, andapply_commands, including malformed-command skipping.
Suppressed comments (1)
tests/unittests/config/test_cc_vyos_userdata.py:186
test_apply_commands_routes_valid_commands_and_skips_malformedcurrently only asserts the delete-with-value path (delete_value). Sinceapply_commandsalso needs to support delete-by-path (no value), it would be good to include adelete …command without a value here and assert thatconfig.delete(...)is invoked.
cc_vyos_userdata.apply_commands(
config,
[
"set system host-name 'edge-a'",
"show version",
"delete system name-server '192.0.2.53'",
],
)
config.set.assert_called_once_with(
["system", "host-name"], "edge-a", replace=True
)
config.delete_value.assert_called_once_with(
["system", "name-server"], "192.0.2.53"
)
config.delete.assert_not_called()
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fb81132 to
b5e7b60
Compare
Proposed Commit Message
Additional Context
Related task: T9172
This is a test-only change. It does not alter cloud-init runtime behavior,
dependencies, or configuration. The cases include the trailing multi-node
metadata behavior fixed in T3735 and the nested
tag-node preservation behavior fixed in T4895.
Test Steps
Validated with Python 3.10.20 and the repository-pinned tool versions:
The three host-dependent tests were deselected because they read
/etc/cloud/cloud.cfg.d/99-installer.cfg, which is not readable in the localenvironment. An unfiltered run has only those three
PermissionErrorfailures; none involves this test module.
Checklist: