Skip to content

Commit 7d5adf5

Browse files
committed
add network cleanup and bump ryuk
1 parent c00b3a5 commit 7d5adf5

4 files changed

Lines changed: 13 additions & 17 deletions

File tree

lib/docker/api.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,13 @@ defmodule Testcontainers.Docker.Api do
196196
@dialyzer {:nowarn_function, create_network: 3}
197197
def create_network(name, conn, opts \\ []) when is_binary(name) do
198198
driver = Keyword.get(opts, :driver, "bridge")
199+
labels = Keyword.get(opts, :labels, %{})
199200

200201
body = %DockerEngineAPI.Model.NetworkCreateRequest{
201202
Name: name,
202203
Driver: driver,
203-
CheckDuplicate: true
204+
CheckDuplicate: true,
205+
Labels: labels
204206
}
205207

206208
case Api.Network.network_create(conn, body) do

lib/testcontainers.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,16 @@ defmodule Testcontainers do
254254

255255
@impl true
256256
def handle_call({:create_network, network_name}, from, state) do
257+
labels = %{
258+
Constants.container_sessionId_label() => state.session_id,
259+
Constants.container_version_label() => Constants.library_version(),
260+
Constants.container_lang_label() => Constants.container_lang_value(),
261+
Constants.container_label() => "true",
262+
Constants.container_reuse() => "false"
263+
}
264+
257265
Task.async(fn ->
258-
result = Api.create_network(network_name, state.conn)
266+
result = Api.create_network(network_name, state.conn, labels: labels)
259267
GenServer.reply(from, result)
260268
end)
261269

lib/util/constants.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ defmodule Testcontainers.Constants do
33

44
def library_name, do: :testcontainers
55
def library_version, do: "2.0.0-rc2"
6-
def ryuk_version, do: "0.13.0"
6+
def ryuk_version, do: "0.14.0"
77
def container_label, do: "org.testcontainers"
88
def container_lang_label, do: "org.testcontainers.lang"
99
def container_reuse_hash_label, do: "org.testcontainers.reuse-hash"

run_tests.sh

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,14 @@
22
set -o pipefail
33

44
TOTAL_RUNS=10
5-
CLEANUP_IMAGES=false
65
FAILURES=()
76

8-
while [[ $# -gt 0 ]]; do
9-
case $1 in
10-
--cleanup-images) CLEANUP_IMAGES=true; shift ;;
11-
*) echo "Unknown option: $1"; exit 1 ;;
12-
esac
13-
done
147

158
for i in $(seq 1 $TOTAL_RUNS); do
169
echo "========================================"
1710
echo "Run $i/$TOTAL_RUNS"
1811
echo "========================================"
1912

20-
echo "Cleaning up Docker containers..."
21-
docker rm -f $(docker ps -aq) &>/dev/null
22-
if [ "$CLEANUP_IMAGES" = true ]; then
23-
echo "Cleaning up Docker images..."
24-
docker rmi -f $(docker images -q) &>/dev/null
25-
fi
26-
2713
echo "Running tests..."
2814
output=$(MIX_ENV=test mix test 2>&1)
2915
exit_code=$?

0 commit comments

Comments
 (0)