Skip to content

Commit

Permalink
Move away from docker e2e images, use gcr and ghcr
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Nola <[email protected]>
  • Loading branch information
dereknola committed Feb 28, 2025
1 parent a61e581 commit a764989
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
44 changes: 22 additions & 22 deletions tests/docker/autoimport/autoimport_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ var _ = Describe("Verify Create", Ordered, func() {
})

It("Create file for auto import and search in the image store", func() {
cmd := `echo docker.io/library/redis:latest | tee /var/lib/rancher/k3s/agent/images/testautoimport.txt`
cmd := `echo mirror.gcr.io/redis:latest | tee /var/lib/rancher/k3s/agent/images/testautoimport.txt`
_, err := tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/redis`
cmd := `k3s ctr images list | grep mirror.gcr.io/redis`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Change name for the file and see if the label is still pinned", func() {
Expand All @@ -62,50 +62,50 @@ var _ = Describe("Verify Create", Ordered, func() {
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/redis`
cmd := `k3s ctr images list | grep mirror.gcr.io/redis`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Create, remove and create again a file", func() {
cmd := `echo docker.io/library/busybox:latest | tee /var/lib/rancher/k3s/agent/images/bb.txt`
cmd := `echo mirror.gcr.io/busybox:latest | tee /var/lib/rancher/k3s/agent/images/bb.txt`
_, err := tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())

cmd = `rm /var/lib/rancher/k3s/agent/images/bb.txt`
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())

cmd = `echo docker.io/library/busybox:latest | tee /var/lib/rancher/k3s/agent/images/bb.txt`
cmd = `echo mirror.gcr.io/busybox:latest | tee /var/lib/rancher/k3s/agent/images/bb.txt`
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Move the folder, add a image and then see if the image is going to be pinned", func() {
cmd := `mv /var/lib/rancher/k3s/agent/images /var/lib/rancher/k3s/agent/test`
_, err := tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

