aboutsummaryrefslogtreecommitdiffstats
path: root/tests/by-name/sh/sharkey-cpu
diff options
context:
space:
mode:
Diffstat (limited to 'tests/by-name/sh/sharkey-cpu')
-rw-r--r--tests/by-name/sh/sharkey-cpu/test.nix57
1 files changed, 23 insertions, 34 deletions
diff --git a/tests/by-name/sh/sharkey-cpu/test.nix b/tests/by-name/sh/sharkey-cpu/test.nix
index 47c16ff..d648429 100644
--- a/tests/by-name/sh/sharkey-cpu/test.nix
+++ b/tests/by-name/sh/sharkey-cpu/test.nix
@@ -1,25 +1,12 @@
{
- nixos-lib,
- pkgsUnstable,
- nixpkgs-unstable,
- vhackPackages,
pkgs,
extraModules,
- nixLib,
+ vhack,
...
}:
-nixos-lib.runTest {
- hostPkgs = pkgs; # the Nixpkgs package set used outside the VMs
-
+vhack.runTest {
name = "sharkey-cpu";
- node = {
- specialArgs = {inherit pkgsUnstable extraModules vhackPackages nixpkgs-unstable nixLib;};
-
- # Use the nixpkgs as constructed by the `nixpkgs.*` options
- pkgs = null;
- };
-
nodes = {
server = {config, ...}: {
imports =
@@ -45,12 +32,22 @@ nixos-lib.runTest {
nodejs = pkgs.lib.getExe pkgs.nodejs;
script = pkgs.writeTextFile {
name = "script.js";
- text = ''
- import * as os from 'node:os';
+ text =
+ # js
+ ''
+ import * as os from 'node:os';
+
+ var cpus = os.cpus()
- console.log(os.cpus()[0].model)
- console.log(os.cpus().length)
- '';
+ if (cpus.length != 0) {
+ console.log(cpus[0].model)
+ } else {
+ // Fail?
+ }
+
+ while (true) {
+ }
+ '';
};
in
pkgs.lib.mkForce "${nodejs} ${script}";
@@ -58,24 +55,16 @@ nixos-lib.runTest {
};
};
- testScript = {nodes, ...}:
- /*
- python
- */
+ services = [
+ {server = "sharkey.service";}
+ ];
+
+ testScript = {...}:
+ # Python
''
from time import sleep
- start_all()
-
# Give the service time to run.
sleep(3)
-
- with subtest("All services running"):
- import json
- def all_services_running(host):
- (status, output) = host.systemctl("list-units --state=failed --plain --no-pager --output=json")
- host_failed = json.loads(output)
- assert len(host_failed) == 0, f"Expected zero failing services, but found: {json.dumps(host_failed, indent=4)}"
- all_services_running(server)
'';
}