Skip to content

Commit 307e501

Browse files
committed
Merge branch 'main' into dev-tools
* main: chore: replace 'assert' with 'require' (#2827) chore: replace 'assert' with 'require' for critical checks (#2824) chore: bump ryuk to latest release (#2818) feat: add require for critical checks (#2812) chore(deps): bump release-drafter/release-drafter from 5.25.0 to 6.0.0 (#2805) feat: add etcd module (#2788) feat: add dynamodb-local module (#2799) fix(redpanda): wait for (#2794) fix(elasticsearch): wait for (#2724) chore: update dockercfg module (#2801)
2 parents 412d57b + fb6a4ba commit 307e501

File tree

140 files changed

+2288
-318
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+2288
-318
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
matrix:
9595
go-version: [1.22.x, 1.x]
9696
platform: [ubuntu-latest]
97-
module: [artemis, azurite, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, databend, dolt, elasticsearch, gcloud, grafana-lgtm, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, valkey, vault, vearch, weaviate]
97+
module: [artemis, azurite, cassandra, chroma, clickhouse, cockroachdb, compose, consul, couchbase, databend, dolt, dynamodb, elasticsearch, etcd, gcloud, grafana-lgtm, inbucket, influxdb, k3s, k6, kafka, localstack, mariadb, milvus, minio, mockserver, mongodb, mssql, mysql, nats, neo4j, ollama, openfga, openldap, opensearch, postgres, pulsar, qdrant, rabbitmq, redis, redpanda, registry, surrealdb, valkey, vault, vearch, weaviate]
9898
uses: ./.github/workflows/ci-test-go.yml
9999
with:
100100
go-version: ${{ matrix.go-version }}

.github/workflows/release-drafter.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ jobs:
1616
pull-requests: write # for release-drafter/release-drafter to add label to PR
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: release-drafter/release-drafter@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # v5.19.0
19+
- uses: release-drafter/release-drafter@3f0f87098bd6b5c5b9a36d49c41d998ea58f9348 # v5.19.0
2020
env:
2121
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.vscode/.testcontainers-go.code-workspace

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@
6161
"name": "module / dolt",
6262
"path": "../modules/dolt"
6363
},
64+
{
65+
"name": "module / dynamodb",
66+
"path": "../modules/dynamodb"
67+
},
6468
{
6569
"name": "module / elasticsearch",
6670
"path": "../modules/elasticsearch"
6771
},
72+
{
73+
"name": "module / etcd",
74+
"path": "../modules/etcd"
75+
},
6876
{
6977
"name": "module / gcloud",
7078
"path": "../modules/gcloud"

cmd/devtools/main_test.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,11 @@ func TestModule_Validate(outer *testing.T) {
148148

149149
for _, test := range tests {
150150
outer.Run(test.name, func(t *testing.T) {
151-
assert.Equal(t, test.expectedErr, test.module.Validate())
151+
if test.expectedErr != nil {
152+
require.EqualError(t, test.module.Validate(), test.expectedErr.Error())
153+
} else {
154+
require.NoError(t, test.module.Validate())
155+
}
152156
})
153157
}
154158
}
@@ -277,7 +281,7 @@ func TestGenerate(t *testing.T) {
277281

278282
moduleDirFileInfo, err := os.Stat(moduleDirPath)
279283
require.NoError(t, err) // error nil implies the file exist
280-
assert.True(t, moduleDirFileInfo.IsDir())
284+
require.True(t, moduleDirFileInfo.IsDir())
281285

282286
moduleDocFile := filepath.Join(examplesDocTmp, moduleNameLower+".md")
283287
_, err = os.Stat(moduleDocFile)
@@ -333,7 +337,7 @@ func TestGenerateModule(t *testing.T) {
333337

334338
moduleDirFileInfo, err := os.Stat(moduleDirPath)
335339
require.NoError(t, err) // error nil implies the file exist
336-
assert.True(t, moduleDirFileInfo.IsDir())
340+
require.True(t, moduleDirFileInfo.IsDir())
337341

338342
moduleDocFile := filepath.Join(modulesDocTmp, moduleNameLower+".md")
339343
_, err = os.Stat(moduleDocFile)

cmd/devtools/mkdocs_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ func TestReadMkDocsConfig(t *testing.T) {
4040
require.NoError(t, err)
4141
require.NotNil(t, config)
4242

43-
assert.Equal(t, "Testcontainers for Go", config.SiteName)
44-
assert.Equal(t, "https://github.com/testcontainers/testcontainers-go", config.RepoURL)
45-
assert.Equal(t, "edit/main/docs/", config.EditURI)
43+
require.Equal(t, "Testcontainers for Go", config.SiteName)
44+
require.Equal(t, "https://github.com/testcontainers/testcontainers-go", config.RepoURL)
45+
require.Equal(t, "edit/main/docs/", config.EditURI)
4646

4747
// theme
4848
theme := config.Theme
@@ -51,9 +51,9 @@ func TestReadMkDocsConfig(t *testing.T) {
5151
// nav bar
5252
nav := config.Nav
5353
assert.Equal(t, "index.md", nav[0].Home)
54-
assert.NotEmpty(t, nav[2].Features)
55-
assert.NotEmpty(t, nav[3].Modules)
56-
assert.NotEmpty(t, nav[4].Examples)
54+
require.NotEmpty(t, nav[2].Features)
55+
require.NotEmpty(t, nav[3].Modules)
56+
require.NotEmpty(t, nav[4].Examples)
5757
}
5858

5959
func TestNavItems(t *testing.T) {

container_ignore_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/stretchr/testify/assert"
9+
"github.com/stretchr/testify/require"
910
)
1011

1112
func TestParseDockerIgnore(t *testing.T) {
@@ -37,7 +38,7 @@ func TestParseDockerIgnore(t *testing.T) {
3738
for _, testCase := range testCases {
3839
exists, excluded, err := parseDockerIgnore(testCase.filePath)
3940
assert.Equal(t, testCase.exists, exists)
40-
assert.Equal(t, testCase.expectedErr, err)
41+
require.ErrorIs(t, testCase.expectedErr, err)
4142
assert.Equal(t, testCase.expectedExcluded, excluded)
4243
}
4344
}

container_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ func TestCustomLabelsImage(t *testing.T) {
320320
ctr, err := testcontainers.GenericContainer(ctx, req)
321321

322322
require.NoError(t, err)
323-
t.Cleanup(func() { assert.NoError(t, ctr.Terminate(ctx)) })
323+
t.Cleanup(func() { require.NoError(t, ctr.Terminate(ctx)) })
324324

325325
ctrJSON, err := ctr.Inspect(ctx)
326326
require.NoError(t, err)

docker_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ func TestContainerStateAfterTermination(t *testing.T) {
307307
state, err := nginx.State(ctx)
308308
require.Error(t, err, "expected error from container inspect.")
309309

310-
assert.Nil(t, state, "expected nil container inspect.")
310+
require.Nil(t, state, "expected nil container inspect.")
311311
})
312312

313313
t.Run("Nil State after termination if raw as already set", func(t *testing.T) {
@@ -1339,7 +1339,7 @@ func TestContainerInspect_RawInspectIsCleanedOnStop(t *testing.T) {
13391339
inspect, err := ctr.Inspect(context.Background())
13401340
require.NoError(t, err)
13411341

1342-
assert.NotEmpty(t, inspect.ID)
1342+
require.NotEmpty(t, inspect.ID)
13431343

13441344
require.NoError(t, ctr.Stop(context.Background(), nil))
13451345
}
@@ -1698,7 +1698,7 @@ func TestDockerContainerCopyEmptyFileFromContainer(t *testing.T) {
16981698
if err != nil {
16991699
t.Fatal(err)
17001700
}
1701-
assert.Empty(t, fileContentFromContainer)
1701+
require.Empty(t, fileContentFromContainer)
17021702
}
17031703

17041704
func TestDockerContainerResources(t *testing.T) {

docs/modules/dynamodb.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# DynamoDB
2+
3+
Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
4+
5+
## Introduction
6+
7+
The Testcontainers module for DynamoDB.
8+
9+
## Adding this module to your project dependencies
10+
11+
Please run the following command to add the DynamoDB module to your Go dependencies:
12+
13+
```
14+
go get github.com/testcontainers/testcontainers-go/modules/dynamodb
15+
```
16+
17+
## Usage example
18+
19+
<!--codeinclude-->
20+
[Creating a DynamoDB container](../../modules/dynamodb/examples_test.go) inside_block:runDynamoDBContainer
21+
<!--/codeinclude-->
22+
23+
## Module Reference
24+
25+
### Run function
26+
27+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
28+
29+
The DynamoDB module exposes one entrypoint function to create the DynamoDB container, and this function receives three parameters:
30+
31+
```golang
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*DynamoDBContainer, error)
33+
```
34+
35+
- `context.Context`, the Go context.
36+
- `string`, the Docker image to use.
37+
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.
38+
39+
### Container Options
40+
41+
When starting the DynamoDB container, you can pass options in a variadic way to configure it.
42+
43+
#### Image
44+
45+
If you need to set a different DynamoDB Docker image, you can set a valid Docker image as the second argument in the `Run` function.
46+
E.g. `Run(context.Background(), "amazon/dynamodb-local:2.2.1")`.
47+
48+
{% include "../features/common_functional_options.md" %}
49+
50+
#### WithSharedDB
51+
52+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
53+
54+
The `WithSharedDB` option tells the DynamoDB container to use a single database file. At the same time, it marks the container as reusable, which causes that successive calls to the `Run` function will return the same container instance, and therefore, the same database file.
55+
56+
#### WithDisableTelemetry
57+
58+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
59+
60+
You can turn off telemetry when starting the DynamoDB container, using the option `WithDisableTelemetry`.
61+
62+
### Container Methods
63+
64+
The DynamoDB container exposes the following methods:
65+
66+
#### ConnectionString
67+
68+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
69+
70+
The `ConnectionString` method returns the connection string to the DynamoDB container. This connection string can be used to connect to the DynamoDB container from your application,
71+
using the AWS SDK or any other DynamoDB client of your choice.
72+
73+
<!--codeinclude-->
74+
[Creating a client](../../modules/dynamodb/dynamodb_test.go) inside_block:createClient
75+
<!--/codeinclude-->
76+
77+
The above example uses `github.com/aws/aws-sdk-go-v2/service/dynamodb` to create a client and connect to the DynamoDB container.

docs/modules/etcd.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# etcd
2+
3+
Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
4+
5+
## Introduction
6+
7+
The Testcontainers module for etcd.
8+
9+
## Adding this module to your project dependencies
10+
11+
Please run the following command to add the etcd module to your Go dependencies:
12+
13+
```
14+
go get github.com/testcontainers/testcontainers-go/modules/etcd
15+
```
16+
17+
## Usage example
18+
19+
<!--codeinclude-->
20+
[Creating a etcd container](../../modules/etcd/examples_test.go) inside_block:runetcdContainer
21+
<!--/codeinclude-->
22+
23+
## Module Reference
24+
25+
### Run function
26+
27+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
28+
29+
The etcd module exposes one entrypoint function to create the etcd container, and this function receives three parameters:
30+
31+
```golang
32+
func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustomizer) (*etcdContainer, error)
33+
```
34+
35+
- `context.Context`, the Go context.
36+
- `string`, the Docker image to use.
37+
- `testcontainers.ContainerCustomizer`, a variadic argument for passing options.
38+
39+
### Container Options
40+
41+
When starting the etcd container, you can pass options in a variadic way to configure it.
42+
43+
#### Image
44+
45+
If you need to set a different etcd Docker image, you can set a valid Docker image as the second argument in the `Run` function.
46+
E.g. `Run(context.Background(), "bitnami/etcd:latest")`.
47+
48+
{% include "../features/common_functional_options.md" %}
49+
50+
#### WithAdditionalArgs
51+
52+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
53+
54+
You can pass additional arguments to the etcd container by using the `WithAdditionalArgs` option. The arguments are passed to the CMD of the etcd container.
55+
56+
#### WithDataDir
57+
58+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
59+
60+
You can set the data directory for the etcd container by using the `WithDataDir` boolean option. The data directory where the etcd data is stored is `/data.etcd`.
61+
62+
#### WithNodes
63+
64+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
65+
66+
You can set the number of nodes for the etcd cluster by using the `WithNodes` option, passing the node names for each of the nodes. Single-node clusters are not allowed,
67+
for that reason the functional option receives three string arguments: the first node, the second node, and a variadic argument for the rest of the nodes.
68+
The module starts a container for each node, having the first node a reference to the other nodes. E.g. `WithNodes("etcd-1", "etcd-2")`, `WithNodes("etcd-1", "etcd-2", "etcd-3")` and so on.
69+
70+
The module creates a Docker network for the etcd cluster, and the nodes are connected to this network, so that they can communicate with each other through the network.
71+
72+
#### WithClusterToken
73+
74+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
75+
76+
Sets the cluster token for the etcd cluster. The cluster token is used to identify the etcd cluster. The default value is `mys3cr3ttok3n`.
77+
The etcd container holds a reference to the cluster token, so you can use it with e.g. `ctr.ClusterToken`.
78+
79+
### Container Methods
80+
81+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
82+
83+
The etcd container exposes the following methods:
84+
85+
#### ClientEndpoint
86+
87+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
88+
89+
Returns the client endpoint for the etcd container and an error, if any. In the case of a cluster, it returns the client endpoint for the first node.
90+
91+
#### PeerEndpoint
92+
93+
- Not available until the next release of testcontainers-go <a href="https://github.com/testcontainers/testcontainers-go"><span class="tc-version">:material-tag: main</span></a>
94+
95+
Returns the peer endpoint for the etcd container and an error, if any. In the case of a cluster, it returns the peer endpoint for the first node.

0 commit comments

Comments
 (0)