Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Redpanda module #743

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
24 changes: 24 additions & 0 deletions docs/modules/redpanda.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Redpanda

Testcontainers can be used to automatically instantiate and manage [Redpanda](https://redpanda.com/) containers.
More precisely Testcontainers uses the official Docker images for [Redpanda](https://hub.docker.com/r/redpandadata/redpanda)

!!! note
This module uses features provided in `docker.redpanda.com/redpandadata/redpanda`.

## Install


```bash
npm install @testcontainers/redpanda --save-dev
```

## Example

<!--codeinclude-->
[Connect:](../../packages/modules/redpanda/src/redpanda-container.test.ts) inside_block:connectToKafka
<!--/codeinclude-->

<!--codeinclude-->
[Schema registry:](../../packages/modules/redpanda/src/redpanda-container.test.ts) inside_block:connectToSchemaRegistry
<!--/codeinclude-->
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ nav:
- PostgreSQL: modules/postgresql.md
- Qdrant: modules/qdrant.md
- Redis: modules/redis.md
- Redpanda: modules/redpanda.md
- Selenium: modules/selenium.md
- Weaviate: modules/weaviate.md
- Configuration: configuration.md
150 changes: 148 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions packages/modules/redpanda/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Config } from "jest";
import * as path from "path";

const config: Config = {
preset: "ts-jest",
moduleNameMapper: {
"^testcontainers$": path.resolve(__dirname, "../../testcontainers/src"),
},
};

export default config;
39 changes: 39 additions & 0 deletions packages/modules/redpanda/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"name": "@testcontainers/redpanda",
"version": "10.8.0",
"license": "MIT",
"keywords": [
"redpanda",
"testing",
"docker",
"testcontainers"
],
"description": "Redpanda module for Testcontainers",
"homepage": "https://github.com/testcontainers/testcontainers-node#readme",
"repository": {
"type": "git",
"url": "https://github.com/testcontainers/testcontainers-node"
},
"bugs": {
"url": "https://github.com/testcontainers/testcontainers-node/issues"
},
"main": "build/index.js",
"files": [
"build"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"prepack": "shx cp ../../../README.md . && shx cp ../../../LICENSE .",
"build": "tsc --project tsconfig.build.json"
},
"dependencies": {
"handlebars": "^4.7.8",
"testcontainers": "^10.8.0"
},
"devDependencies": {
"kafkajs": "^2.2.4",
"node-fetch": "^3.3.2"
}
}
7 changes: 7 additions & 0 deletions packages/modules/redpanda/src/bootstrap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Injected by testcontainers
# This file contains cluster properties which will only be considered when
# starting the cluster for the first time. Afterwards, you can configure cluster
# properties via the Redpanda Admi n API.

kafka_enable_authorization: false
auto_create_topics_enabled: true
8 changes: 8 additions & 0 deletions packages/modules/redpanda/src/entrypoint-tc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

# Wait for testcontainer's injected redpanda config with the port only known after docker start
until grep -q "# Injected by testcontainers" "/etc/redpanda/redpanda.yaml"
do
sleep 0.1
done
exec /entrypoint.sh $@
1 change: 1 addition & 0 deletions packages/modules/redpanda/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { RedpandaContainer, StartedRedpandaContainer } from "./redpanda-container";
Loading
Loading