From dd2248a01f2d6ded8b51034f37810cf819f24387 Mon Sep 17 00:00:00 2001 From: Paulo Zenida Date: Wed, 2 Nov 2022 19:27:30 +0000 Subject: [PATCH] removing docker-compose and relying only on a single docker container --- docker_test.go | 46 ++++++++++++++++++++++++--- testresources/docker-compose-auth.yml | 14 -------- 2 files changed, 41 insertions(+), 19 deletions(-) delete mode 100644 testresources/docker-compose-auth.yml diff --git a/docker_test.go b/docker_test.go index d14e5506c2..2da3c28ae7 100644 --- a/docker_test.go +++ b/docker_test.go @@ -1075,6 +1075,7 @@ func Test_BuildContainerFromDockerfileWithAuthConfig_ShouldSucceedWithAuthConfig }, }, }, + ExposedPorts: []string{"6379/tcp"}, WaitingFor: wait.ForLog("Ready to accept connections"), } @@ -1107,17 +1108,52 @@ func Test_BuildContainerFromDockerfileWithAuthConfig_ShouldFailWithoutAuthConfig } func prepareLocalRegistryWithAuth(t *testing.T) { - compose, err := NewDockerCompose("./testresources/docker-compose-auth.yml") - assert.NoError(t, err, "NewDockerCompose()") + ctx := context.Background() + wd, err := os.Getwd() + assert.NoError(t, err) + req := ContainerRequest{ + Image: "registry:2", + ExposedPorts: []string{"5000:5000/tcp"}, + Env: map[string]string{ + "REGISTRY_AUTH": "htpasswd", + "REGISTRY_AUTH_HTPASSWD_REALM": "Registry", + "REGISTRY_AUTH_HTPASSWD_PATH": "/auth/htpasswd", + "REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY": "/data", + }, + Mounts: ContainerMounts{ + ContainerMount{ + Source: GenericBindMountSource{ + HostPath: fmt.Sprintf("%s/testresources/auth", wd), + }, + Target: "/auth", + }, + ContainerMount{ + Source: GenericBindMountSource{ + HostPath: fmt.Sprintf("%s/testresources/data", wd), + }, + Target: "/data", + }, + }, + WaitingFor: wait.ForExposedPort(), + } + + genContainerReq := GenericContainerRequest{ + ProviderType: providerType, + ContainerRequest: req, + Started: true, + } + + t.Log("creating registry container") + + registryC, err := GenericContainer(ctx, genContainerReq) + assert.NoError(t, err) t.Cleanup(func() { - assert.NoError(t, compose.Down(context.Background(), RemoveOrphans(true), RemoveImagesLocal), "compose.Down()") + assert.NoError(t, registryC.Terminate(context.Background())) }) ctx, cancel := context.WithCancel(context.Background()) t.Cleanup(cancel) - - assert.NoError(t, compose.Up(ctx, Wait(true)), "compose.Up()") } func prepareRedisImage(ctx context.Context, req ContainerRequest, t *testing.T) (Container, error) { diff --git a/testresources/docker-compose-auth.yml b/testresources/docker-compose-auth.yml deleted file mode 100644 index 61469bbdef..0000000000 --- a/testresources/docker-compose-auth.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: '3' -services: - registry: - image: registry:2 - ports: - - "5000:5000" - environment: - REGISTRY_AUTH: htpasswd - REGISTRY_AUTH_HTPASSWD_REALM: Registry - REGISTRY_AUTH_HTPASSWD_PATH: /auth/htpasswd - REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY: /data - volumes: - - ./auth:/auth - - ./data:/data \ No newline at end of file