Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
aaca774
Common + DockerCompose + Logger packages
cristianrgreco Jul 20, 2023
9202742
Container runtime package in progress
cristianrgreco Jul 21, 2023
2daccd7
Container runtime package in progress
cristianrgreco Jul 21, 2023
c18271a
Container runtime package in progress
cristianrgreco Jul 21, 2023
bdb5495
Container runtime package in progress
cristianrgreco Jul 22, 2023
db377c2
Container runtime package in progress
cristianrgreco Jul 22, 2023
0fa2a65
Container runtime package in progress
cristianrgreco Jul 22, 2023
35bfb60
Reaper in progress
cristianrgreco Jul 23, 2023
9d17259
Container runtime package in progress
cristianrgreco Jul 23, 2023
ac51157
Port forwarder works
cristianrgreco Jul 23, 2023
9f79dd7
Cleanup
cristianrgreco Jul 23, 2023
d9464b7
Modules
cristianrgreco Jul 23, 2023
e700b58
Move packages to src
cristianrgreco Jul 23, 2023
a4dab4f
Add package.jsons
cristianrgreco Jul 23, 2023
439126a
Progress
cristianrgreco Jul 23, 2023
05f3045
TS build works
cristianrgreco Jul 23, 2023
1f4a207
Add fixtures
cristianrgreco Jul 23, 2023
1417b51
Root project builds
cristianrgreco Jul 23, 2023
5d5d8fb
Clean up configs + do not build root
cristianrgreco Jul 24, 2023
6d343fd
Rename workspace core to testcontainers
cristianrgreco Jul 24, 2023
f412bb5
Reinstate tests
cristianrgreco Jul 24, 2023
d020a76
Update tests
cristianrgreco Jul 25, 2023
2871588
Remove explicit dependency
cristianrgreco Jul 25, 2023
0dc8ace
Install workspaces into modules
cristianrgreco Jul 25, 2023
0061fd9
Remove tsbuildinfos
cristianrgreco Jul 25, 2023
a70e362
Default logs `since` field to `0` for Podman
cristianrgreco Jul 25, 2023
0a0a668
Lint
cristianrgreco Jul 25, 2023
c9603a9
Eslint and prettier ignore build dirs
cristianrgreco Jul 25, 2023
a4b7717
Update codeinclude paths in docs
cristianrgreco Jul 25, 2023
fe05e1f
Remove base tsconfigs from modules
cristianrgreco Jul 26, 2023
f7e940b
Reaper container should be auto removed
cristianrgreco Jul 26, 2023
887fbff
Update tesconfigs + ts-jest config
cristianrgreco Jul 26, 2023
4d11551
Update smoke test configs
cristianrgreco Jul 26, 2023
e993796
Exclude node_modules
cristianrgreco Jul 26, 2023
02eccfc
Exclude node_modules
cristianrgreco Jul 26, 2023
cc6e8cb
Build before removing dev dependencies for smoke tests
cristianrgreco Jul 26, 2023
808f2a3
Set version in container labels
cristianrgreco Jul 26, 2023
ca24acd
Write version to file as part of build
cristianrgreco Jul 26, 2023
45a0dc9
Fix labels
cristianrgreco Jul 26, 2023
e5bc827
Minor cleanup
cristianrgreco Jul 27, 2023
d3274a3
Remove deprecated lifecycle callbacks
cristianrgreco Jul 27, 2023
dd85754
Add static helper for pull policy
cristianrgreco Jul 27, 2023
d5515bb
Merge common/container-runtime workspaces into testcontainers
cristianrgreco Jul 27, 2023
5933f47
testcontainers package version 10.0.0-beta.0
cristianrgreco Jul 27, 2023
172bf2c
Set versions + example publish works
cristianrgreco Jul 27, 2023
fdda48e
Update publish pipeline
cristianrgreco Jul 27, 2023
7e79bad
Update npm-check-updates and ls-engines to work with workspaces
cristianrgreco Jul 27, 2023
b88f73c
Update metadata of packages
cristianrgreco Jul 27, 2023
9dbe5b7
Update imports in docs
cristianrgreco Jul 27, 2023
186a95d
Make publish access public
cristianrgreco Jul 27, 2023
4df5772
Rename elastic-search -> elasticsearch
cristianrgreco Jul 27, 2023
6b1b497
Update imports in docs
cristianrgreco Jul 27, 2023
3e2a896
Remove redundant fields from root package.json
cristianrgreco Jul 27, 2023
325a81f
Move smoke tests to testcontainers package
cristianrgreco Jul 27, 2023
b5ab603
Unify loggers
cristianrgreco Jul 28, 2023
4ab8d79
Update pull policy doc for compose
cristianrgreco Jul 31, 2023
c1bac51
Custom type for InspectResult should be part of API
cristianrgreco Jul 31, 2023
e86c3b3
Update imports
cristianrgreco Jul 31, 2023
b27f393
Do not assume default copy permissions
cristianrgreco Jul 31, 2023
7e90c79
10.0.0-beta.4
cristianrgreco Jul 31, 2023
4dac01f
Update publish pipeline
cristianrgreco Jul 31, 2023
fb93bad
Target OG testcontainers package
cristianrgreco Aug 1, 2023
1eb0c38
10.0.0-beta.5
cristianrgreco Aug 1, 2023
50f9763
Update publish workflow to install latest testcontainers dependency
cristianrgreco Aug 1, 2023
cf7e829
Update jest config
cristianrgreco Aug 1, 2023
bb41adc
Update package metadata
cristianrgreco Aug 1, 2023
68cce1a
Tidy up imports
cristianrgreco Aug 2, 2023
092707e
Revert "Tidy up imports"
cristianrgreco Aug 2, 2023
fa1ac2c
tsconfig per package instead of in root
cristianrgreco Aug 2, 2023
738a963
Rename tsconfig.build.json to tsconfig.base.json
cristianrgreco Aug 2, 2023
3d4c3d0
Extend tsconfigs
cristianrgreco Aug 2, 2023
ba9c740
10.0.0-beta.6
cristianrgreco Aug 2, 2023
7830fb4
Temporarily skip rancher pipeline
cristianrgreco Aug 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/build/**
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ module.exports = {
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:prettier/recommended"],
rules: {
"prettier/prettier": "error",
"@typescript-eslint/no-empty-function": "off",
},
};
45 changes: 25 additions & 20 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
@@ -1,43 +1,48 @@
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages

name: Node.js Package

on:
release:
types: [published]

jobs:
commit-version:
publish:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: main

- uses: actions/setup-node@v3
with:
node-version: 18
- run: |

- name: Configure Git
run: |
git config user.name github-actions
git config user.email [email protected]
npm --no-git-tag-version version ${{ github.event.release.tag_name }}

- name: Update versions
run: |
npm version ${{ github.event.release.tag_name }} -ws
for module in src/modules/*; do npm install testcontainers@${{ github.event.release.tag_name }} --save -w $module; done
sed -i -E "s/(sonar.projectVersion)=.+/\1=${{ github.event.release.tag_name }}/" sonar-project.properties
git add package.json package-lock.json sonar-project.properties

- name: Build packages
run: |
npm ci --no-optional
npm run build -ws

- name: Git commit and push
run: |
git add \
package-lock.json \
src/**/package.json \
src/testcontainers/src/version.ts \
sonar-project.properties
git commit -m "${{ github.event.release.tag_name }}"
git push

