git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #123926 from pschyska/master

nixos/atop: Add defaultText to types.package options, Fix timing-related test failures.

commitab51a2dbd6b5fcc8f6ae467075a2863ecac7c7d0 authorMichael Raskin <7c6f434c@mail.ru> dateSun 23 May 2021, 18:08 (5 years ago) parentde84bd19cb76c2
2 files changed+32−7
nixos/modules/programs/atop.nix+2 nixos/tests/atop.nix+30−7
nixos/modules/programs/atop.nix+2
@@ -19,6 +19,7 @@ in
1919 package = mkOption {
2020 type = types.package;
2121 default = pkgs.atop;
22+ defaultText = "pkgs.atop";
2223 description = ''
2324 Which package to use for Atop.
2425 '';
@@ -36,6 +37,7 @@ in
3637 package = mkOption {
3738 type = types.package;
3839 default = config.boot.kernelPackages.netatop;
40+ defaultText = "config.boot.kernelPackages.netatop";
3941 description = ''
4042 Which package to use for netatop.
4143 '';
nixos/tests/atop.nix+30−7
@@ -14,7 +14,10 @@ let assertions = rec {
1414 '';
1515 unit = name: state: ''
1616 with subtest("Unit ${name} should be ${state}"):
17− machine.require_unit_state("${name}", "${state}")
17+ if "${state}" == "active":
18+ machine.wait_for_unit("${name}")
19+ else:
20+ machine.require_unit_state("${name}", "${state}")
1821 '';
1922 version = ''
2023 import re
@@ -44,9 +47,19 @@ let assertions = rec {
4447 if present then
4548 unit "atop.service" "active"
4649 + ''
47− with subtest("atop.service should have written some data to /var/log/atop"):
48− files = int(machine.succeed("ls -1 /var/log/atop | wc -l"))
49− assert files > 0, "Expected at least 1 data file"
50+ with subtest("atop.service should write some data to /var/log/atop"):
51+
52+ def has_data_files(last: bool) -> bool:
53+ files = int(machine.succeed("ls -1 /var/log/atop | wc -l"))
54+ if files == 0:
55+ machine.log("Did not find at least one 1 data file")
56+ if not last:
57+ machine.log("Will retry...")
58+ return False
59+ return True
60+
61+ with machine.nested("Waiting for data files"):
62+ retry(has_data_files)
5063 '' else unit "atop.service" "inactive";
5164 atopRotateTimer = present:
5265 unit "atop-rotate.timer" (if present then "active" else "inactive");
@@ -55,11 +68,21 @@ let assertions = rec {
5568 unit "atopacct.service" "active"
5669 + ''
5770 with subtest("atopacct.service should enable process accounting"):
58− machine.succeed("test -f /run/pacct_source")
71+ machine.wait_until_succeeds("test -f /run/pacct_source")
5972
6073 with subtest("atopacct.service should write data to /run/pacct_shadow.d"):
61− files = int(machine.succeed("ls -1 /run/pacct_shadow.d | wc -l"))
62− assert files >= 1, "Expected at least 1 pacct_shadow.d file"
74+
75+ def has_data_files(last: bool) -> bool:
76+ files = int(machine.succeed("ls -1 /run/pacct_shadow.d | wc -l"))
77+ if files == 0:
78+ machine.log("Did not find at least one 1 data file")
79+ if not last:
80+ machine.log("Will retry...")
81+ return False
82+ return True
83+
84+ with machine.nested("Waiting for data files"):
85+ retry(has_data_files)
6386 '' else unit "atopacct.service" "inactive";
6487 netatop = present:
6588 if present then