From d9bf06dfc351057cf8cac6f83fa1235e1397c9e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 11 Oct 2023 11:31:20 +0200 Subject: [PATCH 1/6] docs: include core options on k6 module --- docs/modules/k6.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index 2ab22e17ce..154f133b3e 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -6,7 +6,6 @@ Not available until the next release of testcontainers-go Date: Wed, 11 Oct 2023 13:30:40 +0200 Subject: [PATCH 2/6] docs: complete sections --- docs/modules/k6.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index 154f133b3e..0310bb8069 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -80,3 +80,7 @@ Use the `WithTestScript` option to specify the test script to run. The path to t ```golang k6.RunContainer(ctx, k6.WithTestScript("/tests/test.js")) ``` + +### Container Methods + +The K6 container does not expose any method. From 46db875790563a7c364983593b91f011093f647f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 11 Oct 2023 15:51:12 +0200 Subject: [PATCH 3/6] docs: split usage example by parts --- docs/modules/k6.md | 3 +++ modules/k6/examples_test.go | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index 0310bb8069..872cce1b77 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -21,6 +21,9 @@ go get github.com/testcontainers/testcontainers-go/modules/k6 ## Usage example +[Creating a httpbin application](../../modules/k6/examples_test.go) inside_block:runHTTPBin +[Obtain IP for the httpbin application](../../modules/k6/examples_test.go) inside_block:getHTTPBinIP +[httpbin script](../../modules/k6/scripts/httpbin.js) [Creating a K6 container](../../modules/k6/examples_test.go) inside_block:runK6Container diff --git a/modules/k6/examples_test.go b/modules/k6/examples_test.go index cc9086e429..8ad313931e 100644 --- a/modules/k6/examples_test.go +++ b/modules/k6/examples_test.go @@ -11,7 +11,7 @@ import ( ) func ExampleRunContainer() { - // runK6Container { + // runHTTPBin { ctx := context.Background() // create a container with the httpbin application that will be the target @@ -37,17 +37,21 @@ func ExampleRunContainer() { panic(fmt.Errorf("failed to terminate container: %w", err)) } }() + // } + // getHTTPBinIP { httpbinIP, err := httpbin.ContainerIP(ctx) if err != nil { panic(fmt.Errorf("failed to get httpbin IP: %w", err)) } + // } absPath, err := filepath.Abs(filepath.Join("scripts", "httpbin.js")) if err != nil { panic(fmt.Errorf("failed to get path to test script: %w", err)) } + // runK6Container { // run the httpbin.js test scripts passing the IP address the httpbin container k6, err := k6.RunContainer( ctx, From 7c3d5dd6cd874dd3da013a7cbb48879ba8afadd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Wed, 11 Oct 2023 18:31:10 +0200 Subject: [PATCH 4/6] Apply suggestions from code review Co-authored-by: pablochacin --- docs/modules/k6.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index 872cce1b77..b00c71c639 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -23,7 +23,7 @@ go get github.com/testcontainers/testcontainers-go/modules/k6 [Creating a httpbin application](../../modules/k6/examples_test.go) inside_block:runHTTPBin [Obtain IP for the httpbin application](../../modules/k6/examples_test.go) inside_block:getHTTPBinIP -[httpbin script](../../modules/k6/scripts/httpbin.js) +[k6 script for testing httpbin](../../modules/k6/scripts/httpbin.js) [Creating a K6 container](../../modules/k6/examples_test.go) inside_block:runK6Container @@ -45,7 +45,7 @@ When starting the K6 container, you can pass options in a variadic way to config #### Image If you need to set a different K6 Docker image, you can use `testcontainers.WithImage` with a valid Docker image -for Cassandra. E.g. `testcontainers.WithImage("szkiba/k6x:v0.3.1")`. +for k6x. E.g. `testcontainers.WithImage("szkiba/k6x:v0.3.1")`. {% include "../features/common_functional_options.md" %} From c25d30084f2b242ca9ae247c7b7a7f586ad6d63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Oct 2023 07:55:44 +0200 Subject: [PATCH 5/6] docs: add warning about k6x image --- docs/modules/k6.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index b00c71c639..d852fadf92 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -44,6 +44,9 @@ When starting the K6 container, you can pass options in a variadic way to config #### Image +!!! warning + The K6 module uses a custom Docker image to build the `k6` binary with all the required extensions. This image is based on the official `k6` image and it is available on [Docker Hub](https://hub.docker.com/r/szkiba/k6x). Therefore, only the `szkiba/k6x` image should be used with this module. + If you need to set a different K6 Docker image, you can use `testcontainers.WithImage` with a valid Docker image for k6x. E.g. `testcontainers.WithImage("szkiba/k6x:v0.3.1")`. From f24d8006306727a68bb3897913c425d205702bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20de=20la=20Pe=C3=B1a?= Date: Fri, 13 Oct 2023 15:52:19 +0200 Subject: [PATCH 6/6] docs: simplify Co-authored-by: pablochacin --- docs/modules/k6.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/modules/k6.md b/docs/modules/k6.md index d852fadf92..60e739f4b1 100644 --- a/docs/modules/k6.md +++ b/docs/modules/k6.md @@ -45,7 +45,7 @@ When starting the K6 container, you can pass options in a variadic way to config #### Image !!! warning - The K6 module uses a custom Docker image to build the `k6` binary with all the required extensions. This image is based on the official `k6` image and it is available on [Docker Hub](https://hub.docker.com/r/szkiba/k6x). Therefore, only the `szkiba/k6x` image should be used with this module. + The K6 module uses a `k6x` image to build a `k6` binary with all the required extensions. Therefore, only the [szkiba/k6x](https://hub.docker.com/r/szkiba/k6x) image should be used with this module. If you need to set a different K6 Docker image, you can use `testcontainers.WithImage` with a valid Docker image for k6x. E.g. `testcontainers.WithImage("szkiba/k6x:v0.3.1")`.