Skip to content

Commit 58b3e6e

Browse files
committed
Added support for restart subtest and 60 secs pause on warn's
Version upgrade 3.0.4
1 parent 413cee3 commit 58b3e6e

16 files changed

+233
-94
lines changed

Dockerfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ RUN git clone https://github.com/sumeetchhetri/gatf
4747
#COPY sample /tmp/gatf/sample
4848
#COPY pom.xml /tmp/gatf/
4949
#COPY plugins.txt /tmp/gatf/
50-
RUN cd gatf && git checkout tags/3.0.3 -b v3.0.3 && mvn --quiet install
50+
RUN cd gatf && git checkout tags/3.0.4 -b v3.0.4 && mvn --quiet install
5151

52-
RUN mv /tmp/gatf/alldep-jar/target/gatf-alldep-jar-3.0.3.jar /gatf-alldep.jar
52+
RUN mv /tmp/gatf/alldep-jar/target/gatf-alldep-jar-3.0.4.jar /gatf-alldep.jar

Dockerfile-Gatf-Chrome

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ RUN npm install -g autocannon
2323
# Google Chrome
2424
#============================================
2525
# can specify versions by CHROME_VERSION;
26-
# e.g. google-chrome-stable=53.0.3785.101-1
27-
# google-chrome-beta=53.0.3785.92-1
26+
# e.g. google-chrome-stable=53.0.4785.101-1
27+
# google-chrome-beta=53.0.4785.92-1
2828
# google-chrome-unstable=54.0.2840.14-1
2929
# latest (equivalent to google-chrome-stable)
3030
# google-chrome-beta (pull latest beta)

