vuls: init at 0.27.0
[NixPkgs.git] / nixos / tests / docker-registry.nix
blob4f033fc30b191f908bfd760524f5fdfe93d38f0c
1 # This test runs docker-registry and check if it works
3 import ./make-test-python.nix ({ pkgs, ...} : {
4   name = "docker-registry";
5   meta = with pkgs.lib.maintainers; {
6     maintainers = [ globin ironpinguin cafkafk ];
7   };
9   nodes = {
10     registry = { ... }: {
11       services.dockerRegistry.enable = true;
12       services.dockerRegistry.enableDelete = true;
13       services.dockerRegistry.port = 8080;
14       services.dockerRegistry.listenAddress = "0.0.0.0";
15       services.dockerRegistry.enableGarbageCollect = true;
16       services.dockerRegistry.openFirewall = true;
17     };
19     client1 = { ... }: {
20       virtualisation.docker.enable = true;
21       virtualisation.docker.extraOptions = "--insecure-registry registry:8080";
22     };
24     client2 = { ... }: {
25       virtualisation.docker.enable = true;
26       virtualisation.docker.extraOptions = "--insecure-registry registry:8080";
27     };
28   };
30   testScript = ''
31     client1.start()
32     client1.wait_for_unit("docker.service")
33     client1.succeed("tar cv --files-from /dev/null | docker import - scratch")
34     client1.succeed("docker tag scratch registry:8080/scratch")
36     registry.start()
37     registry.wait_for_unit("docker-registry.service")
38     registry.wait_for_open_port(8080)
39     client1.succeed("docker push registry:8080/scratch")
41     client2.start()
42     client2.wait_for_unit("docker.service")
43     client2.succeed("docker pull registry:8080/scratch")
44     client2.succeed("docker images | grep scratch")
46     client2.succeed(
47         "curl -fsS -X DELETE registry:8080/v2/scratch/manifests/$(curl -fsS -I -H\"Accept: application/vnd.docker.distribution.manifest.v2+json\" registry:8080/v2/scratch/manifests/latest | grep Docker-Content-Digest | sed -e 's/Docker-Content-Digest: //' | tr -d '\\r')"
48     )
50     registry.systemctl("start docker-registry-garbage-collect.service")
51     registry.wait_until_fails("systemctl status docker-registry-garbage-collect.service")
52     registry.wait_for_unit("docker-registry.service")
54     registry.fail("ls -l /var/lib/docker-registry/docker/registry/v2/blobs/sha256/*/*/data")
56     client1.succeed("docker push registry:8080/scratch")
57     registry.succeed(
58         "ls -l /var/lib/docker-registry/docker/registry/v2/blobs/sha256/*/*/data"
59     )
60   '';