testcontainers 9.2.1 → 9.3.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/package.json +1 -1
- package/dist/src/docker/functions/container/create-container.d.ts +2 -1
- package/dist/src/docker/functions/container/create-container.js +3 -0
- package/dist/src/docker/types.d.ts +4 -0
- package/dist/src/generic-container/generic-container.d.ts +3 -1
- package/dist/src/generic-container/generic-container.js +9 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +3 -1
- package/dist/src/modules/abstract-started-container.d.ts +1 -1
- package/dist/src/test-container.d.ts +2 -1
- package/package.json +1 -1
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DockerImageName } from "../../../docker-image-name";
|
|
2
2
|
import Dockerode from "dockerode";
|
|
3
3
|
import { PortWithOptionalBinding } from "../../../port";
|
|
4
|
-
import { BindMount, Environment, ExtraHost, HealthCheck, Labels, TmpFs, Ulimits } from "../../types";
|
|
4
|
+
import { BindMount, Environment, ExtraHost, HealthCheck, Labels, ResourcesQuota, TmpFs, Ulimits } from "../../types";
|
|
5
5
|
export type CreateContainerOptions = {
|
|
6
6
|
imageName: DockerImageName;
|
|
7
7
|
environment: Environment;
|
|
@@ -25,5 +25,6 @@ export type CreateContainerOptions = {
|
|
|
25
25
|
droppedCapabilities?: string[];
|
|
26
26
|
user?: string;
|
|
27
27
|
workingDir?: string;
|
|
28
|
+
resourcesQuota?: ResourcesQuota;
|
|
28
29
|
};
|
|
29
30
|
export declare const createContainer: (options: CreateContainerOptions) => Promise<Dockerode.Container>;
|
|
@@ -15,6 +15,7 @@ const docker_client_1 = require("../../docker-client");
|
|
|
15
15
|
const port_1 = require("../../../port");
|
|
16
16
|
const create_labels_1 = require("../create-labels");
|
|
17
17
|
const createContainer = (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
var _a, _b;
|
|
18
19
|
try {
|
|
19
20
|
logger_1.log.info(`Creating container for image: ${options.imageName}`);
|
|
20
21
|
const { dockerode } = yield (0, docker_client_1.dockerClient)();
|
|
@@ -42,6 +43,8 @@ const createContainer = (options) => __awaiter(void 0, void 0, void 0, function*
|
|
|
42
43
|
Ulimits: getUlimits(options.ulimits),
|
|
43
44
|
CapAdd: options.addedCapabilities,
|
|
44
45
|
CapDrop: options.droppedCapabilities,
|
|
46
|
+
Memory: (_a = options.resourcesQuota) === null || _a === void 0 ? void 0 : _a.memory,
|
|
47
|
+
NanoCpus: (_b = options.resourcesQuota) === null || _b === void 0 ? void 0 : _b.cpu,
|
|
45
48
|
},
|
|
46
49
|
});
|
|
47
50
|
}
|
|
@@ -4,7 +4,7 @@ import { PortWithOptionalBinding } from "../port";
|
|
|
4
4
|
import { PullPolicy } from "../pull-policy";
|
|
5
5
|
import { StartedTestContainer, TestContainer } from "../test-container";
|
|
6
6
|
import { WaitStrategy } from "../wait-strategy";
|
|
7
|
-
import { BindMount, ContentToCopy, Environment, ExtraHost, FileToCopy, HealthCheck, Labels, TmpFs, Ulimits } from "../docker/types";
|
|
7
|
+
import { BindMount, ContentToCopy, Environment, ExtraHost, FileToCopy, HealthCheck, Labels, TmpFs, Ulimits, ResourcesQuota } from "../docker/types";
|
|
8
8
|
import { InspectResult } from "../docker/functions/container/inspect-container";
|
|
9
9
|
import { GenericContainerBuilder } from "./generic-container-builder";
|
|
10
10
|
import { StartedNetwork } from "../network";
|
|
@@ -36,6 +36,7 @@ export declare class GenericContainer implements TestContainer {
|
|
|
36
36
|
protected pullPolicy: PullPolicy;
|
|
37
37
|
protected reuse: boolean;
|
|
38
38
|
protected tarToCopy?: archiver.Archiver;
|
|
39
|
+
protected resourcesQuota?: ResourcesQuota;
|
|
39
40
|
private extraHosts;
|
|
40
41
|
constructor(image: string);
|
|
41
42
|
protected preStart?(): Promise<void>;
|
|
@@ -72,4 +73,5 @@ export declare class GenericContainer implements TestContainer {
|
|
|
72
73
|
withCopyContentToContainer(contentsToCopy: ContentToCopy[]): this;
|
|
73
74
|
protected getTarToCopy(): archiver.Archiver;
|
|
74
75
|
withWorkingDir(workingDir: string): this;
|
|
76
|
+
withResourcesQuota({ memory, cpu }: ResourcesQuota): this;
|
|
75
77
|
}
|
|
@@ -98,6 +98,7 @@ class GenericContainer {
|
|
|
98
98
|
droppedCapabilities: this.droppedCapabilities,
|
|
99
99
|
user: this.user,
|
|
100
100
|
workingDir: this.workingDir,
|
|
101
|
+
resourcesQuota: this.resourcesQuota,
|
|
101
102
|
};
|
|
102
103
|
if (this.reuse) {
|
|
103
104
|
const containerHash = (0, hash_1.hash)(JSON.stringify(createContainerOptions));
|
|
@@ -299,5 +300,13 @@ class GenericContainer {
|
|
|
299
300
|
this.workingDir = workingDir;
|
|
300
301
|
return this;
|
|
301
302
|
}
|
|
303
|
+
withResourcesQuota({ memory, cpu }) {
|
|
304
|
+
// Memory and CPU units from here: https://docs.docker.com/engine/api/v1.42/#tag/Container/operation/ContainerCreate
|
|
305
|
+
// see Memory, NanoCpus parameters
|
|
306
|
+
const ram = memory !== undefined ? memory * Math.pow(1024, 3) : undefined;
|
|
307
|
+
const cpuQuota = cpu !== undefined ? cpu * Math.pow(10, 9) : undefined;
|
|
308
|
+
this.resourcesQuota = { memory: ram, cpu: cpuQuota };
|
|
309
|
+
return this;
|
|
310
|
+
}
|
|
302
311
|
}
|
|
303
312
|
exports.GenericContainer = GenericContainer;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { Network, StartedNetwork, StoppedNetwork } from "./network";
|
|
|
10
10
|
export { Wait } from "./wait";
|
|
11
11
|
export { StartupCheckStrategy, StartupStatus } from "./startup-check-strategy";
|
|
12
12
|
export { PullPolicy, DefaultPullPolicy, AlwaysPullPolicy } from "./pull-policy";
|
|
13
|
+
export { AbstractStartedContainer } from "./modules/abstract-started-container";
|
|
13
14
|
export { PostgreSqlContainer, StartedPostgreSqlContainer } from "./modules/postgresql/postgresql-container";
|
|
14
15
|
export { KafkaContainer, StartedKafkaContainer } from "./modules/kafka/kafka-container";
|
|
15
16
|
export { Neo4jContainer, StartedNeo4jContainer } from "./modules/neo4j/neo4j-container";
|
package/dist/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartedMongoDBContainer = exports.MongoDBContainer = exports.StartedNatsContainer = exports.NatsContainer = exports.StartedMySqlContainer = exports.MySqlContainer = exports.StartedElasticsearchContainer = exports.ElasticsearchContainer = exports.StartedArangoContainer = exports.ArangoDBContainer = exports.StartedNeo4jContainer = exports.Neo4jContainer = exports.StartedKafkaContainer = exports.KafkaContainer = exports.StartedPostgreSqlContainer = exports.PostgreSqlContainer = exports.AlwaysPullPolicy = exports.DefaultPullPolicy = exports.StartupCheckStrategy = exports.Wait = exports.StoppedNetwork = exports.StartedNetwork = exports.Network = exports.DownedDockerComposeEnvironment = exports.StoppedDockerComposeEnvironment = exports.StartedDockerComposeEnvironment = exports.DockerComposeEnvironment = exports.TestContainers = exports.GenericContainerBuilder = exports.GenericContainer = void 0;
|
|
3
|
+
exports.StartedMongoDBContainer = exports.MongoDBContainer = exports.StartedNatsContainer = exports.NatsContainer = exports.StartedMySqlContainer = exports.MySqlContainer = exports.StartedElasticsearchContainer = exports.ElasticsearchContainer = exports.StartedArangoContainer = exports.ArangoDBContainer = exports.StartedNeo4jContainer = exports.Neo4jContainer = exports.StartedKafkaContainer = exports.KafkaContainer = exports.StartedPostgreSqlContainer = exports.PostgreSqlContainer = exports.AbstractStartedContainer = exports.AlwaysPullPolicy = exports.DefaultPullPolicy = exports.StartupCheckStrategy = exports.Wait = exports.StoppedNetwork = exports.StartedNetwork = exports.Network = exports.DownedDockerComposeEnvironment = exports.StoppedDockerComposeEnvironment = exports.StartedDockerComposeEnvironment = exports.DockerComposeEnvironment = exports.TestContainers = exports.GenericContainerBuilder = exports.GenericContainer = void 0;
|
|
4
4
|
var generic_container_1 = require("./generic-container/generic-container");
|
|
5
5
|
Object.defineProperty(exports, "GenericContainer", { enumerable: true, get: function () { return generic_container_1.GenericContainer; } });
|
|
6
6
|
var generic_container_builder_1 = require("./generic-container/generic-container-builder");
|
|
@@ -26,6 +26,8 @@ Object.defineProperty(exports, "StartupCheckStrategy", { enumerable: true, get:
|
|
|
26
26
|
var pull_policy_1 = require("./pull-policy");
|
|
27
27
|
Object.defineProperty(exports, "DefaultPullPolicy", { enumerable: true, get: function () { return pull_policy_1.DefaultPullPolicy; } });
|
|
28
28
|
Object.defineProperty(exports, "AlwaysPullPolicy", { enumerable: true, get: function () { return pull_policy_1.AlwaysPullPolicy; } });
|
|
29
|
+
var abstract_started_container_1 = require("./modules/abstract-started-container");
|
|
30
|
+
Object.defineProperty(exports, "AbstractStartedContainer", { enumerable: true, get: function () { return abstract_started_container_1.AbstractStartedContainer; } });
|
|
29
31
|
var postgresql_container_1 = require("./modules/postgresql/postgresql-container");
|
|
30
32
|
Object.defineProperty(exports, "PostgreSqlContainer", { enumerable: true, get: function () { return postgresql_container_1.PostgreSqlContainer; } });
|
|
31
33
|
Object.defineProperty(exports, "StartedPostgreSqlContainer", { enumerable: true, get: function () { return postgresql_container_1.StartedPostgreSqlContainer; } });
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { RestartOptions, StartedTestContainer, StopOptions, StoppedTestContainer } from "../test-container";
|
|
3
3
|
import { ExecResult, Labels } from "../docker/types";
|
|
4
4
|
import { Readable } from "stream";
|
|
5
|
-
export declare class AbstractStartedContainer {
|
|
5
|
+
export declare class AbstractStartedContainer implements StartedTestContainer {
|
|
6
6
|
protected readonly startedTestContainer: StartedTestContainer;
|
|
7
7
|
constructor(startedTestContainer: StartedTestContainer);
|
|
8
8
|
stop(options?: Partial<StopOptions>): Promise<StoppedTestContainer>;
|
|
@@ -3,7 +3,7 @@ import { PortWithOptionalBinding } from "./port";
|
|
|
3
3
|
import { PullPolicy } from "./pull-policy";
|
|
4
4
|
import { WaitStrategy } from "./wait-strategy";
|
|
5
5
|
import { Readable } from "stream";
|
|
6
|
-
import { ExecResult, ExtraHost, TmpFs, Labels, Ulimits, BindMount, FileToCopy, ContentToCopy, Environment } from "./docker/types";
|
|
6
|
+
import { ExecResult, ExtraHost, TmpFs, Labels, Ulimits, BindMount, FileToCopy, ContentToCopy, Environment, ResourcesQuota } from "./docker/types";
|
|
7
7
|
import { StartedNetwork } from "./network";
|
|
8
8
|
export interface TestContainer {
|
|
9
9
|
start(): Promise<StartedTestContainer>;
|
|
@@ -29,6 +29,7 @@ export interface TestContainer {
|
|
|
29
29
|
withCopyFilesToContainer(filesToCopy: FileToCopy[]): this;
|
|
30
30
|
withCopyContentToContainer(contentsToCopy: ContentToCopy[]): this;
|
|
31
31
|
withWorkingDir(workingDir: string): this;
|
|
32
|
+
withResourcesQuota(resourcesQuota: ResourcesQuota): this;
|
|
32
33
|
}
|
|
33
34
|
export interface RestartOptions {
|
|
34
35
|
timeout: number;
|