mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix some testing issues (#16174)
* Fix some testing issues index doesn't exist in ModuleTestHelper Cache issue in NetSnmpQuery (specifically affects testing) * Apply fixes from StyleCI --------- Co-authored-by: Tony Murray <murrant@users.noreply.github.com>
This commit is contained in:
@@ -407,8 +407,21 @@ class NetSnmpQuery implements SnmpQueryInterface
|
||||
private function exec(string $command, array $oids): SnmpResponse
|
||||
{
|
||||
// use runtime(array) cache if requested. The 'null' driver will simply return the value without caching
|
||||
$driver = $this->cache ? 'array' : 'null';
|
||||
$key = $this->cache ? $this->getCacheKey($command, $oids) : '';
|
||||
$driver = 'null';
|
||||
$key = '';
|
||||
|
||||
if ($this->cache) {
|
||||
$driver = 'array';
|
||||
$key = $this->getCacheKey($command, $oids);
|
||||
|
||||
if (Debug::isEnabled()) {
|
||||
if (Cache::driver($driver)->has($key)) {
|
||||
Log::debug("Cache hit for $command " . implode(',', $oids));
|
||||
} else {
|
||||
Log::debug("Cache miss for $command " . implode(',', $oids) . ', grabbing fresh data.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Cache::driver($driver)->rememberForever($key, function () use ($command, $oids) {
|
||||
$measure = Measurement::start($command);
|
||||
@@ -546,6 +559,6 @@ class NetSnmpQuery implements SnmpQueryInterface
|
||||
$oids = implode(',', $oids);
|
||||
$options = implode(',', $this->options);
|
||||
|
||||
return "$type|{$this->device->hostname}|$this->context|$oids|$options";
|
||||
return "$type|{$this->device->hostname}|{$this->device->community}|$this->context|$oids|$options";
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user