Improve Snmpsim usage to ease testing (#15471)

* Snmpsim use python venv
Patch to enable listening while minimizing output
Update lnms dev:simulate, tests, and ./scripts/save-test-data.php
removed old option to start snmpsim from older scripts, use lnms dev:simulate

* Apply fixes from StyleCI

* various fixes

* Remove patch official package is updated

---------

Co-authored-by: StyleCI Bot <bot@styleci.io>
This commit is contained in:
Tony Murray
2024-07-17 16:05:07 -05:00
committed by GitHub
parent 10669226fc
commit 1cceafb887
11 changed files with 100 additions and 212 deletions

View File

@ -5,7 +5,6 @@ use Illuminate\Support\Str;
use LibreNMS\Exceptions\InvalidModuleException;
use LibreNMS\Util\Debug;
use LibreNMS\Util\ModuleTestHelper;
use LibreNMS\Util\Snmpsim;
$install_dir = realpath(__DIR__ . '/..');
chdir($install_dir);
@ -23,18 +22,11 @@ $options = getopt(
'variant:',
'file:',
'debug',
'snmpsim',
'full',
'help',
]
);
if (isset($options['snmpsim'])) {
$snmpsim = new Snmpsim();
$snmpsim->run();
exit;
}
if (isset($options['v'])) {
$variant = $options['v'];
} elseif (isset($options['variant'])) {

View File

@ -20,7 +20,6 @@ $options = getopt(
'no-save',
'file:',
'debug',
'snmpsim',
'help',
]
);
@ -32,12 +31,6 @@ Debug::setVerbose(
Debug::set(isset($options['d']) || isset($options['debug']))
);
if (isset($options['snmpsim'])) {
$snmpsim = new Snmpsim();
$snmpsim->run();
exit;
}
if (isset($options['h'])
|| isset($options['help'])
|| ! (isset($options['o']) || isset($options['os']) || isset($options['m']) || isset($options['modules']))
@ -120,9 +113,10 @@ if (isset($options['f'])) {
// Now use the saved data to update the saved database data
$snmpsim = new Snmpsim();
$snmpsim->fork();
$snmpsim_ip = $snmpsim->getIp();
$snmpsim_port = $snmpsim->getPort();
$snmpsim->setupVenv();
$snmpsim->start();
echo "Waiting for snmpsim to initialize...\n";
$snmpsim->waitForStartup();
if (! $snmpsim->isRunning()) {
echo "Failed to start snmpsim, make sure it is installed, working, and there are no bad snmprec files.\n";
@ -130,8 +124,6 @@ if (! $snmpsim->isRunning()) {
exit(1);
}
echo "Pausing 10 seconds to allow snmpsim to initialize...\n";
sleep(10);
echo "\n";
try {