Dockerfile-selenoid-chrome.tmpl

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
FROM selenoid/vnc:chrome_128.0
2+
3+
# Install dependencies for Chrome
4+
RUN apt-get update && apt-get install -y \
5+
wget \
6+
curl \
7+
unzip \
8+
ca-certificates \
9+
libx11-6 \
10+
libx264-155 \
11+
libfontconfig \
12+
libxi6 \
13+
libgconf-2-4 \
14+
libnss3 \
15+
libasound2 \
16+
libappindicator3-1 \
17+
libindicator3-7 \
18+
xdg-utils
19+
20+
# Set desired Chrome version (e.g., version 129)
21+
ENV CHROME_VERSION=129
22+
23+
# Download and install the specified version of Chrome
24+
RUN wget https://dl.google.com/linux/direct/google-chrome-stable_${CHROME_VERSION}.0-1_amd64.deb && \
25+
dpkg -i google-chrome-stable_${CHROME_VERSION}.0-1_amd64.deb && \
26+
apt-get -f install -y
27+
RUN LATEST_DRIVER_VERSION=$(curl -sSL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_VERSION}") && \
28+
wget https://chromedriver.storage.googleapis.com/${LATEST_DRIVER_VERSION}/chromedriver_linux64.zip && \
29+
unzip chromedriver_linux64.zip -d /usr/bin && \
30+
chmod +x /usr/bin/chromedriver && \
31+
rm chromedriver_linux64.zip
32+
33+
ENV NODE_MAJOR 20
34+
35+
USER root
36+
RUN apt-get update -y && apt-get install -y ca-certificates curl gnupg && mkdir -p /etc/apt/keyrings
37+
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
38+
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
39+
RUN apt-get update -y && apt-get install nodejs -y
40+
41+
RUN rm -rf /var/lib/apt/lists/* google-chrome-stable_${CHROME_VERSION}.0-1_amd64.deb
42+
43+
RUN mkdir /seltest
44+
COPY dyn-proxy.js /seltest
45+
COPY entrypoint_so.sh /
46+
RUN chmod +x entrypoint_so.sh /seltest/dyn-proxy.js
47+
RUN chmod -R 777 /seltest
48+
49+
USER selenium
50+
51+
EXPOSE 4444 8001
52+
ENTRYPOINT ["/entrypoint_so.sh"]

Dockerfile-selenoid-firefox.tmpl

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
FROM selenoid/vnc:firefox_125.0
2+
3+
FROM selenoid/vnc:latest
4+
5+
# Install dependencies for Firefox
6+
RUN apt-get update && apt-get install -y \
7+
wget \
8+
curl \
9+
unzip \
10+
ca-certificates \
11+
libx11-6 \
12+
libx264-155 \
13+
libfontconfig \
14+
libxi6 \
15+
libgconf-2-4 \
16+
libnss3 \
17+
libasound2 \
18+
libappindicator3-1 \
19+
libindicator3-7 \
20+
xdg-utils
21+
22+
# Set desired Firefox version (e.g., version 118)
23+
ENV FIREFOX_VERSION=118
24+
25+
# Download and install the specified version of Firefox
26+
RUN wget https://ftp.mozilla.org/pub/firefox/releases/${FIREFOX_VERSION}/linux-x86_64/en-US/firefox-${FIREFOX_VERSION}.tar.bz2 && \
27+
tar -xjf firefox-${FIREFOX_VERSION}.tar.bz2 -C /opt && \
28+
ln -s /opt/firefox/firefox /usr/bin/firefox
29+
RUN GECKODRIVER_VERSION=$(curl -sSL "https://github.com/mozilla/geckodriver/releases/latest" | grep -oP 'geckodriver-v[\d\.]+-linux64.tar.gz' | head -n 1) && \
30+
wget https://github.com/mozilla/geckodriver/releases/download/${GECKODRIVER_VERSION}/geckodriver-${GECKODRIVER_VERSION}.tar.gz && \
31+
tar -xvzf geckodriver-${GECKODRIVER_VERSION}.tar.gz && \
32+
mv geckodriver /usr/bin/ && \
33+
chmod +x /usr/bin/geckodriver && \
34+
rm geckodriver-${GECKODRIVER_VERSION}.tar.gz
35+
36+
ENV NODE_MAJOR 20
37+
38+
USER root
39+
RUN apt-get update -y && apt-get install -y ca-certificates curl gnupg && mkdir -p /etc/apt/keyrings
40+
RUN curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
41+
RUN echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | tee /etc/apt/sources.list.d/nodesource.list
42+
RUN apt-get update -y && apt-get install nodejs -y
43+
44+
RUN rm -rf /var/lib/apt/lists/* firefox-${FIREFOX_VERSION}.tar.bz2
45+
46+
RUN mkdir /seltest
47+
COPY dyn-proxy.js /seltest
48+
COPY entrypoint_so.sh /
49+
RUN chmod +x entrypoint_so.sh /seltest/dyn-proxy.js
50+
RUN chmod -R 777 /seltest
51+
52+
USER selenium
53+
54+
EXPOSE 4444 8001
55+
ENTRYPOINT ["/entrypoint_so.sh"]

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ It uses a highly performant asynchronous http client library - async-http-client
325325
For direct execution, we just need to specify a simple config.xml(any name .xml) file with the contents as follows, on the command line,
326326

327327
```sh
328-
java -jar gatf-alldep-3.0.3.jar -executor /workdir/path/to/gatf/config.xml
328+
java -jar gatf-alldep-3.0.4.jar -executor /workdir/path/to/gatf/config.xml
329329
```
330330

331331
```sh
@@ -335,7 +335,7 @@ docker run -v /dev/shm:/dev/shm -v /local-folder:/workdir -e TZ=Asia/Kolkata -it
335335
For direct execution for RPA (selenium), we just need to specify a simple config.xml(any name .xml) file with the contents as follows, on the command line,
336336

337337
```sh
338-
java -jar gatf-alldep-3.0.3.jar -selenium /workdir/path/to/gatf/config.xml
338+
java -jar gatf-alldep-3.0.4.jar -selenium /workdir/path/to/gatf/config.xml
339339
```
340340

341341
```sh
@@ -345,7 +345,7 @@ docker run -v /dev/shm:/dev/shm -v /local-folder:/workdir -e TZ=Asia/Kolkata -it
345345
For validating test script for RPA (selenium), use the following command,
346346

347347
```sh
348-
java -jar gatf-alldep-3.0.3.jar -validate-sel test-script-name-relative-to-workdir.sel /workdir/path/to/gatf/config.xml
348+
java -jar gatf-alldep-3.0.4.jar -validate-sel test-script-name-relative-to-workdir.sel /workdir/path/to/gatf/config.xml
349349
```
350350

351351
```sh
@@ -355,7 +355,7 @@ docker run -v /dev/shm:/dev/shm -v /local-folder:/workdir -e TZ=Asia/Kolkata -it
355355
For running gatf in distributed mode as a listener, use the following command,
356356

357357
```sh
358-
java -jar gatf-alldep-3.0.3.jar -listener
358+
java -jar gatf-alldep-3.0.4.jar -listener
359359
```
360360

361361
```sh
@@ -1347,7 +1347,7 @@ Gatf also provides with a User Interface for managing and executing test cases o
13471347
<br>
13481348

13491349
```sh
1350-
java -jar gatf-alldep-3.0.3.jar -configtool 9080 0.0.0.0 .
1350+
java -jar gatf-alldep-3.0.4.jar -configtool 9080 0.0.0.0 .
13511351
```
13521352

13531353
```sh
@@ -1546,7 +1546,7 @@ jsonapi/users/1,GetUser,GET,Get a user with id = 1,,someheader:val|anotherheader
15461546
<br>
15471547

15481548
```sh
1549-
java -jar gatf-alldep-3.0.3.jar -generator /workdir/path/to/gatf/config.xml
1549+
java -jar gatf-alldep-3.0.4.jar -generator /workdir/path/to/gatf/config.xml
15501550
```
15511551

15521552
```sh

alldep-jar/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.github.sumeetchhetri.gatf</groupId>
66
<artifactId>gatf-parent</artifactId>
7-
<version>3.0.3</version>
7+
<version>3.0.4</version>
88
</parent>
99

1010
<artifactId>gatf-alldep-jar</artifactId>

alldep-jar/src/main/java/com/gatf/executor/core/AcceptanceTestContext.java

+14-2
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,21 @@ public static interface SimulatorInt {
149149
}
150150

151151
protected AtomicBoolean pauseElSearchFlag = new AtomicBoolean(false);
152+
protected AtomicBoolean restartSubtestFlag = new AtomicBoolean(false);
152153
protected AtomicReference<ImmutablePair<String, Integer>> pausedLineNo = new AtomicReference<>();
153154

155+
public void restartSubtest() {
156+
restartSubtestFlag.set(true);
157+
}
158+
159+
public void unRestartSubtest() {
160+
restartSubtestFlag.set(false);
161+
}
162+
163+
public boolean isRestartSubtest() {
164+
return restartSubtestFlag.get();
165+
}
166+
154167
public void pauseElSearch() {
155168
pauseElSearchFlag.set(true);
156169
}
@@ -160,8 +173,7 @@ public void unPauseElSearch() {
160173
}
161174

162175
public boolean isPauseElSearch(boolean isLocal) {
163-
if(isLocal) return pauseElSearchFlag.get();
164-
return pauseElSearchFlag.get() || getPausedLineNo()!=-1;
176+
return pauseElSearchFlag.get();
165177
}
166178

167179
public void setPausedLineNo(String testFile, int lineNo) {

alldep-jar/src/main/java/com/gatf/executor/core/GatfExecutorConfig.java

+10
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,8 @@ public class GatfExecutorConfig implements Serializable, GatfPluginConfig {
172172

173173
private boolean autoPauseOnElNotFound = false;
174174

175+
private boolean waitOnWarnException = false;
176+
175177
public String getBaseUrl() {
176178
return baseUrl;
177179
}
@@ -740,6 +742,14 @@ public void setAutoPauseOnElNotFound(boolean autoPauseOnElNotFound) {
740742
this.autoPauseOnElNotFound = autoPauseOnElNotFound;
741743
}
742744

745+
public boolean isWaitOnWarnException() {
746+
return waitOnWarnException;
747+
}
748+
749+
public void setWaitOnWarnException(boolean waitOnWarnException) {
750+
this.waitOnWarnException = waitOnWarnException;
751+
}
752+
743753
public void validate()
744754
{
745755
if(getTestCaseDir()!=null) {

alldep-jar/src/main/java/com/gatf/selenium/Command.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5607,7 +5607,7 @@ String toCmd() {
56075607
return "warn \"" + value + "\"";
56085608
}
56095609
String javacode() {
5610-
return "if(true)\n{\nthrow new WarnSubTestException(\""+esc(value)+"\");\n}";
5610+
return "throw new WarnSubTestException(\""+esc(value)+"\");";
56115611
}
56125612
WarnCommand(String cmd, Object[] cmdDetails, CommandState state) {
56135613
super(cmdDetails, state);

alldep-jar/src/main/java/com/gatf/selenium/SeleniumTest.java

+28-8
Original file line numberDiff line numberDiff line change
@@ -1195,13 +1195,19 @@ protected List<WebElement> ___invoke_sub_test_dyn___(Class<?> claz, String stNam
11951195
return (List<WebElement>) method.invoke(tst_, new Object[] { __sfname__, ___cw___, ___ocw___, ___sc___1, ___lp___ });
11961196
} catch (InvocationTargetException e) {
11971197
throw e.getCause();
1198+
} catch (RestartsubtestException e) {
1199+
___cxt___.unRestartSubtest();
1200+
return ___invoke_sub_test_dyn___(claz, stName, __sfname__, ___cw___, ___ocw___, ___sc___1, ___lp___);
11981201
}
11991202
} else {
12001203
method.setAccessible(true);
12011204
try {
12021205
return (List<WebElement>) method.invoke(this, new Object[] { __sfname__, ___cw___, ___ocw___, ___sc___1, ___lp___ });
12031206
} catch (InvocationTargetException e) {
12041207
throw e.getCause();
1208+
} catch (RestartsubtestException e) {
1209+
___cxt___.unRestartSubtest();
1210+
return ___invoke_sub_test_dyn___(claz, stName, __sfname__, ___cw___, ___ocw___, ___sc___1, ___lp___);
12051211
}
12061212
}
12071213
}
@@ -1317,6 +1323,17 @@ public SeleniumTestResult(WebDriver d, SeleniumTest test, Throwable exc, String
13171323
if(isPending) System.out.println(cause.getMessage());
13181324
} else if(cause instanceof FailSubTestException || cause instanceof WarnSubTestException || cause instanceof SubTestException) {
13191325
this.isContinue = cause instanceof WarnSubTestException;
1326+
if(this.isContinue) {
1327+
if(test.___cxt___.getGatfExecutorConfig().isWaitOnWarnException())
1328+
{
1329+
try {
1330+
Thread.sleep(60000);
1331+
} catch(Exception e){}
1332+
if(test.___cxt___.isRestartSubtest()) {
1333+
throw new RestartsubtestException();
1334+
}
1335+
}
1336+
}
13201337
this.stName = test.get__subtestname__();
13211338
List<LogEntry> entries = new ArrayList<LogEntry>();
13221339
entries.add(new LogEntry(Level.ALL, new Date().getTime(), cause.getMessage()));
@@ -2814,12 +2831,14 @@ protected List<WebElement> handleWaitFuncWL(WebDriver driver, final SearchContex
28142831
while(true) {
28152832
boolean wasPaused = false;
28162833
while(___cxt___.isPauseElSearch(true)) {
2817-
String relName = testFile.replace(state.basePath, "");
2818-
if(relName.startsWith(File.separator)) {
2819-
relName = relName.substring(1);
2820-
}
2821-
___cxt___.setPausedLineNo(relName, lineNo);
2822-
wasPaused = true;
2834+
if(!wasPaused) {
2835+
String relName = testFile.replace(state.basePath, "");
2836+
if(relName.startsWith(File.separator)) {
2837+
relName = relName.substring(1);
2838+
}
2839+
___cxt___.setPausedLineNo(relName, lineNo);
2840+
wasPaused = true;
2841+
}
28232842
try {
28242843
Thread.sleep(1000);
28252844
System.out.println("Script is currently in paused state......");
@@ -2876,13 +2895,12 @@ protected List<WebElement> handleWaitFuncWL(WebDriver driver, final SearchContex
28762895
} catch (Exception e) {
28772896
e.printStackTrace();
28782897
}
2879-
___cxt___.setPausedLineNo(null, -1);
28802898
}
28812899
}
28822900
} catch (Exception e) {
28832901
e.printStackTrace();
2884-
___cxt___.setPausedLineNo(null, -1);
28852902
}
2903+
___cxt___.setPausedLineNo(null, -1);
28862904
}
28872905
List<WebElement> el = (List<WebElement>)handleWaitOrTransientProv(driver, sc, ce, 0L, relative, classifier, by, subselector, byselsame, value, values, action, oper, tvalue, exmsg, noExcep, timeoutGranularity, isVisible, layers);
28882906
if(!isVisible) {
@@ -3757,6 +3775,8 @@ public static void main(String[] args) throws Exception {
37573775
}
37583776
}
37593777

3778+
public static class RestartsubtestException extends RuntimeException {
3779+
}
37603780
public static class GatfRunTimeErrors extends RuntimeException {
37613781
private List<? extends GatfRunTimeError> errors;
37623782
public GatfRunTimeErrors(List<? extends GatfRunTimeError> errors) {

alldep-jar/src/main/java/com/gatf/ui/GatfReportsHandler.java

+16
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,22 @@ public void service(Request request, Response response) throws Exception {
124124
response.setStatus(HttpStatus.OK_200);
125125
return;
126126
}
127+
else if(action.equals("restartSubtest"))
128+
{
129+
String status = "{\"status\": false}";
130+
if(context!=null) {
131+
if(action.equals("restartSubtest")) context.restartSubtest();
132+
//else context.unRestartSubtest();
133+
Map<String, Object> out = new HashMap<>();
134+
out.put("status", true);
135+
status = WorkflowContextHandler.OM.writeValueAsString(out);
136+
}
137+
response.setContentType(MediaType.APPLICATION_JSON + "; charset=utf-8");
138+
response.setContentLength(status.getBytes("UTF-8").length);
139+
response.getWriter().write(status);
140+
response.setStatus(HttpStatus.OK_200);
141+
return;
142+
}
127143
else if(action.equals("pausedLineNo"))
128144
{
129145
String status = "{\"line\": -1, \"running\": "+(context!=null)+"}";

0 commit comments

Comments
 (0)