mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-21 04:28:40 +03:00
Merge pull request #114241 from sorki/tests/cntr
This commit is contained in:
commit
3d72b0b6b0
@ -69,6 +69,7 @@ in
|
|||||||
cjdns = handleTest ./cjdns.nix {};
|
cjdns = handleTest ./cjdns.nix {};
|
||||||
clickhouse = handleTest ./clickhouse.nix {};
|
clickhouse = handleTest ./clickhouse.nix {};
|
||||||
cloud-init = handleTest ./cloud-init.nix {};
|
cloud-init = handleTest ./cloud-init.nix {};
|
||||||
|
cntr = handleTest ./cntr.nix {};
|
||||||
cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
|
cockroachdb = handleTestOn ["x86_64-linux"] ./cockroachdb.nix {};
|
||||||
consul = handleTest ./consul.nix {};
|
consul = handleTest ./consul.nix {};
|
||||||
containers-bridge = handleTest ./containers-bridge.nix {};
|
containers-bridge = handleTest ./containers-bridge.nix {};
|
||||||
|
63
nixos/tests/cntr.nix
Normal file
63
nixos/tests/cntr.nix
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
# Test for cntr tool
|
||||||
|
{ system ? builtins.currentSystem, config ? { }
|
||||||
|
, pkgs ? import ../.. { inherit system config; }, lib ? pkgs.lib }:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
|
||||||
|
|
||||||
|
mkOCITest = backend:
|
||||||
|
makeTest {
|
||||||
|
name = "cntr-${backend}";
|
||||||
|
|
||||||
|
meta = { maintainers = with lib.maintainers; [ srk mic92 ]; };
|
||||||
|
|
||||||
|
nodes = {
|
||||||
|
${backend} = { pkgs, ... }: {
|
||||||
|
environment.systemPackages = [ pkgs.cntr ];
|
||||||
|
virtualisation.oci-containers = {
|
||||||
|
inherit backend;
|
||||||
|
containers.nginx = {
|
||||||
|
image = "nginx-container";
|
||||||
|
imageFile = pkgs.dockerTools.examples.nginx;
|
||||||
|
ports = [ "8181:80" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
${backend}.wait_for_unit("${backend}-nginx.service")
|
||||||
|
result = ${backend}.wait_until_succeeds(
|
||||||
|
"cntr attach -t ${backend} nginx sh -- -c 'curl localhost | grep Hello'"
|
||||||
|
)
|
||||||
|
assert "Hello" in result
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
mkContainersTest = makeTest {
|
||||||
|
name = "cntr-containers";
|
||||||
|
|
||||||
|
meta = with pkgs.lib.maintainers; { maintainers = [ sorki mic92 ]; };
|
||||||
|
|
||||||
|
machine = { lib, ... }: {
|
||||||
|
environment.systemPackages = [ pkgs.cntr ];
|
||||||
|
containers.test = {
|
||||||
|
autoStart = true;
|
||||||
|
privateNetwork = true;
|
||||||
|
hostAddress = "172.16.0.1";
|
||||||
|
localAddress = "172.16.0.2";
|
||||||
|
config = { };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
testScript = ''
|
||||||
|
machine.start()
|
||||||
|
machine.wait_for_unit("container@test.service")
|
||||||
|
machine.succeed("cntr attach test sh -- -c 'ping -c5 172.16.0.1'")
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
nixos-container = mkContainersTest;
|
||||||
|
} // (lib.foldl' (attrs: backend: attrs // { ${backend} = mkOCITest backend; })
|
||||||
|
{ } [ "docker" "podman" ])
|
@ -1,4 +1,4 @@
|
|||||||
{ lib, rustPlatform, fetchFromGitHub }:
|
{ lib, rustPlatform, fetchFromGitHub, nixosTests }:
|
||||||
|
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage rec {
|
||||||
pname = "cntr";
|
pname = "cntr";
|
||||||
@ -13,6 +13,10 @@ rustPlatform.buildRustPackage rec {
|
|||||||
|
|
||||||
cargoSha256 = "sha256-3e5wDne6Idu+kDinHPcAKHfH/d4DrGg90GkiMbyF280=";
|
cargoSha256 = "sha256-3e5wDne6Idu+kDinHPcAKHfH/d4DrGg90GkiMbyF280=";
|
||||||
|
|
||||||
|
passthru.tests = {
|
||||||
|
nixos = nixosTests.cntr;
|
||||||
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "A container debugging tool based on FUSE";
|
description = "A container debugging tool based on FUSE";
|
||||||
homepage = "https://github.com/Mic92/cntr";
|
homepage = "https://github.com/Mic92/cntr";
|
||||||
|
Loading…
Reference in New Issue
Block a user