about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2024-03-12 20:28:16 +0100
committerGitHub <noreply@github.com>2024-03-12 20:28:16 +0100
commit734b19970849d3eeec994df0176afd493c2ff4bd (patch)
tree5b4c8bba5851b2620b4289ff7f013f4a71b8bf0b /nixos
parent59efc191f2bee12b02a8fff883b4b7a9c7e484a0 (diff)
parentaf67cfa87bed7fd62812aa888cd134412c9e6d75 (diff)
downloadnixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar.gz
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar.bz2
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar.lz
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar.xz
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.tar.zst
nixlib-734b19970849d3eeec994df0176afd493c2ff4bd.zip
Merge pull request #295197 from abysssol/ollama-tests
nixos/ollama: add tests
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/ollama.nix56
2 files changed, 57 insertions, 0 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 6c188593a97a..ac64b85dd486 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -640,6 +640,7 @@ in {
   nzbget = handleTest ./nzbget.nix {};
   nzbhydra2 = handleTest ./nzbhydra2.nix {};
   oh-my-zsh = handleTest ./oh-my-zsh.nix {};
+  ollama = handleTest ./ollama.nix {};
   ombi = handleTest ./ombi.nix {};
   openarena = handleTest ./openarena.nix {};
   openldap = handleTest ./openldap.nix {};
diff --git a/nixos/tests/ollama.nix b/nixos/tests/ollama.nix
new file mode 100644
index 000000000000..4b21f445cdbd
--- /dev/null
+++ b/nixos/tests/ollama.nix
@@ -0,0 +1,56 @@
+import ./make-test-python.nix ({ pkgs, lib, ... }:
+let
+  mainPort = "11434";
+  altPort = "11435";
+
+  curlRequest = port: request:
+    "curl http://127.0.0.1:${port}/api/generate -d '${builtins.toJSON request}'";
+
+  prompt = {
+    model = "tinydolphin";
+    prompt = "lorem ipsum";
+    options = {
+      seed = 69;
+      temperature = 0;
+    };
+  };
+in
+{
+  name = "ollama";
+  meta = with lib.maintainers; {
+    maintainers = [ abysssol ];
+  };
+
+  nodes = {
+    cpu = { ... }: {
+      services.ollama.enable = true;
+    };
+
+    rocm = { ... }: {
+      services.ollama.enable = true;
+      services.ollama.acceleration = "rocm";
+    };
+
+    cuda = { ... }: {
+      services.ollama.enable = true;
+      services.ollama.acceleration = "cuda";
+    };
+
+    altAddress = { ... }: {
+      services.ollama.enable = true;
+      services.ollama.listenAddress = "127.0.0.1:${altPort}";
+    };
+  };
+
+  testScript = ''
+    vms = [ cpu, rocm, cuda, altAddress ];
+
+    start_all()
+    for vm in vms:
+        vm.wait_for_unit("multi-user.target")
+
+    stdout = cpu.succeed("""${curlRequest mainPort prompt}""", timeout=100)
+
+    stdout = altAddress.succeed("""${curlRequest altPort prompt}""", timeout=100)
+  '';
+})