Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@ public class NewSessionQueueFlags implements HasRoles {
@ConfigValue(section = SESSION_QUEUE_SECTION, name = "sessionqueue-batch-size", example = "20")
private int batchSize = DEFAULT_BATCH_SIZE;

@Parameter(
names = {"--sessionqueue-implementation"},
description = "Full classname of the non-default session queue implementation.")
@ConfigValue(
section = SESSION_QUEUE_SECTION,
name = "implementation",
example = "\"org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue\"")
private String sessionQueueImplementation;

@Parameter(
names = {"--sessionqueue-backend-url"},
description =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ java_library(
visibility = [
"//java/src/org/openqa/selenium/grid:__pkg__",
"//java/test/org/openqa/selenium/grid/router:__pkg__",
"//java/test/org/openqa/selenium/grid/sessionqueue/httpd:__pkg__",
],
deps = [
"//java:auto-service",
Expand All @@ -18,6 +19,7 @@ java_library(
"//java/src/org/openqa/selenium/grid/sessionqueue",
"//java/src/org/openqa/selenium/grid/sessionqueue/config",
"//java/src/org/openqa/selenium/grid/sessionqueue/local",
"//java/src/org/openqa/selenium/grid/sessionqueue/redis",
"//java/src/org/openqa/selenium/json",
"//java/src/org/openqa/selenium/netty/server",
artifact("com.beust:jcommander"),
Expand Down
15 changes: 15 additions & 0 deletions java/test/org/openqa/selenium/grid/sessionqueue/config/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_jvm_external//:defs.bzl", "artifact")
load("//java:defs.bzl", "JUNIT5_DEPS", "java_test_suite")

java_test_suite(
name = "SmallTests",
size = "small",
srcs = glob(["*Test.java"]),
deps = [
"//java/src/org/openqa/selenium/grid/config",
"//java/src/org/openqa/selenium/grid/sessionqueue/config",
artifact("com.beust:jcommander"),
artifact("org.junit.jupiter:junit-jupiter-api"),
artifact("org.assertj:assertj-core"),
] + JUNIT5_DEPS,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// 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.sessionqueue.config;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatCode;

import com.beust.jcommander.JCommander;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openqa.selenium.grid.config.AnnotatedConfig;
import org.openqa.selenium.grid.config.Config;

class NewSessionQueueFlagsTest {

private NewSessionQueueFlags flags;

@BeforeEach
void setUp() {
flags = new NewSessionQueueFlags();
}

@Test
void sessionQueueImplementationFlagIsAccepted() {
String impl = "org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue";

assertThatCode(
() ->
JCommander.newBuilder()
.addObject(flags)
.build()
.parse("--sessionqueue-implementation", impl))
.doesNotThrowAnyException();
}

@Test
void sessionQueueImplementationFlagPopulatesConfig() {
String impl = "org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue";
JCommander.newBuilder().addObject(flags).build().parse("--sessionqueue-implementation", impl);

Config config = new AnnotatedConfig(flags);

assertThat(config.get("sessionqueue", "implementation")).contains(impl);
}

@Test
void sessionQueueImplementationIsAbsentWhenFlagNotSet() {
Config config = new AnnotatedConfig(flags);

assertThat(config.get("sessionqueue", "implementation")).isEmpty();
}
}
18 changes: 18 additions & 0 deletions java/test/org/openqa/selenium/grid/sessionqueue/httpd/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
load("@rules_jvm_external//:defs.bzl", "artifact")
load("//java:defs.bzl", "JUNIT5_DEPS", "java_test_suite")
load("//java:version.bzl", "TOOLS_JAVA_VERSION")

java_test_suite(
name = "small-tests",
size = "small",
srcs = glob(["*.java"]),
javacopts = [
"--release",
TOOLS_JAVA_VERSION,
],
deps = [
"//java/src/org/openqa/selenium/grid/sessionqueue/httpd",
artifact("org.assertj:assertj-core"),
artifact("org.junit.jupiter:junit-jupiter-api"),
] + JUNIT5_DEPS,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// 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.sessionqueue.httpd;

import static org.assertj.core.api.Assertions.assertThatCode;

import org.junit.jupiter.api.Test;

class NewSessionQueueServerTest {

// These classes are loaded via Class.forName() at runtime. This test verifies they are bundled
// into the httpd target so that --sessionqueue-implementation works without --ext.
@Test
void localImplementationIsOnClasspath() {
assertThatCode(
() -> Class.forName("org.openqa.selenium.grid.sessionqueue.local.LocalNewSessionQueue"))
.doesNotThrowAnyException();
}

@Test
void redisImplementationIsOnClasspath() {
assertThatCode(
() ->
Class.forName(
"org.openqa.selenium.grid.sessionqueue.redis.RedisBackedNewSessionQueue"))
.doesNotThrowAnyException();
}
}
Loading