@@ -23,6 +23,7 @@ import spock.lang.IgnoreIf
23
23
24
24
import static com.mongodb.ClusterFixture.serverVersionAtLeast
25
25
import static com.mongodb.async.client.Fixture.getMongoClient
26
+ import static com.mongodb.async.client.Fixture.isSharded
26
27
import static java.util.Arrays.asList
27
28
import static java.util.concurrent.TimeUnit.SECONDS
28
29
@@ -149,17 +150,6 @@ class SmokeTestSpecification extends FunctionalSpecification {
149
150
then : ' has a single index left "_id" '
150
151
run(collection. listIndexes(). &into, []). size == 1
151
152
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
-
163
153
then : ' drop the collection'
164
154
run(collection. &drop) == null
165
155
@@ -170,6 +160,26 @@ class SmokeTestSpecification extends FunctionalSpecification {
170
160
! run(database. listCollectionNames(). &into, []). contains(collectionName)
171
161
}
172
162
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
+
173
183
def run (operation , ... args ) {
174
184
def futureResultCallback = new FutureResultCallback ()
175
185
def opArgs = (args != null ) ? args : []
0 commit comments