Skip to content

Commit 4b7892c

Browse files
committed
Working around sharding issue by only testing collection rename when not connected to a sharded cluster
JAVA-1757
1 parent 7bac500 commit 4b7892c

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

driver-async/src/test/functional/com/mongodb/async/client/SmokeTestSpecification.groovy

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import spock.lang.IgnoreIf
2323

2424
import static com.mongodb.ClusterFixture.serverVersionAtLeast
2525
import static com.mongodb.async.client.Fixture.getMongoClient
26+
import static com.mongodb.async.client.Fixture.isSharded
2627
import static java.util.Arrays.asList
2728
import static java.util.concurrent.TimeUnit.SECONDS
2829

@@ -149,17 +150,6 @@ class SmokeTestSpecification extends FunctionalSpecification {
149150
then: 'has a single index left "_id" '
150151
run(collection.listIndexes().&into, []).size == 1
151152

152-
then: 'can rename the collection'
153-
def newCollectionName = 'newCollectionName'
154-
run(collection.&renameCollection, new MongoNamespace(databaseName, newCollectionName)) == null
155-
156-
then: 'the new collection name is in the collection names list'
157-
!run(database.listCollectionNames().&into, []).contains(collectionName)
158-
run(database.listCollectionNames().&into, []).contains(newCollectionName)
159-
160-
when:
161-
collection = database.getCollection(newCollectionName)
162-
163153
then: 'drop the collection'
164154
run(collection.&drop) == null
165155

@@ -170,6 +160,26 @@ class SmokeTestSpecification extends FunctionalSpecification {
170160
!run(database.listCollectionNames().&into, []).contains(collectionName)
171161
}
172162

163+
@IgnoreIf({ isSharded() }) // see JAVA-1757 for why sharded clusters are currently excluded from this test
164+
def 'should handle rename collection administrative scenario without error'() {
165+
given:
166+
def mongoClient = getMongoClient()
167+
def database = mongoClient.getDatabase(databaseName)
168+
def collection = database.getCollection(collectionName)
169+
run(mongoClient.getDatabase(databaseName).&drop) == null
170+
171+
when: 'Create a collection and the created database is in the list'
172+
run(database.&createCollection, collectionName)
173+
174+
then: 'can rename the collection'
175+
def newCollectionName = 'newCollectionName'
176+
run(collection.&renameCollection, new MongoNamespace(databaseName, newCollectionName)) == null
177+
178+
then: 'the new collection name is in the collection names list'
179+
!run(database.listCollectionNames().&into, []).contains(collectionName)
180+
run(database.listCollectionNames().&into, []).contains(newCollectionName)
181+
}
182+
173183
def run(operation, ... args) {
174184
def futureResultCallback = new FutureResultCallback()
175185
def opArgs = (args != null) ? args : []

0 commit comments

Comments
 (0)