Skip to content

Commit

Permalink
[Grid] Fetching hub configuration and updating the node's config before
Browse files Browse the repository at this point in the history
registering the node. Fixes SeleniumHQ#3064
  • Loading branch information
diemol authored and Grigory Mischenko committed Sep 20, 2018
1 parent 1c05260 commit a8a3fcc
Showing 1 changed file with 15 additions and 14 deletions.
Expand Up @@ -255,22 +255,9 @@ private void registerToHub(boolean checkPresenceFirst) {
+ registrationRequest.getConfiguration().getHubPort() + "/grid/register";

try {
URL registration = new URL(tmp);
LOG.info("Registering the node to the hub: " + registration);

HttpRequest request = new HttpRequest(POST, registration.toExternalForm());
updateConfigWithRealPort();
String json = new Json().toJson(registrationRequest);
request.setContent(json.getBytes(UTF_8));

HttpClient client = httpClientFactory.createClient(registration);
HttpResponse response = client.execute(request);
if (response.getStatus() != 200) {
throw new GridException(String.format("The hub responded with %s", response.getStatus()));
}

try {
LOG.fine("Updating the node configuration from the hub");
LOG.fine("Updating the node configuration from the hub before sending registration request");
GridHubConfiguration hubConfiguration = getHubConfiguration();
LOG.fine("Hub configuration: " + new Json().toJson(hubConfiguration));
// the node can not set these values. They must come from the hub
Expand All @@ -287,6 +274,20 @@ private void registerToHub(boolean checkPresenceFirst) {
.getMessage());
}

URL registration = new URL(tmp);
LOG.info("Registering the node to the hub: " + registration);

HttpRequest request = new HttpRequest(POST, registration.toExternalForm());
updateConfigWithRealPort();
String json = new Json().toJson(registrationRequest);
request.setContent(json.getBytes(UTF_8));

HttpClient client = httpClientFactory.createClient(registration);
HttpResponse response = client.execute(request);
if (response.getStatus() != 200) {
throw new GridException(String.format("The hub responded with %s", response.getStatus()));
}

LOG.info("The node is registered to the hub and ready to use");
} catch (Exception e) {
throw new GridException("Error sending the registration request: " + e.getMessage());
Expand Down

0 comments on commit a8a3fcc

Please sign in to comment.