Skip to content

Commit 12a9660

Browse files
committed
server: Separating help messages for various server roles
1 parent c053c80 commit 12a9660

File tree

8 files changed

+86
-55
lines changed

8 files changed

+86
-55
lines changed

Diff for: java/server/src/org/openqa/grid/common/GridDocHelper.java

+34-13
Original file line numberDiff line numberDiff line change
@@ -25,31 +25,54 @@
2525

2626

2727
public class GridDocHelper {
28-
private static Properties gridProperties = load("org/openqa/grid/common/defaults/GridParameters.properties");
28+
private static Properties hubProperties = load(
29+
"org/openqa/grid/common/defaults/HubParameters.properties");
30+
private static Properties nodeProperties = load(
31+
"org/openqa/grid/common/defaults/NodeParameters.properties");
2932

30-
public static void printHelp(String msg) {
31-
printHelpInConsole(msg, true);
33+
public static void printHubHelp(String msg) {
34+
printHubHelp(msg, true);
3235
}
3336

34-
public static void printHelp(String msg, boolean error) {
35-
printHelpInConsole(msg, error);
37+
public static void printHubHelp(String msg, boolean error) {
38+
printHelpInConsole(msg, hubProperties, error);
39+
RemoteControlLauncher.printWrappedLine(
40+
"",
41+
"This synopsis lists options available in hub role only. To get help on the command line options available for other roles run the server with both -role and -help options.");
3642
}
3743

44+
public static void printNodeHelp(String msg) {
45+
printNodeHelp(msg, true);
46+
}
47+
48+
public static void printNodeHelp(String msg, boolean error) {
49+
printHelpInConsole(msg, nodeProperties, error);
50+
RemoteControlLauncher.printWrappedLine(
51+
"",
52+
"This synopsis lists options available in node role only. To get help on the command line options available for other roles run the server with both -role and -help options.");
53+
}
3854

39-
public static String getGridParam(String param) {
55+
private static String getParam(Properties properties, String param) {
4056
if (param == null) {
4157
return "";
4258
}
43-
String s = (String) gridProperties.get(param);
59+
String s = (String) properties.get(param);
4460
if (s == null) {
4561
return "No help specified for " + param;
4662
} else {
4763
return s;
4864
}
4965
}
5066

67+
public static String getHubParam(String param) {
68+
return getParam(hubProperties, param);
69+
}
70+
71+
public static String getNodeParam(String param) {
72+
return getParam(nodeProperties, param);
73+
}
5174

52-
private static void printHelpInConsole(String msg, boolean error) {
75+
private static void printHelpInConsole(String msg, Properties properties, boolean error) {
5376
String indent = " ";
5477
String indent2x = indent + indent;
5578
if (msg != null) {
@@ -61,9 +84,9 @@ private static void printHelpInConsole(String msg, boolean error) {
6184
}
6285

6386
System.out.println("Usage :");
64-
for (Object key : gridProperties.keySet()) {
65-
System.out.println(indent + "-" + key + ":\t");
66-
RemoteControlLauncher.printWrappedLine(System.out, indent2x, getGridParam(key.toString()), true);
87+
for (Object key : properties.keySet()) {
88+
System.out.println(indent + "-" + key + ":");
89+
RemoteControlLauncher.printWrappedLine(System.out, indent2x, getParam(properties, key.toString()), true);
6790
System.out.println("");
6891
}
6992
}
@@ -82,6 +105,4 @@ private static Properties load(String resource) {
82105
throw new RuntimeException(resource + " cannot be loaded.");
83106
}
84107
}
85-
86-
87108
}

Diff for: java/server/src/org/openqa/grid/common/defaults/GridParameters.properties

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
host = <IP | hostname> : usually not needed and determined automatically. For exotic network configuration, network with VPN, specifying the host might be necessary.
2+
port = <xxxx> : the port the remote/hub will listen on. Default to 4444.
3+
4+
throwOnCapabilityNotPresent = <true | false> default to true. If true, the hub will reject test requests right away if no proxy is currently registered that can host that capability.Set it to false to have the request queued until a node supporting the capability is added to the grid.
5+
newSessionWaitTimeout = <XXXX>. Default to no timeout ( -1 ) the time in ms after which a new test waiting for a node to become available will time out.When that happens, the test will throw an exception before starting a browser.
6+
7+
capabilityMatcher = a class implementing the CapabilityMatcher interface. Defaults to org.openqa.grid.internal.utils.DefaultCapabilityMatcher. Specify the logic the hub will follow to define if a request can be assigned to a node.Change this class if you want to have the matching process use regular expression instead of exact match for the version of the browser for instance. All the nodes of a grid instance will use the same matcher, defined by the registry.
8+
prioritizer = a class implementing the Prioritizer interface. Default to null ( no priority = FIFO ).Specify a custom prioritizer if you need the grid to process the tests from the CI, or the IE tests first for instance.
9+
servlets = <com.mycompany.MyServlet,com.mycompany.MyServlet2> to register a new servlet on the hub/node. The servlet will accessible under the path /grid/admin/MyServlet /grid/admin/MyServlet2
10+
11+
grid1Yml = a YML file following grid1 format.
12+
hubConfig = a JSON file following grid2 format that defines the hub properties.
13+
browserTimeout = The timeout in seconds a browser can hang
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
host = <IP | hostname> : usually not needed and determined automatically. For exotic network configuration, network with VPN, specifying the host might be necessary.
2+
port = <xxxx> : the port the remote/hub will listen on. Default to 4444.
3+
4+
cleanupCycle = <XXXX> in ms. How often a proxy will check for timed out thread.
5+
timeout = <XXXX> the timeout in seconds before the hub automatically ends a test that hasn't had any activity in the last X seconds. The browser will be released for another test to use. This typically takes care of the client crashes.
6+
browserTimeout= The timeout in seconds a browser can hang
7+
8+
hub = <http://localhost:4444/grid/register> : the url that will be used to post the registration request. This option takes precedence over -hubHost and -hubPort options.
9+
hubHost = <IP | hostname> : the host address of a hub the registration request should be sent to. Default to localhost. Option -hub takes precedence over this option.
10+
hubPort = <xxxx> : the port listened by a hub the registration request should be sent to. Default to 4444. Option -hub takes precedence over this option.
11+
proxy = the class that will be used to represent the node. By default org.openqa.grid.selenium.proxy.DefaultRemoteProxy.
12+
maxSession = max number of tests that can run at the same time on the node, independently of the browser used.
13+
14+
registerCycle = how often in ms the node will try to register itself again.Allow to restart the hub without having to restart the nodes.
15+
nodePolling = in ms. Interval between alive checks of node how often the hub checks if the node is still alive.
16+
unregisterIfStillDownAfter = in ms. If the node remains down for more than unregisterIfStillDownAfter millisec, it will disappear from the hub.Default is 1min.
17+
downPollingLimit = node is marked as down after downPollingLimit alive checks.
18+
nodeStatusCheckTimeout = in ms. Connection and socket timeout which is used for node alive check.

Diff for: java/server/src/org/openqa/grid/selenium/GridLauncher.java

+16-6
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,25 @@ public static void main(String[] args) throws Exception {
5757
" node as a node of a Selenium grid\n" +
5858
" standalone as a standalone server not being a part of a grid\n" +
5959
"\n" +
60-
"If -role option is not specified the server runs standalone" +
60+
"If -role option is not specified the server runs standalone\n" +
6161
"\n");
62+
RemoteControlLauncher.printWrappedLine("",
63+
"To get help on the command line options available for each role run the server with both -role and -help options");
6264
return;
6365
}
6466

6567
if (helper.isParamPresent("-help") || helper.isParamPresent("-h")){
66-
String separator = "\n----------------------------------\n";
67-
RemoteControlLauncher.usage(separator+"To use as a standalone server"+separator);
68-
GridDocHelper.printHelp(separator+"To use in a grid environment :"+separator,false);
68+
String separator = "\n-----------------------------------------\n";
69+
if (role == GridRole.NOT_GRID) {
70+
RemoteControlLauncher.usage(separator+"To use as a standalone server"+separator);
71+
} else if (role == GridRole.HUB) {
72+
GridDocHelper.printHubHelp(
73+
separator + "To use in a grid environment as the hub:" + separator, false);
74+
} else if (role == GridRole.NODE) {
75+
GridDocHelper.printNodeHelp(separator + "To use in a grid environment as a node:" + separator, false);
76+
} else {
77+
GridDocHelper.printHubHelp(separator + "To use in a grid environment :" + separator, false);
78+
}
6979
return;
7080
}
7181

@@ -86,7 +96,7 @@ public static void main(String[] args) throws Exception {
8696
log.info("Nodes should register to " + h.getRegistrationURL());
8797
log.info("Selenium Grid hub is up and running");
8898
} catch (GridConfigurationException e) {
89-
GridDocHelper.printHelp(e.getMessage());
99+
GridDocHelper.printHubHelp(e.getMessage());
90100
e.printStackTrace();
91101
}
92102
break;
@@ -99,7 +109,7 @@ public static void main(String[] args) throws Exception {
99109
log.info("Selenium Grid node is up and ready to register to the hub");
100110
remote.startRegistrationProcess();
101111
} catch (GridConfigurationException e) {
102-
GridDocHelper.printHelp(e.getMessage());
112+
GridDocHelper.printNodeHelp(e.getMessage());
103113
e.printStackTrace();
104114
}
105115
break;

Diff for: java/server/src/org/openqa/grid/web/servlet/ConsoleServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ private String getConfigInfo(boolean verbose) {
200200
}
201201

202202
private String key(String key) {
203-
return "<abbr title='" + GridDocHelper.getGridParam(key) + "'>" + key + " : </abbr>";
203+
return "<abbr title='" + GridDocHelper.getHubParam(key) + "'>" + key + " : </abbr>";
204204
}
205205

206206
private String prettyHtmlPrint(GridHubConfiguration config) {

Diff for: java/server/src/org/openqa/grid/web/servlet/beta/ConsoleServlet.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ private String getConfigInfo(boolean verbose) {
266266
}
267267

268268
private String key(String key) {
269-
return "<abbr title='" + GridDocHelper.getGridParam(key) + "'>" + key + " : </abbr>";
269+
return "<abbr title='" + GridDocHelper.getHubParam(key) + "'>" + key + " : </abbr>";
270270
}
271271

272272
private String prettyHtmlPrint(GridHubConfiguration config) {

Diff for: java/server/src/org/openqa/selenium/server/cli/RemoteControlLauncher.java

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ public static void usage(String msg) {
107107
"number of times. A simple example of how this could be useful: if you add \"-userContentTransformation https http\" "
108108
+
109109
"then all \"https\" strings in the HTML of the test application will be changed to be \"http\".");
110+
printWrappedLine(
111+
"",
112+
"\nThis synopsis lists options available in standalone role only. To get help on the command line options available for other roles run the server with both -role and -help options.");
110113
}
111114

112115
public static RemoteControlConfiguration parseLauncherOptions(String[] args) {

0 commit comments

Comments
 (0)