testcontainers 8.13.2 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/log-system-diagnostics.js +1 -1
- package/dist/port-check.d.ts +3 -0
- package/dist/port-check.js +28 -1
- package/package.json +1 -1
|
@@ -37,7 +37,7 @@ const getDockerComposeInfo = () => __awaiter(void 0, void 0, void 0, function* (
|
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
catch (err) {
|
|
40
|
-
logger_1.log.
|
|
40
|
+
logger_1.log.info(`Unable to detect docker-compose version, is it installed? ${err}`);
|
|
41
41
|
return undefined;
|
|
42
42
|
}
|
|
43
43
|
});
|
package/dist/port-check.d.ts
CHANGED
|
@@ -11,6 +11,9 @@ export declare class HostPortCheck implements PortCheck {
|
|
|
11
11
|
}
|
|
12
12
|
export declare class InternalPortCheck implements PortCheck {
|
|
13
13
|
private readonly container;
|
|
14
|
+
private isDistroless;
|
|
15
|
+
private commandOutputs;
|
|
14
16
|
constructor(container: Dockerode.Container);
|
|
15
17
|
isBound(port: Port): Promise<boolean>;
|
|
18
|
+
private commandOutputsKey;
|
|
16
19
|
}
|
package/dist/port-check.js
CHANGED
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.InternalPortCheck = exports.HostPortCheck = void 0;
|
|
13
13
|
const net_1 = require("net");
|
|
14
14
|
const exec_container_1 = require("./docker/functions/container/exec-container");
|
|
15
|
+
const logger_1 = require("./logger");
|
|
15
16
|
class HostPortCheck {
|
|
16
17
|
constructor(host) {
|
|
17
18
|
this.host = host;
|
|
@@ -40,6 +41,8 @@ exports.HostPortCheck = HostPortCheck;
|
|
|
40
41
|
class InternalPortCheck {
|
|
41
42
|
constructor(container) {
|
|
42
43
|
this.container = container;
|
|
44
|
+
this.isDistroless = false;
|
|
45
|
+
this.commandOutputs = new Set();
|
|
43
46
|
}
|
|
44
47
|
isBound(port) {
|
|
45
48
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -50,8 +53,32 @@ class InternalPortCheck {
|
|
|
50
53
|
["/bin/bash", "-c", `</dev/tcp/localhost/${port}`],
|
|
51
54
|
];
|
|
52
55
|
const commandResults = yield Promise.all(commands.map((command) => (0, exec_container_1.execContainer)(this.container, command)));
|
|
53
|
-
|
|
56
|
+
const isBound = commandResults.some((result) => result.exitCode === 0);
|
|
57
|
+
if (!isBound) {
|
|
58
|
+
const shellExists = commandResults.some((result) => result.exitCode !== 126);
|
|
59
|
+
if (!shellExists) {
|
|
60
|
+
if (!this.isDistroless) {
|
|
61
|
+
this.isDistroless = true;
|
|
62
|
+
logger_1.log.error(`The HostPortWaitStrategy will not work on a distroless image, use an alternate wait strategy for container ${this.container.id}`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
commandResults
|
|
67
|
+
.map((result) => (Object.assign(Object.assign({}, result), { output: result.output.trim() })))
|
|
68
|
+
.filter((result) => result.exitCode !== 126 && result.output.length > 0)
|
|
69
|
+
.forEach((result) => {
|
|
70
|
+
if (!this.commandOutputs.has(this.commandOutputsKey(result.output))) {
|
|
71
|
+
logger_1.log.trace(`Port check result for container ${this.container.id} exit code ${result.exitCode}: ${result.output}`);
|
|
72
|
+
this.commandOutputs.add(this.commandOutputsKey(result.output));
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return isBound;
|
|
54
78
|
});
|
|
55
79
|
}
|
|
80
|
+
commandOutputsKey(output) {
|
|
81
|
+
return `${this.container.id}:${output}`;
|
|
82
|
+
}
|
|
56
83
|
}
|
|
57
84
|
exports.InternalPortCheck = InternalPortCheck;
|