Add Mosquitto module#1390
Conversation
…ests, and documentation updates.
…up log matching, upgrade to Mosquitto 2 base image, and fix file permissions during setup.
…o a dedicated file and updated related documentation references.
✅ Deploy Preview for testcontainers-node ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
cristianrgreco
left a comment
There was a problem hiding this comment.
Thanks for the module — nice and clean, closely following the HiveMQ structure. A few notes inline. Two points that don't anchor well to a single line:
-
package-lock.json: the diff also removeslibcarrays from several unrelated packages (lightningcss and one MPL-2.0 dep). That looks like npm-version drift rather than part of this module. Could you regenerate the lockfile with the project's npm version so the only change here is the new@testcontainers/mosquittoentry? -
Prior art: for what it's worth, Mosquitto modules already exist in .NET (
Testcontainers.Mosquitto), Python (testcontainers[mqtt]) and Rust (testcontainers-rs-modules-community), so this is a welcome addition. The .NET module is the closest reference if we ever want cross-language API consistency.
…pdate documentation references accordingly.
…guration methods.
…tainer startup logic.
…ad of log message.
cristianrgreco
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround — this addresses almost all of the earlier feedback:
- ✅ Image pinned to
eclipse-mosquitto:2.0.22 - ✅ Nav entry now alphabetically placed (after MongoDB)
- ✅ Wait strategy switched to
Wait.forListeningPorts()— more robust than the log regex - ✅
withUsername/withPasswordreject empty values - ✅ Partial auth now fails loudly via the XOR check (
Both username and password must be set together.) - ✅ Tests merged into a single
mosquitto-container.test.tswith twoit()blocks, docs updated
The XOR guard and the forListeningPorts() switch both look correct. One item from the previous round is still outstanding:
package-lock.json — the diff still strips libc arrays from several unrelated packages (lightningcss and one MPL-2.0 dep); the hunk is unchanged from before. This is npm-version drift rather than part of the module. Could you regenerate the lockfile with the project's npm version (or revert those specific hunks) so the only change is the new @testcontainers/mosquitto entry? Once that's cleaned up I think this is good to go.
4b36c3d to
2d65607
Compare
Hey i'm quite not used to handle this kind of package-lock, i've tried to generate it but it was always removing them, is it because i'm working on a Mac or something would like know if you can help me learn more on that thing 😅 Updated it kind "manually" to have them back but i'm not a huge fan of this move... |
|
@ChxGuillaume Which version of Node/NPM are you using? |
npm --version && node -v Just installed the last Node version with NVM to try and generate it |
|
@ChxGuillaume Two things to get CI green: 1. Lint failure ( It's just a Prettier formatting nit — an extra space: CI runs ESLint without npm run lintThat auto-fixes it (it's 2. The Now that you're on Node 24.18 / npm 11.16 you're on the right toolchain — that version doesn't prune the cross-platform optional deps, so no need to edit anything by hand. The key is to start from a clean lockfile rather than regenerating on top of the manually-edited one: git checkout main -- package-lock.json # discard the hand-edited version
npm install --package-lock-only # npm 11.16 re-resolves cleanly
git diff package-lock.json # should show ONLY the @testcontainers/mosquitto entryIf that diff shows just the new For background on why it was happening before: the disappearing packages are platform-specific native binaries (Linux/Windows/musl), and older npm versions rewrite the lockfile from what's installed locally, dropping everything that doesn't match your Mac. npm 11.x fixes that, so you're good now. 👍 |
…ckage-lock.json`.
|
Thanks for your contribution and for the fast feedback @ChxGuillaume |
Add Mosquitto module
This PR introduces a new
@testcontainers/mosquittomodule for the Eclipse Mosquitto MQTT broker, following the same structure as the existing HiveMQ module.What's included
MosquittoContainer— starts aneclipse-mosquitto:2container with a custom config injected at startup, since Mosquitto 2.x disallows anonymous connections by defaultallow_anonymous true) out of the boxwithUsername()/withPassword()— creates the password file usingmosquitto_passwd -bbefore launching the broker, with achownto fix ownership since Mosquitto drops privileges to themosquittouserStartedMosquittoContainer.getPort()andgetConnectionString()— the latter includes credentials in the URL when auth is configuredmosquitto-container.test.tsandmosquitto-container-auth.test.ts) kept separate to avoid a codeinclude block-name collision betweenmosquittoConnectandmosquittoConnectWithCredentialsdocs/modules/mosquitto.mdwith codeinclude examples for both usage patterns, added to the mkdocs navigation