1717package com .mongodb .async .client ;
1818
1919import com .mongodb .Block ;
20- import com .mongodb .ClusterFixture ;
2120import com .mongodb .ConnectionString ;
2221import com .mongodb .MongoException ;
2322import com .mongodb .MongoNamespace ;
3029import com .mongodb .client .model .CreateCollectionOptions ;
3130import com .mongodb .client .test .CollectionHelper ;
3231import com .mongodb .connection .ServerSettings ;
33- import com .mongodb .connection .ServerVersion ;
3432import com .mongodb .connection .SocketSettings ;
3533import com .mongodb .connection .SslSettings ;
3634import com .mongodb .event .CommandEvent ;
6260import java .util .concurrent .TimeUnit ;
6361
6462import static com .mongodb .ClusterFixture .getMultiMongosConnectionString ;
65- import static com .mongodb .ClusterFixture .isDiscoverableReplicaSet ;
66- import static com .mongodb .ClusterFixture .isStandalone ;
67- import static com .mongodb .ClusterFixture .serverVersionLessThan ;
63+ import static com .mongodb .JsonTestServerVersionChecker .skipTest ;
6864import static com .mongodb .async .client .Fixture .getConnectionString ;
6965import static com .mongodb .async .client .Fixture .getDefaultDatabaseName ;
7066import static com .mongodb .async .client .Fixture .isSharded ;
@@ -87,7 +83,7 @@ public class RetryableReadsTest {
8783 private final BsonDocument gridFSData ;
8884 private final BsonArray data ;
8985 private final BsonDocument definition ;
90- private final BsonArray runOn ;
86+ private final boolean skipTest ;
9187 private JsonPoweredCrudTestHelper helper ;
9288 private final TestCommandListener commandListener ;
9389 private MongoClient mongoClient ;
@@ -100,11 +96,10 @@ public class RetryableReadsTest {
10096
10197 private static final long MIN_HEARTBEAT_FREQUENCY_MS = 50L ;
10298
103- public RetryableReadsTest (final String filename , final BsonArray runOn , final String description , final String databaseName ,
99+ public RetryableReadsTest (final String filename , final String description , final String databaseName ,
104100 final String collectionName , final BsonArray data , final BsonString bucketName ,
105- final BsonDocument definition ) {
101+ final BsonDocument definition , final boolean skipTest ) {
106102 this .filename = filename ;
107- this .runOn = runOn ;
108103 this .description = description ;
109104 this .databaseName = databaseName ;
110105 this .collectionName = collectionName ;
@@ -113,48 +108,14 @@ public RetryableReadsTest(final String filename, final BsonArray runOn, final St
113108 this .gridFSData = (bucketName != null ? (BsonDocument ) data .get (0 ) : null );
114109 this .data = (bucketName != null ? null : data );
115110 this .commandListener = new TestCommandListener ();
111+ this .skipTest = skipTest ;
116112 }
117113
118114 @ Before
119115 public void setUp () {
116+ assumeFalse (skipTest );
120117 assumeTrue ("Skipping test: " + definition .getString ("skipReason" , new BsonString ("" )).getValue (),
121118 !definition .containsKey ("skipReason" ));
122-
123- boolean topologyFound = false ;
124- for (BsonValue info : runOn ) {
125- final BsonDocument document = info .asDocument ();
126- ServerVersion serverVersion = ClusterFixture .getServerVersion ();
127-
128- if (document .containsKey ("minServerVersion" )) {
129- assumeFalse (serverVersion .compareTo (getServerVersion ("minServerVersion" , document )) < 0 );
130- }
131- if (document .containsKey ("maxServerVersion" )) {
132- assumeFalse (serverVersion .compareTo (getServerVersion ("maxServerVersion" , document )) > 0 );
133- }
134- if (document .containsKey ("topology" )) {
135- BsonArray topologyTypes = document .getArray ("topology" );
136- for (BsonValue type : topologyTypes ) {
137- String typeString = type .asString ().getValue ();
138- if (typeString .equals ("sharded" )) {
139- topologyFound = isSharded ();
140- } else if (typeString .equals ("replicaset" )) {
141- topologyFound = isDiscoverableReplicaSet ();
142- } else if (typeString .equals ("single" )) {
143- topologyFound = isStandalone ();
144- }
145- if (topologyFound ) {
146- break ;
147- }
148- }
149- if (topologyFound ) {
150- break ;
151- }
152- } else {
153- topologyFound = true ;
154- }
155- }
156- assumeTrue ("Topology for this test not found." , topologyFound );
157-
158119 collectionHelper = new CollectionHelper <Document >(new DocumentCodec (), new MongoNamespace (databaseName , collectionName ));
159120
160121 collectionHelper .killAllSessions ();
@@ -351,29 +312,19 @@ public static Collection<Object[]> data() throws URISyntaxException, IOException
351312 List <Object []> data = new ArrayList <Object []>();
352313 for (File file : JsonPoweredTestHelper .getTestFiles ("/retryable-reads" )) {
353314 BsonDocument testDocument = JsonPoweredTestHelper .getTestDocument (file );
354- if (testDocument .containsKey ("minServerVersion" )
355- && serverVersionLessThan (testDocument .getString ("minServerVersion" ).getValue ())) {
356- continue ;
357- }
358315 for (BsonValue test : testDocument .getArray ("tests" )) {
359- data .add (new Object []{file .getName (), testDocument .getArray ("runOn" ),
360- test .asDocument ().getString ("description" ).getValue (),
316+ data .add (new Object []{file .getName (), test .asDocument ().getString ("description" ).getValue (),
361317 testDocument .getString ("database_name" , new BsonString (getDefaultDatabaseName ())).getValue (),
362318 testDocument .getString ("collection_name" ,
363319 new BsonString (file .getName ().substring (0 , file .getName ().lastIndexOf ("." )))).getValue (),
364320 (testDocument .containsKey ("bucket_name" ) ? new BsonArray (singletonList (testDocument .getDocument ("data" )))
365321 : testDocument .getArray ("data" )),
366- testDocument .getString ("bucket_name" , null ), test .asDocument ()});
322+ testDocument .getString ("bucket_name" , null ), test .asDocument (), skipTest ( testDocument , test . asDocument ()) });
367323 }
368324 }
369325 return data ;
370326 }
371327
372- private ServerVersion getServerVersion (final String fieldName , final BsonDocument document ) {
373- String [] versionStringArray = document .getString (fieldName ).getValue ().split ("\\ ." );
374- return new ServerVersion (Integer .parseInt (versionStringArray [0 ]), Integer .parseInt (versionStringArray [1 ]));
375- }
376-
377328 private List <BsonDocument > processFiles (final BsonArray bsonArray , final List <BsonDocument > documents ) {
378329 for (BsonValue rawDocument : bsonArray .getValues ()) {
379330 if (rawDocument .isDocument ()) {
0 commit comments