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.
This commit is contained in:
1 parent
dde833e8cf
commit
25dff3322a
1 file changed
+4
-1
@@ -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}
|
||||
|
||||
Reference in new issue
Block a user