Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,169 changes: 1,902 additions & 1,267 deletions package-lock.json

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"check-compiles": "npm run build --ignore-scripts --ws -- --project tsconfig.json --noEmit"
},
"devDependencies": {
"@eslint/js": "^9.27.0",
"@eslint/js": "^9.28.0",
"@eslint/json": "^0.12.0",
"@vitest/coverage-v8": "^3.1.4",
"eslint": "^9.27.0",
"@vitest/coverage-v8": "^3.2.2",
"eslint": "^9.28.0",
"eslint-config-prettier": "^10.1.5",
"eslint-plugin-prettier": "^5.4.0",
"eslint-plugin-prettier": "^5.4.1",
"husky": "^9.1.7",
"lint-staged": "^16.1.0",
"ls-engines": "^0.9.3",
Expand All @@ -34,13 +34,12 @@
"shx": "^0.4.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.3",
"typescript-eslint": "^8.33.0",
"typescript-eslint": "^8.33.1",
"vitest": "^3.1.3"
},
"overrides": {
"msw": {
"@mswjs/interceptors": "0.37.5"
}
"msw": "2.8.4",
"@mswjs/interceptors": "0.37.5"
},
"lint-staged": {
"packages/**/*.ts": [
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/azurite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"testcontainers": "^11.0.1"
},
"devDependencies": {
"@azure/data-tables": "^13.3.0",
"@azure/data-tables": "^13.3.1",
"@azure/storage-blob": "^12.27.0",
"@azure/storage-queue": "^12.26.0"
}
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/chromadb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"chromadb": "2.4.6",
"ollama": "^0.5.15"
"chromadb": "^2.4.6",
"ollama": "^0.5.16"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/clickhouse/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@clickhouse/client": "^1.11.1"
"@clickhouse/client": "^1.11.2"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/cockroachdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@types/pg": "^8.15.2",
"@types/pg": "^8.15.4",
"pg": "^8.16.0"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/couchbase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"testcontainers": "^11.0.1"
},
"devDependencies": {
"couchbase": "4.4.6"
"couchbase": "4.5.0"
}
}
2 changes: 1 addition & 1 deletion packages/modules/hivemq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"mqtt": "^5.13.0"
"mqtt": "^5.13.1"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/k3s/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
"testcontainers": "^11.0.1"
},
"devDependencies": {
"@kubernetes/client-node": "^1.2.0"
"@kubernetes/client-node": "^1.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/modules/kurrentdb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@kurrent/kurrentdb-client": "^1.0.1"
"@kurrent/kurrentdb-client": "^1.0.2"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/localstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
"testcontainers": "^11.0.1"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.817.0"
"@aws-sdk/client-s3": "^3.826.0"
}
}
2 changes: 1 addition & 1 deletion packages/modules/postgresql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@types/pg": "^8.15.2",
"@types/pg": "^8.15.4",
"pg": "^8.16.0"
},
"dependencies": {
Expand Down
3 changes: 1 addition & 2 deletions packages/modules/redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@types/redis": "^4.0.11",
"redis": "^5.1.0"
"redis": "^5.5.6"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
4 changes: 0 additions & 4 deletions packages/modules/toxiproxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,5 @@
"dependencies": {
"testcontainers": "^11.0.1",
"toxiproxy-node-client": "^4.0.0"
},
"devDependencies": {
"@testcontainers/redis": "^11.0.0",
"redis": "^5.1.0"
}
}
162 changes: 65 additions & 97 deletions packages/modules/toxiproxy/src/toxiproxy-container.test.ts
Original file line number Diff line number Diff line change
@@ -1,108 +1,82 @@
import { createClient } from "redis";
import { GenericContainer, Network } from "testcontainers";
import { getImage } from "../../../testcontainers/src/utils/test-helper";
import { ToxiProxyContainer, TPClient } from "./toxiproxy-container";

const IMAGE = getImage(__dirname);

