3
3
import logging
4
4
import os
5
5
import pathlib
6
- import shutil
7
6
import sys
8
7
import tempfile
9
8
import traceback
10
9
from pathlib import Path
10
+ import shutil
11
11
12
12
import docker
13
13
import redis
@@ -110,6 +110,11 @@ def main():
110
110
exit (1 )
111
111
112
112
running_platform = args .platform_name
113
+ tls_enabled = args .tls
114
+ tls_skip_verify = args .tls_skip_verify
115
+ tls_cert = args .cert
116
+ tls_key = args .key
117
+ tls_cacert = args .cacert
113
118
docker_client = docker .from_env ()
114
119
home = str (Path .home ())
115
120
logging .info ("Running the benchmark specs." )
@@ -124,6 +129,11 @@ def main():
124
129
testsuite_spec_files ,
125
130
{},
126
131
running_platform ,
132
+ tls_enabled ,
133
+ tls_skip_verify ,
134
+ tls_cert ,
135
+ tls_key ,
136
+ tls_cacert ,
127
137
)
128
138
129
139
@@ -134,6 +144,11 @@ def prepare_memtier_benchmark_parameters(
134
144
server ,
135
145
local_benchmark_output_filename ,
136
146
oss_cluster_api_enabled ,
147
+ tls_enabled = False ,
148
+ tls_skip_verify = False ,
149
+ tls_cert = None ,
150
+ tls_key = None ,
151
+ tls_cacert = None ,
137
152
):
138
153
benchmark_command = [
139
154
full_benchmark_path ,
@@ -144,6 +159,17 @@ def prepare_memtier_benchmark_parameters(
144
159
"--json-out-file" ,
145
160
local_benchmark_output_filename ,
146
161
]
162
+ if tls_enabled :
163
+ benchmark_command .append ("--tls" )
164
+ if tls_cert is not None and tls_cert != "" :
165
+ benchmark_command .extend (["--cert" , tls_cert ])
166
+ if tls_key is not None and tls_key != "" :
167
+ benchmark_command .extend (["--key" , tls_key ])
168
+ if tls_cacert is not None and tls_cacert != "" :
169
+ benchmark_command .extend (["--cacert" , tls_cacert ])
170
+ if tls_skip_verify :
171
+ benchmark_command .append ("--tls-skip-verify" )
172
+
147
173
if oss_cluster_api_enabled is True :
148
174
benchmark_command .append ("--cluster-mode" )
149
175
benchmark_command_str = " " .join (benchmark_command )
@@ -163,14 +189,29 @@ def process_self_contained_coordinator_stream(
163
189
testsuite_spec_files ,
164
190
topologies_map ,
165
191
running_platform ,
192
+ tls_enabled = False ,
193
+ tls_skip_verify = False ,
194
+ tls_cert = None ,
195
+ tls_key = None ,
196
+ tls_cacert = None ,
166
197
):
167
198
overall_result = True
168
199
total_test_suite_runs = 0
169
200
for test_file in testsuite_spec_files :
170
201
client_containers = []
171
202
172
203
with open (test_file , "r" ) as stream :
173
- benchmark_config , test_name = get_final_benchmark_config (None , stream , "" )
204
+ _ , benchmark_config , test_name = get_final_benchmark_config (
205
+ None , stream , ""
206
+ )
207
+
208
+ if tls_enabled :
209
+ test_name = test_name + "-tls"
210
+ logging .info (
211
+ "Given that TLS is enabled, appending -tls to the testname: {}." .format (
212
+ test_name
213
+ )
214
+ )
174
215
175
216
for topology_spec_name in benchmark_config ["redis-topologies" ]:
176
217
test_result = False
@@ -189,8 +230,22 @@ def process_self_contained_coordinator_stream(
189
230
190
231
port = args .db_server_port
191
232
host = args .db_server_host
192
- r = redis .StrictRedis (host = host , port = port )
233
+
234
+ ssl_cert_reqs = "required"
235
+ if tls_skip_verify :
236
+ ssl_cert_reqs = None
237
+ r = redis .StrictRedis (
238
+ host = host ,
239
+ port = port ,
240
+ ssl = tls_enabled ,
241
+ ssl_cert_reqs = ssl_cert_reqs ,
242
+ ssl_keyfile = tls_key ,
243
+ ssl_certfile = tls_cert ,
244
+ ssl_ca_certs = tls_cacert ,
245
+ ssl_check_hostname = False ,
246
+ )
193
247
r .ping ()
248
+
194
249
ceil_client_cpu_limit = extract_client_cpu_limit (benchmark_config )
195
250
client_cpuset_cpus , current_cpu_pos = generate_cpuset_cpus (
196
251
ceil_client_cpu_limit , current_cpu_pos
@@ -202,6 +257,17 @@ def process_self_contained_coordinator_stream(
202
257
benchmark_tool_workdir = client_mnt_point
203
258
204
259
metadata = {}
260
+ if tls_enabled :
261
+ metadata ["tls" ] = "true"
262
+ if tls_cert is not None and tls_cert != "" :
263
+ _ , tls_cert = cp_to_workdir (temporary_dir_client , tls_cert )
264
+ if tls_cacert is not None and tls_cacert != "" :
265
+ _ , tls_cacert = cp_to_workdir (
266
+ temporary_dir_client , tls_cacert
267
+ )
268
+ if tls_key is not None and tls_key != "" :
269
+ _ , tls_key = cp_to_workdir (temporary_dir_client , tls_key )
270
+
205
271
if "preload_tool" in benchmark_config ["dbconfig" ]:
206
272
data_prepopulation_step (
207
273
benchmark_config ,
@@ -213,6 +279,11 @@ def process_self_contained_coordinator_stream(
213
279
temporary_dir_client ,
214
280
test_name ,
215
281
host ,
282
+ tls_enabled ,
283
+ tls_skip_verify ,
284
+ tls_cert ,
285
+ tls_key ,
286
+ tls_cacert ,
216
287
)
217
288
218
289
benchmark_tool = extract_client_tool (benchmark_config )
@@ -263,7 +334,12 @@ def process_self_contained_coordinator_stream(
263
334
port ,
264
335
host ,
265
336
local_benchmark_output_filename ,
266
- benchmark_tool_workdir ,
337
+ False ,
338
+ tls_enabled ,
339
+ tls_skip_verify ,
340
+ tls_cert ,
341
+ tls_key ,
342
+ tls_cacert ,
267
343
)
268
344
269
345
client_container_image = extract_client_container_image (
@@ -389,6 +465,18 @@ def process_self_contained_coordinator_stream(
389
465
overall_result &= test_result
390
466
391
467
468
+ def cp_to_workdir (benchmark_tool_workdir , srcfile ):
469
+ head , filename = os .path .split (srcfile )
470
+ dstfile = "{}/{}" .format (benchmark_tool_workdir , filename )
471
+ shutil .copyfile (srcfile , dstfile )
472
+ logging .info (
473
+ "Copying to workdir the following file {}. Final workdir file {}" .format (
474
+ srcfile , dstfile
475
+ )
476
+ )
477
+ return dstfile , filename
478
+
479
+
392
480
def data_prepopulation_step (
393
481
benchmark_config ,
394
482
benchmark_tool_workdir ,
@@ -399,6 +487,11 @@ def data_prepopulation_step(
399
487
temporary_dir ,
400
488
test_name ,
401
489
host ,
490
+ tls_enabled = False ,
491
+ tls_skip_verify = False ,
492
+ tls_cert = None ,
493
+ tls_key = None ,
494
+ tls_cacert = None ,
402
495
):
403
496
# setup the benchmark
404
497
(
@@ -426,6 +519,11 @@ def data_prepopulation_step(
426
519
host ,
427
520
local_benchmark_output_filename ,
428
521
False ,
522
+ tls_enabled ,
523
+ tls_skip_verify ,
524
+ tls_cert ,
525
+ tls_key ,
526
+ tls_cacert ,
429
527
)
430
528
431
529
logging .info (
0 commit comments