diff --git a/internal/docker/builder.go b/internal/docker/builder.go index ab9abccb..721fdd9b 100644 --- a/internal/docker/builder.go +++ b/internal/docker/builder.go @@ -47,7 +47,10 @@ type Builder struct { } func NewBuilder(cfg *config.Complement) (*Builder, error) { - cli, err := client.NewEnvClient() + cli, err := client.NewClientWithOpts( + client.FromEnv, + client.WithAPIVersionNegotiation(), + ) if err != nil { return nil, err } diff --git a/internal/docker/deployer.go b/internal/docker/deployer.go index 310af59e..a72d9bbf 100644 --- a/internal/docker/deployer.go +++ b/internal/docker/deployer.go @@ -56,7 +56,10 @@ type Deployer struct { } func NewDeployer(deployNamespace string, cfg *config.Complement) (*Deployer, error) { - cli, err := client.NewEnvClient() + cli, err := client.NewClientWithOpts( + client.FromEnv, + client.WithAPIVersionNegotiation(), + ) if err != nil { return nil, err } diff --git a/test_main.go b/test_main.go index c04641a9..94ceda48 100644 --- a/test_main.go +++ b/test_main.go @@ -6,17 +6,25 @@ import ( "testing" "github.com/matrix-org/complement/b" + "github.com/matrix-org/complement/config" "github.com/matrix-org/complement/ct" ) var ( testPackage *TestPackage - customDeployer func(numServers int) Deployment + customDeployer func(t ct.TestLike, numServers int, config *config.Complement) Deployment ) type complementOpts struct { - cleanup func() - customDeployment func(numServers int) Deployment + // Args: + // - We pass in the Complement config (`testPackage.Config`) so the deployer can inspect + // `DebugLoggingEnabled`, `SpawnHSTimeout`, `PackageNamespace` etc. + cleanup func(config *config.Complement) + // Args: + // - We pass in `t` as there needs to be a way to handle an error in the custom deployer. + // - We pass in the Complement config (`testPackage.Config`) so the deployer can inspect + // `DebugLoggingEnabled`, `SpawnHSTimeout`, `PackageNamespace`, etc. + customDeployment func(t ct.TestLike, numServers int, config *config.Complement) Deployment } type opt func(*complementOpts) @@ -24,14 +32,14 @@ type opt func(*complementOpts) // It is called BEFORE Complement containers are destroyed. // This function should be used for per-suite cleanup operations e.g tearing down containers, killing // child processes, etc. -func WithCleanup(fn func()) opt { +func WithCleanup(fn func(config *config.Complement)) opt { return func(co *complementOpts) { co.cleanup = fn } } // WithDeployment adds a custom mechanism to deploy homeservers. -func WithDeployment(fn func(numServers int) Deployment) opt { +func WithDeployment(fn func(t ct.TestLike, numServers int, config *config.Complement) Deployment) opt { return func(co *complementOpts) { co.customDeployment = fn } @@ -64,7 +72,7 @@ func TestMain(m *testing.M, namespace string, customOpts ...opt) { } exitCode := m.Run() if opts.cleanup != nil { - opts.cleanup() + opts.cleanup(testPackage.Config) } testPackage.Cleanup() os.Exit(exitCode) @@ -91,7 +99,7 @@ func Deploy(t ct.TestLike, numServers int) Deployment { ct.Fatalf(t, "Deploy: testPackage not set, did you forget to call complement.TestMain?") } if customDeployer != nil { - return customDeployer(numServers) + return customDeployer(t, numServers, testPackage.Config) } return testPackage.Deploy(t, numServers) }