Skip to content

Commit a574414

Browse files
authored
Merge branch 'trunk' into js-npm-to-pnpm
2 parents d83a9b5 + 438b77c commit a574414

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Selenium
22

33
[![CI](https://github.com/SeleniumHQ/selenium/actions/workflows/ci.yml/badge.svg?branch=trunk&event=schedule)](https://github.com/SeleniumHQ/selenium/actions/workflows/ci.yml)
4+
[![Releases downloads](https://img.shields.io/github/downloads/SeleniumHQ/selenium/total.svg)](https://github.com/SeleniumHQ/selenium/releases)
45

56
<a href="https://selenium.dev"><img src="common/images/selenium_logo_mark_green.svg" width="180" alt="Selenium Logo"/></a>
67

java/src/org/openqa/selenium/grid/node/config/NodeFlags.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static org.openqa.selenium.grid.node.config.NodeOptions.DEFAULT_REGISTER_PERIOD;
3131
import static org.openqa.selenium.grid.node.config.NodeOptions.DEFAULT_SESSION_TIMEOUT;
3232
import static org.openqa.selenium.grid.node.config.NodeOptions.DEFAULT_USE_SELENIUM_MANAGER;
33-
import static org.openqa.selenium.grid.node.config.NodeOptions.DEFAULT_VNC_ENV_VAR;
33+
import static org.openqa.selenium.grid.node.config.NodeOptions.DEFAULT_VNC_ENV_VARS;
3434
import static org.openqa.selenium.grid.node.config.NodeOptions.NODE_SECTION;
3535
import static org.openqa.selenium.grid.node.config.NodeOptions.OVERRIDE_MAX_SESSIONS;
3636

@@ -202,8 +202,11 @@ public class NodeFlags implements HasRoles {
202202
description =
203203
"Environment variable to check in order to determine if a vnc stream is "
204204
+ "available or not.")
205-
@ConfigValue(section = NODE_SECTION, name = "vnc-env-var", example = "SE_START_XVFB")
206-
public String vncEnvVar = DEFAULT_VNC_ENV_VAR;
205+
@ConfigValue(
206+
section = NODE_SECTION,
207+
name = "vnc-env-var",
208+
example = "[\"SE_START_XVFB\", \"SE_START_VNC\", \"SE_START_NO_VNC\"]")
209+
public List<String> vncEnvVar = DEFAULT_VNC_ENV_VARS;
207210

208211
@Parameter(
209212
names = "--no-vnc-port",

java/src/org/openqa/selenium/grid/node/config/NodeOptions.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.net.URISyntaxException;
3232
import java.time.Duration;
3333
import java.util.ArrayList;
34+
import java.util.Arrays;
3435
import java.util.Collection;
3536
import java.util.Comparator;
3637
import java.util.HashMap;
@@ -78,7 +79,8 @@ public class NodeOptions {
7879
static final boolean DEFAULT_DETECT_DRIVERS = true;
7980
static final boolean DEFAULT_USE_SELENIUM_MANAGER = false;
8081
static final boolean OVERRIDE_MAX_SESSIONS = false;
81-
static final String DEFAULT_VNC_ENV_VAR = "SE_START_XVFB";
82+
static final List<String> DEFAULT_VNC_ENV_VARS =
83+
Arrays.asList("SE_START_XVFB", "SE_START_VNC", "SE_START_NO_VNC");
8284
static final int DEFAULT_NO_VNC_PORT = 7900;
8385
static final int DEFAULT_REGISTER_CYCLE = 10;
8486
static final int DEFAULT_REGISTER_PERIOD = 120;
@@ -286,9 +288,16 @@ public int getDrainAfterSessionCount() {
286288

287289
@VisibleForTesting
288290
boolean isVncEnabled() {
289-
String vncEnvVar = config.get(NODE_SECTION, "vnc-env-var").orElse(DEFAULT_VNC_ENV_VAR);
291+
List<String> vncEnvVars = DEFAULT_VNC_ENV_VARS;
292+
if (config.getAll(NODE_SECTION, "vnc-env-var").isPresent()) {
293+
vncEnvVars = config.getAll(NODE_SECTION, "vnc-env-var").get();
294+
}
290295
if (!vncEnabledValueSet.getAndSet(true)) {
291-
vncEnabled.set(Boolean.parseBoolean(System.getenv(vncEnvVar)));
296+
boolean allEnabled =
297+
vncEnvVars.stream()
298+
.allMatch(
299+
env -> "true".equalsIgnoreCase(System.getProperty(env, System.getenv(env))));
300+
vncEnabled.set(allEnabled);
292301
}
293302
return vncEnabled.get();
294303
}

java/test/org/openqa/selenium/grid/node/config/NodeOptionsTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,50 @@ void settingSlotMatcherAvailable() {
719719
assertThat(nodeOptions.getSlotMatcher()).isExactlyInstanceOf(YesSlotMatcher.class);
720720
}
721721

722+
@Test
723+
void testIsVncEnabledAcceptListEnvVarsAndReturnTrue() {
724+
System.setProperty("SE_START_XVFB", "true");
725+
System.setProperty("SE_START_VNC", "true");
726+
System.setProperty("SE_START_NO_VNC", "true");
727+
String[] rawConfig =
728+
new String[] {
729+
"[node]", "vnc-env-var = [\"SE_START_XVFB\", \"SE_START_VNC\", \"SE_START_NO_VNC\"]",
730+
};
731+
Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig)));
732+
NodeOptions nodeOptionsEnabled = new NodeOptions(config);
733+
assertThat(config.getAll("node", "vnc-env-var").get())
734+
.containsExactly("SE_START_XVFB", "SE_START_VNC", "SE_START_NO_VNC");
735+
assertThat(nodeOptionsEnabled.isVncEnabled()).isTrue();
736+
}
737+
738+
@Test
739+
void testIsVncEnabledAcceptListEnvVarsAndReturnFalse() {
740+
System.setProperty("SE_START_XVFB", "true");
741+
System.setProperty("SE_START_VNC", "false");
742+
String[] rawConfig =
743+
new String[] {
744+
"[node]", "vnc-env-var = [\"SE_START_XVFB\", \"SE_START_VNC\", \"SE_START_NO_VNC\"]",
745+
};
746+
Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig)));
747+
NodeOptions nodeOptionsEnabled = new NodeOptions(config);
748+
assertThat(config.getAll("node", "vnc-env-var").get())
749+
.containsExactly("SE_START_XVFB", "SE_START_VNC", "SE_START_NO_VNC");
750+
assertThat(nodeOptionsEnabled.isVncEnabled()).isFalse();
751+
}
752+
753+
@Test
754+
void testIsVncEnabledAcceptSingleEnvVar() {
755+
System.setProperty("SE_START_XVFB", "false");
756+
String[] rawConfig =
757+
new String[] {
758+
"[node]", "vnc-env-var = \"SE_START_XVFB\"",
759+
};
760+
Config config = new TomlConfig(new StringReader(String.join("\n", rawConfig)));
761+
NodeOptions nodeOptionsEnabled = new NodeOptions(config);
762+
assertThat(config.getAll("node", "vnc-env-var").get()).containsExactly("SE_START_XVFB");
763+
assertThat(nodeOptionsEnabled.isVncEnabled()).isFalse();
764+
}
765+
722766
private Condition<? super List<? extends Capabilities>> supporting(String name) {
723767
return new Condition<>(
724768
caps -> caps.stream().anyMatch(cap -> name.equals(cap.getBrowserName())),

0 commit comments

Comments
 (0)