describe("ToxiProxyContainer", { timeout: 240_000 }, () => {
// Helper to connect to redis
async function connectTo(url: string) {
const client = createClient({
url,
});
client.on("error", () => {}); // Ignore errors
await client.connect();
expect(client.isOpen).toBeTruthy();
return client;
}

// create_proxy {
it("Should create a proxy to an endpoint", async () => {
const containerNetwork = await new Network().start();
const redisContainer = await new GenericContainer("redis:7.2")
.withNetwork(containerNetwork)
.withNetworkAliases("redis")
it("should create a proxy to an endpoint", async () => {
const network = await new Network().start();
const appContainer = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")
.withExposedPorts(8080)
.withNetwork(network)
.withNetworkAliases("app")
.start();

const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(containerNetwork).start();
const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(network).start();

// Create the proxy between Toxiproxy and Redis
const redisProxy = await toxiproxyContainer.createProxy({
name: "redis",
upstream: "redis:6379",
const appProxy = await toxiproxyContainer.createProxy({
name: "app",
upstream: "app:8080",
});

const url = `redis://${redisProxy.host}:${redisProxy.port}`;
const client = await connectTo(url);
await client.set("key", "val");
expect(await client.get("key")).toBe("val");
const response = await fetch(`http://${appProxy.host}:${appProxy.port}/hello-world`);
expect(response.status).toBe(200);

await client.disconnect();
await toxiproxyContainer.stop();
await redisContainer.stop();
await appContainer.stop();
await network.stop();
});
// }

// enabled_disabled {
it("Should enable and disable a proxy", async () => {
const containerNetwork = await new Network().start();
const redisContainer = await new GenericContainer("redis:7.2")
.withNetwork(containerNetwork)
.withNetworkAliases("redis")
it("should enable and disable a proxy", async () => {
const network = await new Network().start();
const appContainer = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")
.withExposedPorts(8080)
.withNetwork(network)
.withNetworkAliases("app")
.start();

const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(containerNetwork).start();
const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(network).start();

// Create the proxy between Toxiproxy and Redis
const redisProxy = await toxiproxyContainer.createProxy({
name: "redis",
upstream: "redis:6379",
const appProxy = await toxiproxyContainer.createProxy({
name: "app",
upstream: "app:8080",
});

const url = `redis://${redisProxy.host}:${redisProxy.port}`;
const client = await connectTo(url);

await client.set("key", "val");
expect(await client.get("key")).toBe("val");

// Disable any new connections to the proxy
await redisProxy.setEnabled(false);
await appProxy.setEnabled(false);
await expect(fetch(`http://${appProxy.host}:${appProxy.port}/hello-world`)).rejects.toThrow();

await expect(client.ping()).rejects.toThrow();
await appProxy.setEnabled(true);
const response = await fetch(`http://${appProxy.host}:${appProxy.port}/hello-world`);
expect(response.status).toBe(200);

// Enable the proxy again
await redisProxy.setEnabled(true);

expect(await client.ping()).toBe("PONG");

await client.disconnect();
await toxiproxyContainer.stop();
await redisContainer.stop();
await appContainer.stop();
await network.stop();
});
// }

// adding_toxic {
it("Should add a toxic to a proxy and then remove", async () => {
const containerNetwork = await new Network().start();
const redisContainer = await new GenericContainer("redis:7.2")
.withNetwork(containerNetwork)
.withNetworkAliases("redis")
it("should add a toxic to a proxy and then remove", async () => {
const network = await new Network().start();
const appContainer = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")
.withExposedPorts(8080)
.withNetwork(network)
.withNetworkAliases("app")
.start();

const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(containerNetwork).start();
const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(network).start();

// Create the proxy between Toxiproxy and Redis
const redisProxy = await toxiproxyContainer.createProxy({
name: "redis",
upstream: "redis:6379",
const appProxy = await toxiproxyContainer.createProxy({
name: "app",
upstream: "app:8080",
});

const url = `redis://${redisProxy.host}:${redisProxy.port}`;
const client = await connectTo(url);

// See https://github.com/ihsw/toxiproxy-node-client for details on the instance interface
const toxic = await redisProxy.instance.addToxic<TPClient.Latency>({
const toxic = await appProxy.instance.addToxic<TPClient.Latency>({
attributes: {
jitter: 50,
latency: 1500,
Expand All @@ -114,55 +88,49 @@ describe("ToxiProxyContainer", { timeout: 240_000 }, () => {
});

const before = Date.now();
await client.ping();
await fetch(`http://${appProxy.host}:${appProxy.port}/hello-world`);
const after = Date.now();
expect(after - before).toBeGreaterThan(1000);

await toxic.remove();

await client.disconnect();
await toxiproxyContainer.stop();
await redisContainer.stop();
await appContainer.stop();
await network.stop();
});
// }

it("Should create multiple proxies", async () => {
const containerNetwork = await new Network().start();
const redisContainer = await new GenericContainer("redis:7.2")
.withNetwork(containerNetwork)
.withNetworkAliases("redis")
it("should create multiple proxies", async () => {
const network = await new Network().start();
const appContainer = await new GenericContainer("cristianrgreco/testcontainer:1.1.14")
.withExposedPorts(8080)
.withNetwork(network)
.withNetworkAliases("app")
.start();

const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(containerNetwork).start();
const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).withNetwork(network).start();

// Create the proxy between Toxiproxy and Redis
const redisProxy = await toxiproxyContainer.createProxy({
name: "redis",
upstream: "redis:6379",
const appProxy = await toxiproxyContainer.createProxy({
name: "app",
upstream: "app:8080",
});

// Create the proxy between Toxiproxy and Redis
const redisProxy2 = await toxiproxyContainer.createProxy({
name: "redis2",
upstream: "redis:6379",
const appProxy2 = await toxiproxyContainer.createProxy({
name: "app2",
upstream: "app:8080",
});

const url = `redis://${redisProxy.host}:${redisProxy.port}`;
const client = await connectTo(url);
await client.set("key", "val");
expect(await client.get("key")).toBe("val");
const response = await fetch(`http://${appProxy.host}:${appProxy.port}/hello-world`);
expect(response.status).toBe(200);

const url2 = `redis://${redisProxy2.host}:${redisProxy2.port}`;
const client2 = await connectTo(url2);
expect(await client2.get("key")).toBe("val");
const response2 = await fetch(`http://${appProxy2.host}:${appProxy2.port}/hello-world`);
expect(response2.status).toBe(200);

await client.disconnect();
await client2.disconnect();
await toxiproxyContainer.stop();
await redisContainer.stop();
await appContainer.stop();
await network.stop();
});

it("Throws an error when too many proxies are created", async () => {
it("throws an error when too many proxies are created", async () => {
const toxiproxyContainer = await new ToxiProxyContainer(IMAGE).start();

for (let i = 0; i < 32; i++) {
Expand Down
3 changes: 1 addition & 2 deletions packages/modules/valkey/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@types/redis": "^4.0.11",
"redis": "^5.1.0"
"redis": "^5.5.6"
},
"dependencies": {
"testcontainers": "^11.0.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/testcontainers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"byline": "^5.0.0",
"debug": "^4.4.1",
"docker-compose": "^1.2.0",
"dockerode": "^4.0.6",
"dockerode": "^4.0.7",
"get-port": "^7.1.0",
"proper-lockfile": "^4.1.2",
"properties-reader": "^2.3.0",
Expand Down
Loading