Skip to content

Commit 2e44072

Browse files
committed
Update spec test; fix test runner
1 parent 339297b commit 2e44072

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

driver-core/src/test/unit/com/mongodb/internal/connection/DefaultServerSpecification.groovy

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,12 @@ class DefaultServerSpecification extends Specification {
234234
]
235235
}
236236

237-
def 'failed open should invalidate the server'() {
237+
def 'network error should not invalidate the pool'() {
238238
given:
239239
def connectionPool = Mock(ConnectionPool)
240-
connectionPool.get(_) >> { throw exceptionToThrow }
240+
connectionPool.get(_) >> {
241+
throw exceptionToThrow
242+
}
241243
def serverMonitor = Mock(ServerMonitor)
242244
def server = defaultServer(connectionPool, serverMonitor)
243245

@@ -247,8 +249,8 @@ class DefaultServerSpecification extends Specification {
247249
then:
248250
def e = thrown(MongoException)
249251
e.is(exceptionToThrow)
250-
1 * connectionPool.invalidate(exceptionToThrow)
251-
1 * serverMonitor.cancelCurrentCheck()
252+
0 * connectionPool.invalidate(_)
253+
0 * serverMonitor.cancelCurrentCheck()
252254

253255
where:
254256
exceptionToThrow << [
@@ -281,7 +283,7 @@ class DefaultServerSpecification extends Specification {
281283
]
282284
}
283285

284-
def 'failed open should invalidate the server asynchronously'() {
286+
def 'failed open should not invalidate the pool asynchronously'() {
285287
given:
286288
def connectionPool = Mock(ConnectionPool)
287289
connectionPool.getAsync(_, _) >> { it.last().onResult(null, exceptionToThrow) }
@@ -301,8 +303,8 @@ class DefaultServerSpecification extends Specification {
301303
then:
302304
!receivedConnection
303305
receivedThrowable.is(exceptionToThrow)
304-
1 * connectionPool.invalidate(exceptionToThrow)
305-
1 * serverMonitor.cancelCurrentCheck()
306+
0 * connectionPool.invalidate(exceptionToThrow)
307+
0 * serverMonitor.cancelCurrentCheck()
306308

307309

308310
where:

driver-sync/src/test/functional/com/mongodb/client/unified/EventMatcher.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,9 +436,16 @@ private static boolean serverDescriptionChangedEventMatches(final BsonDocument e
436436
switch (newType) {
437437
case "Unknown":
438438
return event.getNewDescription().getType() == ServerType.UNKNOWN;
439-
case "LoadBalancer": {
439+
case "LoadBalancer":
440440
return event.getNewDescription().getType() == ServerType.LOAD_BALANCER;
441-
}
441+
case "Mongos":
442+
return event.getNewDescription().getType() == ServerType.SHARD_ROUTER;
443+
case "Standalone":
444+
return event.getNewDescription().getType() == ServerType.STANDALONE;
445+
case "RSPrimary":
446+
return event.getNewDescription().getType() == ServerType.REPLICA_SET_PRIMARY;
447+
case "RSSecondary":
448+
return event.getNewDescription().getType() == ServerType.REPLICA_SET_SECONDARY;
442449
default:
443450
throw new UnsupportedOperationException();
444451
}

0 commit comments

Comments
 (0)