Add support for Shelly device generation detection and update related tests
- Implement generation detection logic for Shelly devices using model codes, metadata, and type inference. - Extend relay switch and inventory handling to include generation capabilities. - Ensure compatibility with Gen1, Gen2, and Gen3 devices for relay control and diagnostics. - Update unit tests to validate generation inference, fallback behavior, and API compatibility.
This commit is contained in:
@@ -132,6 +132,12 @@ it('validates broker sessions and ingests presence, telemetry, logs, and shell l
|
||||
->assertEnvelope()
|
||||
->assertSuccess();
|
||||
|
||||
expect($shellSession->data()['diagnostics'] ?? [])
|
||||
->toHaveKey('ready', true)
|
||||
->toHaveKey('reason_code', 'READY')
|
||||
->and($shellSession->data()['diagnostics']['broker_presence']['connection_id'] ?? null)
|
||||
->toBe('broker-presence-1');
|
||||
|
||||
$shellToken = (string)$shellSession->data()['token'];
|
||||
|
||||
$validateShell = api_client()->post(
|
||||
@@ -172,6 +178,9 @@ it('validates broker sessions and ingests presence, telemetry, logs, and shell l
|
||||
'token' => $shellToken,
|
||||
'transcript' => "edge-broker-shell\n",
|
||||
'reason' => 'agent_exit',
|
||||
'message' => 'Shell exited cleanly.',
|
||||
'code' => 0,
|
||||
'stage' => 'shell_active',
|
||||
],
|
||||
edge_test_broker_headers()
|
||||
);
|
||||
@@ -184,7 +193,15 @@ it('validates broker sessions and ingests presence, telemetry, logs, and shell l
|
||||
expect($closedShell->data())
|
||||
->toHaveKey('status', 'COMPLETED')
|
||||
->and($closedShell->data()['transcript'] ?? null)
|
||||
->toBe("edge-broker-shell\n");
|
||||
->toBe("edge-broker-shell\n")
|
||||
->and($closedShell->data()['metadata']['close_reason'] ?? null)
|
||||
->toBe('agent_exit')
|
||||
->and($closedShell->data()['metadata']['close_message'] ?? null)
|
||||
->toBe('Shell exited cleanly.')
|
||||
->and($closedShell->data()['metadata']['close_code'] ?? null)
|
||||
->toBe(0)
|
||||
->and($closedShell->data()['metadata']['close_stage'] ?? null)
|
||||
->toBe('shell_active');
|
||||
|
||||
$logsPage = api_client()->get('/edge-gateways/' . (int)$gateway['id'] . '/logs', $session['headers']);
|
||||
|
||||
@@ -214,6 +231,35 @@ it('validates broker sessions and ingests presence, telemetry, logs, and shell l
|
||||
->toBe(0.42);
|
||||
});
|
||||
|
||||
it('rejects shell session creation while broker presence is unavailable', function (): void {
|
||||
$department = api_fixtures()->createDepartment([
|
||||
'name' => 'Edge Broker Shell Readiness Department',
|
||||
]);
|
||||
$session = api_fixtures()->createEdgeOperatorSession((int)$department['id']);
|
||||
$gateway = api_fixtures()->createClaimedEdgeGateway([
|
||||
'department_id' => (int)$department['id'],
|
||||
'label' => 'Disconnected Broker Gateway',
|
||||
]);
|
||||
|
||||
$response = api_client()->post(
|
||||
'/edge-gateways/' . (int)$gateway['id'] . '/shell-sessions',
|
||||
['reason' => 'Should fail without broker presence'],
|
||||
$session['headers']
|
||||
);
|
||||
|
||||
$response
|
||||
->assertStatus(409)
|
||||
->assertEnvelope()
|
||||
->assertSuccess(false);
|
||||
|
||||
expect($response->data())
|
||||
->toHaveKey('error_code', 'BROKER_DISCONNECTED')
|
||||
->and($response->data()['diagnostics']['ready'] ?? true)
|
||||
->toBeFalse()
|
||||
->and($response->data()['diagnostics']['broker_presence']['connected'] ?? true)
|
||||
->toBeFalse();
|
||||
});
|
||||
|
||||
it('builds broker backlog and completes gateway operations through broker endpoints', function (): void {
|
||||
$department = api_fixtures()->createDepartment([
|
||||
'name' => 'Edge Broker Backlog Department',
|
||||
|
||||
Reference in New Issue
Block a user