1
+ import itertools
1
2
import logging
2
3
import os
3
4
import tempfile
9
10
10
11
from lib .commands import SSHCommandFailed
11
12
12
- from .helpers import load_results_from_csv
13
+ from .helpers import load_results_from_csv , str_to_tuple
13
14
14
15
MAX_LENGTH = 64 * (1024 ** 3 ) # 64GiB
15
16
@@ -98,12 +99,57 @@ def temp_dir(running_unix_vm_with_fio):
98
99
99
100
100
101
def pytest_addoption (parser ):
102
+ system_memory = os .sysconf ("SC_PAGE_SIZE" ) * os .sysconf ("SC_PHYS_PAGES" )
103
+
101
104
parser .addoption (
102
105
"--prev-csv" ,
103
106
action = "store" ,
104
107
default = None ,
105
108
help = "Path/URI to previous CSV results file for comparison" ,
106
109
)
110
+ parser .addoption (
111
+ "--block-sizes" ,
112
+ action = "store" ,
113
+ type = lambda value : str_to_tuple (value , sep = "," ),
114
+ default = ("4k" , "16k" , "64k" , "1M" ),
115
+ help = "Comma separated values of block sizes to test in disk benchmarks" ,
116
+ )
117
+ parser .addoption (
118
+ "--file-sizes" ,
119
+ action = "store" ,
120
+ type = lambda value : str_to_tuple (value , sep = "," ),
121
+ default = ("1G" , "4G" , f"{ int ((system_memory // (1024. ** 3 )) * 2 )} G" ),
122
+ help = "Comma separated values of file sizes to test in disk benchmarks" ,
123
+ )
124
+ parser .addoption (
125
+ "--modes" ,
126
+ action = "store" ,
127
+ type = lambda value : str_to_tuple (value , sep = "," ),
128
+ default = ("read" , "randread" , "write" , "randwrite" ),
129
+ help = "Comma separated values of rw_modes to test in disk benchmarks" ,
130
+ )
131
+ parser .addoption (
132
+ "--numjobs" ,
133
+ action = "store" ,
134
+ default = 1 ,
135
+ help = "Mapped to fio's --numjobs" ,
136
+ )
137
+ parser .addoption (
138
+ "--iodepth" ,
139
+ action = "store" ,
140
+ default = 1 ,
141
+ help = "Mapped to fio's --iodepth" ,
142
+ )
143
+
144
+
145
+ def pytest_generate_tests (metafunc ):
146
+ if {"block_size" , "file_size" , "rw_mode" } <= set (metafunc .fixturenames ):
147
+ block_sizes = metafunc .config .getoption ("block_sizes" )
148
+ file_sizes = metafunc .config .getoption ("file_sizes" )
149
+ modes = metafunc .config .getoption ("modes" )
150
+
151
+ test_cases = list (itertools .product (block_sizes , file_sizes , modes ))
152
+ metafunc .parametrize ("block_size,file_size,rw_mode" , test_cases )
107
153
108
154
109
155
@pytest .fixture (scope = "session" )
@@ -113,8 +159,10 @@ def prev_results(pytestconfig):
113
159
return {}
114
160
csv_path = csv_uri
115
161
if urlparse (csv_uri ).scheme != "" :
116
- csv_path = f"{ uuid4 ()} .csv"
162
+ logging .info ("Detected CSV path as an url" )
163
+ csv_path = f"/tmp/{ uuid4 ()} .csv"
117
164
urllib .request .urlretrieve (csv_uri , csv_path )
165
+ logging .info (f"Fetching CSV file from { csv_uri } to { csv_path } " )
118
166
if not os .path .exists (csv_path ):
119
167
raise FileNotFoundError (csv_path )
120
168
return load_results_from_csv (csv_path )
0 commit comments