lol

nixos/tests/kubo: various improvements

Add new test to check if kubo.passthru.repoVersion is set correctly.
Also split the existing NixOS VM test into two independent parts. The test already used two independent VMs but just one testScript. This made experimenting with just one of the two VMs slower than it needed to be. It should also increase parallelism slightly since both test scripts can now run at the same time.

Luflosi cf8aa486 b8eebcad

+66 -34
+1 -1
nixos/tests/all-tests.nix
··· 424 424 ksm = handleTest ./ksm.nix {}; 425 425 kthxbye = handleTest ./kthxbye.nix {}; 426 426 kubernetes = handleTestOn ["x86_64-linux"] ./kubernetes {}; 427 - kubo = runTest ./kubo.nix; 427 + kubo = import ./kubo { inherit recurseIntoAttrs runTest; }; 428 428 ladybird = handleTest ./ladybird.nix {}; 429 429 languagetool = handleTest ./languagetool.nix {}; 430 430 latestKernel.login = handleTest ./login.nix { latestKernel = true; };
-32
nixos/tests/kubo.nix nixos/tests/kubo/kubo.nix
··· 18 18 }; 19 19 }; 20 20 21 - nodes.fuse = { config, ... }: { 22 - services.kubo = { 23 - enable = true; 24 - autoMount = true; 25 - }; 26 - users.users.alice = { 27 - isNormalUser = true; 28 - extraGroups = [ config.services.kubo.group ]; 29 - }; 30 - users.users.bob = { 31 - isNormalUser = true; 32 - }; 33 - }; 34 - 35 21 testScript = '' 36 22 start_all() 37 23 ··· 63 49 with subtest("Setting dataDir works properly with the hardened systemd unit"): 64 50 machine.succeed("test -e /mnt/ipfs/config") 65 51 machine.succeed("test ! -e /var/lib/ipfs/") 66 - 67 - with subtest("FUSE mountpoint"): 68 - fuse.fail("echo a | su bob -l -c 'ipfs add --quieter'") 69 - # The FUSE mount functionality is broken as of v0.13.0 and v0.17.0. 70 - # See https://github.com/ipfs/kubo/issues/9044. 71 - # Workaround: using CID Version 1 avoids that. 72 - ipfs_hash = fuse.succeed( 73 - "echo fnord3 | su alice -l -c 'ipfs add --quieter --cid-version=1'" 74 - ).strip() 75 - 76 - fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") 77 - 78 - with subtest("Unmounting of /ipns and /ipfs"): 79 - # Force Kubo to crash and wait for it to restart 80 - fuse.systemctl("kill --signal=SIGKILL ipfs.service") 81 - fuse.wait_for_unit("ipfs.service", timeout = 30) 82 - 83 - fuse.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") 84 52 ''; 85 53 }
+5
nixos/tests/kubo/default.nix
··· 1 + { recurseIntoAttrs, runTest }: 2 + recurseIntoAttrs { 3 + kubo = runTest ./kubo.nix; 4 + kubo-fuse = runTest ./kubo-fuse.nix; 5 + }
+42
nixos/tests/kubo/kubo-fuse.nix
··· 1 + { lib, ...} : { 2 + name = "kubo-fuse"; 3 + meta = with lib.maintainers; { 4 + maintainers = [ mguentner Luflosi ]; 5 + }; 6 + 7 + nodes.machine = { config, ... }: { 8 + services.kubo = { 9 + enable = true; 10 + autoMount = true; 11 + }; 12 + users.users.alice = { 13 + isNormalUser = true; 14 + extraGroups = [ config.services.kubo.group ]; 15 + }; 16 + users.users.bob = { 17 + isNormalUser = true; 18 + }; 19 + }; 20 + 21 + testScript = '' 22 + start_all() 23 + 24 + with subtest("FUSE mountpoint"): 25 + machine.fail("echo a | su bob -l -c 'ipfs add --quieter'") 26 + # The FUSE mount functionality is broken as of v0.13.0 and v0.17.0. 27 + # See https://github.com/ipfs/kubo/issues/9044. 28 + # Workaround: using CID Version 1 avoids that. 29 + ipfs_hash = machine.succeed( 30 + "echo fnord3 | su alice -l -c 'ipfs add --quieter --cid-version=1'" 31 + ).strip() 32 + 33 + machine.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") 34 + 35 + with subtest("Unmounting of /ipns and /ipfs"): 36 + # Force Kubo to crash and wait for it to restart 37 + machine.systemctl("kill --signal=SIGKILL ipfs.service") 38 + machine.wait_for_unit("ipfs.service", timeout = 30) 39 + 40 + machine.succeed(f"cat /ipfs/{ipfs_hash} | grep fnord3") 41 + ''; 42 + }
+5 -1
pkgs/applications/networking/kubo/default.nix
··· 2 2 , buildGoModule 3 3 , fetchurl 4 4 , nixosTests 5 + , callPackage 5 6 }: 6 7 7 8 buildGoModule rec { ··· 29 30 30 31 subPackages = [ "cmd/ipfs" ]; 31 32 32 - passthru.tests.kubo = nixosTests.kubo; 33 + passthru.tests = { 34 + inherit (nixosTests) kubo; 35 + repoVersion = callPackage ./test-repoVersion.nix {}; 36 + }; 33 37 34 38 vendorHash = null; 35 39
+13
pkgs/applications/networking/kubo/test-repoVersion.nix
··· 1 + { runCommand, kubo }: 2 + 3 + runCommand "kubo-test-repoVersion" { } '' 4 + export IPFS_PATH="$TMPDIR" 5 + "${kubo}/bin/ipfs" init --empty-repo 6 + declared_repo_version='${kubo.repoVersion}' 7 + actual_repo_version="$(cat "$IPFS_PATH/version")" 8 + if [ "$declared_repo_version" != "$actual_repo_version" ]; then 9 + echo "kubo.repoVersion is not set correctly. It should be $actual_repo_version but is $declared_repo_version." 10 + exit 1 11 + fi 12 + touch "$out" 13 + ''