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 #3064
  • Loading branch information
diemol committed Sep 2, 2018
1 parent dcf780b commit 88340f4
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

2 comments on commit 88340f4

@barancev
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit broke org.openqa.grid.e2e.node.NodeRecoveryTest, please review it. Is it a wrong test or a regression issue?

@diemol
Copy link
Member Author

@diemol diemol commented on 88340f4 Sep 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @barancev, I fixed the test and it is now checking the correct behaviour.
b613415

Please sign in to comment.