Skip to content

Commit

Permalink
e2e: fix failing tests due to docker plugin settings (#24234)
Browse files Browse the repository at this point in the history
  • Loading branch information
pkazmierczak authored Oct 17, 2024
1 parent f9cbaaf commit a22e563
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 181 deletions.
15 changes: 14 additions & 1 deletion e2e/docker/docker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func runRegistry(t *testing.T) {
// sure the registry is marked as insecure for docker, otherwise pulls will
// fail
_, sedCleanup := jobs3.Submit(t,
"./input/registry-auths.hcl",
"../docker_registry/registry-auths.hcl",
jobs3.Var("registry_address", address),
jobs3.Var("user", "root"),
jobs3.Var("helper_dir", "/usr/local/bin"),
Expand All @@ -67,6 +67,16 @@ func runRegistry(t *testing.T) {
jobs3.Timeout(20*time.Second),
)
t.Cleanup(sedCleanup)

_, dockerConfCleanup := jobs3.Submit(t,
"../docker_registry/registry-auths.hcl",
jobs3.Var("registry_address", address),
jobs3.Var("user", "root"),
jobs3.Var("docker_conf_dir", "/etc/docker"),
jobs3.WaitComplete("create-conf"),
jobs3.Timeout(20*time.Second),
)
t.Cleanup(dockerConfCleanup)
}

func testRedis(t *testing.T) {
Expand All @@ -78,6 +88,7 @@ func testRedis(t *testing.T) {
}

func testAuthBasic(t *testing.T) {
t.Skip("test disabled until we have a local docker registry setup with tf")
// find the private registry service
regAddr, regPort := findService(t, "registry")

Expand All @@ -93,6 +104,7 @@ func testAuthBasic(t *testing.T) {
}

func testAuthFileStatic(t *testing.T) {
t.Skip("test disabled until we have a local docker registry setup with tf")
// find the private registry service
regAddr, regPort := findService(t, "registry")

Expand All @@ -108,6 +120,7 @@ func testAuthFileStatic(t *testing.T) {
}

func testAuthHelper(t *testing.T) {
t.Skip("test disabled until we have a local docker registry setup with tf")
// find the private registry service
regAddr, regPort := findService(t, "registry")

Expand Down
72 changes: 72 additions & 0 deletions e2e/docker/input/docker_config.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: BUSL-1.1

variable "registry_address" {
type = string
description = "The HTTP address of the local registry"
}

variable "docker_conf_dir" {
type = string
description = "The directory in which daemon.json will be written."
default = "/tmp"
}

variable "user" {
type = string
description = "The user to create files as. Should be root in e2e."
# no default because dealing with root files is annoying locally
# try -var=user=$USER for local development
}

job "configure-docker" {
type = "sysbatch"

constraint {
attribute = "${attr.kernel.name}"
value = "linux"
}

group "create-conf" {
task "create-daemon-file" {
driver = "pledge"
user = "${var.user}"

config {
command = "cp"
args = ["${NOMAD_TASK_DIR}/daemon.json", "${var.docker_conf_dir}/daemon.json"]
promises = "stdio rpath wpath cpath"
unveil = ["r:${NOMAD_TASK_DIR}/daemon.json", "rwc:${var.docker_conf_dir}"]
}

template {
destination = "local/daemon.json"
perms = "644"
data = <<EOH
{
"insecure-registries": [
"${var.registry_address}"
]
}
EOH
}
resources {
cpu = 100
memory = 32
}
}

task "restart-docker" {
driver = "raw_exec" # TODO: see if this could be done with pledge?

config {
command = "service"
args = ["docker", "restart"]
}
resources {
cpu = 100
memory = 32
}
}
}
}
170 changes: 0 additions & 170 deletions e2e/docker/input/registry-auths.hcl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ variable "helper_dir" {
default = "/tmp"
}

variable "docker_conf_dir" {
type = string
description = "The directory in which daemon.json will be written."
default = "/tmp"
}

variable "user" {
type = string
description = "The user to create files as. Should be root in e2e."
Expand Down Expand Up @@ -71,14 +77,14 @@ username="auth_helper_user"
password="auth_helper_pass"
case "${value}" in
docker.io/*)
echo "must use local registry"
exit 3
;;
*)
${var.registry_address}*)
echo "{\"Username\": \"$username\", \"Secret\": \"$password\"}"
exit 0
;;
*)
echo "must use local registry"
exit 3
;;
esac
EOH
}
Expand Down
2 changes: 1 addition & 1 deletion e2e/podman/podman_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func runRegistry(t *testing.T) {

// run the sed job to fixup the auth.json file with correct address
_, sedCleanup := jobs3.Submit(t,
"./input/registry-auths.hcl",
"../docker_registry/registry-auths.hcl",
jobs3.Var("registry_address", address),
jobs3.Var("user", "root"),
jobs3.Var("helper_dir", "/usr/local/bin"),
Expand Down
4 changes: 0 additions & 4 deletions e2e/terraform/etc/nomad.d/client-linux.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ plugin "docker" {
volumes {
enabled = true
}
auth {
helper = "test.sh"
config = "/etc/auth.json"
}
}
}

Expand Down

0 comments on commit a22e563

Please sign in to comment.