Skip to content

Commit 2c9cbd7

Browse files
committed
[grid] Removing bus from NewSessionQueue
The bus was being used to fire two events that were not being listened by any other component. The events were removed in a previous commit.
1 parent 267d562 commit 2c9cbd7

13 files changed

Lines changed: 107 additions & 157 deletions

File tree

java/src/org/openqa/selenium/grid/commands/Hub.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ protected Handlers createHandlers(Config config) {
147147
NewSessionQueueOptions newSessionRequestOptions = new NewSessionQueueOptions(config);
148148
NewSessionQueue queue = new LocalNewSessionQueue(
149149
tracer,
150-
bus,
151150
distributorOptions.getSlotMatcher(),
152151
newSessionRequestOptions.getSessionRequestRetryInterval(),
153152
newSessionRequestOptions.getSessionRequestTimeout(),

java/src/org/openqa/selenium/grid/commands/Standalone.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ protected Handlers createHandlers(Config config) {
146146
NewSessionQueueOptions newSessionRequestOptions = new NewSessionQueueOptions(config);
147147
NewSessionQueue queue = new LocalNewSessionQueue(
148148
tracer,
149-
bus,
150149
distributorOptions.getSlotMatcher(),
151150
newSessionRequestOptions.getSessionRequestRetryInterval(),
152151
newSessionRequestOptions.getSessionRequestTimeout(),

java/src/org/openqa/selenium/grid/sessionqueue/local/LocalNewSessionQueue.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.openqa.selenium.Capabilities;
88
import org.openqa.selenium.SessionNotCreatedException;
99
import org.openqa.selenium.concurrent.GuardedRunnable;
10-
import org.openqa.selenium.events.EventBus;
1110
import org.openqa.selenium.grid.config.Config;
1211
import org.openqa.selenium.grid.data.CreateSessionResponse;
1312
import org.openqa.selenium.grid.data.RequestId;
@@ -22,7 +21,6 @@
2221
import org.openqa.selenium.grid.log.LoggingOptions;
2322
import org.openqa.selenium.grid.security.Secret;
2423
import org.openqa.selenium.grid.security.SecretOptions;
25-
import org.openqa.selenium.grid.server.EventBusOptions;
2624
import org.openqa.selenium.grid.sessionqueue.NewSessionQueue;
2725
import org.openqa.selenium.grid.sessionqueue.config.NewSessionQueueOptions;
2826
import org.openqa.selenium.internal.Either;
@@ -97,15 +95,13 @@ public class LocalNewSessionQueue extends NewSessionQueue implements Closeable {
9795

9896
public LocalNewSessionQueue(
9997
Tracer tracer,
100-
EventBus bus,
10198
SlotMatcher slotMatcher,
10299
Duration retryPeriod,
103100
Duration requestTimeout,
104101
Secret registrationSecret) {
105102
super(tracer, registrationSecret);
106103

107104
this.slotMatcher = Require.nonNull("Slot matcher", slotMatcher);
108-
Require.nonNull("Event bus", bus);
109105
Require.nonNegative("Retry period", retryPeriod);
110106

111107
this.requestTimeout = Require.positive("Request timeout", requestTimeout);
@@ -129,14 +125,12 @@ public static NewSessionQueue create(Config config) {
129125
LoggingOptions loggingOptions = new LoggingOptions(config);
130126
Tracer tracer = loggingOptions.getTracer();
131127

132-
EventBusOptions eventBusOptions = new EventBusOptions(config);
133128
NewSessionQueueOptions newSessionQueueOptions = new NewSessionQueueOptions(config);
134129
SecretOptions secretOptions = new SecretOptions(config);
135130
SlotMatcher slotMatcher = new DistributorOptions(config).getSlotMatcher();
136131

137132
return new LocalNewSessionQueue(
138133
tracer,
139-
eventBusOptions.getEventBus(),
140134
slotMatcher,
141135
newSessionQueueOptions.getSessionRequestRetryInterval(),
142136
newSessionQueueOptions.getSessionRequestTimeout(),

java/test/org/openqa/selenium/grid/distributor/AddingNodesTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
package org.openqa.selenium.grid.distributor;
1919

20-
import static com.google.common.collect.Iterables.getOnlyElement;
21-
import static org.junit.Assert.assertEquals;
22-
import static org.openqa.selenium.grid.data.Availability.UP;
23-
import static org.openqa.selenium.remote.Dialect.W3C;
24-
2520
import com.google.common.collect.ImmutableMap;
2621
import com.google.common.collect.ImmutableSet;
2722

@@ -80,6 +75,11 @@
8075
import java.util.UUID;
8176
import java.util.function.Function;
8277

78+
import static com.google.common.collect.Iterables.getOnlyElement;
79+
import static org.junit.Assert.assertEquals;
80+
import static org.openqa.selenium.grid.data.Availability.UP;
81+
import static org.openqa.selenium.remote.Dialect.W3C;
82+
8383
public class AddingNodesTest {
8484

8585
private static final Capabilities CAPS = new ImmutableCapabilities("cheese", "gouda");
@@ -106,7 +106,6 @@ public void setUpDistributor() throws MalformedURLException {
106106
sessions = new LocalSessionMap(tracer, bus);
107107
queue = new LocalNewSessionQueue(
108108
tracer,
109-
bus,
110109
new DefaultSlotMatcher(),
111110
Duration.ofSeconds(2),
112111
Duration.ofSeconds(2),

java/test/org/openqa/selenium/grid/distributor/DistributorTest.java

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ public void setUp() throws URISyntaxException {
133133
sessions = new LocalSessionMap(tracer, bus);
134134
queue = new LocalNewSessionQueue(
135135
tracer,
136-
bus,
137136
new DefaultSlotMatcher(),
138137
Duration.ofSeconds(2),
139138
Duration.ofSeconds(2),
@@ -203,7 +202,6 @@ public void shouldBeAbleToAddANodeAndCreateASession() {
203202
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
204203
NewSessionQueue queue = new LocalNewSessionQueue(
205204
tracer,
206-
bus,
207205
new DefaultSlotMatcher(),
208206
Duration.ofSeconds(2),
209207
Duration.ofSeconds(2),
@@ -244,7 +242,6 @@ public void creatingASessionAddsItToTheSessionMap() {
244242
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
245243
NewSessionQueue queue = new LocalNewSessionQueue(
246244
tracer,
247-
bus,
248245
new DefaultSlotMatcher(),
249246
Duration.ofSeconds(2),
250247
Duration.ofSeconds(2),
@@ -287,7 +284,6 @@ public void shouldBeAbleToRemoveANode() throws MalformedURLException {
287284
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
288285
NewSessionQueue queue = new LocalNewSessionQueue(
289286
tracer,
290-
bus,
291287
new DefaultSlotMatcher(),
292288
Duration.ofSeconds(2),
293289
Duration.ofSeconds(2),
@@ -328,7 +324,6 @@ public void testDrainingNodeDoesNotAcceptNewSessions() {
328324
SessionMap sessions = new LocalSessionMap(tracer, bus);
329325
NewSessionQueue queue = new LocalNewSessionQueue(
330326
tracer,
331-
bus,
332327
new DefaultSlotMatcher(),
333328
Duration.ofSeconds(2),
334329
Duration.ofSeconds(2),
@@ -364,7 +359,6 @@ public void testDrainedNodeShutsDownOnceEmpty() throws InterruptedException {
364359
SessionMap sessions = new LocalSessionMap(tracer, bus);
365360
NewSessionQueue queue = new LocalNewSessionQueue(
366361
tracer,
367-
bus,
368362
new DefaultSlotMatcher(),
369363
Duration.ofSeconds(2),
370364
Duration.ofSeconds(2),
@@ -410,7 +404,6 @@ public void drainedNodeDoesNotShutDownIfNotEmpty() throws InterruptedException {
410404
SessionMap sessions = new LocalSessionMap(tracer, bus);
411405
NewSessionQueue queue = new LocalNewSessionQueue(
412406
tracer,
413-
bus,
414407
new DefaultSlotMatcher(),
415408
Duration.ofSeconds(2),
416409
Duration.ofSeconds(2),
@@ -456,7 +449,6 @@ public void drainedNodeShutsDownAfterSessionsFinish() throws InterruptedExceptio
456449
SessionMap sessions = new LocalSessionMap(tracer, bus);
457450
NewSessionQueue queue = new LocalNewSessionQueue(
458451
tracer,
459-
bus,
460452
new DefaultSlotMatcher(),
461453
Duration.ofSeconds(2),
462454
Duration.ofSeconds(2),
@@ -545,7 +537,6 @@ public void theMostLightlyLoadedNodeIsSelectedFirst() {
545537
SessionMap sessions = new LocalSessionMap(tracer, bus);
546538
NewSessionQueue queue = new LocalNewSessionQueue(
547539
tracer,
548-
bus,
549540
new DefaultSlotMatcher(),
550541
Duration.ofSeconds(2),
551542
Duration.ofSeconds(2),
@@ -594,7 +585,6 @@ public void shouldUseLastSessionCreatedTimeAsTieBreaker() {
594585
SessionMap sessions = new LocalSessionMap(tracer, bus);
595586
NewSessionQueue queue = new LocalNewSessionQueue(
596587
tracer,
597-
bus,
598588
new DefaultSlotMatcher(),
599589
Duration.ofSeconds(2),
600590
Duration.ofSeconds(2),
@@ -673,7 +663,6 @@ public void shouldIncludeHostsThatAreUpInHostList() {
673663
SessionMap sessions = new LocalSessionMap(tracer, bus);
674664
NewSessionQueue queue = new LocalNewSessionQueue(
675665
tracer,
676-
bus,
677666
new DefaultSlotMatcher(),
678667
Duration.ofSeconds(2),
679668
Duration.ofSeconds(2),
@@ -731,7 +720,6 @@ public void shouldNotScheduleAJobIfAllSlotsAreBeingUsed() {
731720
SessionMap sessions = new LocalSessionMap(tracer, bus);
732721
NewSessionQueue queue = new LocalNewSessionQueue(
733722
tracer,
734-
bus,
735723
new DefaultSlotMatcher(),
736724
Duration.ofSeconds(2),
737725
Duration.ofSeconds(2),
@@ -771,7 +759,6 @@ public void shouldReleaseSlotOnceSessionEnds() {
771759
SessionMap sessions = new LocalSessionMap(tracer, bus);
772760
NewSessionQueue queue = new LocalNewSessionQueue(
773761
tracer,
774-
bus,
775762
new DefaultSlotMatcher(),
776763
Duration.ofSeconds(2),
777764
Duration.ofSeconds(2),
@@ -831,7 +818,6 @@ public void shouldNotStartASessionIfTheCapabilitiesAreNotSupported() {
831818
LocalSessionMap sessions = new LocalSessionMap(tracer, bus);
832819
NewSessionQueue queue = new LocalNewSessionQueue(
833820
tracer,
834-
bus,
835821
new DefaultSlotMatcher(),
836822
Duration.ofSeconds(2),
837823
Duration.ofSeconds(2),
@@ -867,7 +853,6 @@ public void attemptingToStartASessionWhichFailsMarksAsTheSlotAsAvailable() {
867853
SessionMap sessions = new LocalSessionMap(tracer, bus);
868854
NewSessionQueue queue = new LocalNewSessionQueue(
869855
tracer,
870-
bus,
871856
new DefaultSlotMatcher(),
872857
Duration.ofSeconds(2),
873858
Duration.ofSeconds(2),
@@ -909,7 +894,6 @@ public void shouldReturnNodesThatWereDownToPoolOfNodesOnceTheyMarkTheirHealthChe
909894
AtomicReference<Availability> isUp = new AtomicReference<>(DOWN);
910895
NewSessionQueue queue = new LocalNewSessionQueue(
911896
tracer,
912-
bus,
913897
new DefaultSlotMatcher(),
914898
Duration.ofSeconds(2),
915899
Duration.ofSeconds(2),
@@ -967,7 +951,6 @@ public void shouldNotRemoveNodeWhoseHealthCheckPassesBeforeThreshold()
967951
handler.addHandler(sessions);
968952
NewSessionQueue queue = new LocalNewSessionQueue(
969953
tracer,
970-
bus,
971954
new DefaultSlotMatcher(),
972955
Duration.ofSeconds(2),
973956
Duration.ofSeconds(2),
@@ -1044,7 +1027,6 @@ public void shouldPrioritizeHostsWithTheMostSlotsAvailableForASessionType() {
10441027

10451028
NewSessionQueue queue = new LocalNewSessionQueue(
10461029
tracer,
1047-
bus,
10481030
new DefaultSlotMatcher(),
10491031
Duration.ofSeconds(2),
10501032
Duration.ofSeconds(2),

java/test/org/openqa/selenium/grid/distributor/local/LocalDistributorTest.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,6 @@
1717

1818
package org.openqa.selenium.grid.distributor.local;
1919

20-
import static java.util.Collections.newSetFromMap;
21-
import static org.assertj.core.api.Assertions.assertThat;
22-
import static org.assertj.core.api.Assertions.fail;
23-
import static org.openqa.selenium.grid.data.Availability.DRAINING;
24-
import static org.openqa.selenium.grid.data.Availability.UP;
25-
import static org.openqa.selenium.remote.Dialect.W3C;
26-
import static org.openqa.selenium.remote.http.HttpMethod.GET;
27-
2820
import org.junit.Before;
2921
import org.junit.Test;
3022
import org.openqa.selenium.Capabilities;
@@ -80,6 +72,14 @@
8072
import java.util.concurrent.Future;
8173
import java.util.concurrent.TimeUnit;
8274

75+
import static java.util.Collections.newSetFromMap;
76+
import static org.assertj.core.api.Assertions.assertThat;
77+
import static org.assertj.core.api.Assertions.fail;
78+
import static org.openqa.selenium.grid.data.Availability.DRAINING;
79+
import static org.openqa.selenium.grid.data.Availability.UP;
80+
import static org.openqa.selenium.remote.Dialect.W3C;
81+
import static org.openqa.selenium.remote.http.HttpMethod.GET;
82+
8383
public class LocalDistributorTest {
8484

8585
private final Secret registrationSecret = new Secret("bavarian smoked");
@@ -109,7 +109,6 @@ public void setUp() throws URISyntaxException {
109109
public void testAddNodeToDistributor() {
110110
NewSessionQueue queue = new LocalNewSessionQueue(
111111
tracer,
112-
bus,
113112
new DefaultSlotMatcher(),
114113
Duration.ofSeconds(2),
115114
Duration.ofSeconds(2),
@@ -142,7 +141,6 @@ public void testAddNodeToDistributor() {
142141
public void testRemoveNodeFromDistributor() {
143142
NewSessionQueue queue = new LocalNewSessionQueue(
144143
tracer,
145-
bus,
146144
new DefaultSlotMatcher(),
147145
Duration.ofSeconds(2),
148146
Duration.ofSeconds(2),
@@ -176,7 +174,6 @@ public void testRemoveNodeFromDistributor() {
176174
public void testAddSameNodeTwice() {
177175
NewSessionQueue queue = new LocalNewSessionQueue(
178176
tracer,
179-
bus,
180177
new DefaultSlotMatcher(),
181178
Duration.ofSeconds(2),
182179
Duration.ofSeconds(2),
@@ -205,7 +202,6 @@ public void testAddSameNodeTwice() {
205202
public void shouldBeAbleToAddMultipleSessionsConcurrently() throws Exception {
206203
NewSessionQueue queue = new LocalNewSessionQueue(
207204
tracer,
208-
bus,
209205
new DefaultSlotMatcher(),
210206
Duration.ofSeconds(2),
211207
Duration.ofSeconds(2),
@@ -294,7 +290,6 @@ public HttpResponse execute(HttpRequest req) {
294290
public void testDrainNodeFromDistributor() {
295291
NewSessionQueue queue = new LocalNewSessionQueue(
296292
tracer,
297-
bus,
298293
new DefaultSlotMatcher(),
299294
Duration.ofSeconds(2),
300295
Duration.ofSeconds(2),
@@ -335,7 +330,6 @@ public void testDrainNodeFromNode() {
335330

336331
NewSessionQueue queue = new LocalNewSessionQueue(
337332
tracer,
338-
bus,
339333
new DefaultSlotMatcher(),
340334
Duration.ofSeconds(2),
341335
Duration.ofSeconds(2),
@@ -361,7 +355,6 @@ public void testDrainNodeFromNode() {
361355
public void slowStartingNodesShouldNotCauseReservationsToBeSerialized() {
362356
NewSessionQueue queue = new LocalNewSessionQueue(
363357
tracer,
364-
bus,
365358
new DefaultSlotMatcher(),
366359
Duration.ofSeconds(2),
367360
Duration.ofSeconds(2),

0 commit comments

Comments
 (0)