Skip to content

Automated nbdkit data plugin supports base64 in format strings#6842

Merged
xiaodwan merged 1 commit intoautotest:masterfrom
ganeshhubale:auto-data-plugin-base64
Mar 30, 2026
Merged

Automated nbdkit data plugin supports base64 in format strings#6842
xiaodwan merged 1 commit intoautotest:masterfrom
ganeshhubale:auto-data-plugin-base64

Conversation

@ganeshhubale
Copy link
Copy Markdown
Contributor

@ganeshhubale ganeshhubale commented Mar 25, 2026

Test results:

# avocado run --vt-type v2v nbdkit.plugin.data
JOB ID     : aad4b5bd2d2ecbc8cd0c3af0b0d878e2ed6a4936
JOB LOG    : /var/log/avocado/job-results/job-2026-03-25T04.33-aad4b5b/job.log
 (1/2) type_specific.io-github-autotest-libvirt.nbdkit.plugin.data.positive_test: STARTED
 (1/2) type_specific.io-github-autotest-libvirt.nbdkit.plugin.data.positive_test: PASS (1.47 s)
 (2/2) type_specific.io-github-autotest-libvirt.nbdkit.plugin.data.negative_test: STARTED
 (2/2) type_specific.io-github-autotest-libvirt.nbdkit.plugin.data.negative_test: PASS (1.45 s)
RESULTS    : PASS 2 | ERROR 0 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB HTML   : /var/log/avocado/job-results/job-2026-03-25T04.33-aad4b5b/results.html
JOB TIME   : 7.92 s

Summary by CodeRabbit

  • Tests
    • Added test coverage for nbdkit data-plugin base64 handling in format strings. Includes a positive case verifying decoding of a base64 payload and a negative case confirming clear error reporting for malformed base64. Tests are gated by nbdkit version, scoped to specific source/destination variants, and integrated into the existing test runner.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 25, 2026

Walkthrough

