Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PBM-1355 tests with remapping #217

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 42 additions & 2 deletions pbm-functional/pytest/test_PBM-1355.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,27 @@ def config(mongod_version):
{"_id": "rs1", "members": [{"host":"rs101"},{"host": "rs102"},{"host": "rs103" }]}
]}

@pytest.fixture(scope="package")
def newconfig():
return { "mongos": "mongos",
"configserver":
{"_id": "newrscfg", "members": [{"host":"newrscfg01"},{"host": "newrscfg02"},{"host": "newrscfg03" }]},
"shards":[
{"_id": "newrs1", "members": [{"host":"newrs101"},{"host": "newrs102"},{"host": "newrs103" }]}
]}

@pytest.fixture(scope="package")
def cluster(config):
return Cluster(config)

@pytest.fixture(scope="package")
def newcluster(newconfig):
return Cluster(newconfig)

@pytest.fixture(scope="function")
def start_cluster(cluster,request):
def start_cluster(cluster,newcluster,request):
try:
newcluster.destroy()
cluster.destroy()
os.chmod("/backups",0o777)
os.system("rm -rf /backups/*")
Expand All @@ -54,7 +68,8 @@ def start_cluster(cluster,request):
finally:
if request.config.getoption("--verbose"):
cluster.get_logs()
cluster.destroy(cleanup_backups=True)
cluster.destroy()
newcluster.destroy()

@pytest.mark.timeout(900,func_only=True)
@pytest.mark.parametrize('backup_type',['logical','physical'])
Expand Down Expand Up @@ -87,6 +102,31 @@ def test_general_PBM_T257(start_cluster,cluster,backup_type,restore_type):
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == 1200
assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False)

@pytest.mark.timeout(900,func_only=True)
@pytest.mark.parametrize('backup_type',['logical','physical'])
def test_remap_PBM_T265(start_cluster,cluster,newcluster,backup_type):
cluster.check_pbm_status()
client=pymongo.MongoClient(cluster.connection)
for i in range(600):
client['test']['test'].insert_one({"doc":i})

backup=cluster.make_backup(backup_type)
backup = backup + ' --replset-remapping="newrs1=rs1,newrscfg=rscfg"'
cluster.destroy()

newcluster.create()
client=pymongo.MongoClient(newcluster.connection)
Cluster.log(client.admin.command({'transitionFromDedicatedConfigServer': 1}))
newcluster.setup_pbm()
result = newcluster.exec_pbm_cli("config --set storage.type=filesystem --set storage.filesystem.path=/backups --set backup.compression=none")
assert result.rc == 0
newcluster.make_resync()

restart = True if backup_type == 'physical' else False
newcluster.make_restore(backup,restart_cluster=restart,check_pbm_status=True,make_resync=False)
assert pymongo.MongoClient(newcluster.connection)["test"]["test"].count_documents({}) == 600
assert pymongo.MongoClient(newcluster.connection)["test"].command("collstats", "test").get("sharded", False)

@pytest.mark.timeout(900,func_only=True)
def test_incremental_PBM_T258(start_cluster,cluster):
cluster.check_pbm_status()
Expand Down