From 16874b44d71a01c113893c39bc7270ab1e5681b9 Mon Sep 17 00:00:00 2001 From: Oleksandr Havryliak Date: Thu, 19 Sep 2024 09:19:27 +0300 Subject: [PATCH] PBM-1114 simulate failure on uploading metadata files --- pbm-functional/pytest/Dockerfile-nginx | 1 + pbm-functional/pytest/conf/nginx.conf | 26 ++++--- pbm-functional/pytest/test_trottling.py | 96 ------------------------- 3 files changed, 18 insertions(+), 105 deletions(-) delete mode 100644 pbm-functional/pytest/test_trottling.py diff --git a/pbm-functional/pytest/Dockerfile-nginx b/pbm-functional/pytest/Dockerfile-nginx index 850cfd89..29552c19 100644 --- a/pbm-functional/pytest/Dockerfile-nginx +++ b/pbm-functional/pytest/Dockerfile-nginx @@ -1,2 +1,3 @@ FROM nginx:stable-alpine COPY conf/nginx.conf /etc/nginx/nginx.conf +EXPOSE 21114 diff --git a/pbm-functional/pytest/conf/nginx.conf b/pbm-functional/pytest/conf/nginx.conf index 27cf3fc1..88cca9b6 100644 --- a/pbm-functional/pytest/conf/nginx.conf +++ b/pbm-functional/pytest/conf/nginx.conf @@ -23,7 +23,6 @@ http { sendfile on; keepalive_timeout 65; limit_req_zone $limit zone=one:10m rate=10r/m; - limit_conn_zone $binary_remote_addr zone=addr:10m; map $request_method $limit { default ""; @@ -32,8 +31,7 @@ http { } server { - listen 80; - listen [::]:80; + listen 21114; server_name minio-nginx; ignore_invalid_headers off; @@ -52,13 +50,23 @@ http { proxy_set_header Connection ""; chunked_transfer_encoding off; - limit_req zone=one; - limit_req_status 429; - - limit_conn addr 10; - limit_conn_status 444; - 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; + } } } diff --git a/pbm-functional/pytest/test_trottling.py b/pbm-functional/pytest/test_trottling.py deleted file mode 100644 index dd72d0d2..00000000 --- a/pbm-functional/pytest/test_trottling.py +++ /dev/null @@ -1,96 +0,0 @@ -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"}, { - "host": "rscfg02"}, {"host": "rscfg03"}]}, - "shards": [ - {"_id": "rs1", "members": [{"host": "rs101"}, { - "host": "rs102"}, {"host": "rs103"}]}, - {"_id": "rs2", "members": [{"host": "rs201"}, { - "host": "rs202"}, {"host": "rs203"}]} - ]} - -@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") - Cluster.log("Setup PBM with minio storage with trottling:\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"}) - client.admin.command( - "shardCollection", "test.test2", key={"_id": "hashed"}) - client.admin.command( - "shardCollection", "test.test3", 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(start_cluster, cluster): - cluster.check_pbm_status() - pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents) - backup = cluster.make_backup("logical") - result = pymongo.MongoClient(cluster.connection)["test"]["test"].delete_many({}) - assert int(result.deleted_count) == len(documents) - cluster.make_restore(backup, check_pbm_status=True) - assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents) - assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False) - Cluster.log("Finished successfully\n") - -""" -@pytest.mark.timeout(300, func_only=True) -def test_physical(start_cluster, cluster): - cluster.check_pbm_status() - pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents) - backup = cluster.make_backup("physical") - result = pymongo.MongoClient(cluster.connection)["test"]["test"].delete_many({}) - assert int(result.deleted_count) == len(documents) - cluster.make_restore(backup, restart_cluster=True,check_pbm_status=True) - assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents) - assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False) - Cluster.log("Finished successfully\n") - -@pytest.mark.timeout(300, func_only=True) -def test_incremental(start_cluster, cluster): - cluster.check_pbm_status() - cluster.make_backup("incremental --base") - pymongo.MongoClient(cluster.connection)["test"]["test"].insert_many(documents) - backup = cluster.make_backup("incremental") - result = pymongo.MongoClient(cluster.connection)["test"]["test"].delete_many({}) - assert int(result.deleted_count) == len(documents) - cluster.make_restore(backup, restart_cluster=True,check_pbm_status=True) - assert pymongo.MongoClient(cluster.connection)["test"]["test"].count_documents({}) == len(documents) - assert pymongo.MongoClient(cluster.connection)["test"].command("collstats", "test").get("sharded", False) - Cluster.log("Finished successfully\n") -"""