The module's code moved out of its container and took mosquitto_ctrl from a host package. A machine whose package index is stale cannot install it (hq issue 205), so the tools failed. The broker's own image carries the tool at the broker's version: the tools exec into the running broker, and the bootstrap seeds from a throwaway container of the same image.
20 lines
1.0 KiB
TypeScript
20 lines
1.0 KiB
TypeScript
// Run after `npm run build`.
|
|
// mosquitto_ctrl runs inside the broker's own container when the manifest names it, so a machine
|
|
// needs no mosquitto package (whose index may be too stale to install from) and the tool always
|
|
// matches the broker's version.
|
|
import assert from "node:assert/strict";
|
|
import { test } from "node:test";
|
|
import { MosquittoClient } from "../dist/client.js"; // compiled: client.ts uses parameter properties, which type stripping cannot run
|
|
|
|
const env = { MESH_PROVISION_MQTT: "127.0.0.1:21883", MESH_MQTT_PASSWORD: "pw" };
|
|
|
|
test("named, the broker's container runs mosquitto_ctrl", () => {
|
|
const c = MosquittoClient.fromEnv({ ...env, MESH_MQTT_CTRL_CONTAINER: "mosquitto" });
|
|
assert.deepEqual(c.ctrl(["dynsec", "listClients"]), ["docker", ["exec", "mosquitto", "mosquitto_ctrl", "dynsec", "listClients"]]);
|
|
});
|
|
|
|
test("unnamed, this machine's mosquitto_ctrl runs", () => {
|
|
const c = MosquittoClient.fromEnv(env);
|
|
assert.deepEqual(c.ctrl(["dynsec", "listClients"]), ["mosquitto_ctrl", ["dynsec", "listClients"]]);
|
|
});
|