-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* PBM tests with ratelimiter * PBM-1114 simulate failure on uploading metadata files * PBM-1114 added test
- Loading branch information
1 parent
72f5b0c
commit 5e1dbce
Showing
4 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
FROM nginx:stable-alpine | ||
COPY conf/nginx.conf /etc/nginx/nginx.conf | ||
EXPOSE 21114 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
user nginx; | ||
worker_processes auto; | ||
|
||
error_log /var/log/nginx/error.log notice; | ||
pid /var/run/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
include /etc/nginx/mime.types; | ||
default_type application/octet-stream; | ||
|
||
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
'$status $body_bytes_sent "$http_referer" ' | ||
'"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
access_log /var/log/nginx/access.log main; | ||
|
||
sendfile on; | ||
keepalive_timeout 65; | ||
limit_req_zone $limit zone=one:10m rate=10r/m; | ||
|
||
map $request_method $limit { | ||
default ""; | ||
PUT $binary_remote_addr; | ||
POST $binary_remote_addr; | ||
} | ||
|
||
server { | ||
listen 21114; | ||
server_name minio-nginx; | ||
|
||
ignore_invalid_headers off; | ||
client_max_body_size 0; | ||
proxy_buffering off; | ||
proxy_request_buffering off; | ||
|
||
location / { | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
|
||
proxy_connect_timeout 300; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection ""; | ||
chunked_transfer_encoding off; | ||
|
||
proxy_pass http://minio:9000/; | ||
} | ||
location ~* metadata\.json { | ||
if ($request_method = PUT) { | ||
return 444; | ||
} | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Proto $scheme; | ||
|
||
proxy_connect_timeout 300; | ||
proxy_http_version 1.1; | ||
proxy_set_header Connection ""; | ||
chunked_transfer_encoding off; | ||
|
||
proxy_pass http://minio:9000$request_uri; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |