PYTHON-4155 Add perf benchmark with TLS enabled (#1481)
This commit is contained in:
parent
c4e4bd638f
commit
c3458e9d8e
@ -2149,6 +2149,18 @@ tasks:
|
||||
- func: "attach benchmark test results"
|
||||
- func: "send dashboard data"
|
||||
|
||||
- name: "perf-6.0-standalone-ssl"
|
||||
tags: ["perf"]
|
||||
commands:
|
||||
- func: "bootstrap mongo-orchestration"
|
||||
vars:
|
||||
VERSION: "v6.0-perf"
|
||||
TOPOLOGY: "server"
|
||||
SSL: "ssl"
|
||||
- func: "run perf tests"
|
||||
- func: "attach benchmark test results"
|
||||
- func: "send dashboard data"
|
||||
|
||||
axes:
|
||||
# Choice of distro
|
||||
- id: platform
|
||||
@ -3118,6 +3130,7 @@ buildvariants:
|
||||
run_on: rhel90-dbx-perf-large
|
||||
tasks:
|
||||
- name: "perf-6.0-standalone"
|
||||
- name: "perf-6.0-standalone-ssl"
|
||||
|
||||
# Platform notes
|
||||
# i386 builds of OpenSSL or Cyrus SASL are not available
|
||||
|
||||
@ -281,6 +281,8 @@ class ClientContext:
|
||||
def client_options(self):
|
||||
"""Return the MongoClient options for creating a duplicate client."""
|
||||
opts = client_context.default_client_options.copy()
|
||||
opts["host"] = host
|
||||
opts["port"] = port
|
||||
if client_context.auth_enabled:
|
||||
opts["username"] = db_user
|
||||
opts["password"] = db_pwd
|
||||
|
||||
@ -30,7 +30,7 @@ except ImportError:
|
||||
|
||||
sys.path[0:0] = [""]
|
||||
|
||||
from test import client_context, host, port, unittest
|
||||
from test import client_context, unittest
|
||||
|
||||
from bson import decode, encode, json_util
|
||||
from gridfs import GridFSBucket
|
||||
@ -139,6 +139,10 @@ class PerformanceTest:
|
||||
|
||||
self.results = results
|
||||
|
||||
def mp_map(self, map_func, files):
|
||||
with mp.Pool(initializer=proc_init, initargs=(client_context.client_options,)) as pool:
|
||||
pool.map(map_func, files)
|
||||
|
||||
|
||||
# BSON MICRO-BENCHMARKS
|
||||
|
||||
@ -397,16 +401,12 @@ class TestGridFsDownload(GridFsTest, unittest.TestCase):
|
||||
proc_client: Optional[MongoClient] = None
|
||||
|
||||
|
||||
def proc_init(*dummy):
|
||||
def proc_init(client_kwargs):
|
||||
global proc_client
|
||||
proc_client = MongoClient(host, port)
|
||||
proc_client = MongoClient(**client_kwargs)
|
||||
|
||||
|
||||
# PARALLEL BENCHMARKS
|
||||
def mp_map(map_func, files):
|
||||
pool = mp.Pool(initializer=proc_init)
|
||||
pool.map(map_func, files)
|
||||
pool.close()
|
||||
|
||||
|
||||
def insert_json_file(filename):
|
||||
@ -431,13 +431,10 @@ def insert_json_file_with_file_id(filename):
|
||||
def read_json_file(filename):
|
||||
assert proc_client is not None
|
||||
coll = proc_client.perftest.corpus
|
||||
temp = tempfile.TemporaryFile(mode="w")
|
||||
try:
|
||||
temp.writelines(
|
||||
[json.dumps(doc) + "\n" for doc in coll.find({"file": filename}, {"_id": False})]
|
||||
)
|
||||
finally:
|
||||
temp.close()
|
||||
with tempfile.TemporaryFile(mode="w") as temp:
|
||||
for doc in coll.find({"file": filename}, {"_id": False}):
|
||||
temp.write(json.dumps(doc))
|
||||
temp.write("\n")
|
||||
|
||||
|
||||
def insert_gridfs_file(filename):
|
||||
@ -460,24 +457,22 @@ def read_gridfs_file(filename):
|
||||
|
||||
|
||||
class TestJsonMultiImport(PerformanceTest, unittest.TestCase):
|
||||
data_size = 565000000
|
||||
|
||||
def setUp(self):
|
||||
self.client = client_context.client
|
||||
self.client.drop_database("perftest")
|
||||
ldjson_path = os.path.join(TEST_PATH, os.path.join("parallel", "ldjson_multi"))
|
||||
self.files = [os.path.join(ldjson_path, s) for s in os.listdir(ldjson_path)]
|
||||
self.data_size = sum(os.path.getsize(fname) for fname in self.files)
|
||||
self.corpus = self.client.perftest.corpus
|
||||
|
||||
def before(self):
|
||||
self.client.perftest.command({"create": "corpus"})
|
||||
self.corpus = self.client.perftest.corpus
|
||||
|
||||
ldjson_path = os.path.join(TEST_PATH, os.path.join("parallel", "ldjson_multi"))
|
||||
self.files = [os.path.join(ldjson_path, s) for s in os.listdir(ldjson_path)]
|
||||
|
||||
def do_task(self):
|
||||
mp_map(insert_json_file, self.files)
|
||||
self.mp_map(insert_json_file, self.files)
|
||||
|
||||
def after(self):
|
||||
self.client.perftest.drop_collection("corpus")
|
||||
self.corpus.drop()
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
@ -485,8 +480,6 @@ class TestJsonMultiImport(PerformanceTest, unittest.TestCase):
|
||||
|
||||
|
||||
class TestJsonMultiExport(PerformanceTest, unittest.TestCase):
|
||||
data_size = 565000000
|
||||
|
||||
def setUp(self):
|
||||
self.client = client_context.client
|
||||
self.client.drop_database("perftest")
|
||||
@ -494,11 +487,12 @@ class TestJsonMultiExport(PerformanceTest, unittest.TestCase):
|
||||
|
||||
ldjson_path = os.path.join(TEST_PATH, os.path.join("parallel", "ldjson_multi"))
|
||||
self.files = [os.path.join(ldjson_path, s) for s in os.listdir(ldjson_path)]
|
||||
self.data_size = sum(os.path.getsize(fname) for fname in self.files)
|
||||
|
||||
mp_map(insert_json_file_with_file_id, self.files)
|
||||
self.mp_map(insert_json_file_with_file_id, self.files)
|
||||
|
||||
def do_task(self):
|
||||
mp_map(read_json_file, self.files)
|
||||
self.mp_map(read_json_file, self.files)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
@ -506,11 +500,12 @@ class TestJsonMultiExport(PerformanceTest, unittest.TestCase):
|
||||
|
||||
|
||||
class TestGridFsMultiFileUpload(PerformanceTest, unittest.TestCase):
|
||||
data_size = 262144000
|
||||
|
||||
def setUp(self):
|
||||
self.client = client_context.client
|
||||
self.client.drop_database("perftest")
|
||||
gridfs_path = os.path.join(TEST_PATH, os.path.join("parallel", "gridfs_multi"))
|
||||
self.files = [os.path.join(gridfs_path, s) for s in os.listdir(gridfs_path)]
|
||||
self.data_size = sum(os.path.getsize(fname) for fname in self.files)
|
||||
|
||||
def before(self):
|
||||
self.client.perftest.drop_collection("fs.files")
|
||||
@ -521,7 +516,7 @@ class TestGridFsMultiFileUpload(PerformanceTest, unittest.TestCase):
|
||||
self.files = [os.path.join(gridfs_path, s) for s in os.listdir(gridfs_path)]
|
||||
|
||||
def do_task(self):
|
||||
mp_map(insert_gridfs_file, self.files)
|
||||
self.mp_map(insert_gridfs_file, self.files)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
@ -529,8 +524,6 @@ class TestGridFsMultiFileUpload(PerformanceTest, unittest.TestCase):
|
||||
|
||||
|
||||
class TestGridFsMultiFileDownload(PerformanceTest, unittest.TestCase):
|
||||
data_size = 262144000
|
||||
|
||||
def setUp(self):
|
||||
self.client = client_context.client
|
||||
self.client.drop_database("perftest")
|
||||
@ -539,13 +532,13 @@ class TestGridFsMultiFileDownload(PerformanceTest, unittest.TestCase):
|
||||
|
||||
gridfs_path = os.path.join(TEST_PATH, os.path.join("parallel", "gridfs_multi"))
|
||||
self.files = [os.path.join(gridfs_path, s) for s in os.listdir(gridfs_path)]
|
||||
|
||||
self.data_size = sum(os.path.getsize(fname) for fname in self.files)
|
||||
for fname in self.files:
|
||||
with open(fname, "rb") as gfile:
|
||||
bucket.upload_from_stream(fname, gfile)
|
||||
|
||||
def do_task(self):
|
||||
mp_map(read_gridfs_file, self.files)
|
||||
self.mp_map(read_gridfs_file, self.files)
|
||||
|
||||
def tearDown(self):
|
||||
super().tearDown()
|
||||
|
||||
@ -321,7 +321,6 @@ class TestCommandAndReadPreference(IntegrationTest):
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.c = ReadPrefTester(
|
||||
client_context.pair,
|
||||
# Ignore round trip times, to test ReadPreference modes only.
|
||||
localThresholdMS=1000 * 1000,
|
||||
)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user