Adds a new data test variant in v2v/tests/cfg/nbdkit/nbdkit.cfg scoped to only source_none..dest_none and gated by nbdkit "[nbdkit-1.46,)", declaring the checkpoint test_data_plugin_supports_base64_in_format_string with positive and negative variants. Implements a new in-run Python test in v2v/tests/src/nbdkit/nbdkit.py that, based on test_state, either verifies a base64-encoded payload is decoded and returned by nbdkit/nbdcopy or checks that a malformed payload yields the Base64 decoding error. message; the checkpoint dispatcher was extended to call this test.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding automated test support for base64 encoding in nbdkit data plugin format strings, which is the primary focus of both the configuration and code changes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@ganeshhubale ganeshhubale force-pushed the auto-data-plugin-base64 branch from 350eab7 to 26e2f05 Compare March 25, 2026 08:38
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@v2v/tests/src/nbdkit/nbdkit.py`:
- Around line 815-845: The test currently allows an invalid test_state and
doesn't assert the command exit status; add an explicit else branch that calls
test.fail for unknown test_state, and in the "positive" branch assert the
process.run exit code indicates success (e.g. result.exit_status == 0) before
checking that original_text is in result.stdout; in the "negative" branch assert
the command failed (e.g. result.exit_status != 0) before inspecting
result.stderr_text for err_msg (use params_get to get expected_err_msg) and call
test.fail with clear messages if expectations are not met; reference
variables/functions: test_state, cmd_str, process.run, result
(exit_status/stdout/stderr_text), original_text, invalid_b64, err_msg,
params_get, and test.fail.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bc05cb2-c886-42d9-b377-026bdb414ff6

📥 Commits

Reviewing files that changed from the base of the PR and between 9562eb2 and 350eab7.

📒 Files selected for processing (2)
  • v2v/tests/cfg/nbdkit/nbdkit.cfg
  • v2v/tests/src/nbdkit/nbdkit.py

Comment thread v2v/tests/src/nbdkit/nbdkit.py
@ganeshhubale
Copy link
Copy Markdown
Contributor Author

@xiaodwan Please have a look.

Signed-off-by: Ganesh Hubale <ghubale@redhat.com>
@ganeshhubale ganeshhubale force-pushed the auto-data-plugin-base64 branch from 26e2f05 to f2ac25f Compare March 30, 2026 06:54
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
v2v/tests/src/nbdkit/nbdkit.py (1)

865-891: ⚠️ Potential issue | 🟠 Major

Add exit status checks and handle invalid test_state.

The test function is missing critical assertions that were flagged in a previous review:

  1. Positive test (line 875): Should verify result.exit_status == 0 before checking stdout content, to ensure the command succeeded as expected.
  2. Negative test (line 885): Should verify result.exit_status != 0 before checking stderr content, to ensure the command failed as expected.
  3. Invalid test_state (after line 890): Should add an else branch to fail explicitly if test_state is neither "positive" nor "negative".
🛡️ Proposed fix with exit status checks and else branch
     def test_data_plugin_supports_base64_in_format_string():
         import base64
         test_state = params_get(params, "test_state")
         if test_state == "positive":
             # Prepare the data
             original_text = b"nbdkit-test123"
             # Encode bytes to a base64 string
             b64_input = base64.b64encode(original_text).decode()
             cmd_str = f"nbdkit -U - data \'base64:{b64_input}\' --run 'nbdcopy $uri -'"
             # Execute command
             result = process.run(cmd_str, shell=True, ignore_status=True)
+            if result.exit_status != 0:
+                test.fail(f"nbdkit command failed unexpectedly: {result.stderr_text}")
             # Result.stdout contains the raw binary output from nbdcopy
             cmd_output = result.stdout
             if original_text not in cmd_output:
                 test.fail(f"Base64 decoding failed. Expected {original_text!r}, got {cmd_output!r}")
         elif test_state == "negative":
             # Negative scenario - Check with invalid value
             invalid_b64 = "base64:SGVsbG8@@@"
             cmd_str = f"nbdkit -U - data \'{invalid_b64}\' --run 'nbdcopy $uri -'"
             # Execute command
             result = process.run(cmd_str, shell=True, ignore_status=True)
+            if result.exit_status == 0:
+                test.fail("Invalid base64 input unexpectedly succeeded.")
             # Verify the error message
             cmd_output = result.stderr_text
             err_msg = params_get(params, "expected_err_msg")
             if err_msg not in cmd_output:
                 test.fail(f"Error message - \'{err_msg}\' not appeared.")
+        else:
+            test.error(f"Unsupported test_state: {test_state!r}")
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@v2v/tests/src/nbdkit/nbdkit.py` around lines 865 - 891, The
test_data_plugin_supports_base64_in_format_string function lacks exit-status
assertions and an invalid-state branch; update the positive branch to assert
result.exit_status == 0 before inspecting result.stdout, update the negative
branch to assert result.exit_status != 0 before inspecting result.stderr_text,
and add an else branch that calls test.fail(...) if test_state is neither
"positive" nor "negative" so the test fails loudly for unknown states.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@v2v/tests/src/nbdkit/nbdkit.py`:
- Around line 865-891: The test_data_plugin_supports_base64_in_format_string
function lacks exit-status assertions and an invalid-state branch; update the
positive branch to assert result.exit_status == 0 before inspecting
result.stdout, update the negative branch to assert result.exit_status != 0
before inspecting result.stderr_text, and add an else branch that calls
test.fail(...) if test_state is neither "positive" nor "negative" so the test
fails loudly for unknown states.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 194e5b49-5e07-4e00-8eeb-7699296b0d04

📥 Commits

Reviewing files that changed from the base of the PR and between 26e2f05 and f2ac25f.

📒 Files selected for processing (2)
  • v2v/tests/cfg/nbdkit/nbdkit.cfg
  • v2v/tests/src/nbdkit/nbdkit.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • v2v/tests/cfg/nbdkit/nbdkit.cfg

@xiaodwan xiaodwan merged commit 0a22a84 into autotest:master Mar 30, 2026
6 checks passed
@ganeshhubale ganeshhubale deleted the auto-data-plugin-base64 branch March 30, 2026 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants