Merge pull request #240571 from gaelreyrol/scaphandre-module-assertions

nixos/prometheus/exporters: adjust scaphandre assertions
This commit is contained in:
Pol Dellaiera 2023-07-04 11:24:24 +02:00 committed by GitHub
commit 3ede00e4fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 15 deletions

View File

@ -304,19 +304,19 @@ in
'services.prometheus.exporters.sql.configFile'
'';
} {
assertion = cfg.scaphandre.enable -> (pkgs.stdenv.hostPlatform.isx86_64 == true);
assertion = cfg.scaphandre.enable -> (pkgs.stdenv.targetPlatform.isx86_64 == true);
message = ''
Only x86_64 host platform architecture is not supported.
Scaphandre only support x86_64 architectures.
'';
} {
assertion = cfg.scaphandre.enable -> ((lib.kernel.whenHelpers pkgs.linux.version).whenOlder "5.11" true).condition == false;
message = ''
A kernel version newer than '5.11' is required. ${pkgs.linux.version}
Scaphandre requires a kernel version newer than '5.11', '${pkgs.linux.version}' given.
'';
} {
assertion = cfg.scaphandre.enable -> (builtins.elem "intel_rapl_common" config.boot.kernelModules);
message = ''
Please enable 'intel_rapl_common' in 'boot.kernelModules'.
Scaphandre needs 'intel_rapl_common' kernel module to be enabled. Please add it in 'boot.kernelModules'.
'';
} ] ++ (flip map (attrNames exporterOpts) (exporter: {
assertion = cfg.${exporter}.firewallFilter != null -> cfg.${exporter}.openFirewall;

View File

@ -5,9 +5,12 @@
, pkg-config
, openssl
, powercap
, nix-update-script
, runCommand
, dieHook
, nixosTests
, testers
, scaphandre
}:
rustPlatform.buildRustPackage rec {
@ -38,17 +41,25 @@ rustPlatform.buildRustPackage rec {
runHook postCheck
'';
passthru.tests = {
stdout = self: runCommand "${pname}-test" {
buildInputs = [
self
dieHook
];
} ''
${self}/bin/scaphandre stdout -t 4 > $out || die "Scaphandre failed to measure consumption"
[ -s $out ]
'';
vm = nixosTests.scaphandre;
passthru = {
updateScript = nix-update-script { };
tests = {
stdout = self: runCommand "${pname}-test" {
buildInputs = [
self
dieHook
];
} ''
${self}/bin/scaphandre stdout -t 4 > $out || die "Scaphandre failed to measure consumption"
[ -s $out ]
'';
vm = nixosTests.scaphandre;
version = testers.testVersion {
inherit version;
package = scaphandre;
command = "scaphandre --version";
};
};
};
meta = with lib; {