Skip to content
Open
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ Before getting started, let's make sure you have everything you need for this wo
You'll need Java 17 or newer for this workshop.
Testcontainers libraries are compatible with Java 8+, but this workshop uses a Spring Boot 3.x application which requires Java 17 or newer.

We would recommend using [SDKMAN](https://sdkman.io/) to install Java on your machine if you are using MacOS, Linux or Windows WSL.
We would recommend using [SDKMAN](https://sdkman.io/) to install Java on your machine if you are using macOS, Linux or Windows WSL.

### Install Docker
You need to have a Docker environment to use Testcontainers.

* You can use Docker Desktop on your machine.
* You can use [Testcontainers Cloud](https://testcontainers.com/cloud). If you are going to use Testcontainers Cloud, then you need to install [Testcontainers Desktop](https://testcontainers.com/desktop/) app.
* If you are using MacOS, you can use Testcontainers Desktop Embedded Runtime.
* If you are using macOS, you can use Testcontainers Desktop Embedded Runtime.

* If you are using a local Docker, check by running:

Expand Down
2 changes: 1 addition & 1 deletion module-3/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ messages from it.
1. Annotate `KafkaCatTest` with `@Testcontainers`

> [!NOTE]
> `@Tescontainers` will manage lifecycle of containers annotated with `@Container`
> `@Testcontainers` will manage lifecycle of containers annotated with `@Container`

2. Create a network to connect both containers

Expand Down
2 changes: 1 addition & 1 deletion module-5/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void reset() {

6. Add the call to `snapshot` as the last action to the `containerIsStarted` method.

7. Let's test how it works now. Setup the test `PostgresWithTemplatesTest` by creating the `PostgresWithTemplates` container, wiring the `JDBCTemplate`, and configuring the context to use our container:
7. Let's test how it works now. Set up the test `PostgresWithTemplatesTest` by creating the `PostgresWithTemplates` container, wiring the `JDBCTemplate`, and configuring the context to use our container:

```java
static PostgresWithTemplates pg = new PostgresWithTemplates();
Expand Down
12 changes: 6 additions & 6 deletions module-6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

We're going to create tests that use an Ollama module and enhance its lifecycle so the modified images are cached.

2. Here's an example of a code that starts the Ollama module, and accesses its API to ensure it's up and running.
2. Here's an example of code that starts the Ollama module, and accesses its API to ensure it's up and running.
Put it into the `OllamaContainerTest` class and make it a test.
(Note how containers are `AutoCloseable` so you can spin use `try-with-resources` with them).
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Normally it would be spin up, but that didn't seem to fit here.

(Note how containers are `AutoCloseable` so you can use `try-with-resources` with them).

```java
try (
Expand All @@ -20,7 +20,7 @@ try (
```

3. By default, the Ollama Docker images don't have any models inside.
So if we want to actually use it to run any inference we need to download the model into the container.
So if we want to actually use it to run an inference we need to download the model into the container.
Create another test method and download a model into the Ollama container.

```java
Expand All @@ -36,7 +36,7 @@ try (OllamaContainer ollama = new OllamaContainer("ollama/ollama:0.1.26")) {
assertThat(modelName).contains("all-minilm");
}
```
4. When you run this test the model is being pulled, and when we rerun the test, it will be pulled again, and again.
4. When you run this test, the model is being pulled, and when we rerun the test, it will be pulled again, and again.
This is not ideal, so we can use the `commitToImage` method from the `OllamaContainer` to persist the model in a new Docker image.
See how you can use the lower level Docker Client API to work with the images:

Expand Down Expand Up @@ -101,7 +101,7 @@ try (
}
```

8. Modify the custom image name (to get a clean stat) and run the test a few time to compare the execution time on the first run and the next ones.
8. Modify the custom image name (to get a clean stat) and run the test several times to compare the execution time on the first run and the next ones.

9. A nice detail of the `OllamaContainer` module is how it can automatically determine and enable the GPU support on runtimes that support it.
This is code from the OllamaContainer class that does this. Learn how you can use Docker Client API and the `withCreateContainerCmdModifier` method to enable it.
Expand All @@ -116,7 +116,7 @@ if (runtimes != null && runtimes.containsKey("nvidia")) {
}
```

10. You can also limit the resources a container has access to like CPU and memory. Here's an example of a test that checks the GC a Java process selects in constrained environments:
10. You can also limit the resources for a container like CPU and memory. Here's an example of a test that checks the GC a Java process selects in constrained environments:
Add it to your test class, run the test, explore the results.

```java
Expand Down
2 changes: 1 addition & 1 deletion module-8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ helloworld.start();
```
10. Now we have the application to point our tunnel to, instantiate the `CloudflaredContainer` and point it to the `helloworld.getFirstMappedPort()`;

11. Assuming you have a valus in the `String url = cloudflare.getPublicUrl();` use the following method to try consuming the url (and ignoring the exceptions if the tunnel is declared, but Cloudflare didn't yet provision it).
11. Assuming you have a value in the `String url = cloudflare.getPublicUrl();` use the following method to try consuming the url (and ignoring the exceptions if the tunnel is declared, but Cloudflare didn't yet provision it).
Note that we disable the DNS caching, because the domain might not be available during the first attempt, but we want to ignore it and try without cached DNS later.

```java
Expand Down