@@ -46,59 +46,16 @@ def local_db_spin(
46
46
required_modules ,
47
47
setup_type ,
48
48
shard_count ,
49
+ flushall_on_every_test_start = False ,
50
+ ignore_keyspace_errors = False ,
49
51
):
50
- # setup Redis
51
- # copy the rdb to DB machine
52
+ redis_conns = []
53
+ artifact_version = "n/a"
54
+ result = True
52
55
temporary_dir = tempfile .mkdtemp ()
53
- redis_7 = args .redis_7
54
- logging .info (
55
- "Using local temporary dir to spin up Redis Instance. Path: {}" .format (
56
- temporary_dir
57
- )
58
- )
59
- if dbdir_folder is not None :
60
- from distutils .dir_util import copy_tree
61
-
62
- copy_tree (dbdir_folder , temporary_dir )
63
- logging .info (
64
- "Copied entire content of {} into temporary path: {}" .format (
65
- dbdir_folder , temporary_dir
66
- )
67
- )
68
- (
69
- _ ,
70
- _ ,
71
- redis_configuration_parameters ,
72
- dataset_load_timeout_secs ,
73
- modules_configuration_parameters_map ,
74
- ) = extract_redis_dbconfig_parameters (benchmark_config , "dbconfig" )
75
56
cluster_api_enabled = False
76
- logging .info (
77
- "Using a dataset load timeout of {} seconds." .format (dataset_load_timeout_secs )
78
- )
79
- redis_conns = []
80
57
if setup_type == "oss-cluster" :
81
58
cluster_api_enabled = True
82
- shard_host = "127.0.0.1"
83
- redis_processes , redis_conns = spin_up_local_redis_cluster (
84
- binary ,
85
- temporary_dir ,
86
- shard_count ,
87
- shard_host ,
88
- args .port ,
89
- local_module_file ,
90
- redis_configuration_parameters ,
91
- dataset_load_timeout_secs ,
92
- modules_configuration_parameters_map ,
93
- redis_7 ,
94
- )
95
-
96
- status = setup_redis_cluster_from_conns (
97
- redis_conns , shard_count , shard_host , args .port
98
- )
99
- if status is False :
100
- raise Exception ("Redis cluster setup failed. Failing test." )
101
-
102
59
dataset , dataset_name , _ , _ = check_dataset_local_requirements (
103
60
benchmark_config ,
104
61
temporary_dir ,
@@ -108,35 +65,108 @@ def local_db_spin(
108
65
shard_count ,
109
66
cluster_api_enabled ,
110
67
)
111
- if setup_type == "oss-standalone" :
112
- redis_processes = spin_up_local_redis (
113
- binary ,
114
- args .port ,
115
- temporary_dir ,
116
- local_module_file ,
68
+
69
+ if args .skip_db_setup :
70
+ logging .info ("Skipping DB Setup..." )
71
+ if dataset is not None :
72
+ logging .info ("Given this benchmark requires an RDB load will skip it..." )
73
+ result = False
74
+ return (
75
+ result ,
76
+ artifact_version ,
77
+ cluster_api_enabled ,
78
+ redis_conns ,
79
+ redis_processes ,
80
+ )
81
+ else :
82
+ # setup Redis
83
+ # copy the rdb to DB machine
84
+ redis_7 = args .redis_7
85
+ logging .info (
86
+ "Using local temporary dir to spin up Redis Instance. Path: {}" .format (
87
+ temporary_dir
88
+ )
89
+ )
90
+ if dbdir_folder is not None :
91
+ from distutils .dir_util import copy_tree
92
+
93
+ copy_tree (dbdir_folder , temporary_dir )
94
+ logging .info (
95
+ "Copied entire content of {} into temporary path: {}" .format (
96
+ dbdir_folder , temporary_dir
97
+ )
98
+ )
99
+ (
100
+ _ ,
101
+ _ ,
117
102
redis_configuration_parameters ,
118
- dbdir_folder ,
119
103
dataset_load_timeout_secs ,
120
104
modules_configuration_parameters_map ,
121
- redis_7 ,
105
+ ) = extract_redis_dbconfig_parameters (benchmark_config , "dbconfig" )
106
+
107
+ logging .info (
108
+ "Using a dataset load timeout of {} seconds." .format (
109
+ dataset_load_timeout_secs
110
+ )
122
111
)
123
112
113
+ if setup_type == "oss-cluster" :
114
+ cluster_api_enabled = True
115
+ shard_host = "127.0.0.1"
116
+ redis_processes , redis_conns = spin_up_local_redis_cluster (
117
+ binary ,
118
+ temporary_dir ,
119
+ shard_count ,
120
+ shard_host ,
121
+ args .port ,
122
+ local_module_file ,
123
+ redis_configuration_parameters ,
124
+ dataset_load_timeout_secs ,
125
+ modules_configuration_parameters_map ,
126
+ redis_7 ,
127
+ )
128
+
129
+ status = setup_redis_cluster_from_conns (
130
+ redis_conns , shard_count , shard_host , args .port
131
+ )
132
+ if status is False :
133
+ raise Exception ("Redis cluster setup failed. Failing test." )
134
+
135
+ if setup_type == "oss-standalone" :
136
+ redis_processes = spin_up_local_redis (
137
+ binary ,
138
+ args .port ,
139
+ temporary_dir ,
140
+ local_module_file ,
141
+ redis_configuration_parameters ,
142
+ dbdir_folder ,
143
+ dataset_load_timeout_secs ,
144
+ modules_configuration_parameters_map ,
145
+ redis_7 ,
146
+ )
147
+ if setup_type == "oss-cluster" :
148
+ for shardn , redis_process in enumerate (redis_processes ):
149
+ logging .info (
150
+ "Checking if shard #{} process with pid={} is alive" .format (
151
+ shardn + 1 , redis_process .pid
152
+ )
153
+ )
154
+ if is_process_alive (redis_process ) is False :
155
+ raise Exception ("Redis process is not alive. Failing test." )
156
+ cluster_init_steps (clusterconfig , redis_conns , local_module_file )
157
+
158
+ if setup_type == "oss-standalone" :
124
159
r = redis .Redis (port = args .port )
125
160
r .ping ()
126
- r .client_setname ("redisbench-admin-stadalone " )
161
+ r .client_setname ("redisbench-admin-standalone " )
127
162
redis_conns .append (r )
128
- if setup_type == "oss-cluster" :
129
- for shardn , redis_process in enumerate (redis_processes ):
130
- logging .info (
131
- "Checking if shard #{} process with pid={} is alive" .format (
132
- shardn + 1 , redis_process .pid
133
- )
134
- )
135
- if is_process_alive (redis_process ) is False :
136
- raise Exception ("Redis process is not alive. Failing test." )
137
163
138
- if setup_type == "oss-cluster" :
139
- cluster_init_steps (clusterconfig , redis_conns , local_module_file )
164
+ if dataset is None :
165
+ if flushall_on_every_test_start :
166
+ logging .info ("Will flush all data at test start..." )
167
+ for shard_n , shard_conn in enumerate (redis_conns ):
168
+ logging .info (f"Flushing all in shard { shard_n } ..." )
169
+ shard_conn .flushall ()
140
170
141
171
if check_dbconfig_tool_requirement (benchmark_config ):
142
172
logging .info ("Detected the requirements to load data via client tool" )
@@ -175,11 +205,10 @@ def local_db_spin(
175
205
)
176
206
)
177
207
178
- dbconfig_keyspacelen_check (
179
- benchmark_config ,
180
- redis_conns ,
181
- )
208
+ dbconfig_keyspacelen_check (benchmark_config , redis_conns , ignore_keyspace_errors )
182
209
183
- run_redis_pre_steps (benchmark_config , redis_conns [0 ], required_modules )
210
+ artifact_version = run_redis_pre_steps (
211
+ benchmark_config , redis_conns [0 ], required_modules
212
+ )
184
213
185
- return cluster_api_enabled , redis_conns , redis_processes
214
+ return result , artifact_version , cluster_api_enabled , redis_conns , redis_processes
0 commit comments