From e7d954d7df83474f1dae84cceb8f6e91cf9e2f70 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 23 May 2020 14:43:41 -0500 Subject: [PATCH] Fix dev:check fail-fast not returning error (#11672) Fix dantherm definition --- LibreNMS/Util/CiHelper.php | 12 +++--- LibreNMS/Util/FileCategorizer.php | 8 +++- .../definitions/discovery/dantherm-os.yaml | 17 +++----- tests/bootstrap.php | 10 +++-- tests/data/dantherm-os.json | 43 +++++-------------- 5 files changed, 36 insertions(+), 54 deletions(-) diff --git a/LibreNMS/Util/CiHelper.php b/LibreNMS/Util/CiHelper.php index ffa3e94a3d..f1e6bd17a0 100644 --- a/LibreNMS/Util/CiHelper.php +++ b/LibreNMS/Util/CiHelper.php @@ -127,7 +127,7 @@ class CiHelper $ret = $this->runCheck($check); if ($this->flags['fail-fast'] && $ret !== 0 && $ret !== 250) { - return $return; + return $ret; } else { $return += $ret; } @@ -311,7 +311,7 @@ class CiHelper return $ret; } - if ($this->flags["{$type}_skip"]) { + if ($this->flags["{$type}_enable"] && $this->flags["{$type}_skip"]) { echo ucfirst($type) . " check skipped.\n"; } return 0; @@ -394,10 +394,10 @@ class CiHelper public function checkEnvSkips() { - $this->flags['unit_skip'] = (bool)getenv('SKIP_UNIT_CHECK'); - $this->flags['lint_skip'] = (bool)getenv('SKIP_LINT_CHECK'); - $this->flags['web_skip'] = (bool)getenv('SKIP_WEB_CHECK'); - $this->flags['style_skip'] = (bool)getenv('SKIP_STYLE_CHECK'); + $this->flags['unit_skip'] = $this->flags['unit_skip'] || getenv('SKIP_UNIT_CHECK'); + $this->flags['lint_skip'] = $this->flags['lint_skip'] || getenv('SKIP_LINT_CHECK'); + $this->flags['web_skip'] = $this->flags['web_skip'] || getenv('SKIP_WEB_CHECK'); + $this->flags['style_skip'] = $this->flags['style_skip'] || getenv('SKIP_STYLE_CHECK'); } public function detectChangedFiles() diff --git a/LibreNMS/Util/FileCategorizer.php b/LibreNMS/Util/FileCategorizer.php index 1690443136..d9dbe8029f 100644 --- a/LibreNMS/Util/FileCategorizer.php +++ b/LibreNMS/Util/FileCategorizer.php @@ -37,7 +37,13 @@ class FileCategorizer extends Categorizer if (getenv('CIHELPER_DEBUG')) { $this->setSkippable(function ($item) { - return in_array($item, ['.travis.yml', 'LibreNMS/Util/CiHelper.php', 'LibreNMS/Util/FileCategorizer.php']); + return in_array($item, [ + '.travis.yml', + 'LibreNMS/Util/CiHelper.php', + 'LibreNMS/Util/FileCategorizer.php', + 'app/Console/Commands/DevCheckCommand.php', + 'tests/Unit/CiHelperTest.php', + ]); }); } diff --git a/includes/definitions/discovery/dantherm-os.yaml b/includes/definitions/discovery/dantherm-os.yaml index ae6a37c67d..f1b74d2f30 100644 --- a/includes/definitions/discovery/dantherm-os.yaml +++ b/includes/definitions/discovery/dantherm-os.yaml @@ -1,23 +1,20 @@ -mib: DANTHERM-COOLING-MIB +mib: DANTHERM-COOLING-MIB modules: sensors: temperature: data: - oid: onBoardTempr - value: onBoardTempr index: onBoardTempr.{{ $index }} num_oid: .1.3.6.1.4.1.46651.1.1.1.{{ $index }} descr: onBoard Tempr - oid: roomTempr - value: roomTempr index: roomTempr.{{ $index }} num_oid: .1.3.6.1.4.1.46651.1.1.2.{{ $index }} - descr: room Tempr + descr: room Tempr - oid: hotSpotTempr - value: hotSpotTempr index: hotSpotTempr.{{ $index }} num_oid: .1.3.6.1.4.1.46651.1.1.3.{{ $index }} descr: hotSpot Tempr @@ -25,13 +22,11 @@ modules: data: - oid: fan1RPM - value: fan1RPM index: fan1RPM.{{ $index }} num_oid: .1.3.6.1.4.1.46651.1.1.8.{{ $index }} descr: fan1 RPM - oid: fan2RPM - value: fan2RPM index: fan2RPM.{{ $index }} num_oid: .1.3.6.1.4.1.46651.1.1.9.{{ $index }} descr: fan2 RPM @@ -39,20 +34,20 @@ modules: data: - oid: fan1Status - value: fan1Status num_oid: .1.3.6.1.4.1.46651.1.1.18.{{ $index }} descr: Fan 1 operation status - state_name: fan1Status_states + index: fan1Status.{{ $index }} + state_name: fanStatus_states states: - { value: 0, graph: 0, generic: 2, descr: Off } - { value: 1, graph: 0, generic: 0, descr: On } - { value: 2, graph: 0, generic: 1, descr: Emergency/Boost } - oid: fan2Status - value: fan2Status num_oid: .1.3.6.1.4.1.46651.1.1.19.{{ $index }} descr: Fan 2 operation status - state_name: fan2Status_states + index: fan2Status.{{ $index }} + state_name: fanStatus_states states: - { value: 0, graph: 0, generic: 2, descr: Off } - { value: 1, graph: 0, generic: 0, descr: On } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 7eabe9d12a..ca0cd6bcf7 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -68,10 +68,12 @@ if (getenv('DBTEST')) { // try to avoid erasing people's primary databases if ($db_config['database'] !== \config('database.connections.mysql.database', 'librenms')) { - echo "Refreshing database..."; - $migrate_result = Artisan::call('migrate:fresh', ['--seed' => true, '--env' => 'testing', '--database' => 'testing']); - $migrate_output = Artisan::output(); - echo "done\n"; + if (!getenv('SKIP_DB_REFRESH')) { + echo "Refreshing database..."; + $migrate_result = Artisan::call('migrate:fresh', ['--seed' => true, '--env' => 'testing', '--database' => 'testing']); + $migrate_output = Artisan::output(); + echo "done\n"; + } } else { echo "Info: Refusing to reset main database: {$db_config['database']}. Running migrations.\n"; $migrate_result = Artisan::call('migrate', ['--seed' => true, '--env' => 'testing', '--database' => 'testing']); diff --git a/tests/data/dantherm-os.json b/tests/data/dantherm-os.json index c6c831fcbf..cd239c0b45 100644 --- a/tests/data/dantherm-os.json +++ b/tests/data/dantherm-os.json @@ -93,8 +93,8 @@ "sensor_class": "state", "poller_type": "snmp", "sensor_oid": ".1.3.6.1.4.1.46651.1.1.18.0", - "sensor_index": "0", - "sensor_type": "fan1Status_states", + "sensor_index": "fan1Status.0", + "sensor_type": "fanStatus_states", "sensor_descr": "Fan 1 operation status", "group": null, "sensor_divisor": 1, @@ -110,15 +110,15 @@ "entPhysicalIndex_measured": null, "sensor_prev": null, "user_func": null, - "state_name": "fan1Status_states" + "state_name": "fanStatus_states" }, { "sensor_deleted": 0, "sensor_class": "state", "poller_type": "snmp", "sensor_oid": ".1.3.6.1.4.1.46651.1.1.19.0", - "sensor_index": "0", - "sensor_type": "fan2Status_states", + "sensor_index": "fan2Status.0", + "sensor_type": "fanStatus_states", "sensor_descr": "Fan 2 operation status", "group": null, "sensor_divisor": 1, @@ -134,7 +134,7 @@ "entPhysicalIndex_measured": null, "sensor_prev": null, "user_func": null, - "state_name": "fan2Status_states" + "state_name": "fanStatus_states" }, { "sensor_deleted": 0, @@ -211,46 +211,25 @@ ], "state_indexes": [ { - "state_name": "fan1Status_states", + "state_name": "fanStatus_states", "state_descr": "Off", "state_draw_graph": 0, "state_value": 0, - "state_generic_value": 0 + "state_generic_value": 2 }, { - "state_name": "fan1Status_states", + "state_name": "fanStatus_states", "state_descr": "On", "state_draw_graph": 0, "state_value": 1, "state_generic_value": 0 }, { - "state_name": "fan1Status_states", + "state_name": "fanStatus_states", "state_descr": "Emergency/Boost", "state_draw_graph": 0, "state_value": 2, - "state_generic_value": 0 - }, - { - "state_name": "fan2Status_states", - "state_descr": "Off", - "state_draw_graph": 0, - "state_value": 0, - "state_generic_value": 0 - }, - { - "state_name": "fan2Status_states", - "state_descr": "On", - "state_draw_graph": 0, - "state_value": 1, - "state_generic_value": 0 - }, - { - "state_name": "fan2Status_states", - "state_descr": "Emergency/Boost", - "state_draw_graph": 0, - "state_value": 2, - "state_generic_value": 0 + "state_generic_value": 1 } ] },