Unverified Commit 37914c29 authored by Defelo's avatar Defelo
Browse files

nixos/tests/olivetin: init

parent 96555810
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -966,6 +966,7 @@ in
  oddjobd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./oddjobd.nix { };
  obs-studio = runTest ./obs-studio.nix;
  oh-my-zsh = handleTest ./oh-my-zsh.nix { };
  olivetin = runTest ./olivetin.nix;
  ollama = runTest ./ollama.nix;
  ollama-cuda = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-cuda.nix;
  ollama-rocm = runTestOn [ "x86_64-linux" "aarch64-linux" ] ./ollama-rocm.nix;
+57 −0
Original line number Diff line number Diff line
{ lib, ... }:

{
  name = "olivetin";
  meta.maintainers = with lib.maintainers; [ defelo ];

  nodes.machine = {
    services.olivetin = {
      enable = true;
      settings = {
        actions = [
          {
            id = "hello_world";
            title = "Say Hello";
            shell = "echo -n 'Hello World!' | tee /tmp/result";
          }
        ];
      };
      extraConfigFiles = [
        (builtins.toFile "secrets.yaml" ''
          actions:
            - id: secret
              title: Secret Action
              shell: echo -n secret > /tmp/result2
        '')
      ];
    };
  };

  interactive.nodes.machine = {
    services.olivetin.settings.ListenAddressSingleHTTPFrontend = "0.0.0.0:8000";
    networking.firewall.allowedTCPPorts = [ 8000 ];
    virtualisation.forwardPorts = [
      {
        from = "host";
        host.port = 8000;
        guest.port = 8000;
      }
    ];
  };

  testScript = ''
    import json

    machine.wait_for_unit("olivetin.service")
    machine.wait_for_open_port(8000)

    response = json.loads(machine.succeed("curl http://localhost:8000/api/StartActionByGetAndWait/hello_world"))
    assert response["logEntry"]["exitCode"] == 0
    assert response["logEntry"]["output"] == "Hello World!"
    assert machine.succeed("cat /tmp/result") == "Hello World!"

    response = json.loads(machine.succeed("curl http://localhost:8000/api/StartActionByGetAndWait/secret"))
    assert response["logEntry"]["exitCode"] == 0
    assert machine.succeed("cat /tmp/result2") == "secret"
  '';
}
+2 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
  buildNpmPackage,
  installShellFiles,
  versionCheckHook,
  nixosTests,
}:

buildGoModule (
@@ -122,6 +123,7 @@ buildGoModule (

    passthru = {
      inherit gen webui;
      tests = { inherit (nixosTests) olivetin; };
      updateScript = ./update.sh;
    };