2020-05-08 10:48:47 +01:00
|
|
|
import ./make-test-python.nix ({ pkgs, ...} : {
|
2022-07-24 19:49:05 +01:00
|
|
|
name = "kubo";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2023-04-14 00:49:48 +01:00
|
|
|
maintainers = [ mguentner Luflosi ];
|
2016-11-26 19:07:01 +00:00
|
|
|
};
|
|
|
|
|
2020-05-08 10:48:47 +01:00
|
|
|
nodes.machine = { ... }: {
|
2022-07-24 19:49:05 +01:00
|
|
|
services.kubo = {
|
2020-05-08 10:48:47 +01:00
|
|
|
enable = true;
|
2020-06-17 21:19:01 +01:00
|
|
|
# Also will add a unix domain socket socket API address, see module.
|
|
|
|
startWhenNeeded = true;
|
2022-10-04 11:44:48 +01:00
|
|
|
settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324";
|
2022-03-17 15:40:54 +00:00
|
|
|
dataDir = "/mnt/ipfs";
|
2020-05-08 10:48:47 +01:00
|
|
|
};
|
2016-11-26 19:07:01 +00:00
|
|
|
};
|
|
|
|
|
2022-04-16 20:14:26 +01:00
|
|
|
nodes.fuse = { ... }: {
|
2022-07-24 19:49:05 +01:00
|
|
|
services.kubo = {
|
2022-04-16 20:14:26 +01:00
|
|
|
enable = true;
|
2022-10-04 11:44:48 +01:00
|
|
|
settings.Addresses.API = "/ip4/127.0.0.1/tcp/2324";
|
2022-04-16 20:14:26 +01:00
|
|
|
autoMount = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-11-26 19:07:01 +00:00
|
|
|
testScript = ''
|
2020-05-08 10:48:47 +01:00
|
|
|
start_all()
|
2017-08-30 14:20:10 +01:00
|
|
|
|
2020-06-17 21:19:01 +01:00
|
|
|
# IPv4 activation
|
|
|
|
|
|
|
|
machine.succeed("ipfs --api /ip4/127.0.0.1/tcp/2324 id")
|
2020-05-08 10:48:47 +01:00
|
|
|
ipfs_hash = machine.succeed(
|
|
|
|
"echo fnord | ipfs --api /ip4/127.0.0.1/tcp/2324 add | awk '{ print $2 }'"
|
|
|
|
)
|
2017-08-30 14:20:10 +01:00
|
|
|
|
2020-05-08 10:48:47 +01:00
|
|
|
machine.succeed(f"ipfs cat /ipfs/{ipfs_hash.strip()} | grep fnord")
|
2020-06-11 22:59:38 +01:00
|
|
|
|
2020-06-17 21:19:01 +01:00
|
|
|
# Unix domain socket activation
|
|
|
|
|
|
|
|
machine.stop_job("ipfs")
|
|
|
|
|
2020-06-11 22:59:38 +01: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 15:40:54 +00: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 20:14:26 +01:00
|
|
|
|
|
|
|
# Test FUSE mountpoint
|
2023-02-06 00:31:04 +00:00
|
|
|
# The FUSE mount functionality is broken as of v0.13.0 and v0.17.0.
|
|
|
|
# See https://github.com/ipfs/kubo/issues/9044.
|
|
|
|
# Workaround: using CID Version 1 avoids that.
|
2022-04-16 20:14:26 +01:00
|
|
|
ipfs_hash = fuse.succeed(
|
2023-02-06 00:31:04 +00:00
|
|
|
"echo fnord3 | ipfs --api /ip4/127.0.0.1/tcp/2324 add --quieter --cid-version=1"
|
2023-02-06 00:35:29 +00:00
|
|
|
).strip()
|
|
|
|
|
|
|
|
fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3")
|
|
|
|
|
|
|
|
# Force Kubo to crash and wait for it to restart
|
|
|
|
# Tests the unmounting of /ipns and /ipfs
|
|
|
|
fuse.systemctl("kill --signal=SIGKILL ipfs.service")
|
|
|
|
fuse.wait_for_unit("ipfs.service", timeout = 30)
|
2022-04-16 20:14:26 +01:00
|
|
|
|
2023-02-06 00:35:29 +00:00
|
|
|
fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3")
|
2020-05-08 10:48:47 +01:00
|
|
|
'';
|
2016-11-26 19:07:01 +00:00
|
|
|
})
|