spec/support/mongos_macros.rb in mongo-2.18.3 vs spec/support/mongos_macros.rb in mongo-2.19.0
- old
+ new
@@ -1,6 +1,7 @@
# frozen_string_literal: true
+# rubocop:todo all
module MongosMacros
class << self
attr_accessor :distinct_ran
@@ -10,8 +11,14 @@
# Work around for SERVER-39704 when seeing a Mongo::Error::OperationFailure
# SnapshotUnavailable error -- run the distinct command on each mongos.
def run_mongos_distincts(db_name, collection='test')
MongosMacros.distinct_ran[db_name] ||= ::Utils.mongos_each_direct_client do |direct_client|
direct_client.use(db_name)[collection].distinct('foo').to_a
+ end
+ end
+
+ def maybe_run_mongos_distincts(db_name, collection='test')
+ if ClusterConfig.instance.topology == :sharded
+ run_mongos_distincts(db_name, collection)
end
end
end