Skip to content

Commit

Permalink
PBM-1417. Allow multi-DB backup (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
sandraromanchenko authored Nov 7, 2024
1 parent f516d86 commit 500e019
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion pbm-functional/pytest/test_replicaset.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,17 @@ def test_logical(start_cluster,cluster):
cluster.check_pbm_status()
pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents)
pymongo.MongoClient(cluster.connection)["test"]["test1"].insert_many(documents)
backup_partial=cluster.make_backup("logical --ns=test.test")
pymongo.MongoClient(cluster.connection)["test2"]["test21"].insert_many(documents)
pymongo.MongoClient(cluster.connection)["test2"]["test22"].insert_many(documents)
backup_partial=cluster.make_backup("logical --ns=test.test,test2.*")
backup_full=cluster.make_backup("logical")
pymongo.MongoClient(cluster.connection).drop_database('test')
pymongo.MongoClient(cluster.connection).drop_database('test2')
cluster.make_restore(backup_partial,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test"]["test1"].count_documents({}) == 0
assert pymongo.MongoClient(cluster.connection)["test2"]["test21"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test2"]["test22"].count_documents({}) == len(documents)
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(backup_full,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents)
Expand Down
16 changes: 11 additions & 5 deletions pbm-functional/pytest/test_sharded.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ def start_cluster(cluster,request):
cluster.setup_pbm()
client=pymongo.MongoClient(cluster.connection)
client.admin.command("enableSharding", "test")
client.admin.command("enableSharding", "test2")
client.admin.command("shardCollection", "test.test", key={"_id": "hashed"})
client.admin.command("shardCollection", "test.test2", key={"_id": "hashed"})
client.admin.command("shardCollection", "test.test3", key={"_id": "hashed"})
client.admin.command("shardCollection", "test2.test21", key={"_id": "hashed"})
yield True

finally:
Expand All @@ -55,16 +57,20 @@ def test_logical_PBM_T218(start_cluster,cluster):
cluster.check_pbm_status()
pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents)
pymongo.MongoClient(cluster.connection)["test"]["test1"].insert_many(documents)
backup_partial_sharded=cluster.make_backup("logical --ns=test.test")
backup_partial_unsharded=cluster.make_backup("logical --ns=test.test1")
pymongo.MongoClient(cluster.connection)["test2"]["test21"].insert_many(documents)
pymongo.MongoClient(cluster.connection)["test2"]["test22"].insert_many(documents)
backup_partial=cluster.make_backup("logical --ns=test.test,test2.*")
backup_full=cluster.make_backup("logical")
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(backup_partial_sharded,check_pbm_status=True)
cluster.make_restore(backup_partial,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False)
cluster.make_restore(backup_partial_unsharded,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test1"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test"]["test1"].count_documents({}) == 0
assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test1").get("sharded", True) is False
assert pymongo.MongoClient(cluster.connection)["test2"]["test21"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test2"].command("collstats", "test21").get("sharded", False)
assert pymongo.MongoClient(cluster.connection)["test2"]["test22"].count_documents({}) == len(documents)
assert pymongo.MongoClient(cluster.connection)["test2"].command("collstats", "test22").get("sharded", True) is False
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(backup_full,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test1"].count_documents({}) == len(documents)
Expand Down

0 comments on commit 500e019

Please sign in to comment.