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-815: physical restore + logical PITR #844

Merged
merged 23 commits into from
Jul 5, 2023

PBM-815: fix dist txn for logical

6503468
Select commit
Loading
Failed to load commit list.
Sign in for the full log view
Merged

PBM-815: physical restore + logical PITR #844

PBM-815: fix dist txn for logical
6503468
Select commit
Loading
Failed to load commit list.
GitHub Actions / JUnit Test Report failed Jul 4, 2023 in 0s

14 tests run, 13 passed, 0 skipped, 1 failed.

Annotations

Check failure on line 110 in psmdb-testing/pbm-functional/pytest/test_PBM-773.py

See this annotation in the file changed.

@github-actions github-actions / JUnit Test Report

test_PBM-773.test_logical

AssertionError: assert 12 == 4
 +  where 12 = <bound method Collection.count_documents of Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test')>({})
 +    where <bound method Collection.count_documents of Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test')> = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
 +  and   4 = len([{'_id': ObjectId('64a44bc6adba7a1fc9d51cb1'), 'a': 1}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb2'), 'b': 2}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb3'), 'c': 3}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb4'), 'd': 4}])
Raw output
start_cluster = True, cluster = <cluster.Cluster object at 0x7ff04d072e50>

    @pytest.mark.testcase(test_case_key="T221", test_step_key=1)
    @pytest.mark.timeout(300,func_only=True)
    def test_logical(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:]
        with open(file, "wb") as f:
            f.truncate()
        with open(file, "ab") as f:
            for doc in docs:
                f.write(bson.encode(doc))
        cluster.make_restore(backup,check_pbm_status=True)
>       assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents)
E       AssertionError: assert 12 == 4
E        +  where 12 = <bound method Collection.count_documents of Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test')>({})
E        +    where <bound method Collection.count_documents of Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test')> = Collection(Database(MongoClient(host=['mongos:27017'], document_class=dict, tz_aware=False, connect=True), 'test'), 'test').count_documents
E        +  and   4 = len([{'_id': ObjectId('64a44bc6adba7a1fc9d51cb1'), 'a': 1}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb2'), 'b': 2}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb3'), 'c': 3}, {'_id': ObjectId('64a44bc6adba7a1fc9d51cb4'), 'd': 4}])

test_PBM-773.py:110: AssertionError