Skip to content

Commit 411df25

Browse files
committed
Fixed tests and race condition potential
Signed-off-by: Viet Nguyen Duc <[email protected]>
1 parent b0f3cd9 commit 411df25

File tree

3 files changed

+20
-72
lines changed

3 files changed

+20
-72
lines changed

java/test/org/openqa/selenium/grid/e2e/BUILD.bazel

Lines changed: 0 additions & 20 deletions
This file was deleted.

java/test/org/openqa/selenium/grid/e2e/SessionTimeoutTest.java

Lines changed: 0 additions & 51 deletions
This file was deleted.

java/test/org/openqa/selenium/grid/router/StressTest.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import static java.nio.charset.StandardCharsets.UTF_8;
2121
import static java.util.concurrent.TimeUnit.MINUTES;
2222
import static org.assertj.core.api.Assertions.assertThat;
23+
import static org.junit.jupiter.api.Assertions.assertThrows;
24+
import static org.junit.jupiter.api.Assertions.assertTrue;
2325

2426
import java.io.StringReader;
2527
import java.util.LinkedList;
@@ -33,6 +35,7 @@
3335
import org.junit.jupiter.api.BeforeEach;
3436
import org.junit.jupiter.api.Test;
3537
import org.openqa.selenium.By;
38+
import org.openqa.selenium.NoSuchSessionException;
3639
import org.openqa.selenium.WebDriver;
3740
import org.openqa.selenium.grid.config.MapConfig;
3841
import org.openqa.selenium.grid.config.MemoizedConfig;
@@ -65,7 +68,12 @@ public void setupServers() {
6568
DeploymentTypes.DISTRIBUTED.start(
6669
browser.getCapabilities(),
6770
new TomlConfig(
68-
new StringReader("[node]\n" + "driver-implementation = " + browser.displayName())));
71+
new StringReader(
72+
"[node]\n"
73+
+ "driver-implementation = "
74+
+ browser.displayName()
75+
+ "\n"
76+
+ "session-timeout = 15")));
6977
tearDowns.add(deployment);
7078

7179
server = deployment.getServer();
@@ -124,4 +132,15 @@ void multipleSimultaneousSessions() throws Exception {
124132

125133
CompletableFuture.allOf(futures).get(4, MINUTES);
126134
}
135+
136+
@Test
137+
void testStopTimedOutSession() throws Exception {
138+
assertThat(server.isStarted()).isTrue();
139+
WebDriver driver =
140+
RemoteWebDriver.builder().oneOf(browser.getCapabilities()).address(server.getUrl()).build();
141+
driver.get(appServer.getUrl().toString());
142+
Thread.sleep(15000);
143+
NoSuchSessionException exception = assertThrows(NoSuchSessionException.class, driver::getTitle);
144+
assertTrue(exception.getMessage().startsWith("Cannot find session with id:"));
145+
}
127146
}

0 commit comments

Comments
 (0)