Skip to content

Support comma-separated mount options in TC_TMPFS - #12193

Open
ErickGCA wants to merge 1 commit into
testcontainers:mainfrom
ErickGCA:fix/jdbc-tmpfs-mount-options
Open

ErickGCA wants to merge 1 commit into
testcontainers:mainfrom
ErickGCA:fix/jdbc-tmpfs-mount-options

Conversation

@ErickGCA

@ErickGCA ErickGCA commented Dec 1, 2026 •

Copy link
Copy Markdown

TC_TMPFS splits its value on every comma, but docker tmpfs mount options are comma separated too, so something like TC_TMPFS=/var/lib/postgresql/data:rw,size=256m blows up in ConnectionUrl.parseTmpfsOptions with ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1, because size=256m becomes its own entry with no :. in practice there's no way to limit the tmpfs size from the jdbc url

the fix only splits on a comma when a new path: entry comes right after it, so /a:rw,size=64m,/b:ro gives /a -> rw,size=64m and /b -> ro, and the documented key:value,key1:value1 format keeps working

added two cases to ConnectionUrlTest and one to DatabaseDriverTmpfsTest that starts postgres and checks /proc/mounts has size=65536k, the new tests fail without the change

Summary by CodeRabbit

  • Bug Fixes
    • Fixed parsing of temporary filesystem settings so commas within mount options, such as size limits, stay associated with the correct mount.
    • Multiple mount paths in a single setting are now handled separately.
    • PostgreSQL connections now correctly apply comma-separated temporary filesystem options, including normalized size values.

Docker tmpfs mount options are comma-separated (e.g. rw,size=64m), but the
TC_TMPFS value was also split on every comma, so passing more than one
option for a path failed with ArrayIndexOutOfBoundsException. Only split
before a new path:options entry.
@ErickGCA
ErickGCA requested a review from a team as a code owner December 1, 2026 00:53
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The TC_TMPFS parser now preserves commas within mount options and separates entries at new path declarations. Unit tests check parsing, and a PostgreSQL test checks the normalized tmpfs size in the container.

Changes: TC_TMPFS parsing

Layer / File(s) Summary
Parse entries and verify mount options
modules/jdbc/src/main/java/org/testcontainers/jdbc/ConnectionUrl.java, modules/jdbc/src/test/java/org/testcontainers/jdbc/ConnectionUrlTest.java, modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java
The parser splits entries at new path: declarations and splits each entry at its first colon. Unit tests check options and multiple paths. The PostgreSQL test checks that size=64m appears as size=65536k in the container mount output.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested reviewers: eddumelendez

Merge Risk: Minimal · up to c8740

This change lets TC_TMPFS accept comma-separated mount options such as size=64m without throwing an exception. The supplied evidence shows no concrete merge-blocking risk.

Pre-merge checks: Passed 7

Check name Status Explanation
Title check Passed The title names the main change: TC_TMPFS now accepts comma-separated mount options. The raw summary says parseTmpfsOptions now splits only at commas that precede a new path entry, so commas inside an…
Description check Passed The description covers the problem, the fix, and the tests. It describes the failure with TC_TMPFS=/var/lib/postgresql/data:rw,size=256m and the ArrayIndexOutOfBoundsException. It explains the new spl…
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.
New Module Registration Passed The check applies only when the PR adds a new directory under modules/. The changed-file inventory (git diff --name-status between the review base and head) lists three modified files and no added fil…
Public Api Compatibility Passed The check fails only when the PR removes, renames, or changes the signature, return type, or visibility of a public or protected class, method, constructor, or field under src/main/java. The PR change…
Tests For Behaviour Changes Passed The PR changes behaviour in production code under modules/jdbc/src/main/java/org/testcontainers/jdbc/ConnectionUrl.java. The TC_TMPFS parsing now splits only at a comma that precedes a new path:…
Full details: Title check

Explanation

The title names the main change: TC_TMPFS now accepts comma-separated mount options. The raw summary says parseTmpfsOptions now splits only at commas that precede a new path entry, so commas inside an entry's options are kept. The title is specific and matches the changeset.

Full details: Description check

Explanation

The description covers the problem, the fix, and the tests. It describes the failure with TC_TMPFS=/var/lib/postgresql/data:rw,size=256m and the ArrayIndexOutOfBoundsException. It explains the new split rule with an example and says the documented key:value,key1:value1 format still works. It lists the added ConnectionUrlTest and DatabaseDriverTmpfsTest cases and says the new tests fail without the change. The template is a contributor guide with no required headings beyond describing the changes, and the description meets that. It does not reference an issue number, but the template only asks for one if the PR relates to an existing issue.

Full details: New Module Registration

Explanation

The check applies only when the PR adds a new directory under modules/. The changed-file inventory (git diff --name-status between the review base and head) lists three modified files and no added files: - M modules/jdbc/src/main/java/org/testcontainers/jdbc/ConnectionUrl.java - M modules/jdbc/src/test/java/org/testcontainers/jdbc/ConnectionUrlTest.java - M modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java These edits touch existing modules (jdbc, postgresql) and add no new module directory. The check's applicability condition is not met, so it passes. The PR's TC_TMPFS parsing change does not trigger the module-registration requirements (issue template dropdowns, dependabot, labeler, docs page, mkdocs nav).

Full details: Public Api Compatibility

Explanation

The check fails only when the PR removes, renames, or changes the signature, return type, or visibility of a public or protected class, method, constructor, or field under src/main/java. The PR changes three files: ConnectionUrl.java (main), ConnectionUrlTest.java, and DatabaseDriverTmpfsTest.java (tests). The only main-source change is in the body of parseTmpfsOptions (ConnectionUrl.java, around lines 153-162). The diff adds a comment, changes the split regex to ,(?=[^,:]+:), and uses split(":", 2). The method is declared private Map<String, String> parseTmpfsOptions(Map<String, String> containerParameters) at line 149, so it is not public or protected. Its signature is unchanged. The public accessor getTmpfsOptions() (line 199) and the field tmpfsOptions are untouched. No public or protected API element was removed, renamed, re-typed, or re-scoped. The check's additive-change allowance applies, so the check passes.

Full details: Tests For Behaviour Changes

Explanation

The PR changes behaviour in production code under modules/jdbc/src/main/java/org/testcontainers/jdbc/ConnectionUrl.java. The TC_TMPFS parsing now splits only at a comma that precedes a new path: entry, and it splits each entry at its first colon. This is a bug fix, so the check applies. The PR also adds tests that exercise the change: - modules/jdbc/src/test/java/org/testcontainers/jdbc/ConnectionUrlTest.java adds testTmpfsOptionWithMultipleMountOptions (/var/lib/postgresql/data:rw,size=256m,mode=1777 keeps all options under one path) and testTmpfsOptionWithMultiplePathsAndMountOptions (/a:rw,size=64m,/b:ro gives /a → rw,size=64m and /b → ro). - modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java adds testDatabaseHasTmpFsWithMountOptionsViaConnectionString, which starts PostgreSQL with TC_TMPFS=/testtmpfs:rw,size=64m and checks /proc/mounts for size=65536k. The path check uses the module-scoped locations (modules/jdbc/src/main/java and src/test). The changed production behaviour has direct test coverage in the same PR, so the check does not fail.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • 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

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between a736c02 and c8740ff.

Files selected for processing: 3

  • modules/jdbc/src/main/java/org/testcontainers/jdbc/ConnectionUrl.java
  • modules/jdbc/src/test/java/org/testcontainers/jdbc/ConnectionUrlTest.java
  • modules/postgresql/src/test/java/org/testcontainers/jdbc/DatabaseDriverTmpfsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant