mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-05 16:02:34 +00:00
Add load balancer (#453)
This commit is contained in:
47
tests/Traits/PrepareLoadBalancer.php
Normal file
47
tests/Traits/PrepareLoadBalancer.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Traits;
|
||||
|
||||
use App\Enums\Database;
|
||||
use App\Enums\LoadBalancerMethod;
|
||||
use App\Enums\PHP;
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Enums\SiteType;
|
||||
use App\Enums\Webserver;
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
|
||||
trait PrepareLoadBalancer
|
||||
{
|
||||
private function prepare(): void
|
||||
{
|
||||
$this->site->type = SiteType::LOAD_BALANCER;
|
||||
$this->site->type_data = [
|
||||
'method' => LoadBalancerMethod::ROUND_ROBIN,
|
||||
];
|
||||
$this->site->save();
|
||||
|
||||
$servers = Server::factory(2)->create([
|
||||
'user_id' => $this->user->id,
|
||||
'project_id' => $this->user->current_project_id,
|
||||
]);
|
||||
foreach ($servers as $server) {
|
||||
$server->type()->createServices([
|
||||
'webserver' => Webserver::NGINX,
|
||||
'database' => Database::NONE,
|
||||
'php' => PHP::NONE,
|
||||
]);
|
||||
$server->services()->update([
|
||||
'status' => ServiceStatus::READY,
|
||||
]);
|
||||
Site::factory()->create([
|
||||
'domain' => 'vito.test',
|
||||
'aliases' => ['www.vito.test'],
|
||||
'server_id' => $server->id,
|
||||
'type' => SiteType::PHP_BLANK,
|
||||
'path' => '/home/vito/vito.test',
|
||||
'web_directory' => '',
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user