Skip to content

Commit 69a8f73

Browse files
committed
Pin image sha for testing and fix volume expectations
1 parent 11cb2fb commit 69a8f73

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/test/java/org/jenkinsci/plugins/docker/workflow/client/DockerClientTest.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,22 @@ public void setup() throws Exception {
5757

5858
@Test
5959
public void test_run() throws IOException, InterruptedException {
60+
// Pin to a specific sha256 hash of the image to avoid any potential issues with the image changing in the future.
61+
// Original image tag: docker:20.10.9-dind
62+
String image = "docker.io/library/docker@sha256:d842418d21545fde57c2512681d9bdc4ce0e54f2e0305a293ee20a9b6166932b";
6063
EnvVars launchEnv = DockerTestUtil.newDockerLaunchEnv();
6164
String containerId =
62-
dockerClient.run(launchEnv, "docker:20.10.9-dind", null, null, Collections.<String, String>emptyMap(), Collections.<String>emptyList(), new EnvVars(),
65+
dockerClient.run(launchEnv, image, null, null, Collections.<String, String>emptyMap(), Collections.<String>emptyList(), new EnvVars(),
6366
dockerClient.whoAmI(), "cat");
6467
Assert.assertEquals(64, containerId.length());
6568
ContainerRecord containerRecord = dockerClient.getContainerRecord(launchEnv, containerId);
66-
Assert.assertEquals(dockerClient.inspect(launchEnv, "docker:20.10.9-dind", ".Id"), containerRecord.getImageId());
69+
Assert.assertEquals(dockerClient.inspect(launchEnv, image, ".Id"), containerRecord.getImageId());
6770
Assert.assertTrue(containerRecord.getContainerName().length() > 0);
6871
Assert.assertTrue(containerRecord.getHost().length() > 0);
6972
Assert.assertTrue(containerRecord.getCreated() > 1000000000000L);
70-
Assert.assertEquals(Collections.<String>emptyList(), dockerClient.getVolumes(launchEnv, containerId));
7173

72-
// Check that an anonymous volume was created
74+
// Check that an anonymous volume was created mounted at /var/lib/docker
75+
Assert.assertEquals(Collections.<String>singletonList("/var/lib/docker"), dockerClient.getVolumes(launchEnv, containerId));
7376
String anonymousVolumeName = dockerClient.inspect(launchEnv, containerId, "range .Mounts }}{{ .Name }}{{ end");
7477
Assert.assertEquals(64, anonymousVolumeName.length());
7578

0 commit comments

Comments
 (0)