Files
XC_VM/tests/Unit/ClusterAdminLoadBalancerTest.php
T
Claude e6b6234175 refactor(cluster): enum settings, policy version, enrolment start and CLI helpers written once
- ClusterSettings::enum() reads every enum setting against ENUMS; an
  unknown stored cluster_transport is now published as the default,
  auto (recorded in ADR 0004).
- ClusterPolicy::ver(), one enrolment start for SSH and code enrolment,
  one public protocol range.
- StrictQuery takes a message; the query-or-throw copies use it.
- The cluster CLI commands share the 'Cluster API unavailable' and
  'is an LB' helpers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rdv7hXd8RWhLHoj5Ma2ZqY
2026-09-28 18:02:41 +00:00

32 lines
1.4 KiB
PHP

<?php
use PHPUnit\Framework\TestCase;
use XcVm\Domain\Cluster\ClusterAdmin;
/**
* Which servers rows are load balancers: what the Cluster Nodes page lists
* for a code, and what cluster:enrol-code, cluster:reenrol and server:enrol
* accept.
*/
final class ClusterAdminLoadBalancerTest extends TestCase {
public function testALoadBalancerIsNeitherMainNorAProxy(): void {
$this->assertTrue(ClusterAdmin::isLoadBalancer(['is_main' => 0, 'server_type' => 0]));
$this->assertTrue(ClusterAdmin::isLoadBalancer(['is_main' => '0', 'server_type' => '0']));
$this->assertTrue(ClusterAdmin::isLoadBalancer([]), 'no type: a server, as the servers table defaults it');
$this->assertFalse(ClusterAdmin::isLoadBalancer(null));
$this->assertFalse(ClusterAdmin::isLoadBalancer(['is_main' => 1, 'server_type' => 0]));
$this->assertFalse(ClusterAdmin::isLoadBalancer(['is_main' => 0, 'server_type' => 1]));
$this->assertFalse(ClusterAdmin::isLoadBalancer(['is_main' => 0, 'server_type' => '1']));
}
public function testThePageListsOnlyLoadBalancers(): void {
$rServers = [
1 => ['is_main' => 1, 'server_type' => 0, 'server_name' => 'Main'],
2 => ['is_main' => 0, 'server_type' => 0, 'server_name' => 'LB 1'],
3 => ['is_main' => 0, 'server_type' => 1, 'server_name' => 'Proxy'],
4 => ['is_main' => 0, 'server_type' => 0],
];
$this->assertSame([2 => 'LB 1', 4 => '#4'], ClusterAdmin::loadBalancers($rServers));
}
}