def validate_all_collections():
""" Connecto to mongo and run db.collection.validate() on everything """
retry_count = 0
try:
client = pymongo.MongoClient("localhost", 27017, maxPoolSize=50)
except Exception as exc:
if retry_count > 20:
raise Exception("Retries exceeded") from exc
retry_count += 1
sleep(6)
for db in (client[name] for name in
client.database_names()
if name != "local"):
for collection in db.collection_names(include_system_collections=False):
if db.validate_collection(collection, scandata=True, full=True)['errors']:
raise ValidationFailed("Collection failed to validate", collection)
评论列表
文章目录