From 44c1ee5f4319a55035f4302d2010f816956708c4 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Fri, 12 Jan 2018 15:24:12 -0600 Subject: [PATCH] Fix tests... (#8080) Don't exit when we can't add a device, fail :) --- LibreNMS/Util/ModuleTestHelper.php | 4 ++-- tests/OSModulesTest.php | 4 ++++ ...{edgecos_ECS3510-52T.json => edgecos_ecs3510-52t.json} | 0 ...{edgecos_ECS4210-28T.json => edgecos_ecs4210-28t.json} | 8 ++++---- ...{edgecos_ECS4510-28F.json => edgecos_ecs4510-28f.json} | 4 ++-- ...{edgecos_ECS4510-52T.json => edgecos_ecs4510-52t.json} | 4 ++-- .../{edgecos_ES3528MV2.json => edgecos_es3528mv2.json} | 4 ++-- 7 files changed, 16 insertions(+), 12 deletions(-) rename tests/data/{edgecos_ECS3510-52T.json => edgecos_ecs3510-52t.json} (100%) rename tests/data/{edgecos_ECS4210-28T.json => edgecos_ecs4210-28t.json} (93%) rename tests/data/{edgecos_ECS4510-28F.json => edgecos_ecs4510-28f.json} (97%) rename tests/data/{edgecos_ECS4510-52T.json => edgecos_ecs4510-52t.json} (97%) rename tests/data/{edgecos_ES3528MV2.json => edgecos_es3528mv2.json} (97%) diff --git a/LibreNMS/Util/ModuleTestHelper.php b/LibreNMS/Util/ModuleTestHelper.php index ae06d216ed..f019345932 100644 --- a/LibreNMS/Util/ModuleTestHelper.php +++ b/LibreNMS/Util/ModuleTestHelper.php @@ -398,8 +398,8 @@ class ModuleTestHelper $device_id = addHost($snmpsim->getIp(), 'v2c', $snmpsim->getPort()); $this->qPrint("Added device: $device_id\n"); } catch (\Exception $e) { - echo $e->getMessage() . PHP_EOL; - exit; + echo $this->file_name . ': ' . $e->getMessage() . PHP_EOL; + return null; } // Populate the device variable diff --git a/tests/OSModulesTest.php b/tests/OSModulesTest.php index f7bc588c5b..f940197aeb 100644 --- a/tests/OSModulesTest.php +++ b/tests/OSModulesTest.php @@ -55,6 +55,10 @@ class OSModulesTest extends DBTestCase $results = $helper->generateTestData($snmpsim, true); + if (is_null($results)) { + $this->fail("$target_os: Failed to collect data."); + } + foreach ($modules as $module) { $this->assertEquals( $expected_data[$module]['discovery'], diff --git a/tests/data/edgecos_ECS3510-52T.json b/tests/data/edgecos_ecs3510-52t.json similarity index 100% rename from tests/data/edgecos_ECS3510-52T.json rename to tests/data/edgecos_ecs3510-52t.json diff --git a/tests/data/edgecos_ECS4210-28T.json b/tests/data/edgecos_ecs4210-28t.json similarity index 93% rename from tests/data/edgecos_ECS4210-28T.json rename to tests/data/edgecos_ecs4210-28t.json index 4800915a10..fda146069f 100644 --- a/tests/data/edgecos_ECS4210-28T.json +++ b/tests/data/edgecos_ecs4210-28t.json @@ -30,8 +30,8 @@ "mempool_precision": "1", "mempool_descr": "Memory", "mempool_perc": "93", - "mempool_used": "124489728", - "mempool_free": "9728000", + "mempool_used": "124547072", + "mempool_free": "9670656", "mempool_total": "134217728", "mempool_largestfree": null, "mempool_lowestfree": null, @@ -50,7 +50,7 @@ "processor_oid": ".1.3.6.1.4.1.259.10.1.42.101.1.39.2.1.0", "processor_index": "0", "processor_type": "edgecos", - "processor_usage": "45", + "processor_usage": "100", "processor_descr": "Processor", "processor_precision": "1", "processor_perc_warn": "75" @@ -59,4 +59,4 @@ }, "poller": "matches discovery" } -} \ No newline at end of file +} diff --git a/tests/data/edgecos_ECS4510-28F.json b/tests/data/edgecos_ecs4510-28f.json similarity index 97% rename from tests/data/edgecos_ECS4510-28F.json rename to tests/data/edgecos_ecs4510-28f.json index 6d56636026..c4c159e86f 100644 --- a/tests/data/edgecos_ECS4510-28F.json +++ b/tests/data/edgecos_ecs4510-28f.json @@ -50,7 +50,7 @@ "processor_oid": ".1.3.6.1.4.1.259.10.1.24.1.39.2.1.0", "processor_index": "0", "processor_type": "edgecos", - "processor_usage": "15", + "processor_usage": "31", "processor_descr": "Processor", "processor_precision": "1", "processor_perc_warn": "75" @@ -59,4 +59,4 @@ }, "poller": "matches discovery" } -} \ No newline at end of file +} diff --git a/tests/data/edgecos_ECS4510-52T.json b/tests/data/edgecos_ecs4510-52t.json similarity index 97% rename from tests/data/edgecos_ECS4510-52T.json rename to tests/data/edgecos_ecs4510-52t.json index e0f414fd37..dc1ba5eaa3 100644 --- a/tests/data/edgecos_ECS4510-52T.json +++ b/tests/data/edgecos_ecs4510-52t.json @@ -50,7 +50,7 @@ "processor_oid": ".1.3.6.1.4.1.259.10.1.24.1.39.2.1.0", "processor_index": "0", "processor_type": "edgecos", - "processor_usage": "28", + "processor_usage": "27", "processor_descr": "Processor", "processor_precision": "1", "processor_perc_warn": "75" @@ -59,4 +59,4 @@ }, "poller": "matches discovery" } -} \ No newline at end of file +} diff --git a/tests/data/edgecos_ES3528MV2.json b/tests/data/edgecos_es3528mv2.json similarity index 97% rename from tests/data/edgecos_ES3528MV2.json rename to tests/data/edgecos_es3528mv2.json index 365a6faf12..2fbfdd25d1 100644 --- a/tests/data/edgecos_ES3528MV2.json +++ b/tests/data/edgecos_es3528mv2.json @@ -50,7 +50,7 @@ "processor_oid": ".1.3.6.1.4.1.259.10.1.22.1.39.2.1.0", "processor_index": "0", "processor_type": "edgecos", - "processor_usage": "22", + "processor_usage": "20", "processor_descr": "Processor", "processor_precision": "1", "processor_perc_warn": "75" @@ -59,4 +59,4 @@ }, "poller": "matches discovery" } -} \ No newline at end of file +}