Added support for hub protocol (#10434)

This commit is contained in:
Andres Galindo
2018-03-28 15:57:48 -04:00
committed by Isaac A. Murchie
parent e51db2de68
commit 048ca4be43
2 changed files with 8 additions and 3 deletions
+1
View File
@@ -47,6 +47,7 @@ you will see your device on the grid console page:
"registerCycle": 5000,
"hubPort": <grid_port>,
"hubHost": "<Grid_host_name_or_grid_ip-address>"
"hubProtocol": "<Protocol_of_Grid_defaults_to_http>"
}
}
```
+7 -3
View File
@@ -2,6 +2,10 @@ import request from 'request-promise';
import { fs } from 'appium-support';
import logger from './logger';
const hubUri = (config) => {
const protocol = config.hubProtocol || 'http';
return `${protocol}://${config.hubHost}:${config.hubPort}`;
};
async function registerNode (configFile, addr, port) {
let data;
@@ -26,7 +30,7 @@ async function registerToGrid (options_post, jsonObject) {
if (response === undefined || response.statusCode !== 200) {
throw new Error('Request failed');
}
let logMessage = `Appium successfully registered with the grid on ${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}`;
let logMessage = `Appium successfully registered with the grid on ${hubUri(jsonObject.configuration)}`;
logger.debug(logMessage);
} catch (err) {
logger.error(`Request to register with grid was unsuccessful: ${err.message}`);
@@ -79,7 +83,7 @@ async function postRequest (data, addr, port) {
};
// the post options
let post_options = {
url: `http://${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}/grid/register`,
url: `${hubUri(jsonObject.configuration)}/grid/register`,
method: 'POST',
body: data,
headers: post_headers,
@@ -116,7 +120,7 @@ async function isAlreadyRegistered (jsonObject) {
let id = jsonObject.configuration.id;
try {
let response = await request({
uri: `http://${jsonObject.configuration.hubHost}:${jsonObject.configuration.hubPort}/grid/api/proxy?id=${id}`,
uri: `${hubUri(jsonObject.configuration)}/grid/api/proxy?id=${id}`,
method : 'GET',
timeout : 10000,
resolveWithFullResponse: true // return the full response, not just the body