about summary refs log tree commit diff
path: root/tvix/boot/tests/default.nix
blob: 4a38b3f65083f4af3724ccc03f0270028272e348 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{ depot, pkgs, ... }:

let
  # Seed a tvix-store with the tvix docs, then start a VM, ask it to list all
  # files in /nix/store, and ensure the store path is present, which acts as a
  # nice smoketest.
  mkBootTest = blobServiceAddr:
    pkgs.stdenv.mkDerivation {
      name = "run-vm";
      nativeBuildInputs = [
        depot.tvix.store
        depot.tvix.boot.runVM
      ];
      buildCommand = ''
        touch $out

        # Configure tvix to put data in the local working directory
        export BLOB_SERVICE_ADDR=${blobServiceAddr}
        export DIRECTORY_SERVICE_ADDR=sled://$PWD/directories.sled
        export PATH_INFO_SERVICE_ADDR=sled://$PWD/pathinfo.sled

        # Seed the tvix store with some data
        # Create a `docs` directory with the contents from ../docs
        # Make sure it still is called "docs" when calling import, so we can
        # predict the store path.
        cp -R ${../../docs} docs
        outpath=$(tvix-store import docs)

        echo "Store contents imported to $outpath"

        CH_CMDLINE="tvix.find" run-tvix-vm 2>&1 | tee output.txt
        grep ${../../docs} output.txt
      '';
      requiredSystemFeatures = [ "kvm" ];
    };
in
depot.nix.readTree.drvTargets {
  docs-sled = (mkBootTest "sled://$PWD/blobs.sled");
  docs-objectstore-local = (mkBootTest "objectstore+file://$PWD/blobs");
}