Unverified Commit b18f49a4 authored by Johann Wagner's avatar Johann Wagner Committed by GitHub
Browse files

nixos/tests/librenms: Using services.snmpd module for tests to fix test timeouts (#332925)

parent 7cdac43d
Loading
Loading
Loading
Loading
+18 −25
Original line number Diff line number Diff line
@@ -3,7 +3,8 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
let
  api_token = "f87f42114e44b63ad1b9e3c3d33d6fbe"; # random md5 hash
  wrong_api_token = "e68ba041fcf1eab923a7a6de3af5f726"; # another random md5 hash
in {
in
{
  name = "librenms";
  meta.maintainers = lib.teams.wdz.members;

@@ -60,19 +61,12 @@ in {
  };

  nodes.snmphost = {
    networking.firewall.allowedUDPPorts = [ 161 ];

    systemd.services.snmpd = {
      description = "snmpd";
      after = [ "network-online.target" ];
      wants = [ "network-online.target" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        Type = "forking";
        User = "root";
        Group = "root";
        ExecStart = let
          snmpd-config = pkgs.writeText "snmpd-config" ''
    services.snmpd = {
      enable = true;
      openFirewall = true;

      configText = ''
        com2sec readonly default public

        group MyROGroup v2c        readonly
@@ -82,15 +76,14 @@ in {
        syslocation Testcity, Testcountry
        syscontact Testi mc Test <test@example.com>
      '';
        in "${pkgs.net-snmp}/bin/snmpd -c ${snmpd-config} -C";
      };

    };
  };

  testScript = ''
    start_all()

    snmphost.wait_until_succeeds("pgrep snmpd")
    snmphost.wait_for_unit("snmpd.service")

    librenms.wait_for_unit("lnms-api-init.service")
    librenms.wait_for_open_port(80)