27
27
28
28
29
29
def _header_args_from_spec (test_spec : TestSpec ) -> list [str ]:
30
- params = []
31
- for header , value in test_spec .headers :
32
- params .append (f'--header="{ header } : { value } "' )
33
- return params
30
+ return [f'--header="{ header } : { value } "' for header , value in test_spec .headers ]
34
31
35
32
36
33
def _args_from_spec (test_spec : TestSpec ) -> list [str ]:
@@ -42,8 +39,7 @@ def _args_from_spec(test_spec: TestSpec) -> list[str]:
42
39
if duration := test_spec .time_limit :
43
40
args .append (f"--duration={ duration } s" )
44
41
if body_file := test_spec .body_file :
45
- args .append (f"--body-file=test_data/{ body_file } " )
46
- args .append ("--method=POST" )
42
+ args .extend ((f"--body-file=test_data/{ body_file } " , "--method=POST" ))
47
43
return args
48
44
49
45
@@ -109,8 +105,8 @@ def print_suite_config(self) -> None:
109
105
if "rps" in self ._benchmark_modes :
110
106
table .add_row ("RPS benchmarks duration" , f"{ self ._time_limit } seconds" )
111
107
if "latency" in self ._benchmark_modes :
112
- table .add_row ("Latency benchmarks RPS limit" , self ._rate_limit )
113
- table .add_row ("Latency benchmarks requests limit" , self ._request_limit )
108
+ table .add_row ("Latency benchmarks RPS limit" , str ( self ._rate_limit ) )
109
+ table .add_row ("Latency benchmarks requests limit" , str ( self ._request_limit ) )
114
110
table .add_row ("Warmup time" , f"{ self ._warmup_time } seconds" )
115
111
table .add_row ("Endpoint modes" , ", " .join (self ._endpoint_modes ))
116
112
table .add_row ("Endpoint categories" , ", " .join (self ._categories ))
@@ -193,8 +189,7 @@ def run_benchmark(self, test_spec: TestSpec) -> dict[str, Any]:
193
189
* _args_from_spec (test_spec ),
194
190
)
195
191
results = json .loads (res )
196
- error_percentage = get_error_percentage (results ["result" ])
197
- if error_percentage :
192
+ if error_percentage := get_error_percentage (results ["result" ]):
198
193
self .console .print (f" [red][Error][/red] { test_spec .pretty_name } with errors ({ error_percentage } %)" )
199
194
else :
200
195
self .console .print (f" [green][Completed][/green] { test_spec .pretty_name } " )
@@ -212,7 +207,10 @@ def provide_service(self, spec: FrameworkSpec) -> Generator[bool, None, None]:
212
207
try :
213
208
container .kill ()
214
209
except APIError as error :
215
- if not (error .status_code == 409 and "not running" in error .explanation ):
210
+ if (
211
+ error .status_code != 409
212
+ or "not running" not in error .explanation
213
+ ):
216
214
# the container stopped for reasons
217
215
raise error
218
216
yield False
0 commit comments