publish-npm:
needs: commit-version
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: main
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci --no-optional
- run: npm publish
- name: Publish packages to NPM
run: npm publish -ws
env:
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
7 changes: 5 additions & 2 deletions .github/workflows/test-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
run: npm run test:ci -- generic-container.test.ts

rancher-desktop:
if: false # https://github.com/rancher-sandbox/rancher-desktop/issues/5285
runs-on: ${{ matrix.os-version }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -220,9 +221,11 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci --omit=optional
- name: Build workspaces
run: npm run build -ws
- name: Remove dev dependencies
run: npm prune --omit=dev
- name: Run CommonJS module smoke test
run: node smoke-test.js
run: node src/testcontainers/smoke-test.js
- name: Run ES module smoke test
run: node smoke-test.mjs
run: node src/testcontainers/smoke-test.mjs
7 changes: 5 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ jobs:
run: npm run test:ci -- generic-container.test.ts

rancher-desktop:
if: false # https://github.com/rancher-sandbox/rancher-desktop/issues/5285
runs-on: ${{ matrix.os-version }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -214,9 +215,11 @@ jobs:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci --omit=optional
- name: Build workspaces
run: npm run build -ws
- name: Remove dev dependencies
run: npm prune --omit=dev
- name: Run CommonJS module smoke test
run: node smoke-test.js
run: node src/testcontainers/smoke-test.js
- name: Run ES module smoke test
run: node smoke-test.mjs
run: node src/testcontainers/smoke-test.mjs
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
dist/
build/
*.tsbuildinfo
node_modules/
coverage/

Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
**/build/**
22 changes: 20 additions & 2 deletions docs/features/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,29 @@ const environment = await new DockerComposeEnvironment(composeFilePath, composeF

### With a pull policy

Testcontainers will automatically pull an image if it doesn't exist. This is configurable:

```javascript
const { DockerComposeEnvironment, AlwaysPullPolicy } = require("testcontainers");
const { DockerComposeEnvironment, PullPolicy } = require("testcontainers");

const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
.withPullPolicy(PullPolicy.alwaysPull())
.up();
```

Create a custom pull policy:

```typescript
const { GenericContainer, ImagePullPolicy } = require("testcontainers");

class CustomPullPolicy implements ImagePullPolicy {
public shouldPull(): boolean {
return true;
}
}

const environment = await new DockerComposeEnvironment(composeFilePath, composeFile)
.withPullPolicy(new AlwaysPullPolicy())
.withPullPolicy(new CustomPullPolicy())
.up();
```

Expand Down
22 changes: 19 additions & 3 deletions docs/features/containers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,26 @@ const container = await new GenericContainer("alpine:3.10").start();
Testcontainers will automatically pull an image if it doesn't exist. This is configurable:

```javascript
const { GenericContainer, AlwaysPullPolicy } = require("testcontainers");
const { GenericContainer, PullPolicy } = require("testcontainers");

const container = await new GenericContainer("alpine")
.withPullPolicy(new AlwaysPullPolicy())
.withPullPolicy(PullPolicy.alwaysPull())
.start();
```

Create a custom pull policy:

```typescript
const { GenericContainer, ImagePullPolicy } = require("testcontainers");

class CustomPullPolicy implements ImagePullPolicy {
public shouldPull(): boolean {
return true;
}
}

const container = await new GenericContainer("alpine")
.withPullPolicy(new CustomPullPolicy())
.start();
```

Expand Down Expand Up @@ -395,7 +411,7 @@ import {
} from "testcontainers";

class CustomContainer extends GenericContainer {
protected override async beforeContainerStarted(): Promise<void> {
protected override async beforeContainerCreated(): Promise<void> {
// ...
}

Expand Down
23 changes: 20 additions & 3 deletions docs/features/images.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,33 @@ const container = await GenericContainer
.build("my-custom-image", { deleteOnExit: false });
```

### With pull policy
### With a pull policy

Testcontainers will automatically pull an image if it doesn't exist. This is configurable:

```javascript
const { GenericContainer, AlwaysPullPolicy } = require("testcontainers");
const { GenericContainer, PullPolicy } = require("testcontainers");

const container = await GenericContainer
.fromDockerfile("/path/to/build-context")
.withPullPolicy(new AlwaysPullPolicy())
.withPullPolicy(PullPolicy.alwaysPull())
.build();
```

Create a custom pull policy:

```typescript
const { GenericContainer, ImagePullPolicy } = require("testcontainers");

class CustomPullPolicy implements ImagePullPolicy {
public shouldPull(): boolean {
return true;
}
}

const container = await GenericContainer
.fromDockerfile("/path/to/build-context")
.withPullPolicy(new CustomPullPolicy())
.build();
```

Expand Down
8 changes: 7 additions & 1 deletion docs/modules/arangodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

[ArangoDB](https://www.arangodb.com/) is an open source friendly multi-model database. You can find the documentation of the [ArangoDB JavaScript](https://www.arangodb.com/docs/stable/drivers/js.html) driver here.

## Install

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

## Example

<!--codeinclude-->
[](../../src/modules/arangodb/arangodb-container.test.ts) inside_block:connect
[](../../src/modules/arangodb/src/arangodb-container.test.ts) inside_block:connect
<!--/codeinclude-->

10 changes: 8 additions & 2 deletions docs/modules/elastic-search.md → docs/modules/elasticsearch.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

[Elasticsearch](https://www.elastic.co/elasticsearch/) is a search engine based on the Lucene library. It provides a distributed, multitenant-capable full-text search engine with an HTTP web interface and schema-free JSON documents.

## Install

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

## Examples

<!--codeinclude-->
[Create an index:](../../src/modules/elasticsearch/elasticsearch-container.test.ts) inside_block:createIndex
[Create an index:](../../src/modules/elasticsearch/src/elasticsearch-container.test.ts) inside_block:createIndex
<!--/codeinclude-->

<!--codeinclude-->
[Index a document:](../../src/modules/elasticsearch/elasticsearch-container.test.ts) inside_block:indexDocument
[Index a document:](../../src/modules/elasticsearch/src/elasticsearch-container.test.ts) inside_block:indexDocument
<!--/codeinclude-->
8 changes: 7 additions & 1 deletion docs/modules/hivemq.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
This module allows automatic start up of [HiveMQ's](https://www.hivemq.com/) docker container within
Jest suites, to enable programmatic testing of JavaScript based MQTT client applications.

## Install

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

## Resources

* [Community forum](https://community.hivemq.com/)
Expand All @@ -18,5 +24,5 @@ Please make sure to check out the hivemq-docs for the [Community Edition](https:
## Examples

<!--codeinclude-->
[Connect with a mqtt.js client to HiveMQ](../../src/modules/hivemq/hivemq-container.test.ts) inside_block:connect
[Connect with a mqtt.js client to HiveMQ](../../src/modules/hivemq/src/hivemq-container.test.ts) inside_block:connect
<!--/codeinclude-->
12 changes: 9 additions & 3 deletions docs/modules/kafka.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@

[Kafka](https://kafka.apache.org/) is an open-source distributed event streaming platform used by thousands of companies for high-performance data pipelines, streaming analytics, data integration, and mission-critical applications.

## Install

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

## Examples

<!--codeinclude-->
[Connect to Kafka using in-built ZooKeeper:](../../src/modules/kafka/kafka-container.test.ts) inside_block:connectBuiltInZK
[Connect to Kafka using in-built ZooKeeper:](../../src/modules/kafka/src/kafka-container.test.ts) inside_block:connectBuiltInZK
<!--/codeinclude-->

<!--codeinclude-->
[Connect to Kafka using your own ZooKeeper:](../../src/modules/kafka/kafka-container.test.ts) inside_block:connectProvidedZK
[Connect to Kafka using your own ZooKeeper:](../../src/modules/kafka/src/kafka-container.test.ts) inside_block:connectProvidedZK
<!--/codeinclude-->

<!--codeinclude-->
[Connect to Kafka using SSL:](../../src/modules/kafka/kafka-container.test.ts) inside_block:ssl
[Connect to Kafka using SSL:](../../src/modules/kafka/src/kafka-container.test.ts) inside_block:ssl
<!--/codeinclude-->
10 changes: 8 additions & 2 deletions docs/modules/mongodb.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@

[MongoDB](https://www.mongodb.com/) is an open source NoSQL database management program. NoSQL is used as an alternative to traditional relational databases. NoSQL databases are quite useful for working with large sets of distributed data. MongoDB is a tool that can manage document-oriented information, store or retrieve information.

## Install

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

## Examples

<!--codeinclude-->
[Mongo 4.0.x:](../../src/modules/mongodb/mongodb-container.test.ts) inside_block:connect4
[Mongo 4.0.x:](../../src/modules/mongodb/src/mongodb-container.test.ts) inside_block:connect4
<!--/codeinclude-->

<!--codeinclude-->
[MongoDB 6.0.x:](../../src/modules/mongodb/mongodb-container.test.ts) inside_block:connect6
[MongoDB 6.0.x:](../../src/modules/mongodb/src/mongodb-container.test.ts) inside_block:connect6
<!--/codeinclude-->
14 changes: 10 additions & 4 deletions docs/modules/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,26 @@

[MySQL](https://www.mysql.com/) is the world's most popular open source database. With its proven performance, reliability and ease-of-use, MySQL has become the leading database choice for web-based applications, covering the entire range from personal projects and websites, via e-commerce and information services, all the way to high profile web properties including Facebook, Twitter, YouTube, Yahoo! and many more.

## Install

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

## Examples

<!--codeinclude-->
[Connect and execute query:](../../src/modules/mysql/mysql-container.test.ts) inside_block:connect
[Connect and execute query:](../../src/modules/mysql/src/mysql-container.test.ts) inside_block:connect
<!--/codeinclude-->

<!--codeinclude-->
[Connect and execute query using URI:](../../src/modules/mysql/mysql-container.test.ts) inside_block:uriConnect
[Connect and execute query using URI:](../../src/modules/mysql/src/mysql-container.test.ts) inside_block:uriConnect
<!--/codeinclude-->

<!--codeinclude-->
[Set username:](../../src/modules/mysql/mysql-container.test.ts) inside_block:setUsername
[Set username:](../../src/modules/mysql/src/mysql-container.test.ts) inside_block:setUsername
<!--/codeinclude-->

<!--codeinclude-->
[Execute a query inside the container:](../../src/modules/mysql/mysql-container.test.ts) inside_block:executeQuery
[Execute a query inside the container:](../../src/modules/mysql/src/mysql-container.test.ts) inside_block:executeQuery
<!--/codeinclude-->
Loading