Update TestNodeHierarchy to include a fuller FTN setup for testing. Update testing.
This commit is contained in:
@@ -2,42 +2,39 @@
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
/**
|
||||
* Our testing heirarchy.
|
||||
*
|
||||
*/
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Seeder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
use App\Models\{Address, Domain, Setup, System, Zone};
|
||||
use App\Models\{Address,Domain,Setup,System,Zone};
|
||||
|
||||
class TestNodeHierarchy extends Seeder
|
||||
{
|
||||
public const DEBUG=FALSE;
|
||||
public const DEBUG = TRUE;
|
||||
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function run()
|
||||
{
|
||||
DB::table('domains')
|
||||
->insert([
|
||||
'name'=>'a',
|
||||
'active'=>TRUE,
|
||||
'public'=>TRUE,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
foreach (['a','b','c','d','e','f'] as $domain) {
|
||||
DB::table('domains')
|
||||
->insert([
|
||||
'name'=>$domain,
|
||||
'active'=>TRUE,
|
||||
'public'=>TRUE,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
DB::table('domains')
|
||||
->insert([
|
||||
'name'=>'b',
|
||||
'active'=>TRUE,
|
||||
'public'=>TRUE,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
foreach (['a','b'] as $domain) {
|
||||
$do = Domain::where('name',$domain)->sole();
|
||||
$this->hierarchy($do,100);
|
||||
$this->hierarchy($do,101);
|
||||
@@ -45,9 +42,38 @@ class TestNodeHierarchy extends Seeder
|
||||
|
||||
// Configure my addresses
|
||||
$so = Setup::findOrFail(config('app.id'));
|
||||
|
||||
// ZC 100:0/0@a
|
||||
$ao = Address::findFTN('100:0/0@a');
|
||||
$so->system_id = $ao->system_id;
|
||||
$so->save();
|
||||
$ao->system_id = $so->system_id;
|
||||
$ao->save();
|
||||
|
||||
// RC 100:1/0@b
|
||||
$ao = Address::findFTN('100:1/0@b');
|
||||
$ao->system_id = $so->system_id;
|
||||
$ao->save();
|
||||
|
||||
// NC 100:20/0@c
|
||||
$ao = Address::findFTN('100:20/0@c');
|
||||
$ao->system_id = $so->system_id;
|
||||
$ao->save();
|
||||
|
||||
// HUB 100:30/100@d
|
||||
$ao = Address::findFTN('100:30/100@d');
|
||||
$ao->system_id = $so->system_id;
|
||||
$ao->save();
|
||||
|
||||
// NODE 100:40/101@e
|
||||
$ao = Address::findFTN('100:40/101@e');
|
||||
$ao->system_id = $so->system_id;
|
||||
$ao->save();
|
||||
|
||||
// POINT 100:50/101.3277@f
|
||||
$ao = Address::createFTN('100:50/101.3277@f',$so->system);
|
||||
|
||||
$so->system->name = 'Clearing Houz TEST';
|
||||
$so->system->address = 'localhost';
|
||||
$so->system->save();
|
||||
|
||||
// Add file area
|
||||
DB::table('fileareas')
|
||||
@@ -66,9 +92,7 @@ class TestNodeHierarchy extends Seeder
|
||||
|
||||
private function hierarchy(Domain $domain,int $zoneid)
|
||||
{
|
||||
$hosts = [1,2,3,4,5];
|
||||
$hubs = [10,20,30,40,50];
|
||||
$nodes = [100,200,300,400,500];
|
||||
$levels = [1,2,3,4,5];
|
||||
$hubnodes = [-2,-1,+1,+2,+3];
|
||||
|
||||
$so = $this->system(sprintf('ZC %s-%s',$domain->name,$zoneid));
|
||||
@@ -85,185 +109,196 @@ class TestNodeHierarchy extends Seeder
|
||||
]);
|
||||
|
||||
$zo = Zone::where('zone_id',$zoneid)->where('domain_id',$domain->id)->sole();
|
||||
if (self::DEBUG)
|
||||
dump(['zo'=>$zo->zone_id,'rid'=>0,'hid'=>0,'nid'=>0]);
|
||||
|
||||
// ZC
|
||||
if (self::DEBUG)
|
||||
printf("- ZC %d:%d/%d.%d@%s\n",$zo->zone_id,0,0,0,$domain->name);
|
||||
|
||||
$region_id = 0;
|
||||
// ZC Address
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>0,
|
||||
'host_id'=>0,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$region_id,
|
||||
'node_id'=>0,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_ZC,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
// ZC Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$zo->zone_id,'hid'=>$zo->zone_id,'nid'=>$nid]);
|
||||
foreach ($hubnodes as $hnid) {
|
||||
$host_id = $region_id*100+$hnid+3;
|
||||
|
||||
$so = $this->system(sprintf('ZC Node 0/%d',$nid));
|
||||
if (self::DEBUG)
|
||||
printf(" - NODE %d:%d/%d.%d@%s\n",$zo->zone_id,$region_id,$host_id,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('ZC Node 0/%d',$host_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>0,
|
||||
'host_id'=>0,
|
||||
'node_id'=>$nid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$region_id,
|
||||
'node_id'=>$host_id,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_NN,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
}
|
||||
|
||||
if (self::DEBUG)
|
||||
dump(['end'=>'nodes top']);
|
||||
|
||||
// Regions
|
||||
foreach ($hosts as $rid) {
|
||||
$hostid = $rid;
|
||||
// RC
|
||||
foreach ($levels as $region_id) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>0]);
|
||||
printf(" - RC %d:%d/%d.%d@%s\n",$zo->zone_id,$region_id,0,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('Region %03d:%03d/%03d.0@%s',$zoneid,$rid,0,$domain->name));
|
||||
$so = $this->system(sprintf('RC %03d:%03d/%03d.0@%s',$zoneid,$region_id,0,$domain->name));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>$rid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$region_id,
|
||||
'node_id'=>0,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_RC,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
// RC Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>$nid]);
|
||||
foreach ($hubnodes as $hnid) {
|
||||
$host_id = $hnid+3;
|
||||
|
||||
$so = $this->system(sprintf('RC Node %d/%d',$rid,$nid));
|
||||
if (self::DEBUG)
|
||||
printf(" - NODE %d:%d/%d.%d@%s\n",$zo->zone_id,$region_id,$host_id,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('RC Node %d/%d',$region_id,$host_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>$rid,
|
||||
'node_id'=>$nid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$region_id,
|
||||
'node_id'=>$host_id,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_NN,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
}
|
||||
if (self::DEBUG)
|
||||
dump(['end'=>'NODES regions']);
|
||||
|
||||
// Hosts
|
||||
foreach ($hosts as $rrid) {
|
||||
$hostid = $rid*10+$rrid-1;
|
||||
// NC
|
||||
foreach ($levels as $ncid) {
|
||||
$net_id = $region_id*10+$ncid-1;
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>0]);
|
||||
|
||||
$so = $this->system(sprintf('Host %d:%d/0 (R%d)',$zoneid,$hostid,$rid));
|
||||
printf(" - NC %d:%d/%d.%d@%s\n",$zo->zone_id,$net_id,0,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('NC %d:%d/0 (R%d)',$zo->zone_id,$net_id,$region_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>$hostid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$net_id,
|
||||
'node_id'=>0,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_NC,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
// Nodes
|
||||
foreach ($nodes as $nid) {
|
||||
if (self::DEBUG)
|
||||
dump(['rid'=>$rid,'hid'=>$hostid,'nid'=>$nid]);
|
||||
// NC Nodes
|
||||
foreach ($hubnodes as $hnid) {
|
||||
$host_id = $hnid+3;
|
||||
|
||||
$so = $this->system(sprintf('Host Node %d/%d (R%d)',$hostid,$nid,$rid));
|
||||
if (self::DEBUG)
|
||||
printf(" - NODE %d:%d/%d.%d@%s\n",$zo->zone_id,$net_id,$host_id,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('NC Node %d/%d (R%d)',$net_id,$host_id,$region_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>$hostid,
|
||||
'node_id'=>$nid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$net_id,
|
||||
'node_id'=>$host_id,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'role'=>Address::NODE_NN,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
}
|
||||
|
||||
// Hubs
|
||||
foreach ($hubs as $bid) {
|
||||
$so = $this->system(sprintf('HUB %d/%d (R%d)',$hostid,$bid,$rid));
|
||||
foreach ($levels as $hbid) {
|
||||
$host_id = $hbid*100;
|
||||
|
||||
if (self::DEBUG)
|
||||
printf(" - HUB %d:%d/%d.%d@%s\n",$zo->zone_id,$net_id,$host_id,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('HUB %d/%d (R%d)',$net_id,$host_id,$region_id));
|
||||
$hub = new Address;
|
||||
$hub->zone_id = $zo->id;
|
||||
$hub->active = TRUE;
|
||||
$hub->region_id = $rid;
|
||||
$hub->host_id = $hostid;
|
||||
$hub->node_id = $bid;
|
||||
$hub->region_id = $region_id;
|
||||
$hub->host_id = $net_id;
|
||||
$hub->node_id = $host_id;
|
||||
$hub->point_id = 0;
|
||||
$hub->system_id = $so->id;
|
||||
$hub->role = Address::NODE_HC;
|
||||
$hub->created_at = Carbon::now();
|
||||
$hub->updated_at = Carbon::now();
|
||||
$hub->save();
|
||||
|
||||
// Nodes
|
||||
// HUB Nodes
|
||||
foreach ($hubnodes as $nid) {
|
||||
$nodeid = $bid+$nid;
|
||||
$so = $this->system(sprintf('Hub Node %d/%d (R%d/H%d)',$hostid,$nodeid,$rid,$hub->node_id));
|
||||
$host_id = $hub->node_id+$nid;
|
||||
|
||||
if (self::DEBUG)
|
||||
printf(" - NODE %d:%d/%d.%d@%s\n",$zo->zone_id,$net_id,$host_id,0,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('Hub Node %d/%d (R%d/H%d)',$net_id,$host_id,$region_id,$hub->node_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'validated'=>TRUE,
|
||||
'region_id'=>$rid,
|
||||
'host_id'=>$hostid,
|
||||
'node_id'=>$nodeid,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$net_id,
|
||||
'node_id'=>$host_id,
|
||||
'point_id'=>0,
|
||||
'system_id'=>$so->id,
|
||||
'hub_id'=>$hub->id,
|
||||
'role'=>Address::NODE_NN,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
|
||||
foreach ($hubnodes as $nid) {
|
||||
$point_id = $nid+3;
|
||||
|
||||
if (self::DEBUG)
|
||||
printf(" - POINT %d:%d/%d.%d@%s\n",$zo->zone_id,$net_id,$host_id,$point_id,$domain->name);
|
||||
|
||||
$so = $this->system(sprintf('Node Point %d/%d.%d (R%d/H%d)',$net_id,$host_id,$point_id,$region_id,$hub->node_id));
|
||||
DB::table('addresses')
|
||||
->insert([
|
||||
'zone_id'=>$zo->id,
|
||||
'active'=>TRUE,
|
||||
'region_id'=>$region_id,
|
||||
'host_id'=>$net_id,
|
||||
'node_id'=>$host_id,
|
||||
'point_id'=>$point_id,
|
||||
'system_id'=>$so->id,
|
||||
'created_at'=>Carbon::now(),
|
||||
'updated_at'=>Carbon::now(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self::DEBUG)
|
||||
dump(['end'=>'NODES normal']);
|
||||
}
|
||||
|
||||
if (self::DEBUG)
|
||||
dump(['end'=>'heirarchy']);
|
||||
}
|
||||
|
||||
private function system(string $name): System
|
||||
@@ -275,8 +310,9 @@ class TestNodeHierarchy extends Seeder
|
||||
$o->active = TRUE;
|
||||
$o->created_at = Carbon::now();
|
||||
$o->updated_at = Carbon::now();
|
||||
$o->address = 'myhostname';
|
||||
$o->save();
|
||||
|
||||
return $o;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user