mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
@@ -180,7 +180,7 @@ class ValidateAndInstallServerJob implements ShouldBeEncrypted, ShouldQueue
|
||||
]);
|
||||
|
||||
// Start proxy if needed
|
||||
if (! $this->server->isBuildServer()) {
|
||||
if ($this->server->isProxyShouldRun()) {
|
||||
$proxyShouldRun = CheckProxy::run($this->server, true);
|
||||
if ($proxyShouldRun) {
|
||||
// Ensure networks exist BEFORE dispatching async proxy startup
|
||||
|
||||
@@ -310,6 +310,11 @@ class ValidateAndInstall extends Component
|
||||
if ($this->server->isSentinelEnabled()) {
|
||||
CheckAndStartSentinelJob::dispatch($this->server);
|
||||
}
|
||||
if (! $this->server->isProxyShouldRun()) {
|
||||
$this->dispatch('success', 'Server validated.');
|
||||
|
||||
return;
|
||||
}
|
||||
$this->dispatch('success', 'Server validated, proxy is starting in a moment.');
|
||||
$proxyShouldRun = CheckProxy::run($this->server, true);
|
||||
if (! $proxyShouldRun) {
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
<?php
|
||||
|
||||
use App\Actions\Proxy\StartProxy;
|
||||
use App\Enums\ProxyTypes;
|
||||
use App\Events\ServerReachabilityChanged;
|
||||
use App\Jobs\ValidateAndInstallServerJob;
|
||||
use App\Livewire\Server\ValidateAndInstall;
|
||||
use App\Models\InstanceSettings;
|
||||
use App\Models\PrivateKey;
|
||||
@@ -10,6 +13,7 @@ use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\Process;
|
||||
use Illuminate\Support\Facades\Queue;
|
||||
use Livewire\Livewire;
|
||||
|
||||
uses(RefreshDatabase::class);
|
||||
@@ -85,3 +89,37 @@ it('shows the sudo command for non-root servers', function () {
|
||||
expect(validateDockerVersionError($this->server->fresh()))
|
||||
->toContain('Run "sudo docker version --format json" on the server as the deploy user');
|
||||
});
|
||||
|
||||
it('validates a server without a proxy and does not start a proxy', function () {
|
||||
Queue::fake();
|
||||
$this->server->proxy->set('type', ProxyTypes::NONE->value);
|
||||
$this->server->save();
|
||||
$this->server->settings->update(['is_reachable' => true, 'is_usable' => true]);
|
||||
fakeDockerVersionOutput('{"Server":{"Version":"29.6.2"}}');
|
||||
|
||||
expect(validateDockerVersionError($this->server->fresh()))->toBeNull()
|
||||
->and($this->server->fresh()->is_validating)->toBeFalsy();
|
||||
Queue::assertNotPushed(StartProxy::class);
|
||||
});
|
||||
|
||||
it('validates a server without a proxy in the background job', function () {
|
||||
Queue::fake();
|
||||
$this->server->proxy->set('type', ProxyTypes::NONE->value);
|
||||
$this->server->save();
|
||||
$this->server->settings->update(['is_reachable' => true, 'is_usable' => true]);
|
||||
|
||||
$server = Mockery::mock($this->server->fresh())->makePartial();
|
||||
$server->shouldReceive('validateConnection')->andReturn(['uptime' => true, 'error' => null]);
|
||||
$server->shouldReceive('validateOS')->andReturn('debian');
|
||||
$server->shouldReceive('validatePrerequisites')->andReturn(['success' => true]);
|
||||
$server->shouldReceive('validateDockerEngine')->andReturn(true);
|
||||
$server->shouldReceive('validateDockerCompose')->andReturn(true);
|
||||
$server->shouldReceive('validateDockerEngineVersion')->andReturn(true);
|
||||
$server->shouldReceive('gatherServerMetadata')->andReturnNull();
|
||||
|
||||
(new ValidateAndInstallServerJob($server))->handle();
|
||||
|
||||
expect($this->server->fresh()->validation_logs)->toBeNull()
|
||||
->and($this->server->fresh()->is_validating)->toBeFalsy();
|
||||
Queue::assertNotPushed(StartProxy::class);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user