Improve our parent/children identification with points, fix our testing that was failing with NULLs and asserted out. Added zone:check so that's its easier to identify parent for FTNs
This commit is contained in:
@@ -6,8 +6,48 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
use App\Models\{Address,Domain,Setup};
|
||||
use App\Models\{Address,Domain,Setup,System};
|
||||
|
||||
/**
|
||||
* Here we test mail routing.
|
||||
*
|
||||
* - COMMON to all routing nodes
|
||||
* + We have RCs defined - everything for a node in the Region goes to an RC, unless RC's node defined locally, or nodes assigned to ZC
|
||||
* ie: region_id is the same, find the NC/HUB/NODE address for the system_id that has been assigned 0/0 in the same region.
|
||||
* nodes assigned to ZC have region_id = 0. Nodes with hub_id = NULL and host_id=0 are RC nodes.
|
||||
* + We have NCs defined - everything under the Host goes to the NC, unless NC's nodes defined locally or nodes assigned to the RC
|
||||
* ie: node_id defines the NCs responsible. Nodes with hub_id = NULL are an NC node.
|
||||
* + We have HUBs defined - everything under the Hub goes to the HUB, unless HUB's nodes defined locally
|
||||
* ie: hub_id defines who the hub is.
|
||||
* + We have NODES defined - mail collected locally, including mail for it's point
|
||||
*
|
||||
* - Routing scenarios:
|
||||
* - We are ZC for a domain
|
||||
* + See COMMON
|
||||
* + Everything else is collected locally
|
||||
*
|
||||
* - We are RC for a domain
|
||||
* + See COMMON
|
||||
* + Any nodes in our RC not defined with an NC is collected locally, including points
|
||||
* + Everything else is sent to the ZC (our uplink)
|
||||
*
|
||||
* - We are NC for a domain
|
||||
* + See COMMON
|
||||
* + Any nodes in our NC not defined with a HUB is collected locally, including points
|
||||
* + Everything else is sent to the RC or ZC (our uplink)
|
||||
*
|
||||
* - We are a Hub for a domain
|
||||
* + See COMMON
|
||||
* + Any nodes in our HUB is collected locally, including points
|
||||
* + Everything else is sent to the NC or RC (our uplink)
|
||||
*
|
||||
* - We are a Node in a domain
|
||||
* + See COMMON
|
||||
* + Everything else is sent to the HUB or Host or RC (our uplink)
|
||||
*
|
||||
* @see Address::parent()
|
||||
* @see Address::children()
|
||||
*/
|
||||
class RoutingTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
@@ -38,7 +78,7 @@ class RoutingTest extends TestCase
|
||||
private function session_nc(): void
|
||||
{
|
||||
// Add session info, and we have 51 children
|
||||
$ao = Address::findFTN('100:10/0@a');
|
||||
$ao = Address::findFTN('100:10/7@a');
|
||||
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
|
||||
}
|
||||
|
||||
@@ -93,8 +133,17 @@ class RoutingTest extends TestCase
|
||||
$this->assertEquals('101:0/0.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// Get a list of active addresses in a Region
|
||||
public function test_rc_session_children()
|
||||
{
|
||||
$this->session_rc();
|
||||
|
||||
$ao = Address::findFTN('100:1/0@a');
|
||||
$this->assertEquals(185,$ao->children()->count());
|
||||
}
|
||||
|
||||
// An RCs node still collects mail from the RC
|
||||
public function test_zc_rc_node_rc()
|
||||
public function test_rc_node_rc()
|
||||
{
|
||||
$this->session_rc();
|
||||
|
||||
@@ -105,58 +154,45 @@ class RoutingTest extends TestCase
|
||||
}
|
||||
|
||||
// An NC collects mail for its children
|
||||
public function test_zc_nc_node_rc()
|
||||
public function test_rc_nc_node_rc()
|
||||
{
|
||||
return $this->assertTrue(TRUE);
|
||||
$this->session_rc();
|
||||
|
||||
// A NCs parent should still be the RC
|
||||
$ao = Address::findFTN('100:10/0@a');
|
||||
$ao = Address::findFTN('100:10/7@a');
|
||||
$this->assertEquals($ao->role,Address::NODE_NC);
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn); // @todo fails, returning NULL?
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// A Hub still collects mail from NC
|
||||
public function test_zc_hub_node_nc()
|
||||
public function test_rc_hub_node_nc()
|
||||
{
|
||||
return $this->assertTrue(TRUE);
|
||||
$this->session_rc();
|
||||
|
||||
// A Hubs parent should still be the NC
|
||||
$ao = Address::findFTN('100:10/20.0@a');
|
||||
$this->assertEquals($ao->role,Address::NODE_HC);
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn); // @todo fails, returning NULL?
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// A Hub's node still collects mail from Hub
|
||||
public function test_zc_hub_node_hub()
|
||||
public function test_rc_hub_node_hub()
|
||||
{
|
||||
return $this->assertTrue(TRUE);
|
||||
$this->session_rc();
|
||||
|
||||
// A Hubs node should still be the Hub
|
||||
$ao = Address::findFTN('100:10/22.0@a');
|
||||
$this->assertEquals($ao->role,Address::NODE_ACTIVE);
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn); // @todo fails, returning NULL?
|
||||
}
|
||||
|
||||
// When we have an RC with session details, we route to all its children
|
||||
public function test_rc_session_children()
|
||||
{
|
||||
$this->session_rc();
|
||||
|
||||
$ao = Address::findFTN('100:1/0@a');
|
||||
$this->assertCount(185,$ao->children);
|
||||
$this->assertEquals('100:1/0.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// An RCs parent is us even if we have session details for another RC
|
||||
public function test_rc_parent()
|
||||
{
|
||||
return $this->assertTrue(TRUE);
|
||||
$this->session_rc();
|
||||
|
||||
$ao = Address::findFTN('100:2/0@a');
|
||||
$this->assertEquals('100:0/0.0@a',$ao->parent()->ftn); // @todo fails, returning NULL?
|
||||
$this->assertNull($ao->parent()?->ftn);
|
||||
}
|
||||
|
||||
// If we also have session details for an NC, then there are less RC nodes
|
||||
@@ -164,7 +200,7 @@ class RoutingTest extends TestCase
|
||||
{
|
||||
$this->session_rc();
|
||||
|
||||
$ao = Address::findFTN('100:10/0@a');
|
||||
$ao = Address::findFTN('100:10/7@a');
|
||||
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
|
||||
|
||||
$ao = Address::findFTN('100:1/0@a');
|
||||
@@ -185,6 +221,7 @@ class RoutingTest extends TestCase
|
||||
$ao = Address::findFTN('100:10/22@a');
|
||||
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// If we also have session details for an Hub, then there are less RC nodes
|
||||
public function test_rc_hub_session_child()
|
||||
{
|
||||
@@ -193,4 +230,40 @@ class RoutingTest extends TestCase
|
||||
$ao = Address::findFTN('100:10/22@a');
|
||||
$this->assertEquals('100:10/20.0@a',$ao->parent()->ftn);
|
||||
}
|
||||
|
||||
// When we have an RC with session details, we route to all its children
|
||||
public function test_nc_session_children()
|
||||
{
|
||||
$this->session_nc();
|
||||
|
||||
$ao = Address::findFTN('100:10/7@a');
|
||||
$this->assertCount(35,$ao->children);
|
||||
}
|
||||
|
||||
// A points parent is the node, if we have traffic for a point and we have session details for the node
|
||||
public function test_point_session_node()
|
||||
{
|
||||
//$this->session_hub();
|
||||
|
||||
$so = new System;
|
||||
$so->name = 'Point System';
|
||||
$so->sysop = 'Point Sysop';
|
||||
$so->location = 'Melbourne, AU';
|
||||
$so->active = TRUE;
|
||||
$so->save();
|
||||
|
||||
// Create a child
|
||||
$ao = Address::createFTN('100:10/21.2@a',$so);
|
||||
$ao->region_id = 1; // @todo This should be worked out from the parent node (if exists), or another node on the same host
|
||||
$ao->save();
|
||||
|
||||
$ao = Address::findFTN('100:10/21.0@a');
|
||||
$ao->system->sessions()->attach([$ao->zone_id=>['sespass'=>'ABCD']]);
|
||||
|
||||
$ao = Address::findFTN('100:10/21.2@a');
|
||||
$this->assertEquals('100:10/21.0@a',$ao->parent()?->ftn);
|
||||
|
||||
$ao = Address::findFTN('100:10/21@a');
|
||||
$this->assertCount(1,$ao->children);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user