Skip to content

Commit

Permalink
PBM-1114 added test
Browse files Browse the repository at this point in the history
  • Loading branch information
olexandr-havryliak committed Sep 19, 2024
1 parent 16874b4 commit 25f33b6
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions pbm-functional/pytest/test_PBM-1114.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pytest
import pymongo
import bson
import testinfra
import time
import os
import docker
import threading

from datetime import datetime
from cluster import Cluster

documents = [{"a": 1}, {"b": 2}, {"c": 3}, {"d": 4}]

@pytest.fixture(scope="package")
def docker_client():
return docker.from_env()

@pytest.fixture(scope="package")
def config():
return {"mongos": "mongos",
"configserver":
{"_id": "rscfg", "members": [{"host": "rscfg01"}]},
"shards": [
{"_id": "rs1", "members": [{"host": "rs101"}]},
{"_id": "rs2", "members": [{"host": "rs201"}]}
]}

@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()
result = cluster.exec_pbm_cli("config --set storage.s3.endpointUrl=http://nginx-minio:21114")
Cluster.log("Setup PBM with nginx proxy:\n" + result.stdout)
assert result.rc == 0
client = pymongo.MongoClient(cluster.connection)
client.admin.command("enableSharding", "test")
client.admin.command("shardCollection", "test.test", key={"_id": "hashed"})
yield True
finally:
if request.config.getoption("--verbose"):
cluster.get_logs()
cluster.destroy()

@pytest.mark.timeout(300, func_only=True)
def test_logical_PBM_T266(start_cluster, cluster):
cluster.check_pbm_status()
pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents)
result = cluster.exec_pbm_cli("backup --wait")
assert result.rc != 0, result.stdout + result.stderr

0 comments on commit 25f33b6

Please sign in to comment.