nixos/ipfs: convert tests to python driver & simplify
This commit is contained in:
parent
3e6e4ce55c
commit
8b5707b547
|
@ -143,6 +143,7 @@ in
|
||||||
initrdNetwork = handleTest ./initrd-network.nix {};
|
initrdNetwork = handleTest ./initrd-network.nix {};
|
||||||
installer = handleTest ./installer.nix {};
|
installer = handleTest ./installer.nix {};
|
||||||
iodine = handleTest ./iodine.nix {};
|
iodine = handleTest ./iodine.nix {};
|
||||||
|
ipfs = handleTest ./ipfs.nix {};
|
||||||
ipv6 = handleTest ./ipv6.nix {};
|
ipv6 = handleTest ./ipv6.nix {};
|
||||||
jackett = handleTest ./jackett.nix {};
|
jackett = handleTest ./jackett.nix {};
|
||||||
jellyfin = handleTest ./jellyfin.nix {};
|
jellyfin = handleTest ./jellyfin.nix {};
|
||||||
|
|
|
@ -1,55 +1,25 @@
|
||||||
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
||||||
import ./make-test.nix ({ pkgs, ...} : {
|
|
||||||
name = "ipfs";
|
name = "ipfs";
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ mguentner ];
|
maintainers = [ mguentner ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes.machine = { ... }: {
|
||||||
adder =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
services.ipfs = {
|
services.ipfs = {
|
||||||
enable = true;
|
enable = true;
|
||||||
defaultMode = "norouting";
|
|
||||||
gatewayAddress = "/ip4/127.0.0.1/tcp/2323";
|
|
||||||
apiAddress = "/ip4/127.0.0.1/tcp/2324";
|
apiAddress = "/ip4/127.0.0.1/tcp/2324";
|
||||||
};
|
};
|
||||||
networking.firewall.allowedTCPPorts = [ 4001 ];
|
|
||||||
};
|
|
||||||
getter =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
services.ipfs = {
|
|
||||||
enable = true;
|
|
||||||
defaultMode = "norouting";
|
|
||||||
autoMount = true;
|
|
||||||
};
|
|
||||||
networking.firewall.allowedTCPPorts = [ 4001 ];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
startAll;
|
start_all()
|
||||||
$adder->waitForUnit("ipfs-norouting");
|
machine.wait_for_unit("ipfs")
|
||||||
$getter->waitForUnit("ipfs-norouting");
|
|
||||||
|
|
||||||
# wait until api is available
|
machine.wait_until_succeeds("ipfs --api /ip4/127.0.0.1/tcp/2324 id")
|
||||||
$adder->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/2324 id");
|
ipfs_hash = machine.succeed(
|
||||||
my $addrId = $adder->succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id -f=\"<id>\"");
|
"echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | awk '{ print $2 }'"
|
||||||
my $addrIp = (split /[ \/]+/, $adder->succeed("ip -o -4 addr show dev eth1"))[3];
|
)
|
||||||
|
|
||||||
$adder->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/2324 config Addresses.Gateway | grep /ip4/127.0.0.1/tcp/2323)\" ]");
|
machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord")
|
||||||
|
|
||||||
# wait until api is available
|
|
||||||
$getter->waitUntilSucceeds("ipfs --api /ip4/127.0.0.1/tcp/5001 id");
|
|
||||||
my $ipfsHash = $adder->mustSucceed("echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | cut -d' ' -f2");
|
|
||||||
chomp($ipfsHash);
|
|
||||||
|
|
||||||
$adder->mustSucceed("[ -n \"\$(echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | grep added)\" ]");
|
|
||||||
|
|
||||||
$getter->mustSucceed("ipfs --api /ip4/127.0.0.1/tcp/5001 swarm connect /ip4/$addrIp/tcp/4001/ipfs/$addrId");
|
|
||||||
$getter->mustSucceed("[ -n \"\$(ipfs --api /ip4/127.0.0.1/tcp/5001 cat /ipfs/$ipfsHash | grep fnord)\" ]");
|
|
||||||
$getter->mustSucceed("[ -n \"$(cat /ipfs/$ipfsHash | grep fnord)\" ]");
|
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user