Skip to content

cloud-init: T9172: add userdata command regression tests - #116

Open
jeleel-muibi wants to merge 1 commit into
vyos:rollingfrom
jeleel-muibi:t9172-cloud-init-userdata-tests
Open

cloud-init: T9172: add userdata command regression tests#116
jeleel-muibi wants to merge 1 commit into
vyos:rollingfrom
jeleel-muibi:t9172-cloud-init-userdata-tests

Conversation

@jeleel-muibi

Copy link
Copy Markdown

Proposed Commit Message

cloud-init: T9172: add userdata command regression tests

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.

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:

python -m pytest -q tests/unittests/config/test_cc_vyos_userdata.py
9 passed

python -m black --check tests/unittests/config/test_cc_vyos_userdata.py
1 file would be left unchanged

python -m isort --check-only --diff tests/unittests/config/test_cc_vyos_userdata.py
python -m flake8 tests/unittests/config/test_cc_vyos_userdata.py
python -m mypy tests/unittests/config/test_cc_vyos_userdata.py
python -m pylint tests/unittests/config/test_cc_vyos_userdata.py
All passed; pylint rated the file 10.00/10.

python -m pytest -q tests/unittests \
  -k 'not test_get_script_folder_per_boot and not test_get_script_folder_per_instance and not test_get_script_folder_per_once'
3228 passed, 10 skipped, 3 deselected

The three host-dependent tests were deselected because they read
/etc/cloud/cloud.cfg.d/99-installer.cfg, which is not readable in the local
environment. An unfiltered run has only those three PermissionError
failures; none involves this test module.

Checklist:

  • My code follows the process laid out in the documentation
  • I have updated or added any unit tests accordingly
  • I have updated or added any documentation accordingly (not applicable: test-only change)

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.
@coderabbitai

coderabbitai Bot commented Aug 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 66ee248d-5345-4f47-b155-6fbc6333753e

📥 Commits

Reviewing files that changed from the base of the PR and between 6e3104c and dab383a.

📒 Files selected for processing (1)
  • tests/unittests/config/test_cc_vyos_userdata.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • ansible/ansible (manual)
📜 Recent review details
⏰ Context from checks skipped due to timeout. (2)
  • GitHub Check: Mergify Merge Protections
  • GitHub Check: Summary
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Use Black code formatter with 79-character line length for Python code
Use isort with Black profile for import sorting in Python code

Files:

  • tests/unittests/config/test_cc_vyos_userdata.py
🔍 Remote MCP vyos.dev

Relevant context

  • Exact matching task: T9172 — “cloud-init: add regression coverage for vyos_config_commands”, status In progress, priority Low. Its acceptance criteria match this PR: unit tests only, mocked ConfigTree/template discovery, set/delete behavior, multi/tag handling, and malformed-command skipping.
  • The task author confirmed they were actively working on the implementation and would submit a PR.
  • Historical tag-node bug T4895 reported that repeated tag-node values were overwritten unless replace=False was used; this validates the nested tag-node preservation test.
  • Historical multi-node bug T3735 involved template markers with trailing content/whitespace not matching a strict ^multi:$ pattern; this supports the trailing-metadata test.
  • Separate resolved task T8185 documents a default-config path mismatch: cloud-init used /usr/share/vyos/config.boot.default, while flavor builds placed files under /opt/vyatta/etc/config.boot.default. Template/path fixtures should avoid assuming these locations are interchangeable.
🔇 Additional comments (1)
tests/unittests/config/test_cc_vyos_userdata.py (1)

3-186: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Added comprehensive coverage for VyOS userdata handling.
    • Verified template discovery and multi-node detection.
    • Added tests for parsing valid and malformed commands.
    • Covered setting, appending, preserving nested values, and deleting configuration nodes.
    • Confirmed valid commands are processed while malformed input is skipped.

Walkthrough

Changes

VyOS userdata tests

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 ⚠️ Warning 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 addition of userdata regression tests.
Description check ✅ Passed The description accurately explains the VyOS regression tests, test scope, isolation approach, 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
✨ 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the rolling label Aug 8, 2026
@jeleel-muibi
jeleel-muibi marked this pull request as ready for review August 8, 2026 11:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

1 participant