Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit e3f539d

Browse files
committed
Fixed an issue where the node will attempt to reboot and will be stuck in an endless loop trying to kill safari and never rebooting. Fixing the issue by commenting out the kill browsers command and just sending a reboot command
1 parent 5e92540 commit e3f539d

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
1.3.3 - Fixed an issue where the node will attempt to reboot and will be stuck in an endless loop trying to kill safari and never rebooting. Fixing the issue by commenting out the kill browsers command and just sending a reboot command
12
1.3.2 - Fixing a bug where node config JSON have all Integers converted to Doubles by Gson, which prevents nodes from starting
23
1.3.1 - When sending config to HUB and reciving it from HUB, parse the config and pretty print it into the file
34
- Performance improvment in the tests, don't try to ping hub asking for local box's info when in test mode

SeleniumGridExtras/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.groupon.selenium-grid-extras</groupId>
88
<artifactId>SeleniumGridExtras</artifactId>
9-
<version>1.3.2-SNAPSHOT</version>
9+
<version>1.3.3-SNAPSHOT</version>
1010

1111
<repositories>
1212
<repository>

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/grid/proxies/SetupTeardownProxy.java

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
import com.groupon.seleniumgridextras.utilities.HttpUtility;
4646

47+
import org.apache.log4j.Logger;
4748
import org.openqa.grid.common.exception.RemoteUnregisterException;
4849

4950

@@ -65,10 +66,12 @@ public class SetupTeardownProxy extends DefaultRemoteProxy implements TestSessio
6566
private boolean available = true;
6667
private boolean restarting = false;
6768

69+
private static Logger logger = Logger.getLogger(SetupTeardownProxy.class);
70+
6871

6972
public SetupTeardownProxy(RegistrationRequest request, Registry registry) {
7073
super(request, registry);
71-
System.out.println("Attaching a node: " + getHost());
74+
writeProxyLog("Attaching a node: " + getHost());
7275
}
7376

7477
@Override
@@ -77,10 +80,9 @@ public TestSession getNewSession(Map<String, Object> requestedCapability) {
7780
if (timeToReboot() && !this.isBusy()) {
7881
setAvailable(false);
7982
setRestarting(false);
80-
killBrowserForCurrentSession();
83+
// killBrowserForCurrentSession();
8184
stopGridNode();
8285
rebootGridExtrasNode();
83-
unregister();
8486
}
8587

8688
if (isAvailable()) {
@@ -111,22 +113,23 @@ public void afterSession(TestSession session) {
111113
}
112114

113115
protected void stopGridNode() {
114-
System.out.println("Asking " + getHost() + " to stop grid node politely");
115-
System.out.println(callRemoteGridExtras("stop_grid?port=5555"));
116+
writeProxyLog("Asking " + getHost() + " to stop grid node politely");
117+
writeProxyLog(callRemoteGridExtras("stop_grid?port=5555"));
118+
unregister();
116119
}
117120

118121
protected void killBrowserForCurrentSession() {
119-
System.out.println("Asking " + getHost() + " to politely kill all browsers");
122+
writeProxyLog("Asking " + getHost() + " to politely kill all browsers");
120123

121-
System.out.println(callRemoteGridExtras("kill_ie"));
122-
System.out.println(callRemoteGridExtras("kill_safari"));
123-
System.out.println(callRemoteGridExtras("kill_chrome"));
124-
System.out.println(callRemoteGridExtras("kill_firefox"));
124+
writeProxyLog(callRemoteGridExtras("kill_ie"));
125+
writeProxyLog(callRemoteGridExtras("kill_safari"));
126+
writeProxyLog(callRemoteGridExtras("kill_chrome"));
127+
writeProxyLog(callRemoteGridExtras("kill_firefox"));
125128
}
126129

127130
private void rebootGridExtrasNode() {
128-
System.out.println("Asking SeleniumGridExtras to reboot " + getHost());
129-
System.out.println(callRemoteGridExtras("reboot"));
131+
writeProxyLog("Asking SeleniumGridExtras to reboot " + getHost());
132+
writeProxyLog(callRemoteGridExtras("reboot"));
130133
}
131134

132135
private JsonObject callRemoteGridExtras(String action) {
@@ -138,16 +141,17 @@ private JsonObject callRemoteGridExtras(String action) {
138141
new URL("http://" + getHost() + ":3000/" + action));
139142

140143
JsonParser j = new JsonParser();
144+
logger.info(returnedString);
141145
return (JsonObject) j.parse(returnedString);
142146

143147
} catch (MalformedURLException e) {
144-
System.out.println(e.toString());
148+
writeProxyLog(e.toString());
145149
e.printStackTrace();
146150
} catch (ProtocolException e) {
147-
System.out.println(e.toString());
151+
writeProxyLog(e.toString());
148152
e.printStackTrace();
149153
} catch (IOException e) {
150-
System.out.println(e.toString());
154+
writeProxyLog(e.toString());
151155
e.printStackTrace();
152156
}
153157

@@ -174,7 +178,7 @@ protected boolean timeToReboot() {
174178
int sessionLimit = status.get("node_sessions_limit").getAsInt();
175179

176180
if (!nodeRunning) {
177-
System.out.println("The grid node on " + getHost() + " does not seem to be running");
181+
writeProxyLog("The grid node on " + getHost() + " does not seem to be running");
178182
} else if (sessionLimit == 0) {
179183
return false;
180184
} else if (sessionsStarted >= sessionLimit) {
@@ -190,7 +194,7 @@ protected boolean timeToReboot() {
190194
}
191195

192196
public void unregister() {
193-
System.out.println("Sending Un register command for " + getHost());
197+
writeProxyLog("Sending Un register command for " + getHost());
194198
addNewEvent(new RemoteUnregisterException("Unregistering the node."));
195199
}
196200

@@ -202,4 +206,8 @@ public void setRestarting(boolean restarting) {
202206
this.restarting = restarting;
203207
}
204208

209+
private void writeProxyLog(Object logItem){
210+
logger.info(logItem.toString());
211+
}
212+
205213
}

SeleniumGridExtras/src/main/java/com/groupon/seleniumgridextras/utilities/FileIOUtility.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,13 @@ public static String getAsString(File file) throws FileNotFoundException {
5555
return readString;
5656
}
5757

58-
public static void writeToFile(File filename, String content) throws IOException {
58+
public static void writeToFile(File filename, String content, boolean append) throws IOException {
5959
logger.debug("Writing to " + filename.getAbsolutePath() + " following content\n" + content);
60-
FileUtils.writeStringToFile(filename, content);
60+
FileUtils.writeStringToFile(filename, content, append);
61+
}
62+
63+
public static void writeToFile(File filename, String content) throws IOException {
64+
FileIOUtility.writeToFile(filename, content, false);
6165
}
6266

6367
public static void writePrettyJsonToFile(File filename, String content) throws IOException{

0 commit comments

Comments
 (0)