@@ -41,37 +41,27 @@ import java.util.concurrent.TimeUnit
4141import static Fixture.getMongoClient
4242import static TestHelper.run
4343import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet
44- import static com.mongodb.ClusterFixture.isStandalone
4544import static com.mongodb.ClusterFixture.serverVersionAtLeast
4645
4746class MongoClientSessionSpecification extends FunctionalSpecification {
4847
4948 def ' should throw IllegalArgumentException if options are null' () {
5049 when :
51- Fixture . getMongoClient(). startSession(null , Stub (SingleResultCallback ))
50+ getMongoClient(). startSession(null , Stub (SingleResultCallback ))
5251
5352 then :
5453 thrown(IllegalArgumentException )
5554 }
5655
57- @IgnoreIf ({ serverVersionAtLeast(3 , 6 ) && !isStandalone() })
58- def ' should throw MongoClientException starting a session when sessions are not supported' () {
59- when :
60- startSession(ClientSessionOptions . builder(). build())
61-
62- then :
63- thrown(MongoClientException )
64- }
65-
66- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
56+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
6757 def ' should create session with correct defaults' () {
6858 when :
6959 def options = ClientSessionOptions . builder(). build()
7060 def clientSession = startSession(options)
7161
7262 then :
7363 clientSession != null
74- clientSession. getOriginator() == Fixture . getMongoClient()
64+ clientSession. getOriginator() == getMongoClient()
7565 clientSession. isCausallyConsistent()
7666 clientSession. getOptions() == ClientSessionOptions . builder()
7767 .defaultTransactionOptions(TransactionOptions . builder()
@@ -88,7 +78,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
8878 clientSession. close()
8979 }
9080
91- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
81+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
9282 def ' cluster time should advance' () {
9383 given :
9484 def firstOperationTime = new BsonTimestamp (42 , 1 )
@@ -132,7 +122,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
132122 clientSession. close()
133123 }
134124
135- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
125+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
136126 def ' operation time should advance' () {
137127 given :
138128 def firstOperationTime = new BsonTimestamp (42 , 1 )
@@ -173,7 +163,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
173163 clientSession. close()
174164 }
175165
176- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
166+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
177167 def ' methods that use the session should throw if the session is closed' () {
178168 given :
179169 def options = ClientSessionOptions . builder(). build()
@@ -202,7 +192,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
202192 clientSession. close()
203193 }
204194
205- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
195+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
206196 def ' informational methods should not throw if the session is closed' () {
207197 given :
208198 def options = ClientSessionOptions . builder(). build()
@@ -219,7 +209,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
219209 true
220210 }
221211
222- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
212+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
223213 def ' should apply causally consistent session option to client session' () {
224214 when :
225215 def clientSession = startSession(ClientSessionOptions . builder(). causallyConsistent(causallyConsistent). build())
@@ -235,7 +225,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
235225 causallyConsistent << [true , false ]
236226 }
237227
238- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
228+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
239229 def ' client session should have server session with valid identifier' () {
240230 given :
241231 def clientSession = startSession(ClientSessionOptions . builder(). build())
@@ -254,7 +244,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
254244 clientSession. close()
255245 }
256246
257- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
247+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
258248 def ' should use a default session' () {
259249 given :
260250 def commandListener = new TestCommandListener ()
@@ -273,25 +263,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
273263 client?. close()
274264 }
275265
276- @IgnoreIf ({ serverVersionAtLeast(3 , 6 ) && !isStandalone() })
277- def ' should not use a default session when sessions are not supported' () {
278- given :
279- def commandListener = new TestCommandListener ()
280- def options = Fixture . getMongoClientBuilderFromConnectionString(). addCommandListener(commandListener). build()
281- def client = AsyncMongoClients . create(options)
282-
283- when :
284- run(client. getDatabase(' admin' ). &runCommand, new BsonDocument (' ping' , new BsonInt32 (1 )))
285-
286- then :
287- def pingCommandStartedEvent = commandListener. events. get(0 )
288- ! (pingCommandStartedEvent as CommandStartedEvent ). command. containsKey(' lsid' )
289-
290- cleanup :
291- client?. close()
292- }
293-
294- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
266+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
295267 def ' should throw exception if unacknowledged write used with explicit session' () {
296268 given :
297269 def session = run(getMongoClient(). &startSession)
@@ -334,7 +306,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
334306 // This test is inherently racy as it's possible that the server _does_ replicate fast enough and therefore the test passes anyway
335307 // even if causal consistency was not actually in effect. For that reason the test iterates a number of times in order to increase
336308 // confidence that it's really causal consistency that is causing the test to succeed
337- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
309+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
338310 @Category (Slow )
339311 def ' should find inserted document on a secondary when causal consistency is enabled' () {
340312 given :
0 commit comments