@@ -41,37 +41,27 @@ import java.util.concurrent.TimeUnit
41
41
import static Fixture.getMongoClient
42
42
import static TestHelper.run
43
43
import static com.mongodb.ClusterFixture.isDiscoverableReplicaSet
44
- import static com.mongodb.ClusterFixture.isStandalone
45
44
import static com.mongodb.ClusterFixture.serverVersionAtLeast
46
45
47
46
class MongoClientSessionSpecification extends FunctionalSpecification {
48
47
49
48
def ' should throw IllegalArgumentException if options are null' () {
50
49
when :
51
- Fixture . getMongoClient(). startSession(null , Stub (SingleResultCallback ))
50
+ getMongoClient(). startSession(null , Stub (SingleResultCallback ))
52
51
53
52
then :
54
53
thrown(IllegalArgumentException )
55
54
}
56
55
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 ) })
67
57
def ' should create session with correct defaults' () {
68
58
when :
69
59
def options = ClientSessionOptions . builder(). build()
70
60
def clientSession = startSession(options)
71
61
72
62
then :
73
63
clientSession != null
74
- clientSession. getOriginator() == Fixture . getMongoClient()
64
+ clientSession. getOriginator() == getMongoClient()
75
65
clientSession. isCausallyConsistent()
76
66
clientSession. getOptions() == ClientSessionOptions . builder()
77
67
.defaultTransactionOptions(TransactionOptions . builder()
@@ -88,7 +78,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
88
78
clientSession. close()
89
79
}
90
80
91
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
81
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
92
82
def ' cluster time should advance' () {
93
83
given :
94
84
def firstOperationTime = new BsonTimestamp (42 , 1 )
@@ -132,7 +122,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
132
122
clientSession. close()
133
123
}
134
124
135
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
125
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
136
126
def ' operation time should advance' () {
137
127
given :
138
128
def firstOperationTime = new BsonTimestamp (42 , 1 )
@@ -173,7 +163,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
173
163
clientSession. close()
174
164
}
175
165
176
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
166
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
177
167
def ' methods that use the session should throw if the session is closed' () {
178
168
given :
179
169
def options = ClientSessionOptions . builder(). build()
@@ -202,7 +192,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
202
192
clientSession. close()
203
193
}
204
194
205
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
195
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
206
196
def ' informational methods should not throw if the session is closed' () {
207
197
given :
208
198
def options = ClientSessionOptions . builder(). build()
@@ -219,7 +209,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
219
209
true
220
210
}
221
211
222
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
212
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
223
213
def ' should apply causally consistent session option to client session' () {
224
214
when :
225
215
def clientSession = startSession(ClientSessionOptions . builder(). causallyConsistent(causallyConsistent). build())
@@ -235,7 +225,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
235
225
causallyConsistent << [true , false ]
236
226
}
237
227
238
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
228
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
239
229
def ' client session should have server session with valid identifier' () {
240
230
given :
241
231
def clientSession = startSession(ClientSessionOptions . builder(). build())
@@ -254,7 +244,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
254
244
clientSession. close()
255
245
}
256
246
257
- @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) || isStandalone() })
247
+ @IgnoreIf ({ !serverVersionAtLeast(3 , 6 ) })
258
248
def ' should use a default session' () {
259
249
given :
260
250
def commandListener = new TestCommandListener ()
@@ -273,25 +263,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
273
263
client?. close()
274
264
}
275
265
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 ) })
295
267
def ' should throw exception if unacknowledged write used with explicit session' () {
296
268
given :
297
269
def session = run(getMongoClient(). &startSession)
@@ -334,7 +306,7 @@ class MongoClientSessionSpecification extends FunctionalSpecification {
334
306
// This test is inherently racy as it's possible that the server _does_ replicate fast enough and therefore the test passes anyway
335
307
// even if causal consistency was not actually in effect. For that reason the test iterates a number of times in order to increase
336
308
// 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 ) })
338
310
@Category (Slow )
339
311
def ' should find inserted document on a secondary when causal consistency is enabled' () {
340
312
given :
0 commit comments