Fix invalid test data (#9099)

* Fix invalid test data
and add test for it

* fix bgp

* add missing comma back
This commit is contained in:
Tony Murray
2018-08-28 14:18:59 -05:00
committed by GitHub
parent 31a21ba2bc
commit f73f7ec5ce
5 changed files with 136 additions and 118 deletions

View File

@@ -226,6 +226,7 @@ class ModuleTestHelper
*
* @param array $modules
* @return array
* @throws InvalidModuleException
*/
public static function findOsWithData($modules = [])
{
@@ -253,11 +254,15 @@ class ModuleTestHelper
continue; // no test data for selected modules
}
$os_list[$base_name] = [
$os,
$variant,
self::resolveModuleDependencies($valid_modules),
];
try {
$os_list[$base_name] = [
$os,
$variant,
self::resolveModuleDependencies($valid_modules),
];
} catch (InvalidModuleException $e) {
throw new InvalidModuleException("Invalid module " . $e->getMessage() . " in $os $variant");
}
}
return $os_list;

View File

@@ -31,6 +31,22 @@ use LibreNMS\Util\ModuleTestHelper;
class OSModulesTest extends DBTestCase
{
/**
* Test all modules for a particular OS
*
* @group os
* @dataProvider dumpedDataProvider
*/
public function testDataIsValid($os, $variant, $modules)
{
// special case if data provider throws exception
if ($os === false) {
$this->fail($modules);
}
$this->assertNotEmpty($modules, "No modules to test for $os $variant");
}
/**
* Test all modules for a particular OS
*
@@ -105,6 +121,11 @@ class OSModulesTest extends DBTestCase
$modules = explode(',', getenv('TEST_MODULES'));
}
return ModuleTestHelper::findOsWithData($modules);
try {
return ModuleTestHelper::findOsWithData($modules);
} catch (InvalidModuleException $e) {
// special case for exception
return [[false, false, $e->getMessage()]];
}
}
}

View File

@@ -10986,18 +10986,6 @@
},
"poller": "matches discovery"
},
"bgp-peers": {
"discovery": {
"devices": [
{
"bgpLocalAs": null
}
],
"bgpPeers": [],
"bgpPeers_cbgp": []
},
"poller": "matches discovery"
},
"vlans": {
"discovery": {
"vlans": [

View File

@@ -1,55 +1,57 @@
{
"discovery": {
"applications": {
"app_type": "ntp-client",
"app_state": "UNKNOWN",
"discovered": "1",
"app_state_prev": null,
"app_status": "",
"app_instance": ""
"applications": {
"discovery": {
"applications": {
"app_type": "ntp-client",
"app_state": "UNKNOWN",
"discovered": "1",
"app_state_prev": null,
"app_status": "",
"app_instance": ""
},
"application_metrics": []
},
"application_metrics": []
},
"poller": {
"applications": {
"app_type": "ntp-client",
"app_state": "OK",
"discovered": "1",
"app_state_prev": "UNKNOWN",
"app_status": "",
"app_instance": ""
},
"application_metrics": [
{
"metric": "clk_jitter",
"value": "0.853",
"value_prev": null,
"app_type": "ntp-client"
"poller": {
"applications": {
"app_type": "ntp-client",
"app_state": "OK",
"discovered": "1",
"app_state_prev": "UNKNOWN",
"app_status": "",
"app_instance": ""
},
{
"metric": "clk_wander",
"value": "0.025",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "frequency",
"value": "91.141",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "offset",
"value": "0.702900",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "sys_jitter",
"value": "2.581995",
"value_prev": null,
"app_type": "ntp-client"
}
]
"application_metrics": [
{
"metric": "clk_jitter",
"value": "0.853",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "clk_wander",
"value": "0.025",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "frequency",
"value": "91.141",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "offset",
"value": "0.702900",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "sys_jitter",
"value": "2.581995",
"value_prev": null,
"app_type": "ntp-client"
}
]
}
}
}

View File

@@ -1,55 +1,57 @@
{
"discovery": {
"applications": {
"app_type": "ntp-client",
"app_state": "UNKNOWN",
"discovered": "1",
"app_state_prev": null,
"app_status": "",
"app_instance": ""
"applications": {
"discovery": {
"applications": {
"app_type": "ntp-client",
"app_state": "UNKNOWN",
"discovered": "1",
"app_state_prev": null,
"app_status": "",
"app_instance": ""
},
"application_metrics": []
},
"application_metrics": []
},
"poller": {
"applications": {
"app_type": "ntp-client",
"app_state": "OK",
"discovered": "1",
"app_state_prev": "UNKNOWN",
"app_status": "",
"app_instance": ""
},
"application_metrics": [
{
"metric": "clk_jitter",
"value": "0.853",
"value_prev": null,
"app_type": "ntp-client"
"poller": {
"applications": {
"app_type": "ntp-client",
"app_state": "OK",
"discovered": "1",
"app_state_prev": "UNKNOWN",
"app_status": "",
"app_instance": ""
},
{
"metric": "clk_wander",
"value": "0.025",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "frequency",
"value": "91.141",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "offset",
"value": "0.702900",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "sys_jitter",
"value": "2.581995",
"value_prev": null,
"app_type": "ntp-client"
}
]
"application_metrics": [
{
"metric": "clk_jitter",
"value": "0.853",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "clk_wander",
"value": "0.025",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "frequency",
"value": "91.141",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "offset",
"value": "0.702900",
"value_prev": null,
"app_type": "ntp-client"
},
{
"metric": "sys_jitter",
"value": "2.581995",
"value_prev": null,
"app_type": "ntp-client"
}
]
}
}
}