-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[grid] Update for node shutdown gracefully
Signed-off-by: Viet Nguyen Duc <nguyenducviet4496@gmail.com>
- Loading branch information
Showing
6 changed files
with
138 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
load("@rules_jvm_external//:defs.bzl", "artifact") | ||
load("//java:defs.bzl", "JUNIT5_DEPS", "java_selenium_test_suite") | ||
|
||
java_selenium_test_suite( | ||
name = "large-tests", | ||
size = "large", | ||
srcs = glob(["*.java"]), | ||
browsers = [ | ||
"chrome", | ||
], | ||
deps = [ | ||
"//java/src/org/openqa/selenium:core", | ||
"//java/src/org/openqa/selenium/chrome", | ||
"//java/src/org/openqa/selenium/grid", | ||
"//java/src/org/openqa/selenium/remote/http", | ||
artifact("com.google.guava:guava"), | ||
artifact("org.junit.jupiter:junit-jupiter-api"), | ||
artifact("org.assertj:assertj-core"), | ||
] + JUNIT5_DEPS, | ||
) |
51 changes: 51 additions & 0 deletions
51
java/test/org/openqa/selenium/grid/e2e/SessionTimeoutTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Licensed to the Software Freedom Conservancy (SFC) under one | ||
// or more contributor license agreements. See the NOTICE file | ||
// distributed with this work for additional information | ||
// regarding copyright ownership. The SFC licenses this file | ||
// to you under the Apache License, Version 2.0 (the | ||
// "License"); you may not use this file except in compliance | ||
// with the License. You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, | ||
// software distributed under the License is distributed on an | ||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
// KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations | ||
// under the License. | ||
|
||
package org.openqa.selenium.grid.e2e; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.net.URI; | ||
import org.assertj.core.api.Assumptions; | ||
import org.junit.jupiter.api.Test; | ||
import org.openqa.selenium.NoSuchSessionException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.chrome.ChromeOptions; | ||
import org.openqa.selenium.grid.Bootstrap; | ||
import org.openqa.selenium.remote.RemoteWebDriver; | ||
|
||
public class SessionTimeoutTest { | ||
@Test | ||
void testSessionTimeout() throws Exception { | ||
Assumptions.assumeThat(System.getProperty("webdriver.chrome.binary")).isNull(); | ||
Bootstrap.main(("hub --host 127.0.0.1 --port 4444").split(" ")); | ||
Bootstrap.main( | ||
("node --host 127.0.0.1 --port 5555 --session-timeout 15 --selenium-manager true") | ||
.split(" ")); | ||
|
||
var options = new ChromeOptions(); | ||
options.addArguments("--disable-search-engine-choice-screen"); | ||
options.addArguments("--headless=new"); | ||
|
||
WebDriver driver = new RemoteWebDriver(URI.create("http://localhost:4444").toURL(), options); | ||
driver.get("http://localhost:4444"); | ||
Thread.sleep(15000); | ||
NoSuchSessionException exception = assertThrows(NoSuchSessionException.class, driver::getTitle); | ||
assertTrue(exception.getMessage().startsWith("Cannot find session with id:")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters