mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 20:55:31 +03:00
tests/prometheus-exporters: allow overriding test-node-name
allows the prometheus-exporters test abstraction to work with e.g. hyphenated exporter-names
This commit is contained in:
parent
b381aacbba
commit
8c49e5a78c
1 changed files with 13 additions and 7 deletions
|
@ -22,6 +22,9 @@ let
|
||||||
* `metricProvider` (optional)
|
* `metricProvider` (optional)
|
||||||
* this attribute contains additional machine config
|
* this attribute contains additional machine config
|
||||||
*
|
*
|
||||||
|
* `nodeName` (optional)
|
||||||
|
* override an incompatible testnode name
|
||||||
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* exporterTests.<exporterName> = {
|
* exporterTests.<exporterName> = {
|
||||||
* exporterConfig = {
|
* exporterConfig = {
|
||||||
|
@ -646,24 +649,27 @@ let
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
mapAttrs (exporter: testConfig: (makeTest {
|
mapAttrs (exporter: testConfig: (makeTest (let
|
||||||
|
nodeName = testConfig.nodeName or exporter;
|
||||||
|
|
||||||
|
in {
|
||||||
name = "prometheus-${exporter}-exporter";
|
name = "prometheus-${exporter}-exporter";
|
||||||
|
|
||||||
nodes.${exporter} = mkMerge [{
|
nodes.${nodeName} = mkMerge [{
|
||||||
services.prometheus.exporters.${exporter} = testConfig.exporterConfig;
|
services.prometheus.exporters.${exporter} = testConfig.exporterConfig;
|
||||||
} testConfig.metricProvider or {}];
|
} testConfig.metricProvider or {}];
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
${exporter}.start()
|
${nodeName}.start()
|
||||||
${concatStringsSep "\n" (map (line:
|
${concatStringsSep "\n" (map (line:
|
||||||
if (builtins.substring 0 1 line == " " || builtins.substring 0 1 line == ")")
|
if (builtins.substring 0 1 line == " " || builtins.substring 0 1 line == ")")
|
||||||
then line
|
then line
|
||||||
else "${exporter}.${line}"
|
else "${nodeName}.${line}"
|
||||||
) (splitString "\n" (removeSuffix "\n" testConfig.exporterTest)))}
|
) (splitString "\n" (removeSuffix "\n" testConfig.exporterTest)))}
|
||||||
${exporter}.shutdown()
|
${nodeName}.shutdown()
|
||||||
'';
|
'';
|
||||||
|
|
||||||
meta = with maintainers; {
|
meta = with maintainers; {
|
||||||
maintainers = [ willibutz ];
|
maintainers = [ willibutz elseym ];
|
||||||
};
|
};
|
||||||
})) exporterTests
|
}))) exporterTests
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue