PBM. Change selective test for config shards #207
53 tests run, 48 passed, 0 skipped, 5 failed.
Annotations
Check failure on line 199 in pbm-functional/pytest/test_PBM-1355.py
github-actions / JUnit Test Report
test_PBM-1355.test_logical_selective_PBM_T259[full-pitr-sharded]
AssertionError: assert 899 == 1200
+ where 899 = count_documents({})
+ where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
Raw output
start_cluster = True, cluster = <cluster.Cluster object at 0x7f34c4969310>
backup_type = 'full', restore_type = 'pitr', coll_type = 'sharded'
@pytest.mark.timeout(900,func_only=True)
@pytest.mark.parametrize('coll_type',['sharded','unsharded'])
@pytest.mark.parametrize('restore_type',['base','pitr'])
@pytest.mark.parametrize('backup_type',['full','part'])
def test_logical_selective_PBM_T259(start_cluster,cluster,backup_type,restore_type,coll_type):
cluster.check_pbm_status()
client=pymongo.MongoClient(cluster.connection)
for i in range(600):
client['test']['test'].insert_one({"doc":i})
client['test']['test1'].insert_one({"doc":i})
if coll_type == 'sharded':
collection = 'test'
empty_collection = 'test1'
else:
collection = 'test1'
empty_collection = 'test'
backup = cluster.make_backup("logical")
if backup_type == 'part':
backup = cluster.make_backup("logical --ns=test." + collection)
restore = backup
else:
restore = backup + ' --ns=test.' + collection
if restore_type == 'base':
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(restore,restart_cluster=False,check_pbm_status=True,make_resync=False)
assert pymongo.MongoClient(cluster.connection)["test"][collection].count_documents({}) == 600
assert pymongo.MongoClient(cluster.connection)["test"][empty_collection].count_documents({}) == 0
else:
cluster.enable_pitr(pitr_extra_args="--set pitr.oplogSpanMin=0.5")
for i in range(600):
client['test']['test'].insert_one({"doc":i})
client['test']['test1'].insert_one({"doc":i})
time.sleep(0.1)
time.sleep(10)
pitr = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")
Cluster.log("Time for PITR is: " + pitr)
cluster.disable_pitr(pitr)
restore = " --base-snapshot=" + restore + " --time=" + pitr
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(restore,restart_cluster=False,check_pbm_status=True,make_resync=False)
> assert pymongo.MongoClient(cluster.connection)["test"][collection].count_documents({}) == 1200
E AssertionError: assert 899 == 1200
E + where 899 = count_documents({})
E + where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
test_PBM-1355.py:199: AssertionError
Check failure on line 184 in pbm-functional/pytest/test_PBM-1355.py
github-actions / JUnit Test Report
test_PBM-1355.test_logical_selective_PBM_T259[part-base-sharded]
AssertionError: assert 289 == 600
+ where 289 = count_documents({})
+ where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
Raw output
start_cluster = True, cluster = <cluster.Cluster object at 0x7f34c4969310>
backup_type = 'part', restore_type = 'base', coll_type = 'sharded'
@pytest.mark.timeout(900,func_only=True)
@pytest.mark.parametrize('coll_type',['sharded','unsharded'])
@pytest.mark.parametrize('restore_type',['base','pitr'])
@pytest.mark.parametrize('backup_type',['full','part'])
def test_logical_selective_PBM_T259(start_cluster,cluster,backup_type,restore_type,coll_type):
cluster.check_pbm_status()
client=pymongo.MongoClient(cluster.connection)
for i in range(600):
client['test']['test'].insert_one({"doc":i})
client['test']['test1'].insert_one({"doc":i})
if coll_type == 'sharded':
collection = 'test'
empty_collection = 'test1'
else:
collection = 'test1'
empty_collection = 'test'
backup = cluster.make_backup("logical")
if backup_type == 'part':
backup = cluster.make_backup("logical --ns=test." + collection)
restore = backup
else:
restore = backup + ' --ns=test.' + collection
if restore_type == 'base':
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(restore,restart_cluster=False,check_pbm_status=True,make_resync=False)
> assert pymongo.MongoClient(cluster.connection)["test"][collection].count_documents({}) == 600
E AssertionError: assert 289 == 600
E + where 289 = count_documents({})
E + where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
test_PBM-1355.py:184: AssertionError
Check failure on line 199 in pbm-functional/pytest/test_PBM-1355.py
github-actions / JUnit Test Report
test_PBM-1355.test_logical_selective_PBM_T259[part-pitr-sharded]
AssertionError: assert 606 == 1200
+ where 606 = count_documents({})
+ where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
Raw output
start_cluster = True, cluster = <cluster.Cluster object at 0x7f34c4969310>
backup_type = 'part', restore_type = 'pitr', coll_type = 'sharded'
@pytest.mark.timeout(900,func_only=True)
@pytest.mark.parametrize('coll_type',['sharded','unsharded'])
@pytest.mark.parametrize('restore_type',['base','pitr'])
@pytest.mark.parametrize('backup_type',['full','part'])
def test_logical_selective_PBM_T259(start_cluster,cluster,backup_type,restore_type,coll_type):
cluster.check_pbm_status()
client=pymongo.MongoClient(cluster.connection)
for i in range(600):
client['test']['test'].insert_one({"doc":i})
client['test']['test1'].insert_one({"doc":i})
if coll_type == 'sharded':
collection = 'test'
empty_collection = 'test1'
else:
collection = 'test1'
empty_collection = 'test'
backup = cluster.make_backup("logical")
if backup_type == 'part':
backup = cluster.make_backup("logical --ns=test." + collection)
restore = backup
else:
restore = backup + ' --ns=test.' + collection
if restore_type == 'base':
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(restore,restart_cluster=False,check_pbm_status=True,make_resync=False)
assert pymongo.MongoClient(cluster.connection)["test"][collection].count_documents({}) == 600
assert pymongo.MongoClient(cluster.connection)["test"][empty_collection].count_documents({}) == 0
else:
cluster.enable_pitr(pitr_extra_args="--set pitr.oplogSpanMin=0.5")
for i in range(600):
client['test']['test'].insert_one({"doc":i})
client['test']['test1'].insert_one({"doc":i})
time.sleep(0.1)
time.sleep(10)
pitr = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")
Cluster.log("Time for PITR is: " + pitr)
cluster.disable_pitr(pitr)
restore = " --base-snapshot=" + restore + " --time=" + pitr
pymongo.MongoClient(cluster.connection).drop_database('test')
cluster.make_restore(restore,restart_cluster=False,check_pbm_status=True,make_resync=False)
> assert pymongo.MongoClient(cluster.connection)["test"][collection].count_documents({}) == 1200
E AssertionError: assert 606 == 1200
E + where 606 = count_documents({})
E + where count_documents = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
test_PBM-1355.py:199: AssertionError
Check failure on line 102 in pbm-functional/pytest/test_PBM-773.py
github-actions / JUnit Test Report
test_PBM-773.test_logical_PBM_T221
UnboundLocalError: cannot access local variable 'index' where it is not associated with a value
Raw output
start_cluster = True, cluster = <cluster.Cluster object at 0x7f34c4a6bbd0>
@pytest.mark.timeout(300,func_only=True)
def test_logical_PBM_T221(start_cluster,cluster):
cluster.check_pbm_status()
cluster.make_backup("logical")
cluster.enable_pitr()
client = pymongo.MongoClient(cluster.connection)
db = client.test
collection = db.test
collection.insert_many(documents)
time.sleep(10)
with client.start_session() as session:
with session.start_transaction():
collection.insert_one({"e": 5}, session=session)
collection.insert_one({"f": 6}, session=session)
collection.insert_one({"g": 7}, session=session)
collection.insert_one({"h": 8}, session=session)
collection.insert_one({"i": 9}, session=session)
collection.insert_one({"j": 10}, session=session)
collection.insert_one({"k": 11}, session=session)
collection.insert_one({"l": 12}, session=session)
session.commit_transaction()
time.sleep(10)
pitr = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")
backup="--time=" + pitr
Cluster.log("Time for PITR is: " + pitr)
time.sleep(10)
cluster.disable_pitr()
cluster.make_restore(backup,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents) + 8
folder="/backups/pbmPitr/rs1/" + datetime.utcnow().strftime("%Y%m%d") + "/"
for entry in os.scandir(folder):
file = entry.path
with open(file, "rb") as f:
data= f.read()
docs = bson.decode_all(data)
for doc in docs:
if "commitTransaction" in doc["o"]:
if doc["o"]["commitTransaction"] == 1:
Cluster.log("Oplog entry with commitTransaction: \n" + str(doc))
index = docs.index(doc)
Cluster.log("Index: " + str(index))
Cluster.log("Modifying oplog backup for shard rs1")
Cluster.log("Removing oplog entry with commitTransaction and all entries after it")
> del docs[index:]
E UnboundLocalError: cannot access local variable 'index' where it is not associated with a value
test_PBM-773.py:102: UnboundLocalError
Check failure on line 51 in pbm-functional/pytest/test_timeseries.py
github-actions / JUnit Test Report
test_timeseries.test_logical_PBM_T261
failed on teardown with "AssertionError: Unexpected exit code 1 for CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f34c4971610>, exit_status=1, command=b'pbm config --set pitr.enabled=false --out json', _stdout=b'{"error":"another operation in progress","operation":{"node":"rs201:27017","opid":"675ad07eb84eb92385669dcd","replset":"rs2","type":"backup"}}\n', _stderr=b'')
assert 1 == 0
+ where 1 = CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f34c4971610>, exit_status=1, command=b'pbm ...,"operation":{"node":"rs201:27017","opid":"675ad07eb84eb92385669dcd","replset":"rs2","type":"backup"}}\n', _stderr=b'').rc"
Raw output
cluster = <cluster.Cluster object at 0x7f34c4aaca50>
request = <SubRequest 'start_cluster' for <Function test_logical_PBM_T261>>
@pytest.fixture(scope="function")
def start_cluster(cluster,request):
try:
cluster.destroy()
os.chmod("/backups",0o777)
os.system("rm -rf /backups/*")
cluster.create()
cluster.setup_pbm()
client=pymongo.MongoClient(cluster.connection)
mongod_version=client.server_info()["version"]
if version.parse(mongod_version) < version.parse("6.0.0"):
pytest.skip("Unsupported version for sharded timeseries")
client.admin.command("enableSharding", "test")
client.test.create_collection('test1',timeseries={'timeField':'timestamp','metaField': 'data'})
client.test.create_collection('test2',timeseries={'timeField':'timestamp','metaField': 'data'})
client.admin.command("shardCollection", "test.test1", key={"timestamp": 1})
client.test["test2"].create_index([("data",pymongo.HASHED )])
client.admin.command("shardCollection", "test.test2", key={"data": "hashed"})
yield True
finally:
if request.config.getoption("--verbose"):
cluster.get_logs()
> cluster.destroy(cleanup_backups=True)
test_timeseries.py:51:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
cluster.py:494: in destroy
self.disable_pitr()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <cluster.Cluster object at 0x7f34c4aaca50>, time_param = None
def disable_pitr(self, time_param=None):
n = testinfra.get_host("docker://" + self.pbm_cli)
if time_param:
target_time = int(datetime.fromisoformat(time_param).timestamp())
pitr_end = 0
while pitr_end < target_time:
result = n.check_output("pbm s -s backups -o json")
backups = json.loads(result)
if 'backups' in backups and 'pitrChunks' in backups['backups'] and 'pitrChunks' in backups['backups']['pitrChunks']:
pitr_end_cur = backups['backups']['pitrChunks']['pitrChunks'][0].get('range', {}).get('end', None)
if pitr_end_cur is not None:
pitr_end = pitr_end_cur
if pitr_end < target_time:
time.sleep(1)
> result = n.check_output(
"pbm config --set pitr.enabled=false --out json")
E AssertionError: Unexpected exit code 1 for CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f34c4971610>, exit_status=1, command=b'pbm config --set pitr.enabled=false --out json', _stdout=b'{"error":"another operation in progress","operation":{"node":"rs201:27017","opid":"675ad07eb84eb92385669dcd","replset":"rs2","type":"backup"}}\n', _stderr=b'')
E assert 1 == 0
E + where 1 = CommandResult(backend=<testinfra.backend.docker.DockerBackend object at 0x7f34c4971610>, exit_status=1, command=b'pbm ...,"operation":{"node":"rs201:27017","opid":"675ad07eb84eb92385669dcd","replset":"rs2","type":"backup"}}\n', _stderr=b'').rc
cluster.py:584: AssertionError