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)
|
||||
* this attribute contains additional machine config
|
||||
*
|
||||
* `nodeName` (optional)
|
||||
* override an incompatible testnode name
|
||||
*
|
||||
* Example:
|
||||
* exporterTests.<exporterName> = {
|
||||
* exporterConfig = {
|
||||
|
@ -646,24 +649,27 @@ let
|
|||
};
|
||||
};
|
||||
in
|
||||
mapAttrs (exporter: testConfig: (makeTest {
|
||||
mapAttrs (exporter: testConfig: (makeTest (let
|
||||
nodeName = testConfig.nodeName or exporter;
|
||||
|
||||
in {
|
||||
name = "prometheus-${exporter}-exporter";
|
||||
|
||||
nodes.${exporter} = mkMerge [{
|
||||
nodes.${nodeName} = mkMerge [{
|
||||
services.prometheus.exporters.${exporter} = testConfig.exporterConfig;
|
||||
} testConfig.metricProvider or {}];
|
||||
|
||||
testScript = ''
|
||||
${exporter}.start()
|
||||
${nodeName}.start()
|
||||
${concatStringsSep "\n" (map (line:
|
||||
if (builtins.substring 0 1 line == " " || builtins.substring 0 1 line == ")")
|
||||
then line
|
||||
else "${exporter}.${line}"
|
||||
else "${nodeName}.${line}"
|
||||
) (splitString "\n" (removeSuffix "\n" testConfig.exporterTest)))}
|
||||
${exporter}.shutdown()
|
||||
${nodeName}.shutdown()
|
||||
'';
|
||||
|
||||
meta = with maintainers; {
|
||||
maintainers = [ willibutz ];
|
||||
maintainers = [ willibutz elseym ];
|
||||
};
|
||||
})) exporterTests
|
||||
}))) exporterTests
|
||||
|
|
Loading…
Reference in a new issue