about summary refs log tree commit diff
path: root/tvix/boot
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/boot')
-rw-r--r--tvix/boot/tests/default.nix55
1 files changed, 39 insertions, 16 deletions
diff --git a/tvix/boot/tests/default.nix b/tvix/boot/tests/default.nix
index 4a38b3f65083..378efaccc982 100644
--- a/tvix/boot/tests/default.nix
+++ b/tvix/boot/tests/default.nix
@@ -1,10 +1,17 @@
-{ depot, pkgs, ... }:
+{ depot, pkgs, lib, ... }:
 
 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:
+  mkBootTest =
+    { blobServiceAddr ? "memory://"
+    , directoryServiceAddr ? "memory://"
+    , pathInfoServiceAddr ? "memory://"
+      # The path to import (via tvix-store import).
+    , importPath ? ../../docs
+    , importPathName ? "docs"
+    }:
     pkgs.stdenv.mkDerivation {
       name = "run-vm";
       nativeBuildInputs = [
@@ -14,27 +21,43 @@ let
       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
+        # Start the tvix daemon, listening on a unix socket.
+        BLOB_SERVICE_ADDR=${blobServiceAddr} \
+          DIRECTORY_SERVICE_ADDR=${directoryServiceAddr} \
+          PATH_INFO_SERVICE_ADDR=${pathInfoServiceAddr} \
+          tvix-store daemon -l $PWD/tvix-store.socket &
 
-        # 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)
+        # Wait for the socket to be created.
+        while [ ! -e $PWD/tvix-store.socket ]; do sleep 1; done
 
-        echo "Store contents imported to $outpath"
+        # Export env vars so that subsequent tvix-store commands will talk to
+        # our tvix-store daemon over the unix socket.
+        export BLOB_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
+        export DIRECTORY_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
+        export PATH_INFO_SERVICE_ADDR=grpc+unix://$PWD/tvix-store.socket
+      '' + lib.optionalString (importPath != null) ''
+        echo "Importing ${importPath} into tvix-store with name ${importPathName}…"
+        cp -R ${importPath} ${importPathName}
+        outpath=$(tvix-store import ${importPathName})
+
+        echo "imported to $outpath"
+
+        # Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing.
 
         CH_CMDLINE="tvix.find" run-tvix-vm 2>&1 | tee output.txt
-        grep ${../../docs} output.txt
+        grep $outpath output.txt
       '';
       requiredSystemFeatures = [ "kvm" ];
     };
 in
 depot.nix.readTree.drvTargets {
-  docs-sled = (mkBootTest "sled://$PWD/blobs.sled");
-  docs-objectstore-local = (mkBootTest "objectstore+file://$PWD/blobs");
+  docs-memory = (mkBootTest { });
+  docs-sled = (mkBootTest {
+    blobServiceAddr = "sled://$PWD/blobs.sled";
+    directoryServiceAddr = "sled://$PWD/directories.sled";
+    pathInfoServiceAddr = "sled://$PWD/pathinfo.sled";
+  });
+  docs-objectstore-local = (mkBootTest {
+    blobServiceAddr = "objectstore+file://$PWD/blobs";
+  });
 }