Skip to content

Commit aa84236

Browse files
PBM test with WORM bucket using profile
1 parent fd3fd8c commit aa84236

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

pbm-functional/pytest/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ COPY --from=easyrsa /etc/x509/ /etc/x509/
3939
COPY --from=easyrsa /etc/nginx-minio/ca.crt /etc/nginx-minio/ca.crt
4040
COPY conf/supervisord.d/ /etc/supervisord.d/
4141
COPY conf/pbm/minio.yaml /etc/pbm.conf
42+
COPY conf/pbm/minio-worm.yaml /etc/minio-worm.conf
4243
COPY conf/pbm/fs.yaml /etc/pbm-fs.conf
4344
COPY conf/pbm/pbm-1525.yaml /etc/pbm-1525.conf
4445
COPY conf/pbm/pbm-1043.yaml /etc/pbm-1043.conf
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
storage:
2+
type: s3
3+
s3:
4+
endpointUrl: http://minio:9000
5+
bucket: worm
6+
credentials:
7+
access-key-id: "minio1234"
8+
secret-access-key: "minio1234"

pbm-functional/pytest/docker-compose.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ services:
6464
depends_on:
6565
- minio
6666
entrypoint: >
67-
/bin/sh -c " sleep 5; /usr/bin/mc alias set myminio http://minio:9000 minio1234 minio1234; /usr/bin/mc mb myminio/bcp; exit 0; "
67+
/bin/sh -c " sleep 5; /usr/bin/mc alias set myminio http://minio:9000 minio1234 minio1234; /usr/bin/mc mb myminio/bcp; /usr/bin/mc mb --with-lock myminio/worm; exit 0; "
6868
6969
pykmip:
7070
image: pykmip/local
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import pytest
2+
import pymongo
3+
import time
4+
import os
5+
6+
from datetime import datetime
7+
from cluster import Cluster
8+
9+
@pytest.fixture(scope="package")
10+
def config():
11+
return { "mongos": "mongos",
12+
"configserver":
13+
{"_id": "rscfg", "members": [{"host":"rscfg01"}]},
14+
"shards":[
15+
{"_id": "rs1", "members": [{"host":"rs101"}]},
16+
{"_id": "rs2", "members": [{"host":"rs201"}]}
17+
]}
18+
19+
@pytest.fixture(scope="package")
20+
def cluster(config):
21+
return Cluster(config)
22+
23+
@pytest.fixture(scope="function")
24+
def start_cluster(cluster,request):
25+
try:
26+
cluster.destroy()
27+
os.chmod("/backups",0o777)
28+
os.system("rm -rf /backups/*")
29+
cluster.create()
30+
cluster.setup_pbm()
31+
profile=cluster.exec_pbm_cli("profile add worm /etc/minio-worm.conf --wait")
32+
assert profile.rc==0, profile.stderr
33+
assert "OK" in profile.stdout, profile.stdout
34+
client=pymongo.MongoClient(cluster.connection)
35+
client.admin.command("enableSharding", "test")
36+
client.admin.command("shardCollection", "test.test", key={"_id": "hashed"})
37+
yield True
38+
39+
finally:
40+
if request.config.getoption("--verbose"):
41+
cluster.get_logs()
42+
cluster.destroy(cleanup_backups=True)
43+
44+
@pytest.mark.timeout(300,func_only=True)
45+
@pytest.mark.parametrize('backup_type',['logical','physical'])
46+
def test_worm_profile(start_cluster,cluster,backup_type):
47+
client=pymongo.MongoClient(cluster.connection)
48+
for i in range(300):
49+
client['test']['test'].insert_one({"doc":i})
50+
51+
backup=cluster.make_backup(backup_type + " --profile worm")
52+
pymongo.MongoClient(cluster.connection).drop_database('test')
53+
Cluster.log("Attempt restore " + backup_type + " backup from the worm storage")
54+
if backup_type == 'logical':
55+
cluster.make_restore(backup, check_pbm_status=True)
56+
else:
57+
cluster.make_restore(backup, restart_cluster=True, check_pbm_status=True)
58+
time.sleep(5)
59+
assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == 300
60+
assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False)

0 commit comments

Comments
 (0)