2020-05-08 11:48:47 +02:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
2016-11-26 20:07:01 +01:00
|
|
|
name = "ipfs";
|
2021-01-10 20:08:30 +01:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2016-11-26 20:07:01 +01:00
|
|
|
maintainers = [ mguentner ];
|
|
|
|
};
|
|
|
|
|
2020-05-08 11:48:47 +02:00
|
|
|
nodes.machine = { ... }: {
|
|
|
|
services.ipfs = {
|
|
|
|
enable = true;
|
2020-06-17 22:19:01 +02:00
|
|
|
# Also will add a unix domain socket socket API address, see module.
|
|
|
|
startWhenNeeded = true;
|
2020-05-08 11:48:47 +02:00
|
|
|
apiAddress = "/ip4/127.0.0.1/tcp/2324";
|
2022-03-17 16:40:54 +01:00
|
|
|
dataDir = "/mnt/ipfs";
|
2020-05-08 11:48:47 +02:00
|
|
|
};
|
2016-11-26 20:07:01 +01:00
|
|
|
};
|
|
|
|
|
2022-04-16 21:14:26 +02:00
|
|
|
nodes.fuse = { ... }: {
|
|
|
|
services.ipfs = {
|
|
|
|
enable = true;
|
|
|
|
apiAddress = "/ip4/127.0.0.1/tcp/2324";
|
|
|
|
autoMount = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-11-26 20:07:01 +01:00
|
|
|
testScript = ''
|
2020-05-08 11:48:47 +02:00
|
|
|
start_all()
|
2017-08-30 15:20:10 +02:00
|
|
|
|
2020-06-17 22:19:01 +02:00
|
|
|
# IPv4 activation
|
|
|
|
|
|
|
|
machine.succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id")
|
2020-05-08 11:48:47 +02:00
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | awk '{ print $2 }'"
|
|
|
|
)
|
2017-08-30 15:20:10 +02:00
|
|
|
|
2020-05-08 11:48:47 +02:00
|
|
|
machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord")
|
2020-06-11 23:59:38 +02:00
|
|
|
|
2020-06-17 22:19:01 +02:00
|
|
|
# Unix domain socket activation
|
|
|
|
|
|
|
|
machine.stop_job("ipfs")
|
|
|
|
|
2020-06-11 23:59:38 +02:00
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord2 | ipfs --api /unix/run/ipfs.sock add | awk '{ print $2 }'"
|
|
|
|
)
|
|
|
|
machine.succeed(
|
|
|
|
f"ipfs --api /unix/run/ipfs.sock cat /ipfs/{ipfs_hash.strip()} | grep fnord2"
|
|
|
|
)
|
2022-03-17 16:40:54 +01:00
|
|
|
|
|
|
|
# Test if setting dataDir works properly with the hardened systemd unit
|
|
|
|
machine.succeed("test -e /mnt/ipfs/config")
|
|
|
|
machine.succeed("test ! -e /var/lib/ipfs/")
|
2022-04-16 21:14:26 +02:00
|
|
|
|
|
|
|
# Test FUSE mountpoint
|
|
|
|
ipfs_hash = fuse.succeed(
|
2022-06-13 21:01:32 +02:00
|
|
|
"echo fnord3 | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter"
|
2022-04-16 21:14:26 +02:00
|
|
|
)
|
|
|
|
|
2022-07-10 18:46:58 +02:00
|
|
|
# The FUSE mount functionality is broken as of v0.13.0.
|
|
|
|
# See https://github.com/ipfs/kubo/issues/9044.
|
|
|
|
# fuse.succeed(f"cat /ipfs/{ipfs_hash.strip()} | grep fnord3")
|
2020-05-08 11:48:47 +02:00
|
|
|
'';
|
2016-11-26 20:07:01 +01:00
|
|
|
})
|