Skip to content

Commit e5ce7bf

Browse files
authored
Added lnms dev:check modules only (librenms#17044)
* lnms dev:check --os-modules-only always Make --os-modules-only always work. So if you run as worked before like this to skip os detection tests: `lnms dev:check unit --os ios --os-modules-only` Or like this to just test all discovery/polling modules (new): `lnms dev:check unit --os-modules-only` * Doc improvement
1 parent 1a82b02 commit e5ce7bf

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

LibreNMS/Util/CiHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function checkUnit()
203203
array_push($phpunit_cmd, '--group', 'docs');
204204
} elseif ($this->flags['unit_svg']) {
205205
$phpunit_cmd[] = 'tests/SVGTest.php';
206-
} elseif ($this->flags['unit_modules']) {
206+
} elseif ($this->flags['unit_modules'] || $this->flags['os-modules-only']) {
207207
$phpunit_cmd[] = 'tests/OSModulesTest.php';
208208
}
209209

app/Console/Commands/DevCheckCommand.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,14 @@ private function parseInput()
9696
'lint_enable' => false,
9797
'unit_enable' => true,
9898
'web_enable' => false,
99-
'os-modules-only' => $this->option('os-modules-only'),
10099
]);
101100
$this->helper->setOS(explode(',', $os));
102101
}
103102

103+
$this->helper->setFlags([
104+
'os-modules-only' => $this->option('os-modules-only'),
105+
]);
106+
104107
if ($modules = $this->option('module')) {
105108
$this->helper->setFlags(['style_enable' => false, 'lint_enable' => false, 'unit_enable' => true, 'web_enable' => false]);
106109
$this->helper->setModules(explode(',', $modules));

doc/Developing/os/Test-Units.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,17 @@ tests: `lnms dev:check unit --db --snmpsim`
6464

6565
`lnms dev:check unit -o osname`
6666

67+
### Test an OS, but only discovery and polling modules (exluding OS detection)
68+
`lnms dev:check unit --os osname --os-modules-only`
69+
70+
6771
### Specific Module
6872

6973
`lnms dev:check unit -m modulename`
7074

75+
### Test all modules for all os and stop on failure
76+
`lnms dev:check unit --db -snmpsim --os-modules-only -f`
77+
7178
## Using snmpsim for testing
7279

7380
You can run snmpsim to access test data by running
@@ -83,6 +90,17 @@ the community and 127.1.6.1:1161 as the host.
8390
snmpget -v 2c -c ios_c3560e 127.1.6.1:1161 sysDescr.0
8491
```
8592

93+
## Simulate specific device from test data
94+
95+
Add/update a device called "snmpsim" to your install and set to use a specific snmprec file
96+
97+
```bash
98+
lnms dev:simulate ios_2960x
99+
```
100+
101+
You can then run `./discovery.php -h snmpsim -d -v` and `lnms device:poll snmpsim -vvv`
102+
to discover and poll the simulated device.
103+
86104
## Snmprec format
87105

88106
Snmprec files are simple files that store the snmp data. The data

0 commit comments

Comments
 (0)