about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorTomas Antonio Lopez <entropy.overseer@entropic.network>2023-12-25 03:49:11 +0100
committerTomas Antonio Lopez <entropy.overseer@entropic.network>2023-12-25 03:49:11 +0100
commit195cbfc0124ea3d5e4b6469cdd3efb42840d32eb (patch)
tree547b5ec158b60c5e090b29a96ee28dd1ab936a47 /nixos
parent2382d423f427a2dc30ea6cee8b0b4c615c6f5cb3 (diff)
downloadnixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar.gz
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar.bz2
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar.lz
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar.xz
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.tar.zst
nixlib-195cbfc0124ea3d5e4b6469cdd3efb42840d32eb.zip
nixosTests.sourcehut: split tests belonging to different services
Diffstat (limited to 'nixos')
-rw-r--r--nixos/tests/all-tests.nix2
-rw-r--r--nixos/tests/sourcehut/builds.nix54
-rw-r--r--nixos/tests/sourcehut/default.nix6
-rw-r--r--nixos/tests/sourcehut/git.nix (renamed from nixos/tests/sourcehut/sourcehut.nix)18
4 files changed, 61 insertions, 19 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 62588d1f738b..14d3a45326ef 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -768,7 +768,7 @@ in {
   solanum = handleTest ./solanum.nix {};
   sonarr = handleTest ./sonarr.nix {};
   sonic-server = handleTest ./sonic-server.nix {};
-  sourcehut = handleTest ./sourcehut/sourcehut.nix {};
+  sourcehut = handleTest ./sourcehut {};
   spacecookie = handleTest ./spacecookie.nix {};
   spark = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./spark {};
   sqlite3-to-mysql = handleTest ./sqlite3-to-mysql.nix {};
diff --git a/nixos/tests/sourcehut/builds.nix b/nixos/tests/sourcehut/builds.nix
new file mode 100644
index 000000000000..f1f928ecc3d0
--- /dev/null
+++ b/nixos/tests/sourcehut/builds.nix
@@ -0,0 +1,54 @@
+import ../make-test-python.nix ({ pkgs, lib, ... }:
+let
+  domain = "sourcehut.localdomain";
+in
+{
+  name = "sourcehut";
+
+  meta.maintainers = with pkgs.lib.maintainers; [ tomberek nessdoor ];
+
+  nodes.machine = { config, pkgs, nodes, ... }: {
+    imports = [
+      ./nodes/common.nix
+    ];
+
+    networking.domain = domain;
+    networking.extraHosts = ''
+      ${config.networking.primaryIPAddress} builds.${domain}
+      ${config.networking.primaryIPAddress} meta.${domain}
+    '';
+
+    services.sourcehut = {
+      builds = {
+        enable = true;
+        # FIXME: see why it does not seem to activate fully.
+        #enableWorker = true;
+        images = { };
+      };
+
+      settings."builds.sr.ht" = {
+        oauth-client-secret = pkgs.writeText "buildsrht-oauth-client-secret" "2260e9c4d9b8dcedcef642860e0504bc";
+        oauth-client-id = "299db9f9c2013170";
+      };
+    };
+  };
+
+  testScript = ''
+    start_all()
+    machine.wait_for_unit("multi-user.target")
+
+    with subtest("Check whether meta comes up"):
+         machine.wait_for_unit("metasrht-api.service")
+         machine.wait_for_unit("metasrht.service")
+         machine.wait_for_unit("metasrht-webhooks.service")
+         machine.wait_for_open_port(5000)
+         machine.succeed("curl -sL http://localhost:5000 | grep meta.${domain}")
+         machine.succeed("curl -sL http://meta.${domain} | grep meta.${domain}")
+
+    with subtest("Check whether builds comes up"):
+         machine.wait_for_unit("buildsrht.service")
+         machine.wait_for_open_port(5002)
+         machine.succeed("curl -sL http://localhost:5002 | grep builds.${domain}")
+         #machine.wait_for_unit("buildsrht-worker.service")
+  '';
+})
diff --git a/nixos/tests/sourcehut/default.nix b/nixos/tests/sourcehut/default.nix
new file mode 100644
index 000000000000..04f1551d70d9
--- /dev/null
+++ b/nixos/tests/sourcehut/default.nix
@@ -0,0 +1,6 @@
+{ system, pkgs, ... }:
+
+{
+  git = import ./git.nix { inherit system pkgs; };
+  builds = import ./builds.nix { inherit system pkgs; };
+}
diff --git a/nixos/tests/sourcehut/sourcehut.nix b/nixos/tests/sourcehut/git.nix
index e704f2a4e9e0..cb3ca57ddf62 100644
--- a/nixos/tests/sourcehut/sourcehut.nix
+++ b/nixos/tests/sourcehut/git.nix
@@ -14,24 +14,12 @@ in
 
     networking.domain = domain;
     networking.extraHosts = ''
-      ${config.networking.primaryIPAddress} builds.${domain}
       ${config.networking.primaryIPAddress} git.${domain}
       ${config.networking.primaryIPAddress} meta.${domain}
     '';
 
     services.sourcehut = {
-      builds = {
-        enable = true;
-        # FIXME: see why it does not seem to activate fully.
-        #enableWorker = true;
-        images = { };
-      };
       git.enable = true;
-
-      settings."builds.sr.ht" = {
-        oauth-client-secret = pkgs.writeText "buildsrht-oauth-client-secret" "2260e9c4d9b8dcedcef642860e0504bc";
-        oauth-client-id = "299db9f9c2013170";
-      };
       settings."git.sr.ht" = {
         oauth-client-secret = pkgs.writeText "gitsrht-oauth-client-secret" "3597288dc2c716e567db5384f493b09d";
         oauth-client-id = "d07cb713d920702e";
@@ -106,11 +94,5 @@ in
       with subtest("Verify that the repo is downloadable and its contents match the original"):
            machine.succeed("curl https://git.${domain}/~${userName}/test/archive/v0.1.tar.gz | tar -xz")
            machine.succeed("diff test-v0.1/hello.txt test/hello.txt")
-
-      with subtest("Check whether builds comes up"):
-           machine.wait_for_unit("buildsrht.service")
-           machine.wait_for_open_port(5002)
-           machine.succeed("curl -sL http://localhost:5002 | grep builds.${domain}")
-           #machine.wait_for_unit("buildsrht-worker.service")
     '';
 })