2016-09-18 20:57:01 +02:00
|
|
|
# This test runs docker-registry and check if it works
|
|
|
|
|
2019-11-24 13:35:09 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
2016-09-18 20:57:01 +02:00
|
|
|
name = "docker-registry";
|
2021-01-10 20:08:30 +01:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2023-10-18 19:58:47 +02:00
|
|
|
maintainers = [ globin ironpinguin ];
|
2016-09-18 20:57:01 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
2018-07-20 22:56:59 +02:00
|
|
|
registry = { ... }: {
|
2016-09-18 20:57:01 +02:00
|
|
|
services.dockerRegistry.enable = true;
|
2018-03-26 13:54:01 +02:00
|
|
|
services.dockerRegistry.enableDelete = true;
|
2016-09-18 20:57:01 +02:00
|
|
|
services.dockerRegistry.port = 8080;
|
|
|
|
services.dockerRegistry.listenAddress = "0.0.0.0";
|
2018-04-06 15:11:52 +02:00
|
|
|
services.dockerRegistry.enableGarbageCollect = true;
|
2016-09-18 20:57:01 +02:00
|
|
|
networking.firewall.allowedTCPPorts = [ 8080 ];
|
|
|
|
};
|
|
|
|
|
2018-07-20 22:56:59 +02:00
|
|
|
client1 = { ... }: {
|
2016-09-18 20:57:01 +02:00
|
|
|
virtualisation.docker.enable = true;
|
|
|
|
virtualisation.docker.extraOptions = "--insecure-registry registry:8080";
|
|
|
|
};
|
|
|
|
|
2018-07-20 22:56:59 +02:00
|
|
|
client2 = { ... }: {
|
2016-09-18 20:57:01 +02:00
|
|
|
virtualisation.docker.enable = true;
|
|
|
|
virtualisation.docker.extraOptions = "--insecure-registry registry:8080";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2019-11-24 13:35:09 +01:00
|
|
|
client1.start()
|
|
|
|
client1.wait_for_unit("docker.service")
|
|
|
|
client1.succeed("tar cv --files-from /dev/null | docker import - scratch")
|
|
|
|
client1.succeed("docker tag scratch registry:8080/scratch")
|
|
|
|
|
|
|
|
registry.start()
|
|
|
|
registry.wait_for_unit("docker-registry.service")
|
2022-06-11 14:22:53 +02:00
|
|
|
registry.wait_for_open_port(8080)
|
2019-11-24 13:35:09 +01:00
|
|
|
client1.succeed("docker push registry:8080/scratch")
|
|
|
|
|
|
|
|
client2.start()
|
|
|
|
client2.wait_for_unit("docker.service")
|
|
|
|
client2.succeed("docker pull registry:8080/scratch")
|
|
|
|
client2.succeed("docker images | grep scratch")
|
|
|
|
|
|
|
|
client2.succeed(
|
|
|
|
"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')"
|
|
|
|
)
|
|
|
|
|
|
|
|
registry.systemctl("start docker-registry-garbage-collect.service")
|
|
|
|
registry.wait_until_fails("systemctl status docker-registry-garbage-collect.service")
|
|
|
|
registry.wait_for_unit("docker-registry.service")
|
|
|
|
|
|
|
|
registry.fail("ls -l /var/lib/docker-registry/docker/registry/v2/blobs/sha256/*/*/data")
|
|
|
|
|
|
|
|
client1.succeed("docker push registry:8080/scratch")
|
|
|
|
registry.succeed(
|
|
|
|
"ls -l /var/lib/docker-registry/docker/registry/v2/blobs/sha256/*/*/data"
|
|
|
|
)
|
2016-09-18 20:57:01 +02:00
|
|
|
'';
|
|
|
|
})
|