Merge pull request #295197 from abysssol/ollama-tests

nixos/ollama: add tests

authored by Pol Dellaiera and committed by GitHub 734b1997 59efc191

+60 -2
+1
nixos/tests/all-tests.nix
··· 640 nzbget = handleTest ./nzbget.nix {}; 641 nzbhydra2 = handleTest ./nzbhydra2.nix {}; 642 oh-my-zsh = handleTest ./oh-my-zsh.nix {}; 643 ombi = handleTest ./ombi.nix {}; 644 openarena = handleTest ./openarena.nix {}; 645 openldap = handleTest ./openldap.nix {};
··· 640 nzbget = handleTest ./nzbget.nix {}; 641 nzbhydra2 = handleTest ./nzbhydra2.nix {}; 642 oh-my-zsh = handleTest ./oh-my-zsh.nix {}; 643 + ollama = handleTest ./ollama.nix {}; 644 ombi = handleTest ./ombi.nix {}; 645 openarena = handleTest ./openarena.nix {}; 646 openldap = handleTest ./openldap.nix {};
+56
nixos/tests/ollama.nix
···
··· 1 + import ./make-test-python.nix ({ pkgs, lib, ... }: 2 + let 3 + mainPort = "11434"; 4 + altPort = "11435"; 5 + 6 + curlRequest = port: request: 7 + "curl http://127.0.0.1:${port}/api/generate -d '${builtins.toJSON request}'"; 8 + 9 + prompt = { 10 + model = "tinydolphin"; 11 + prompt = "lorem ipsum"; 12 + options = { 13 + seed = 69; 14 + temperature = 0; 15 + }; 16 + }; 17 + in 18 + { 19 + name = "ollama"; 20 + meta = with lib.maintainers; { 21 + maintainers = [ abysssol ]; 22 + }; 23 + 24 + nodes = { 25 + cpu = { ... }: { 26 + services.ollama.enable = true; 27 + }; 28 + 29 + rocm = { ... }: { 30 + services.ollama.enable = true; 31 + services.ollama.acceleration = "rocm"; 32 + }; 33 + 34 + cuda = { ... }: { 35 + services.ollama.enable = true; 36 + services.ollama.acceleration = "cuda"; 37 + }; 38 + 39 + altAddress = { ... }: { 40 + services.ollama.enable = true; 41 + services.ollama.listenAddress = "127.0.0.1:${altPort}"; 42 + }; 43 + }; 44 + 45 + testScript = '' 46 + vms = [ cpu, rocm, cuda, altAddress ]; 47 + 48 + start_all() 49 + for vm in vms: 50 + vm.wait_for_unit("multi-user.target") 51 + 52 + stdout = cpu.succeed("""${curlRequest mainPort prompt}""", timeout=100) 53 + 54 + stdout = altAddress.succeed("""${curlRequest altPort prompt}""", timeout=100) 55 + ''; 56 + })
+3 -2
pkgs/tools/misc/ollama/default.nix
··· 7 , overrideCC 8 , makeWrapper 9 , stdenv 10 11 , pkgs 12 , cmake ··· 163 "-X=github.com/jmorganca/ollama/server.mode=release" 164 ]; 165 166 - # for now, just test that rocm and cuda build 167 - passthru.tests = lib.optionalAttrs stdenv.isLinux { 168 rocm = pkgs.ollama.override { acceleration = "rocm"; }; 169 cuda = pkgs.ollama.override { acceleration = "cuda"; }; 170 };
··· 7 , overrideCC 8 , makeWrapper 9 , stdenv 10 + , nixosTests 11 12 , pkgs 13 , cmake ··· 164 "-X=github.com/jmorganca/ollama/server.mode=release" 165 ]; 166 167 + passthru.tests = { 168 + service = nixosTests.ollama; 169 rocm = pkgs.ollama.override { acceleration = "rocm"; }; 170 cuda = pkgs.ollama.override { acceleration = "cuda"; }; 171 };