mirror of
https://github.com/Vateron-Media/XC_VM.git
synced 2026-11-07 19:03:36 +01:00
- MAIN's update lists the load balancers it could not tell (offline then) and cron:servers tells each one once, when it is back and still behind. The hourly re-send by version alone undid an admin's rollback of one load balancer within the hour. - cron:tmp no longer sweeps state with the leftovers: the root cron's hourly and daily stamps (fanout_binary, xcvm_core, ytdlp, ffmpeg), so each check stops running, and asking GitHub, every ~11 minutes on every node; and the updater's archive, which post-update reads again after the chown of the whole tree. - the updater, after a failed copy, still gives the tree back to xc_vm and checks nginx.conf before it stops: cp re-owns the directories it did reach, and the service started on a tree xc_vm could not enter. When nothing was copied, the archive goes before the post-update that puts the server back online, so it installs nothing from it.
51 lines
2.1 KiB
PHP
51 lines
2.1 KiB
PHP
<?php
|
|
|
|
use XcVm\Cli\Commands\UpdateCommand;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
/**
|
|
* UpdateCommand::pinned() — the release MAIN names to a load balancer.
|
|
*
|
|
* A MAIN on the dev channel names its nightly (x.y.z-dev.N); dropping it sent
|
|
* the LB to its own channel lookup instead of MAIN's build.
|
|
*/
|
|
class UpdateCommandPinnedTest extends TestCase {
|
|
public function testAcceptsReleaseAndNightlyTags(): void {
|
|
$this->assertSame('1.2.3', UpdateCommand::pinned(' 1.2.3 '));
|
|
$this->assertSame('1.2.3-dev.7', UpdateCommand::pinned('1.2.3-dev.7'));
|
|
}
|
|
|
|
/** cron:servers: a load balancer MAIN's update could not tell is told once it is back. */
|
|
public function testOnlyTheLoadBalancersMainCouldNotTellAreToldLater(): void {
|
|
if (!defined('XC_VM_VERSION')) {
|
|
define('XC_VM_VERSION', '2.6.0');
|
|
}
|
|
$rNow = 1800000000;
|
|
$rLb = ['is_main' => 0, 'server_type' => 0, 'enabled' => 1, 'status' => 1, 'last_check_ago' => $rNow - 30, 'xc_vm_version' => '0.0.1'];
|
|
$rServers = [
|
|
1 => ['id' => 1, 'is_main' => 1] + $rLb,
|
|
2 => ['id' => 2] + $rLb,
|
|
3 => ['id' => 3, 'xc_vm_version' => XC_VM_VERSION] + $rLb,
|
|
4 => ['id' => 4, 'server_type' => 1] + $rLb,
|
|
5 => ['id' => 5, 'status' => 5] + $rLb,
|
|
6 => ['id' => 6, 'last_check_ago' => $rNow - 600] + $rLb,
|
|
7 => ['id' => 7, 'enabled' => 0] + $rLb,
|
|
8 => ['id' => 8, 'xc_vm_version' => null] + $rLb,
|
|
10 => ['id' => 10] + $rLb,
|
|
];
|
|
// Back and behind (2), or its release unknown (8): told. Still updating
|
|
// (5), offline (6) or disabled (7): waited for. MAIN, one on MAIN's
|
|
// release by now (3), a proxy (4) and one that is gone (9): dropped.
|
|
$this->assertSame(['tell' => [2, 8], 'wait' => [5, 6, 7]], UpdateCommand::lbsToTell($rServers, [1, 2, 3, 4, 5, 6, 7, 8, 9, '2'], $rNow));
|
|
// 10 is behind and online, but MAIN's update did tell it: an admin
|
|
// rolled it back, and it stays there.
|
|
$this->assertSame(['tell' => [], 'wait' => []], UpdateCommand::lbsToTell($rServers, [], $rNow));
|
|
}
|
|
|
|
public function testRejectsAnythingElse(): void {
|
|
foreach ([null, '', '1.2', '1.2.3-beta.1', '1.2.3-dev', '1.2.3;id', 123] as $rBad) {
|
|
$this->assertNull(UpdateCommand::pinned($rBad));
|
|
}
|
|
}
|
|
}
|