cmd = `echo 'docker.io/library/mysql:latest' | sudo tee /var/lib/rancher/k3s/agent/test/mysql.txt`
cmd = `echo 'mirror.gcr.io/mysql:latest' | sudo tee /var/lib/rancher/k3s/agent/test/mysql.txt`
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Expand All @@ -114,10 +114,10 @@ var _ = Describe("Verify Create", Ordered, func() {
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/mysql`
cmd := `k3s ctr images list | grep mirror.gcr.io/mysql`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Restarts normally", func() {
Expand All @@ -129,10 +129,10 @@ var _ = Describe("Verify Create", Ordered, func() {

It("Verify bb.txt image and see if are pinned", func() {
Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Removes bb.txt file", func() {
Expand All @@ -141,10 +141,10 @@ var _ = Describe("Verify Create", Ordered, func() {
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).Should(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

It("Restarts normally", func() {
Expand All @@ -156,10 +156,10 @@ var _ = Describe("Verify Create", Ordered, func() {

It("Verify if bb.txt image is unpinned", func() {
Eventually(func(g Gomega) {
cmd := `k3s ctr images list | grep library/busybox`
cmd := `k3s ctr images list | grep mirror.gcr.io/busybox`
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).ShouldNot(ContainSubstring("io.cattle.k3s.pinned=pinned"))
g.Expect(tc.Servers[0].RunCmdOnNode(cmd)).ShouldNot(ContainSubstring("io.cri-containerd.pinned=pinned"))
}, "620s", "5s").Should(Succeed())
}, "300s", "5s").Should(Succeed())
})

})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/privateregistry/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def provision(vm, role, role_num, node_num)
endpoint:
- http://%{net}.100:5000
rewrite:
"^library/(.*)$": "docker-io-library/$1"
"^library/(.*)$": "ghcr-io-library/$1"
' > /etc/rancher/k3s/registries.yaml
SCRIPT

Expand Down
16 changes: 8 additions & 8 deletions tests/e2e/privateregistry/privateregistry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,32 +78,32 @@ var _ = Describe("Verify Create", Ordered, func() {
Expect(err).NotTo(HaveOccurred())

})
// Mirror the image as NODEIP:5000/docker-io-library/nginx:1.27.3, but reference it as my-registry.local/library/nginx:1.27.3 -
// Mirror the image as NODEIP:5000/ghcr-io-library/nginx:1.26.2, but reference it as my-registry.local/library/nginx:1.26.2 -
// the rewrite in registries.yaml's entry for my-registry.local should ensure that it is rewritten properly when pulling from
// NODEIP:5000 as a mirror.
It("Should pull and image from dockerhub and send it to private registry", func() {
cmd := "docker pull docker.io/library/nginx:1.27.3"
It("Should pull and image from ghcr and send it to private registry", func() {
cmd := "docker pull ghcr.io/linuxserver/nginx:1.26.2"
_, err := tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

nodeIP, err := tc.Servers[0].FetchNodeExternalIP()
Expect(err).NotTo(HaveOccurred())

cmd = "docker tag docker.io/library/nginx:1.27.3 " + nodeIP + ":5000/docker-io-library/nginx:1.27.3"
cmd = "docker tag ghcr.io/linuxserver/nginx:1.26.2 " + nodeIP + ":5000/ghcr-io-library/nginx:1.26.2"
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

cmd = "docker push " + nodeIP + ":5000/docker-io-library/nginx:1.27.3"
cmd = "docker push " + nodeIP + ":5000/ghcr-io-library/nginx:1.26.2"
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)

cmd = "docker image remove docker.io/library/nginx:1.27.3 " + nodeIP + ":5000/docker-io-library/nginx:1.27.3"
cmd = "docker image remove ghcr.io/linuxserver/nginx:1.26.2 " + nodeIP + ":5000/ghcr-io-library/nginx:1.26.2"
_, err = tc.Servers[0].RunCmdOnNode(cmd)
Expect(err).NotTo(HaveOccurred(), "failed: "+cmd)
})

It("Should create and validate deployment with private registry on", func() {
res, err := tc.Servers[0].RunCmdOnNode("kubectl create deployment my-webpage --image=my-registry.local/library/nginx:1.27.3")
res, err := tc.Servers[0].RunCmdOnNode("kubectl create deployment my-webpage --image=my-registry.local/library/nginx:1.26.2")
fmt.Println(res)
Expect(err).NotTo(HaveOccurred())

Expand All @@ -120,7 +120,7 @@ var _ = Describe("Verify Create", Ordered, func() {
}, "60s", "5s").Should(Succeed())

cmd := "curl -m 5 -s -f http://" + pod.Status.PodIP
Expect(tc.Servers[0].RunCmdOnNode(cmd)).To(ContainSubstring("Welcome to nginx!"))
Expect(tc.Servers[0].RunCmdOnNode(cmd)).To(ContainSubstring("Welcome to our server"))
})

})
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/s3/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def provision(vm, role, role_num, node_num)


runS3mock = <<~'SCRIPT'
docker run -p 9090:9090 -p 9191:9191 -d -e initialBuckets=test-bucket -e debug=true -t adobe/s3mock
docker run -p 9090:9090 -p 9191:9191 -d -e initialBuckets=test-bucket -e debug=true -t mirror.gcr.io/adobe/s3mock
SCRIPT


Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/startup/startup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,9 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
})
Context("Verify server picks up preloaded images on start", func() {
It("Downloads and preloads images", func() {
_, err := tc.Servers[0].RunCmdOnNode("docker pull ranchertest/mytestcontainer:latest")
_, err := tc.Servers[0].RunCmdOnNode("docker pull rancher/shell:v0.1.28")
Expect(err).NotTo(HaveOccurred())
_, err = tc.Servers[0].RunCmdOnNode("docker save ranchertest/mytestcontainer:latest -o /tmp/mytestcontainer.tar")
_, err = tc.Servers[0].RunCmdOnNode("docker save rancher/shell:v0.1.28 -o /tmp/mytestcontainer.tar")
Expect(err).NotTo(HaveOccurred())
_, err = tc.Servers[0].RunCmdOnNode("mkdir -p /var/lib/rancher/k3s/agent/images/")
Expect(err).NotTo(HaveOccurred())
Expand All @@ -352,9 +352,9 @@ var _ = Describe("Various Startup Configurations", Ordered, func() {
})
It("has loaded the test container image", func() {
Eventually(func() (string, error) {
cmd := "k3s crictl images | grep ranchertest/mytestcontainer"
cmd := "k3s crictl images | grep rancher/shell"
return tc.Servers[0].RunCmdOnNode(cmd)
}, "120s", "5s").Should(ContainSubstring("ranchertest/mytestcontainer"))
}, "120s", "5s").Should(ContainSubstring("rancher/shell"))
})
It("Kills the cluster", func() {
err := KillK3sCluster(tc.AllNodes())
Expand Down

0 comments on commit a764989

Please sign in to comment.