Skip to content

PBM-1479 verify index metadata after logical restore #272

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

Merged
merged 1 commit into from
Feb 4, 2025
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
62 changes: 62 additions & 0 deletions pbm-functional/pytest/test_indexes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import pytest
import pymongo
import time
import os
import docker

from datetime import datetime
from cluster import Cluster

@pytest.fixture(scope="package")
def config():
return {"_id": "rs1", "members": [{"host":"rs101"}]}

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

@pytest.fixture(scope="function")
def start_cluster(cluster,request):
try:
cluster.destroy()
cluster.create()
cluster.setup_pbm()
yield

finally:
if request.config.getoption("--verbose"):
cluster.get_logs()
cluster.destroy(cleanup_backups=True)

def create_index_with_options(connection,option):
client = pymongo.MongoClient(connection)['test']['test']
if option == 'collation':
index = client.create_index("test_field", name="test_index", collation={"locale":"en", "strength": 2})
elif option == 'sparse':
index = client.create_index("test_field", name="test_index", sparse=True)
elif option == 'unique':
index = client.create_index("test_field", name="test_index", unique=True)
elif option == 'partialFilterExpression':
index = client.create_index("test_field", name="test_index", partialFilterExpression={"test_field":{"$exists": True}})
elif option == 'expireAfterSeconds':
index = client.create_index("test_field", name="test_index", expireAfterSeconds=3600)
elif option == 'min':
index = client.create_index([("test_field", pymongo.GEO2D)], name="test_index", min=-180)
elif option == 'max':
index = client.create_index([("test_field", pymongo.GEO2D)], name="test_index", max=180)
elif option == 'wildcardProjection':
index = client.create_index("$**", name="test_index", wildcardProjection={"_id": 1, "test_field": 0})
return index

@pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
@pytest.mark.timeout(300,func_only=True)
def test_logical_PBM_288(start_cluster,cluster,index_option):
cluster.check_pbm_status()
index = create_index_with_options(cluster.connection,index_option)
backup = cluster.make_backup("logical")
cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
assert index in indexes
assert index_option in indexes['test_index']

Check failure on line 60 in pbm-functional/pytest/test_indexes.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_indexes.test_logical_PBM_288[collation]

AssertionError: assert 'collation' in {'key': [('test_field', 1)], 'v': 2}
Raw output
start_cluster = None, cluster = <cluster.Cluster object at 0x7f5678c0b850>
index_option = 'collation'

    @pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
    @pytest.mark.timeout(300,func_only=True)
    def test_logical_PBM_288(start_cluster,cluster,index_option):
        cluster.check_pbm_status()
        index = create_index_with_options(cluster.connection,index_option)
        backup = cluster.make_backup("logical")
        cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
        indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
        assert index in indexes
>       assert index_option in indexes['test_index']
E       AssertionError: assert 'collation' in {'key': [('test_field', 1)], 'v': 2}

test_indexes.py:60: AssertionError

Check failure on line 60 in pbm-functional/pytest/test_indexes.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_indexes.test_logical_PBM_288[partialFilterExpression]

AssertionError: assert 'partialFilterExpression' in {'key': [('test_field', 1)], 'v': 2}
Raw output
start_cluster = None, cluster = <cluster.Cluster object at 0x7f5678c0b850>
index_option = 'partialFilterExpression'

    @pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
    @pytest.mark.timeout(300,func_only=True)
    def test_logical_PBM_288(start_cluster,cluster,index_option):
        cluster.check_pbm_status()
        index = create_index_with_options(cluster.connection,index_option)
        backup = cluster.make_backup("logical")
        cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
        indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
        assert index in indexes
>       assert index_option in indexes['test_index']
E       AssertionError: assert 'partialFilterExpression' in {'key': [('test_field', 1)], 'v': 2}

test_indexes.py:60: AssertionError

Check failure on line 60 in pbm-functional/pytest/test_indexes.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_indexes.test_logical_PBM_288[min]

AssertionError: assert 'min' in {'key': [('test_field', '2d')], 'v': 2}
Raw output
start_cluster = None, cluster = <cluster.Cluster object at 0x7f5678c0b850>
index_option = 'min'

    @pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
    @pytest.mark.timeout(300,func_only=True)
    def test_logical_PBM_288(start_cluster,cluster,index_option):
        cluster.check_pbm_status()
        index = create_index_with_options(cluster.connection,index_option)
        backup = cluster.make_backup("logical")
        cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
        indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
        assert index in indexes
>       assert index_option in indexes['test_index']
E       AssertionError: assert 'min' in {'key': [('test_field', '2d')], 'v': 2}

test_indexes.py:60: AssertionError

Check failure on line 60 in pbm-functional/pytest/test_indexes.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_indexes.test_logical_PBM_288[max]

AssertionError: assert 'max' in {'key': [('test_field', '2d')], 'v': 2}
Raw output
start_cluster = None, cluster = <cluster.Cluster object at 0x7f5678c0b850>
index_option = 'max'

    @pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
    @pytest.mark.timeout(300,func_only=True)
    def test_logical_PBM_288(start_cluster,cluster,index_option):
        cluster.check_pbm_status()
        index = create_index_with_options(cluster.connection,index_option)
        backup = cluster.make_backup("logical")
        cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
        indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
        assert index in indexes
>       assert index_option in indexes['test_index']
E       AssertionError: assert 'max' in {'key': [('test_field', '2d')], 'v': 2}

test_indexes.py:60: AssertionError

Check failure on line 60 in pbm-functional/pytest/test_indexes.py

View workflow job for this annotation

GitHub Actions / JUnit Test Report

test_indexes.test_logical_PBM_288[wildcardProjection]

AssertionError: assert 'wildcardProjection' in {'key': [('$**', 1)], 'v': 2}
Raw output
start_cluster = None, cluster = <cluster.Cluster object at 0x7f5678c0b850>
index_option = 'wildcardProjection'

    @pytest.mark.parametrize("index_option", ["collation","sparse","unique","partialFilterExpression","expireAfterSeconds","min","max","wildcardProjection"])
    @pytest.mark.timeout(300,func_only=True)
    def test_logical_PBM_288(start_cluster,cluster,index_option):
        cluster.check_pbm_status()
        index = create_index_with_options(cluster.connection,index_option)
        backup = cluster.make_backup("logical")
        cluster.make_restore(backup,make_resync=False,check_pbm_status=False)
        indexes = pymongo.MongoClient(cluster.connection)['test']['test'].index_information()
        assert index in indexes
>       assert index_option in indexes['test_index']
E       AssertionError: assert 'wildcardProjection' in {'key': [('$**', 1)], 'v': 2}

test_indexes.py:60: AssertionError
Cluster.log("Finished successfully")

Loading