Skip to content

Commit

Permalink
PBM-1308 STR
Browse files Browse the repository at this point in the history
  • Loading branch information
olexandr-havryliak committed May 2, 2024
1 parent 8dd0d29 commit 8217b76
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/PBM-CUSTOM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
if: success() || failure()
with:
report_paths: '**/junit.xml'

exclude_sources: '/.pytest_cache/,/__pycache__/'
2 changes: 1 addition & 1 deletion .github/workflows/PBM-FULL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ jobs:
if: success() || failure()
with:
report_paths: '**/junit.xml'

exclude_sources: '/.pytest_cache/,/__pycache__/'
2 changes: 1 addition & 1 deletion .github/workflows/PBM.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ jobs:
if: success() || failure()
with:
report_paths: '**/junit.xml'

exclude_sources: '/.pytest_cache/,/__pycache__/'
63 changes: 63 additions & 0 deletions pbm-functional/pytest/test_PBM-799.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import pytest
import pymongo
import bson
import testinfra
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"},{"host": "rs102"},{"host": "rs103"},
# {"host": "rs104"},{"host": "rs105"},{"host": "rs106"},{"host": "rs107"}
{"host": "rs104", "hidden": True, "priority": 0, "votes": 0},
{"host": "rs105", "hidden": True, "priority": 0, "votes": 0},
{"host": "rs106", "hidden": True, "priority": 0, "votes": 0},
{"host": "rs107", "hidden": True, "priority": 0, "votes": 0}
]}

@pytest.fixture(scope="package")
def pbm_mongodb_uri():
return 'mongodb://pbm:[email protected]:27017/?authSource=admin&w=3'

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

@pytest.fixture(scope="function")
def start_cluster(cluster,request):
try:
cluster.destroy()
cluster.create()
cluster.setup_pbm()
os.chmod("/backups",0o777)
os.system("rm -rf /backups/*")
result = cluster.exec_pbm_cli("config --set storage.type=filesystem --set storage.filesystem.path=/backups --set backup.compression=none --out json")
assert result.rc == 0
Cluster.log("Setup PBM with fs storage:\n" + result.stdout)
yield True
finally:
if request.config.getoption("--verbose"):
cluster.get_logs()
cluster.destroy(cleanup_backups=True)

@pytest.mark.timeout(300,func_only=True)
def test_logical(start_cluster,cluster):
cluster.check_pbm_status()
for i in range(100):
pymongo.MongoClient(cluster.connection)["test"]["test"].insert_one({"a": i})
backup = cluster.make_backup("logical")
backup_status = cluster.exec_pbm_cli("describe-backup " + backup).stdout
Cluster.log("Backup status: \n" + backup_status)
cluster.make_resync()

cluster.check_pbm_status()
backup_status = cluster.exec_pbm_cli("describe-backup " + backup).stdout
Cluster.log("Backup status: \n" + backup_status)
cluster.make_restore(backup,check_pbm_status=True)
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == 100
Cluster.log("Finished successfully")

0 comments on commit 8217b76

Please sign in to comment.