Skip to content

Commit

Permalink
fix app path for remote rexecution
Browse files Browse the repository at this point in the history
  • Loading branch information
saikrishna321 committed Apr 25, 2024
1 parent f7cd127 commit aa9ac94
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/CapabilityManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ISessionCapability } from './interfaces/ISessionCapability';
import _ from 'lodash';
import { IDevice } from './interfaces/IDevice';
import { prisma } from './prisma';
import { DevicePlugin } from './plugin';

export enum DEVICE_FARM_CAPABILITIES {
BUILD_NAME = 'build',
Expand Down Expand Up @@ -36,7 +37,7 @@ async function findAppPath(fileName: string) {
const appInfo: any = await prisma.appInformation.findFirst({
where: { uploadedFileName: fileName as string },
});
return appInfo?.path;
return `${DevicePlugin.serverUrl}${appInfo?.path}`;
} else {
return fileName;
}
Expand Down Expand Up @@ -74,6 +75,7 @@ export async function iOSCapabilities(
wdaBundleId?: string;
},
) {
caps.firstMatch[0]['appium:app'] = await findAppPath(caps.alwaysMatch['appium:app']);
caps.firstMatch[0]['appium:udid'] = freeDevice.udid;
caps.firstMatch[0]['appium:deviceName'] = freeDevice.name;
caps.firstMatch[0]['appium:platformVersion'] = freeDevice.sdk;
Expand All @@ -91,6 +93,7 @@ export async function iOSCapabilities(
'appium:mjpegServerPort',
'appium:udid',
'appium:deviceName',
'appium:app',
];
deleteMatch.forEach((value) => deleteAlwaysMatch(caps, value));
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules
4 changes: 3 additions & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ class DevicePlugin extends BasePlugin {
public static IS_HUB = false;
private static httpServer: any;
private static adbInstance: any;
public static serverUrl: string;

constructor(pluginName: string, cliArgs: any) {
super(pluginName, cliArgs);
// here, CLI Args are already pluginArgs. Different case for updateServer
log.debug(`📱 Plugin Args: ${JSON.stringify(cliArgs)}`);
// plugin args will assign undefined value as well for bindHostOrIp
this.pluginArgs = Object.assign({}, DefaultPluginArgs, this.cliArgs as unknown as IPluginArgs);
this.pluginArgs = Object.assign({}, DefaultPluginArgs, cliArgs as unknown as IPluginArgs);
// not pretty but will do for now
if (this.pluginArgs.bindHostOrIp === undefined) {
this.pluginArgs.bindHostOrIp = ip.address();
Expand Down Expand Up @@ -231,6 +232,7 @@ class DevicePlugin extends BasePlugin {
);
} else {
DevicePlugin.IS_HUB = true;
DevicePlugin.serverUrl = `http://${pluginArgs.bindHostOrIp}:${cliArgs.port}`;
log.info(`📣📣📣 I'm a hub and I'm listening on ${pluginArgs.bindHostOrIp}:${cliArgs.port}`);
}

Expand Down

0 comments on commit aa9ac94

Please sign in to comment.