1717
1818package org .openqa .selenium .grid .distributor ;
1919
20- import static org .assertj .core .api .Assertions .assertThat ;
21- import static org .assertj .core .api .Assertions .fail ;
22- import static org .junit .Assert .assertFalse ;
23- import static org .junit .Assert .assertTrue ;
24- import static org .openqa .selenium .grid .data .Availability .DOWN ;
25- import static org .openqa .selenium .grid .data .Availability .UP ;
26- import static org .openqa .selenium .remote .Dialect .W3C ;
27-
2820import com .google .common .collect .ImmutableMap ;
2921import com .google .common .collect .ImmutableSet ;
3022
3123import org .junit .After ;
3224import org .junit .Assert ;
3325import org .junit .Before ;
34- import org .junit .Ignore ;
3526import org .junit .Test ;
3627import org .openqa .selenium .Capabilities ;
3728import org .openqa .selenium .ImmutableCapabilities ;
10394import java .util .logging .Logger ;
10495import java .util .stream .Collectors ;
10596
97+ import static org .assertj .core .api .Assertions .assertThat ;
98+ import static org .junit .Assert .assertTrue ;
99+ import static org .openqa .selenium .grid .data .Availability .DOWN ;
100+ import static org .openqa .selenium .grid .data .Availability .UP ;
101+ import static org .openqa .selenium .remote .Dialect .W3C ;
102+
106103public class DistributorTest {
107104
108105 private static final Logger LOG = Logger .getLogger ("Distributor Test" );
@@ -581,8 +578,8 @@ public void theMostLightlyLoadedNodeIsSelectedFirst() {
581578 .add (massive );
582579
583580 wait .until (obj -> distributor .getStatus ().getNodes ().size () == 4 );
584- wait .until (ignored -> distributor .getStatus ().getNodes ().stream (). allMatch (
585- node -> node .getAvailability () == UP && node .hasCapacity ()));
581+ wait .until (ignored -> distributor .getStatus ().getNodes ().stream ()
582+ . allMatch ( node -> node .getAvailability () == UP && node .hasCapacity ()));
586583 wait .until (obj -> distributor .getStatus ().hasCapacity ());
587584
588585 Either <SessionNotCreatedException , CreateSessionResponse > result =
@@ -1125,6 +1122,7 @@ private Node createNode(Capabilities stereotype, int count, int currentLoad) {
11251122 for (int i = 0 ; i < count ; i ++) {
11261123 builder .add (stereotype , new TestSessionFactory ((id , caps ) -> new HandledSession (uri , caps )));
11271124 }
1125+ builder .maximumConcurrentSessions (12 );
11281126
11291127 LocalNode node = builder .build ();
11301128 for (int i = 0 ; i < currentLoad ; i ++) {
@@ -1147,77 +1145,6 @@ private Node createBrokenNode(Capabilities stereotype) {
11471145 .build ();
11481146 }
11491147
1150- @ Test
1151- @ Ignore
1152- public void shouldCorrectlySetSessionCountsWhenStartedAfterNodeWithSession () {
1153- fail ("write me!" );
1154- }
1155-
1156- @ Test
1157- public void statusShouldIndicateThatDistributorIsNotAvailableIfNodesAreDown ()
1158- throws URISyntaxException {
1159- Capabilities capabilities = new ImmutableCapabilities ("cheese" , "peas" );
1160- URI uri = new URI ("http://example.com" );
1161-
1162- Node node = LocalNode .builder (tracer , bus , uri , uri , registrationSecret )
1163- .add (
1164- capabilities ,
1165- new TestSessionFactory ((id , caps ) -> new Session (id , uri , stereotype , caps , Instant .now ())))
1166- .advanced ()
1167- .healthCheck (() -> new HealthCheck .Result (DOWN , "TL;DR" ))
1168- .build ();
1169-
1170- local = new LocalDistributor (
1171- tracer ,
1172- bus ,
1173- new PassthroughHttpClient .Factory (node ),
1174- sessions ,
1175- queue ,
1176- new DefaultSlotSelector (),
1177- registrationSecret ,
1178- Duration .ofMinutes (5 ),
1179- false ,
1180- Duration .ofSeconds (5 ));
1181-
1182- local .add (node );
1183-
1184- DistributorStatus status = local .getStatus ();
1185- assertFalse (status .hasCapacity ());
1186- }
1187-
1188- @ Test
1189- public void disabledNodeShouldNotAcceptNewRequests ()
1190- throws URISyntaxException
1191- {
1192- Capabilities capabilities = new ImmutableCapabilities ("cheese" , "peas" );
1193-
1194- URI uri = new URI ("http://example.com" );
1195- Node node = LocalNode .builder (tracer , bus , uri , uri , registrationSecret )
1196- .add (
1197- capabilities ,
1198- new TestSessionFactory ((id , caps ) -> new Session (id , uri , stereotype , caps , Instant .now ())))
1199- .advanced ()
1200- .healthCheck (() -> new HealthCheck .Result (DOWN , "TL;DR" ))
1201- .build ();
1202-
1203- local = new LocalDistributor (
1204- tracer ,
1205- bus ,
1206- new PassthroughHttpClient .Factory (node ),
1207- sessions ,
1208- queue ,
1209- new DefaultSlotSelector (),
1210- registrationSecret ,
1211- Duration .ofMinutes (5 ),
1212- false ,
1213- Duration .ofSeconds (5 ));
1214-
1215- local .add (node );
1216-
1217- DistributorStatus status = local .getStatus ();
1218- assertFalse (status .hasCapacity ());
1219- }
1220-
12211148 @ Test
12221149 public void shouldFallbackToSecondAvailableCapabilitiesIfFirstNotAvailable () {
12231150 CombinedHandler handler = new CombinedHandler ();
0 commit comments