Cache astext in tests to avoid DNS lookup (#12784)

This commit is contained in:
Jellyfrog 2021-04-23 04:05:23 +02:00 committed by GitHub
parent 11d4f8c669
commit b9b7a8caa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -26,6 +26,7 @@ namespace LibreNMS\Tests\Feature\SnmpTraps;
use App\Models\BgpPeer;
use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Snmptrap\Dispatcher;
use LibreNMS\Snmptrap\Trap;
@ -33,8 +34,10 @@ class BgpTrapTest extends SnmpTrapTestCase
{
public function testBgpUp()
{
// Cache it to avoid DNS Lookup
Config::set('astext.1', 'PHPUnit ASTEXT');
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'idle']);
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'idle', 'bgpPeerRemoteAs' => 1]);
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname
@ -56,8 +59,10 @@ BGP4-MIB::bgpPeerState.$bgppeer->bgpPeerIdentifier established\n";
public function testBgpDown()
{
// Cache it to avoid DNS Lookup
Config::set('astext.1', 'PHPUnit ASTEXT');
$device = Device::factory()->create();
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'established']);
$bgppeer = BgpPeer::factory()->make(['bgpPeerState' => 'established', 'bgpPeerRemoteAs' => 1]);
$device->bgppeers()->save($bgppeer);
$trapText = "$device->hostname