Skip to content

Commit 65f027c

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

File tree

4 files changed

+69
-1
lines changed

4 files changed

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

0 commit comments

Comments
 (0)