Skip to content

Commit 90e16d0

Browse files
committed
Fix issue where -host is not honored in all server modes.
Also increase the scope of -host to all roles [standalone, hub, and node]
1 parent 1d76974 commit 90e16d0

File tree

7 files changed

+31
-24
lines changed

7 files changed

+31
-24
lines changed

java/server/src/org/openqa/grid/internal/cli/CommonCliOptions.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,16 @@ public abstract class CommonCliOptions {
6666
)
6767
private String role;
6868

69+
/**
70+
* Hostname or IP to use. Defaults to {@code null}. Automatically determined when {@code null}.
71+
*/
72+
@Parameter(
73+
names = "-host",
74+
description = "<String> IP or hostname : usually determined automatically. Most commonly useful in exotic network configurations (e.g. network with VPN)"
75+
)
76+
// initially defaults to null from type
77+
private String host;
78+
6979
/**
7080
* Port to bind to. Default determined by configuration type.
7181
*/
@@ -133,6 +143,9 @@ void fillCommonConfiguration(StandaloneConfiguration configuration) {
133143
if (log != null) {
134144
configuration.log = log;
135145
}
146+
if (host != null) {
147+
configuration.host = host;
148+
}
136149
if (port != null) {
137150
configuration.port = port;
138151
}

java/server/src/org/openqa/grid/internal/cli/CommonGridCliOptions.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,6 @@ abstract class CommonGridCliOptions extends CommonCliOptions {
5757
)
5858
private Map<String, String> custom;
5959

60-
/**
61-
* Hostname or IP to use. Defaults to {@code null}. Automatically determined when {@code null}.
62-
*/
63-
@Parameter(
64-
names = "-host",
65-
description = "<String> IP or hostname : usually determined automatically. Most commonly useful in exotic network configurations (e.g. network with VPN)"
66-
)
67-
// initially defaults to null from type
68-
private String host;
69-
7060
/**
7161
* Max "browser" sessions a node can handle. Default determined by configuration type.
7262
*/
@@ -102,9 +92,6 @@ void fillCommonGridConfiguration(GridConfiguration configuration) {
10292
if (custom != null) {
10393
configuration.custom = custom;
10494
}
105-
if (host != null) {
106-
configuration.host = host;
107-
}
10895
if (maxSession != null) {
10996
configuration.maxSession = maxSession;
11097
}

java/server/src/org/openqa/grid/internal/utils/configuration/GridConfiguration.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ public class GridConfiguration extends StandaloneConfiguration {
4444
@Expose
4545
public Map<String, String> custom = new HashMap<>();
4646

47-
/**
48-
* Hostname or IP to use. Defaults to {@code null}. Automatically determined when {@code null}.
49-
*/
50-
@Expose
51-
// initially defaults to null from type
52-
public String host;
53-
5447
/**
5548
* Max "browser" sessions a node can handle. Default determined by configuration type.
5649
*/
@@ -87,7 +80,6 @@ public void merge(GridConfiguration other) {
8780
}
8881
super.merge(other);
8982

90-
// don't merge 'host'
9183
if (isMergeAble(other.cleanUpCycle, cleanUpCycle)) {
9284
cleanUpCycle = other.cleanUpCycle;
9385
}
@@ -125,7 +117,6 @@ public String toString(String format) {
125117
sb.append(super.toString(format));
126118
sb.append(toString(format, "cleanUpCycle", cleanUpCycle));
127119
sb.append(toString(format, "custom", custom));
128-
sb.append(toString(format, "host", host));
129120
sb.append(toString(format, "maxSession", maxSession));
130121
sb.append(toString(format, "servlets", servlets));
131122
sb.append(toString(format, "withoutServlets", withoutServlets));

java/server/src/org/openqa/grid/internal/utils/configuration/StandaloneConfiguration.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ public class StandaloneConfiguration {
124124
@Expose
125125
public String log;
126126

127+
/**
128+
* Hostname or IP to use. Defaults to {@code null}. Automatically determined when {@code null}.
129+
*/
130+
@Expose
131+
// initially defaults to null from type
132+
public String host;
133+
127134
/**
128135
* Port to bind to. Default determined by configuration type.
129136
*/
@@ -188,8 +195,8 @@ public void merge(StandaloneConfiguration other) {
188195
if (isMergeAble(other.timeout, timeout)) {
189196
timeout = other.timeout;
190197
}
191-
// role, port, log, debug, version, enablePassThrough, and help are not merged, they are only consumed by the
192-
// immediately running process and should never affect a remote
198+
// role, host, port, log, debug, version, enablePassThrough, and help are not merged,
199+
// they are only consumed by the immediately running process and should never affect a remote
193200
}
194201

195202
/**
@@ -236,6 +243,7 @@ public String toString(String format) {
236243
sb.append(toString(format, "debug", debug));
237244
sb.append(toString(format, "jettyMaxThreads", jettyMaxThreads));
238245
sb.append(toString(format, "log", log));
246+
sb.append(toString(format, "host", host));
239247
sb.append(toString(format, "port", port));
240248
sb.append(toString(format, "role", role));
241249
sb.append(toString(format, "timeout", timeout));

java/server/src/org/openqa/grid/web/Hub.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ private void initServer() {
176176
httpConfig.setSecurePort(config.port);
177177

178178
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfig));
179+
http.setHost(config.host);
179180
http.setPort(config.port);
180181

181182
server.addConnector(http);

java/server/src/org/openqa/selenium/remote/server/SeleniumServer.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,9 @@ public boolean boot() {
184184
if (configuration.port == null) {
185185
configuration.port = 4444;
186186
}
187+
if (configuration.host != null) {
188+
http.setHost(configuration.host);
189+
}
187190
http.setPort(configuration.port);
188191
http.setIdleTimeout(500000);
189192

java/server/test/org/openqa/grid/internal/utils/configuration/StandaloneConfigurationTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public void testDefaults() {
4242
assertEquals(StandaloneConfiguration.DEFAULT_BROWSER_TIMEOUT, sc.browserTimeout);
4343
assertEquals(StandaloneConfiguration.DEFAULT_DEBUG_TOGGLE, sc.debug);
4444
assertEquals(StandaloneConfiguration.DEFAULT_TIMEOUT, sc.timeout);
45+
assertEquals(StandaloneConfiguration.DEFAULT_PORT, sc.port);
46+
assertEquals(null, sc.host);
4547
assertNull(sc.jettyMaxThreads);
4648
assertNull(sc.log);
4749
}
@@ -58,6 +60,8 @@ public void testConstructorEqualsDefaultConfig() {
5860
assertEquals(expected.timeout, actual.timeout);
5961
assertEquals(expected.jettyMaxThreads, actual.jettyMaxThreads);
6062
assertEquals(expected.log, actual.log);
63+
assertEquals(expected.port, actual.port);
64+
assertEquals(null, actual.host);
6165
}
6266

6367
@Test

0 commit comments

Comments
 (0)