diff --git a/nixos/tests/kubo/kubo-fuse.nix b/nixos/tests/kubo/kubo-fuse.nix index adc1ab1b9e41..a1afd4e1eb0b 100644 --- a/nixos/tests/kubo/kubo-fuse.nix +++ b/nixos/tests/kubo/kubo-fuse.nix @@ -43,11 +43,39 @@ machine.succeed(f"diff /tmp/test.txt /ipfs/{ipfs_hash}") - with subtest("Unmounting of /ipns and /ipfs"): + with subtest("/mfs/ FUSE mountpoint"): + with subtest("Write the test file in three different ways"): + machine.succeed("cp /tmp/test.txt /mfs/test-1.txt") + machine.succeed("su alice -c 'ipfs files write --create /test-2.txt < /tmp/test.txt'") + machine.succeed(f"ipfs files cp /ipfs/{ipfs_hash} /test-3.txt") + + with subtest("Show the files (for debugging)"): + # Different hashes for the different ways of adding the file to the MFS probably come from different linking structures of the merkle tree. Copying the file to /mfs with `cp` is even non-deterministic. + machine.succeed("ipfs files ls --long >&2") + machine.succeed("ls -l /mfs >&2") + + with subtest("Check that everyone has permission to read the file (because of Mounts.FuseAllowOther)"): + machine.succeed("su alice -c 'cat /mfs/test-1.txt' | grep fnord3") + machine.succeed("su bob -c 'cat /mfs/test-1.txt' | grep fnord3") + + with subtest("Check the file contents"): + machine.succeed("diff /tmp/test.txt /mfs/test-1.txt") + machine.succeed("diff /tmp/test.txt /mfs/test-2.txt") + machine.succeed("diff /tmp/test.txt /mfs/test-3.txt") + + with subtest("Check the CID extended attribute"): + output = machine.succeed( + "getfattr --only-values --name=ipfs_cid /mfs/test-3.txt" + ).strip() + assert ipfs_hash == output, f"Expected {ipfs_hash} but got {output}" + + + with subtest("Unmounting of /ipns, /ipfs and /mfs"): # Force Kubo to crash and wait for it to restart machine.systemctl("kill --signal=SIGKILL ipfs.service") machine.wait_for_unit("ipfs.service", timeout = 30) machine.succeed(f"diff /tmp/test.txt /ipfs/{ipfs_hash}") + machine.succeed("diff /tmp/test.txt /mfs/test-3.txt") ''; }