mirror of
https://github.com/NixOS/nixpkgs.git
synced 2026-10-31 01:02:20 +00:00
nixosTests.prometheus-exporters.ipmi: test IPMI datapath (#564427)
This commit is contained in:
@@ -600,16 +600,73 @@ let
|
||||
|
||||
ipmi =
|
||||
{ pkgs, ... }:
|
||||
let
|
||||
exporterConfig = pkgs.writeText "ipmi-exporter.yml" ''
|
||||
modules:
|
||||
default:
|
||||
user: ipmiusr
|
||||
pass: test
|
||||
privilege: admin
|
||||
driver: LAN_2_0
|
||||
timeout: 2000
|
||||
# necessary for openipmi bmc, per ipmi-sensors(8)
|
||||
workaround_flags:
|
||||
- opensesspriv
|
||||
collectors:
|
||||
- ipmi
|
||||
'';
|
||||
simulatorConfig = pkgs.writeText "ipmi-simulator.conf" ''
|
||||
name "ipmisim1"
|
||||
|
||||
startlan 1
|
||||
addr 192.168.1.1 623
|
||||
priv_limit admin
|
||||
guid a123456789abcdefa123456789abcdef
|
||||
endlan
|
||||
|
||||
user 2 true "ipmiusr" "test" admin 10
|
||||
'';
|
||||
simulatorCommands = "${pkgs.openipmi}/etc/ipmi/ipmisim1.emu";
|
||||
in
|
||||
{
|
||||
maintainers = pkgs.freeipmi.meta.maintainers;
|
||||
exporterConfig = {
|
||||
enable = true;
|
||||
configFile = exporterConfig;
|
||||
};
|
||||
metricProvider = {
|
||||
networking.firewall.allowedUDPPorts = [ 623 ];
|
||||
systemd.services.ipmi-simulator = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
preStart = ''
|
||||
# ipmi_sim expects specific name for its SDR.
|
||||
${pkgs.coreutils}/bin/install -Dm600 \
|
||||
${pkgs.openipmi}/share/openipmi/ipmisim1.bsdr \
|
||||
/run/ipmi-simulator/ipmi_sim/ipmisim1/sdr.20.main
|
||||
'';
|
||||
serviceConfig = {
|
||||
ExecStart = ''
|
||||
${pkgs.openipmi}/bin/ipmi_sim -n \
|
||||
-c ${simulatorConfig} \
|
||||
-f ${simulatorCommands} \
|
||||
-s /run/ipmi-simulator
|
||||
'';
|
||||
RuntimeDirectory = "ipmi-simulator";
|
||||
};
|
||||
};
|
||||
};
|
||||
exporterTest = ''
|
||||
wait_for_unit("ipmi-simulator.service")
|
||||
wait_until_succeeds("ss -lunp | grep -F '192.168.1.1:623'")
|
||||
wait_for_unit("prometheus-ipmi-exporter.service")
|
||||
wait_for_open_port(9290)
|
||||
|
||||
# ipmi_sim command file sets MBTemp = 0x60 (96).
|
||||
succeed(
|
||||
"curl -sSf http://localhost:9290/metrics | grep 'ipmi_scrape_duration_seconds'"
|
||||
"curl -sSf 'http://localhost:9290/ipmi?target=192.168.1.1' > /tmp/ipmi-metrics",
|
||||
"grep -F 'ipmi_up{collector=\"ipmi\"} 1' /tmp/ipmi-metrics",
|
||||
"grep -F 'ipmi_temperature_celsius{id=\"3\",name=\"MBTemp\"} 96' /tmp/ipmi-metrics",
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
libgcrypt,
|
||||
readline,
|
||||
libgpg-error,
|
||||
nixosTests,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
@@ -44,6 +45,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
|
||||
doCheck = true;
|
||||
|
||||
passthru.tests = { inherit (nixosTests.prometheus-exporters) ipmi; };
|
||||
|
||||
meta = {
|
||||
description = "Implementation of the Intelligent Platform Management Interface";
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
{
|
||||
stdenv,
|
||||
buildPackages,
|
||||
fetchpatch,
|
||||
fetchurl,
|
||||
popt,
|
||||
ncurses,
|
||||
python3,
|
||||
readline,
|
||||
lib,
|
||||
nixosTests,
|
||||
openssl,
|
||||
}:
|
||||
|
||||
@@ -19,6 +21,20 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
sha256 = "sha256-xi049dp99Cmaw6ZSUI6VlTd1JEAYHjTHayrs69fzAbk=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
# Fix broken command order in shipped ipmisim1:
|
||||
(fetchpatch {
|
||||
url = "https://github.com/cminyard/openipmi/commit/07adcedd824496d69be469101a7be1bbe371741a.patch";
|
||||
hash = "sha256-zAbnyliZr5HV9dYlyse4ff1lYJty+/74aqmXHWJM13c=";
|
||||
})
|
||||
|
||||
# Sensors not marked ready after set_sensor_value.
|
||||
(fetchpatch {
|
||||
url = "https://github.com/cminyard/openipmi/commit/2325cc63727bab6a0f29fca2db4ba7d69c11e3b9.patch";
|
||||
hash = "sha256-ZbxV7ThFDbI5vxlLLavMrAZzCj3gPnR0sRcyHub5S30=";
|
||||
})
|
||||
];
|
||||
|
||||
postConfigure = lib.optionalString (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
||||
substituteInPlace lanserv/Makefile \
|
||||
--replace-fail "sdrcomp/sdrcomp_build -o" "${buildPackages.openipmi}/bin/sdrcomp -o"
|
||||
@@ -42,6 +58,13 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"BUILD_CC=${stdenv.cc.targetPrefix}cc"
|
||||
];
|
||||
|
||||
# Include SDR files; ipmi-sim requires .bsdr (installed as sdr.20.main) to
|
||||
# advertise its sensor names.
|
||||
postInstall = ''
|
||||
install -Dm444 lanserv/ipmisim1.sdrs $out/share/openipmi/ipmisim1.sdrs
|
||||
install -Dm444 lanserv/ipmisim1.bsdr $out/share/openipmi/ipmisim1.bsdr
|
||||
'';
|
||||
|
||||
outputs = [
|
||||
"out"
|
||||
"lib"
|
||||
@@ -49,6 +72,8 @@ stdenv.mkDerivation (finalAttrs: {
|
||||
"man"
|
||||
];
|
||||
|
||||
passthru.tests = { inherit (nixosTests.prometheus-exporters) ipmi; };
|
||||
|
||||
meta = {
|
||||
homepage = "https://openipmi.sourceforge.io/";
|
||||
description = "User-level library that provides a higher-level abstraction of IPMI and generic services";
|
||||
|
||||
Reference in New Issue
Block a user