Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,47 @@ export declare interface PopularFlag {
}

/**
* A preset configuration for pass-through flags.
* Response for GetPopularFlags API.
*/
export declare interface FlagPreset {
readonly label: string;
readonly value: string;
readonly description: string;
export declare interface GetPopularFlagsResponse {
readonly flags: PopularFlag[];
}

/**
* Response for PreflightLabServerRelease API.
*/
export declare interface PreflightLabServerReleaseResponse {
readonly permissionDenied?: PermissionDenied;
readonly ready?: ReleaseReady;
}

/**
* No deploy permission.
*/
export declare interface PermissionDenied {}

/**
* All checks passed. Here are the available versions to deploy.
*/
export declare interface ReleaseReady {
readonly versions: DeployableVersion[];
}

/**
* Represents the status of a Lab Server release.
*/
export type ReleaseStatus = 'Latest' | 'Current' | 'Deprecated' | '';

/**
* Configuration for a specific Lab Server release.
*/
export declare interface HostReleaseConfig {
export declare interface DeployableVersion {
readonly name: string;
readonly version: string;
readonly port: ReleasePort;
readonly syncCMD: string[];
readonly asyncCMD: string[];
readonly status: ReleaseStatus;
readonly buildTime: string;
readonly ports?: ReleasePort[];
readonly releaseDetails?: ReleaseDetails;
}

/**
Expand All @@ -82,11 +106,76 @@ export declare interface ReleasePort {
readonly portNumber: number;
}

/**
* Details about a specific release.
*/
export declare interface ReleaseDetails {
readonly changeLogs?: ChangeLogGroup[];
readonly files?: FileRecord[];
readonly syncCommands?: CommandRecord[];
readonly asyncCommands?: CommandRecord[];
}

/**
* Represents a group of changes or bugs related to a release.
*/
export declare interface ChangeLogGroup {
readonly name: string;
readonly items: ChangeLogItem[];
}

/**
* Represents a single change record or bug record for a release.
*/
export declare interface ChangeLogItem {
readonly change?: ChangeRecord;
readonly bug?: BugRecord;
}

/**
* Represents a single change record for a release.
*/
export declare interface ChangeRecord {
readonly cl: number;
readonly author: string;
readonly text: string;
readonly bugs: number[];
}

/**
* Represents a single bug record for a release.
*/
export declare interface BugRecord {
readonly bug: number;
readonly text: string;
}

/**
* Represents a single file record for a release.
*/
export declare interface FileRecord {
readonly name: string;
readonly path: string;
}

/**
* Represents a single command record for a release.
*/
export declare interface CommandRecord {
readonly name: string;
readonly command: string;
}

/**
* Response for DecommissionHost API.
*/
export declare interface DecommissionHostResponse {}

/**
* Response for UpdatePassThroughFlags API.
*/
export declare interface UpdatePassThroughFlagsResponse {}

/**
* Response for those rollout action
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,12 @@ export class FakeConfigService extends ConfigService {
const isHostManaged = scenario.overview.host.name === 'host-x.example.com';
const hostName = scenario.overview.host.name;

let uiStatus: Partial<DeviceConfigUiStatus> | undefined;
let uiStatus: Partial<DeviceConfigUiStatus> | undefined = {
permissions: {visible: true, editability: {editable: true}},
wifi: {visible: true, editability: {editable: true}},
dimensions: {visible: true, editability: {editable: true}},
settings: {visible: true, editability: {editable: true}},
};
if (deviceId === 'WIFI_DIMENSIONS_ONLY_DEVICE') {
uiStatus = {
permissions: {visible: false},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {Observable, of, throwError} from 'rxjs';
import {
DecommissionHostResponse,
GetHostDebugInfoResponse,
GetPopularFlagsResponse,
HostHeaderInfo,
HostReleaseConfig,
PopularFlag,
PreflightLabServerReleaseResponse,
ReleaseLabServerRequest,
ReleaseLabServerResponse,
RestartLabServerResponse,
StartLabServerResponse,
StopLabServerResponse,
UpdatePassThroughFlagsResponse,
} from '../../models/host_action';
import {
CheckRemoteControlEligibilityResponse,
Expand All @@ -25,7 +26,10 @@ import {
RemoteControlDevicesResponse,
} from '../../models/host_overview';
import {MOCK_HOST_SCENARIOS} from '../mock_data';
import {createHostActions} from '../mock_data/hosts/ui_status_utils';
import {
createDefaultReleaseResponse,
createHostActions,
} from '../mock_data/hosts/ui_status_utils';
import {HostService} from './host_service';

/**
Expand Down Expand Up @@ -110,34 +114,58 @@ export class FakeHostService extends HostService {
});
}

override getPopularFlags(hostName: string): Observable<PopularFlag[]> {
return of([
{
name: 'No Mute Android',
description: 'Disables muting of Android devices',
cmd: '--nomute_android',
},
{
name: 'No Binary Log',
description: 'Disables binary logging to save space',
cmd: '--nobinarylog',
},
{
name: 'Enable Linux Device',
description: 'Enables support for Linux devices',
cmd: '--enable_linux_device',
},
]);
override getPopularFlags(
hostName: string,
): Observable<GetPopularFlagsResponse> {
return of({
flags: [
{
name: 'Standard Satellite',
cmd: '--nomute_android --noandroid_device_daemon',
description: 'Default configuration for Android Satellite Labs',
},
{
name: 'Linux Support',
cmd: '--enable_linux_device',
description: 'Enables detection of Linux devices',
},
{
name: 'Debug Mode',
cmd: '--debug_mode=true --verbose',
description: 'Enables verbose logging for debugging',
},
{
name: 'Flashstation Cache',
cmd: '--flashstation_cache_dir=/tmp/fs_cache',
description: 'Custom cache directory for Flashstation',
},
{
name: 'No Binary Log',
cmd: '--nobinarylog',
description: 'Disables binary logging to save space',
},
{
name: 'Custom Flag',
cmd: `--my_message=":text: field_a: 'test' field_b: 123"`,
description: 'Custom flag for testing',
},
{
name: 'Custom Flag 2',
cmd: `--flagD="some value"`,
description: 'Custom flag for testing 2',
},
],
});
}

override updatePassThroughFlags(
hostName: string,
flags: string,
): Observable<void> {
): Observable<UpdatePassThroughFlagsResponse> {
const scenario = MOCK_HOST_SCENARIOS.find((s) => s.hostName === hostName);
if (scenario && scenario.overview) {
scenario.overview.labServer.passThroughFlags = flags;
return of(undefined);
return of({});
} else {
return throwError(
() =>
Expand All @@ -148,31 +176,13 @@ export class FakeHostService extends HostService {
}
}

override getReleaseConfigs(
override preflightLabServerRelease(
hostName: string,
): Observable<HostReleaseConfig[]> {
return of([
{
name: 'MH_SATELLITE_LAB',
version: '4.349.0',
port: {protocol: 'grpc', portNumber: 9994},
syncCMD: [
'sudo systemctl stop mobileharness-lab',
'sudo /usr/bin/mh_lab_installer --version 4.349.0',
],
asyncCMD: ['sudo systemctl start mobileharness-lab'],
},
{
name: 'MH_SATELLITE_LAB',
version: '4.348.0',
port: {protocol: 'grpc', portNumber: 9994},
syncCMD: [
'sudo systemctl stop mobileharness-lab',
'sudo /usr/bin/mh_lab_installer --version 4.348.0',
],
asyncCMD: ['sudo systemctl start mobileharness-lab'],
},
]);
): Observable<PreflightLabServerReleaseResponse> {
const scenario = MOCK_HOST_SCENARIOS.find((s) => s.hostName === hostName);
const preflightLabServerReleaseResponse =
scenario?.releaseResponse || createDefaultReleaseResponse();
return of(preflightLabServerReleaseResponse);
}

override decommissionMissingDevices(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import {InjectionToken} from '@angular/core';
import {Observable} from 'rxjs';

import {
DecommissionHostResponse,
ReleaseLabServerRequest,
ReleaseLabServerResponse,
GetHostDebugInfoResponse,
GetPopularFlagsResponse,
HostHeaderInfo,
HostReleaseConfig,
PopularFlag,
PreflightLabServerReleaseResponse,
ReleaseLabServerRequest,
ReleaseLabServerResponse,
RestartLabServerResponse,
StartLabServerResponse,
StopLabServerResponse,
UpdatePassThroughFlagsResponse,
} from '../../models/host_action';
import {
CheckRemoteControlEligibilityResponse,
Expand Down Expand Up @@ -57,20 +59,24 @@ export abstract class HostService {
/**
* Retrieves popular pass-through flags for a host.
*/
abstract getPopularFlags(hostName: string): Observable<PopularFlag[]>;
abstract getPopularFlags(
hostName: string,
): Observable<GetPopularFlagsResponse>;

/**
* Updates the pass through flags for a specific host.
*/
abstract updatePassThroughFlags(
hostName: string,
flags: string,
): Observable<void>;
): Observable<UpdatePassThroughFlagsResponse>;

/**
* Retrieves release configurations for a host.
*/
abstract getReleaseConfigs(hostName: string): Observable<HostReleaseConfig[]>;
abstract preflightLabServerRelease(
hostName: string,
): Observable<PreflightLabServerReleaseResponse>;

/**
* Decommissions missing devices on a specific host.
Expand Down
Loading
Loading