From 25dff3322a2f47e41705954f2cb2284b3f36b936 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Mon, 29 Jan 2024 09:49:57 -0500 Subject: [PATCH] test: Randomize docker network name (#4306) We were observing TestAuthorizeSession_Errors failing in CI due to it complaining that a docker network with name TestAuthorizeSession_Errors already exists. Looking deeper, it turns out that internal/daemon/controller/handlers/targets/tcp and internal/daemon/controller/handlers/targets/ssh both have a test with that same name, and for some reason, they often run on top of each other, causing one of the tests to fail to create a docker network. To prevent any conflicts with tests that have the same name, this commit randomizes the network name that is created. --- internal/credential/vault/supported.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/credential/vault/supported.go b/internal/credential/vault/supported.go index fbd30a43f..999413d38 100644 --- a/internal/credential/vault/supported.go +++ b/internal/credential/vault/supported.go @@ -21,6 +21,7 @@ import ( "github.com/hashicorp/boundary/globals" "github.com/hashicorp/boundary/internal/db/common" "github.com/hashicorp/go-rootcerts" + "github.com/hashicorp/go-secure-stdlib/base62" vault "github.com/hashicorp/vault/api" _ "github.com/jackc/pgx/v5/stdlib" "github.com/ory/dockertest/v3" @@ -169,7 +170,9 @@ func gotNewServer(t testing.TB, opt ...TestOption) *TestVaultServer { // Engine: 20.10.6 if opts.dockerNetwork { - network, err := pool.CreateNetwork(t.Name()) + id, err := base62.Random(4) + require.NoError(err) + network, err := pool.CreateNetwork(fmt.Sprintf("%s-%s", t.Name(), id)) require.NoError(err) server.network = network dockerOptions.Networks = []*dockertest.Network{network}