Skip to content

test: cover an empty and a copied /opt/containerbase volume - #8396

Open
viceice wants to merge 1 commit into
viceice/feat/volume-initfrom
viceice/test/volume
Open

viceice wants to merge 1 commit into
viceice/feat/volume-initfrom
viceice/test/volume

Conversation

@viceice

@viceice viceice commented Nov 20, 2026

Copy link
Copy Markdown
Member

Changes

  • test/readonly installs git, jq, java, python and a pip tool at build time.
  • New volume cases with a read-only root:
    • empty volume: after the init jq is there, then node, git, java -version, python and the pip tool work on first use;
    • image update: a second list moves a tool to another version, the image's version wins, nothing is removed;
    • a cp -a copy of the image's /opt/containerbase: the init does nothing and nothing is downloaded.
  • Layer 4 of Make /opt/containerbase usable as a volume mount #7956.

Context

Please select one of the following:

  • This closes an existing Issue, Closes: #
  • This doesn't close an Issue, but I accept the risk that this PR may be closed if maintainers disagree with its opening or implementation

AI assistance disclosure

Did you use AI tools to create any part of this pull request?

Please select one option and, if yes, briefly describe how AI was used (e.g., code, tests, docs) and which tool(s) you used.

  • No — I did not use AI for this contribution.
  • Yes — minimal assistance (e.g., IDE autocomplete, small code completions, grammar fixes).
  • Yes — substantive assistance (AI-generated non‑trivial portions of code, tests, or documentation).
  • Yes — other (please describe):

Tests written by Claude Opus 5.5 (Claude Code).

Use of AI in replying to PR comments

Who answers review comments:

  • @viceice will read and reply directly. Name the account.
  • An agent will draft replies and @viceice will read them before they are posted. Name the account.
  • An agent will draft replies and reply autonomously. This is heavily discouraged, and we prefer that there are humans in the loop
  • Nobody has explicitly committed to replying.

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please select one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified tests

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@viceice
viceice added this pull request to stack #8398 November 20, 2026 10:00
@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Test empty, updated, and copied containerbase volumes

🧪 Tests 🕐 20-40 Minutes

Grey Divider

AI Description

• Add build-time tools to exercise volume initialization and first-use installation.
• Test empty and updated volumes under a read-only root filesystem.
• Verify copied volumes reuse installed tools without initialization or downloads.
Merge Risk 🟢 Low

Blast radius 🟢 Low 💥 0 capabilities

  • No production behavior changes identified.
Behavioral complexity 🟢 Low 🧩 Assessed behavior

  • No production behavior changes identified.
Potential damage 🟢 Low 🩹 Assessed behavior

  • No production behavior changes identified.
Assessed commit c4025a8
Diagram

graph TD
  A["Test image"] --> B["Mounted volume"] --> C{"Lists match?"}
  C -->|No| D["Initialize volume"] --> E["Tool commands"] --> G["Test assertions"]
  C -->|Yes| F["Skip initialization"] --> E
Loading
High-Level Assessment

Keep the Docker integration tests: unit tests could check list reconciliation but would not establish behavior with actual bind mounts, a read-only root, user permissions, and unavailable downloads.

Files changed (2) +104 / -0

Tests (2) +104 / -0
DockerfileSeed the read-only test image with additional tools +15/-0

Seed the read-only test image with additional tools

• Installs git, jq, Java, Python, and the pip tool hashin at build time so volume tests can check their restoration or reuse. Adds Renovate metadata for the versioned tools.

test/readonly/Dockerfile

test.shExercise empty, updated, and copied volume lifecycles +89/-0

Exercise empty, updated, and copied volume lifecycles

• Adds writable host-volume helpers and tests initialization and first-use tools with a read-only root. A changed tool list checks that the image-selected version wins without removing existing tools; a copied volume checks reuse without initialization or downloads.

test/readonly/test.sh

@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1)

Grey Divider


View low (1)
Informational
1. Copy folder can leak when the first cleanup fails 🐞 Bug ⭐ New
Description
The EXIT trap calls volume_rm "${volume}" before volume_rm "${copy}", and both helpers rely on
docker run and rmdir succeeding. Under set -euo pipefail (line 9 of the script), a failure in
the first call aborts the trap body, so the copy folder is never removed and stays in the host's
/tmp.
Code

test/readonly/test.sh[126]

+trap 'rm -f "${volume}.list"; volume_rm "${volume}"; volume_rm "${copy}"' EXIT
Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

Issue description
The EXIT trap in test/readonly/test.sh runs `volume_rm "${volume}"` and then `volume_rm "${copy}"` in one list. With `set -euo pipefail` a failure in the first call aborts the trap, so the copy folder is left on the host.

Fix Focus Areas
- test/readonly/test.sh[119-126]

Recommended Fix
Change the trap so that each removal runs regardless of the other, for example: `trap 'rm -f "${volume}.list"; volume_rm "${volume}" || true; volume_rm "${copy}" || true' EXIT`. Keep the `rm -f` for the list file as is.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Resolved findings
1. The image-update test misses removed tools ✓ Resolved Medium

Resolving commit: d9cf1f8

Resolution reason
The ls check was replaced by explicit directory assertions: the original flux 2.10.0 image version
directory must still exist, and the new 0.27.2 version directory must exist too.
Description
The image-update case asserts that the old Flux installation remains with `ls
/opt/containerbase/tools/flux`, which also succeeds when only the newly selected version is present.
After flux --version restores version 0.27.2, the test can pass even if the update deleted the
image’s original v2.10.0 version, contrary to the case’s stated “nothing is removed” behavior.

2. Volume tests never exercise runtime tool installation ✓ Resolved Medium

Resolving commit: d9cf1f8

Resolution reason
Added runtime-install coverage on the writable volume in the empty-volume scenario: `install-tool jq
1.7.1` runs inside volume_run, then asserts the version folder exists on the volume and versions/jq
points to 1.7.1. Also asserts flux version directories on the volume in the image-update scenario.
Description
The new volume scenarios in test/readonly/test.sh only read or restore tools that were installed
at build time: the init restores git and jq, and node, python, hashin and flux are reached through
their wrappers or the build-time list. No install-tool call runs against the writable
/opt/containerbase volume, so the read-only test does not show that a runtime install lands on the
volume. The existing EROFS check covers only the failing install on the read-only root, so the one
case where runtime install must work with a writable volume goes untested.

Grey Divider

Tip of the day
💡 Did you know, you can keep summaries lean with Findings visible per group, which tucks the rest behind a View link

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@viceice
viceice force-pushed the viceice/test/volume branch 8 times, most recently from 0cfa7fd to 52f7b71 Compare November 23, 2026 13:03
Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
@viceice
viceice force-pushed the viceice/test/volume branch from 52f7b71 to c4025a8 Compare November 23, 2026 15:01
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.

1 participant