1
|
|
|
import time |
2
|
|
|
import random |
3
|
|
|
import pdb |
4
|
|
|
import threading |
5
|
|
|
import logging |
6
|
|
|
from multiprocessing import Pool, Process |
7
|
|
|
import pytest |
8
|
|
|
from utils import * |
9
|
|
|
import ujson |
10
|
|
|
|
11
|
|
|
CONFIG_TIMEOUT = 80 |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
class TestCacheConfig: |
15
|
|
|
""" |
16
|
|
|
****************************************************************** |
17
|
|
|
The following cases are used to test `get_config` function |
18
|
|
|
****************************************************************** |
19
|
|
|
""" |
20
|
|
|
|
21
|
|
|
@pytest.fixture(scope="function", autouse=True) |
22
|
|
|
def skip_http_check(self, args): |
23
|
|
|
if args["handler"] == "HTTP": |
24
|
|
|
pytest.skip("skip in http mode") |
25
|
|
|
|
26
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
27
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
28
|
|
|
def reset_configs(self, connect): |
29
|
|
|
''' |
30
|
|
|
reset configs so the tests are stable |
31
|
|
|
''' |
32
|
|
|
relpy = connect.set_config("cache.cache_size", '4GB') |
33
|
|
|
config_value = connect.get_config("cache.cache_size") |
34
|
|
|
assert config_value == '4GB' |
35
|
|
|
# relpy = connect.set_config("cache", "insert_buffer_size", '2GB') |
36
|
|
|
# config_value = connect.get_config("cache", "insert_buffer_size") |
37
|
|
|
# assert config_value == '1073741824' |
38
|
|
|
|
39
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
40
|
|
|
def test_get_cache_size_invalid_parent_key(self, connect, collection): |
41
|
|
|
''' |
42
|
|
|
target: get invalid parent key |
43
|
|
|
method: call get_config without parent_key: cache |
44
|
|
|
expected: status not ok |
45
|
|
|
''' |
46
|
|
|
invalid_configs = ["Cache_config", "cache config", "cache_Config", "cacheconfig"] |
47
|
|
|
for config in invalid_configs: |
48
|
|
|
with pytest.raises(Exception) as e: |
49
|
|
|
config_value = connect.get_config(config + str(".cache_size")) |
50
|
|
|
|
51
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
52
|
|
|
def test_get_cache_size_invalid_child_key(self, connect, collection): |
53
|
|
|
''' |
54
|
|
|
target: get invalid child key |
55
|
|
|
method: call get_config without child_key: cache_size |
56
|
|
|
expected: status not ok |
57
|
|
|
''' |
58
|
|
|
invalid_configs = ["Cpu_cache_size", "cpu cache_size", "cpucachecapacity"] |
59
|
|
|
for config in invalid_configs: |
60
|
|
|
with pytest.raises(Exception) as e: |
61
|
|
|
config_value = connect.get_config("cache." + config) |
62
|
|
|
|
63
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
64
|
|
|
def test_get_cache_size_valid(self, connect, collection): |
65
|
|
|
''' |
66
|
|
|
target: get cache_size |
67
|
|
|
method: call get_config correctly |
68
|
|
|
expected: status ok |
69
|
|
|
''' |
70
|
|
|
config_value = connect.get_config("cache.cache_size") |
71
|
|
|
assert config_value |
72
|
|
|
|
73
|
|
|
@pytest.mark.level(2) |
74
|
|
|
def test_get_insert_buffer_size_invalid_parent_key(self, connect, collection): |
75
|
|
|
''' |
76
|
|
|
target: get invalid parent key |
77
|
|
|
method: call get_config without parent_key: cache |
78
|
|
|
expected: status not ok |
79
|
|
|
''' |
80
|
|
|
invalid_configs = ["Cache_config", "cache config", "cache_Config", "cacheconfig"] |
81
|
|
|
for config in invalid_configs: |
82
|
|
|
with pytest.raises(Exception) as e: |
83
|
|
|
config_value = connect.get_config(config + ".insert_buffer_size") |
84
|
|
|
|
85
|
|
|
@pytest.mark.level(2) |
86
|
|
|
def test_get_insert_buffer_size_invalid_child_key(self, connect, collection): |
87
|
|
|
''' |
88
|
|
|
target: get invalid child key |
89
|
|
|
method: call get_config without child_key: insert_buffer_size |
90
|
|
|
expected: status not ok |
91
|
|
|
''' |
92
|
|
|
invalid_configs = ["Insert_buffer size", "insert buffer_size", "insertbuffersize"] |
93
|
|
|
for config in invalid_configs: |
94
|
|
|
with pytest.raises(Exception) as e: |
95
|
|
|
config_value = connect.get_config("cache." + config) |
96
|
|
|
|
97
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
98
|
|
|
def test_get_insert_buffer_size_valid(self, connect, collection): |
99
|
|
|
''' |
100
|
|
|
target: get insert_buffer_size |
101
|
|
|
method: call get_config correctly |
102
|
|
|
expected: status ok |
103
|
|
|
''' |
104
|
|
|
config_value = connect.get_config("cache.insert_buffer_size") |
105
|
|
|
assert config_value |
106
|
|
|
|
107
|
|
|
@pytest.mark.level(2) |
108
|
|
|
def test_get_preload_collection_invalid_child_key(self, connect, collection): |
109
|
|
|
''' |
110
|
|
|
target: get invalid child key |
111
|
|
|
method: call get_config without child_key: preload_collection |
112
|
|
|
expected: status not ok |
113
|
|
|
''' |
114
|
|
|
invalid_configs = ["preloadtable", "preload collection "] |
115
|
|
|
for config in invalid_configs: |
116
|
|
|
with pytest.raises(Exception) as e: |
117
|
|
|
config_value = connect.get_config("cache." + config) |
118
|
|
|
|
119
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
120
|
|
|
def test_get_preload_collection_valid(self, connect, collection): |
121
|
|
|
''' |
122
|
|
|
target: get preload_collection |
123
|
|
|
method: call get_config correctly |
124
|
|
|
expected: status ok |
125
|
|
|
''' |
126
|
|
|
config_value = connect.get_config("cache.preload_collection") |
127
|
|
|
assert config_value == '' |
128
|
|
|
|
129
|
|
|
""" |
130
|
|
|
****************************************************************** |
131
|
|
|
The following cases are used to test `set_config` function |
132
|
|
|
****************************************************************** |
133
|
|
|
""" |
134
|
|
|
|
135
|
|
|
def get_memory_available(self, connect): |
136
|
|
|
info = connect._cmd("get_system_info") |
137
|
|
|
mem_info = ujson.loads(info) |
138
|
|
|
mem_total = int(mem_info["memory_total"]) |
139
|
|
|
mem_used = int(mem_info["memory_used"]) |
140
|
|
|
logging.getLogger().info(mem_total) |
141
|
|
|
logging.getLogger().info(mem_used) |
142
|
|
|
mem_available = mem_total - mem_used |
143
|
|
|
return int(mem_available / 1024 / 1024 / 1024) |
144
|
|
|
|
145
|
|
|
def get_memory_total(self, connect): |
146
|
|
|
info = connect._cmd("get_system_info") |
147
|
|
|
mem_info = ujson.loads(info) |
148
|
|
|
mem_total = int(mem_info["memory_total"]) |
149
|
|
|
return int(mem_total / 1024 / 1024 / 1024) |
150
|
|
|
|
151
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
152
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
153
|
|
|
def test_set_cache_size_invalid_parent_key(self, connect, collection): |
154
|
|
|
''' |
155
|
|
|
target: set invalid parent key |
156
|
|
|
method: call set_config without parent_key: cache |
157
|
|
|
expected: status not ok |
158
|
|
|
''' |
159
|
|
|
self.reset_configs(connect) |
160
|
|
|
invalid_configs = ["Cache_config", "cache config", "cache_Config", "cacheconfig"] |
161
|
|
|
for config in invalid_configs: |
162
|
|
|
with pytest.raises(Exception) as e: |
163
|
|
|
relpy = connect.set_config(config + ".cache_size", '4294967296') |
164
|
|
|
|
165
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
166
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
167
|
|
|
def test_set_cache_invalid_child_key(self, connect, collection): |
168
|
|
|
''' |
169
|
|
|
target: set invalid child key |
170
|
|
|
method: call set_config with invalid child_key |
171
|
|
|
expected: status not ok |
172
|
|
|
''' |
173
|
|
|
self.reset_configs(connect) |
174
|
|
|
invalid_configs = ["abc", 1] |
175
|
|
|
for config in invalid_configs: |
176
|
|
|
with pytest.raises(Exception) as e: |
177
|
|
|
relpy = connect.set_config("cache." + config, '4294967296') |
178
|
|
|
|
179
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
180
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
181
|
|
|
def test_set_cache_size_valid(self, connect, collection): |
182
|
|
|
''' |
183
|
|
|
target: set cache_size |
184
|
|
|
method: call set_config correctly |
185
|
|
|
expected: status ok, set successfully |
186
|
|
|
''' |
187
|
|
|
self.reset_configs(connect) |
188
|
|
|
relpy = connect.set_config("cache.cache_size", '2147483648') |
189
|
|
|
config_value = connect.get_config("cache.cache_size") |
190
|
|
|
assert config_value == '2GB' |
191
|
|
|
|
192
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
193
|
|
|
@pytest.mark.level(2) |
194
|
|
|
def test_set_cache_size_valid_multiple_times(self, connect, collection): |
195
|
|
|
''' |
196
|
|
|
target: set cache_size |
197
|
|
|
method: call set_config correctly and repeatedly |
198
|
|
|
expected: status ok |
199
|
|
|
''' |
200
|
|
|
self.reset_configs(connect) |
201
|
|
|
for i in range(20): |
202
|
|
|
relpy = connect.set_config("cache.cache_size", '4294967296') |
203
|
|
|
config_value = connect.get_config("cache.cache_size") |
204
|
|
|
assert config_value == '4294967296' |
205
|
|
|
for i in range(20): |
206
|
|
|
relpy = connect.set_config("cache.cache_size", '2147483648') |
207
|
|
|
config_value = connect.get_config("cache.cache_size") |
208
|
|
|
assert config_value == '2147483648' |
209
|
|
|
|
210
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
211
|
|
|
@pytest.mark.level(2) |
212
|
|
|
def test_set_insert_buffer_size_invalid_parent_key(self, connect, collection): |
213
|
|
|
''' |
214
|
|
|
target: set invalid parent key |
215
|
|
|
method: call set_config without parent_key: cache |
216
|
|
|
expected: status not ok |
217
|
|
|
''' |
218
|
|
|
self.reset_configs(connect) |
219
|
|
|
invalid_configs = ["Cache_config", "cache config", "cache_Config", "cacheconfig"] |
220
|
|
|
for config in invalid_configs: |
221
|
|
|
with pytest.raises(Exception) as e: |
222
|
|
|
relpy = connect.set_config(config + ".insert_buffer_size", '1073741824') |
223
|
|
|
|
224
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
225
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
226
|
|
|
def test_set_insert_buffer_size_valid(self, connect, collection): |
227
|
|
|
''' |
228
|
|
|
target: set insert_buffer_size |
229
|
|
|
method: call get_config correctly |
230
|
|
|
expected: status ok, set successfully |
231
|
|
|
''' |
232
|
|
|
self.reset_configs(connect) |
233
|
|
|
relpy = connect.set_config("cache.insert_buffer_size", '2GB') |
234
|
|
|
|
235
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
236
|
|
|
@pytest.mark.level(2) |
237
|
|
|
def test_set_insert_buffer_size_valid_multiple_times(self, connect, collection): |
238
|
|
|
''' |
239
|
|
|
target: set insert_buffer_size |
240
|
|
|
method: call get_config correctly and repeatedly |
241
|
|
|
expected: status ok |
242
|
|
|
''' |
243
|
|
|
self.reset_configs(connect) |
244
|
|
|
for i in range(20): |
245
|
|
|
with pytest.raises(Exception) as e: |
246
|
|
|
relpy = connect.set_config("cache.insert_buffer_size", '1GB') |
247
|
|
|
for i in range(20): |
248
|
|
|
with pytest.raises(Exception) as e: |
249
|
|
|
relpy = connect.set_config("cache.insert_buffer_size", '2GB') |
250
|
|
|
|
251
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
252
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
253
|
|
|
def test_set_cache_out_of_memory_value_A(self, connect, collection): |
254
|
|
|
''' |
255
|
|
|
target: set cache_size / insert_buffer_size to be out-of-memory |
256
|
|
|
method: call set_config with child values bigger than current system memory |
257
|
|
|
expected: status not ok (cache_size + insert_buffer_size < system memory) |
258
|
|
|
''' |
259
|
|
|
self.reset_configs(connect) |
260
|
|
|
mem_total = self.get_memory_total(connect) |
261
|
|
|
logging.getLogger().info(mem_total) |
262
|
|
|
with pytest.raises(Exception) as e: |
263
|
|
|
relpy = connect.set_config("cache.cache_size", str(int(mem_total + 1) + '')) |
264
|
|
|
|
265
|
|
|
|
266
|
|
|
class TestGPUConfig: |
267
|
|
|
""" |
268
|
|
|
****************************************************************** |
269
|
|
|
The following cases are used to test `get_config` function |
270
|
|
|
****************************************************************** |
271
|
|
|
""" |
272
|
|
|
|
273
|
|
|
@pytest.fixture(scope="function", autouse=True) |
274
|
|
|
def skip_http_check(self, args): |
275
|
|
|
if args["handler"] == "HTTP": |
276
|
|
|
pytest.skip("skip in http mode") |
277
|
|
|
|
278
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
279
|
|
|
def test_get_gpu_search_threshold_invalid_parent_key(self, connect, collection): |
280
|
|
|
''' |
281
|
|
|
target: get invalid parent key |
282
|
|
|
method: call get_config without parent_key: gpu |
283
|
|
|
expected: status not ok |
284
|
|
|
''' |
285
|
|
|
if str(connect._cmd("mode")) == "CPU": |
286
|
|
|
pytest.skip("Only support GPU mode") |
287
|
|
|
invalid_configs = ["Engine_config", "engine config"] |
288
|
|
|
for config in invalid_configs: |
289
|
|
|
with pytest.raises(Exception) as e: |
290
|
|
|
config_value = connect.get_config(config + ".gpu_search_threshold") |
291
|
|
|
|
292
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
293
|
|
|
def test_get_gpu_search_threshold_invalid_child_key(self, connect, collection): |
294
|
|
|
''' |
295
|
|
|
target: get invalid child key |
296
|
|
|
method: call get_config without child_key: gpu_search_threshold |
297
|
|
|
expected: status not ok |
298
|
|
|
''' |
299
|
|
|
if str(connect._cmd("mode")) == "CPU": |
300
|
|
|
pytest.skip("Only support GPU mode") |
301
|
|
|
invalid_configs = ["Gpu_search threshold", "gpusearchthreshold"] |
302
|
|
|
for config in invalid_configs: |
303
|
|
|
with pytest.raises(Exception) as e: |
304
|
|
|
config_value = connect.get_config("gpu." + config) |
305
|
|
|
|
306
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
307
|
|
|
def test_get_gpu_search_threshold_valid(self, connect, collection): |
308
|
|
|
''' |
309
|
|
|
target: get gpu_search_threshold |
310
|
|
|
method: call get_config correctly |
311
|
|
|
expected: status ok |
312
|
|
|
''' |
313
|
|
|
if str(connect._cmd("mode")) == "CPU": |
314
|
|
|
pytest.skip("Only support GPU mode") |
315
|
|
|
config_value = connect.get_config("gpu.gpu_search_threshold") |
316
|
|
|
assert config_value |
317
|
|
|
|
318
|
|
|
""" |
319
|
|
|
****************************************************************** |
320
|
|
|
The following cases are used to test `set_config` function |
321
|
|
|
****************************************************************** |
322
|
|
|
""" |
323
|
|
|
|
324
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
325
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
326
|
|
|
def test_set_gpu_invalid_child_key(self, connect, collection): |
327
|
|
|
''' |
328
|
|
|
target: set invalid child key |
329
|
|
|
method: call set_config with invalid child_key |
330
|
|
|
expected: status not ok |
331
|
|
|
''' |
332
|
|
|
invalid_configs = ["abc", 1] |
333
|
|
|
for config in invalid_configs: |
334
|
|
|
with pytest.raises(Exception) as e: |
335
|
|
|
relpy = connect.set_config("gpu." + config, 1000) |
336
|
|
|
|
337
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
338
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
339
|
|
|
def test_set_gpu_search_threshold_invalid_parent_key(self, connect, collection): |
340
|
|
|
''' |
341
|
|
|
target: set invalid parent key |
342
|
|
|
method: call set_config without parent_key: gpu |
343
|
|
|
expected: status not ok |
344
|
|
|
''' |
345
|
|
|
if str(connect._cmd("mode")) == "CPU": |
346
|
|
|
pytest.skip("Only support GPU mode") |
347
|
|
|
invalid_configs = ["Engine_config", "engine config"] |
348
|
|
|
for config in invalid_configs: |
349
|
|
|
with pytest.raises(Exception) as e: |
350
|
|
|
relpy = connect.set_config(config + ".gpu_search_threshold", 1000) |
351
|
|
|
|
352
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
353
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
354
|
|
|
def test_set_gpu_search_threshold_valid(self, connect, collection): |
355
|
|
|
''' |
356
|
|
|
target: set gpu_search_threshold |
357
|
|
|
method: call set_config correctly |
358
|
|
|
expected: status ok |
359
|
|
|
''' |
360
|
|
|
if str(connect._cmd("mode")) == "CPU": |
361
|
|
|
pytest.skip("Only support GPU mode") |
362
|
|
|
relpy = connect.set_config("gpu.gpu_search_threshold", 2000) |
363
|
|
|
config_value = connect.get_config("gpu.gpu_search_threshold") |
364
|
|
|
assert config_value == '2000' |
365
|
|
|
|
366
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
367
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
368
|
|
|
def test_set_gpu_invalid_values(self, connect, collection): |
369
|
|
|
''' |
370
|
|
|
target: set gpu |
371
|
|
|
method: call set_config with invalid child values |
372
|
|
|
expected: status not ok |
373
|
|
|
''' |
374
|
|
|
for i in [-1, "1000\n", "1000\t", "1000.0", 1000.35]: |
375
|
|
|
with pytest.raises(Exception) as e: |
376
|
|
|
relpy = connect.set_config("gpu.use_blas_threshold", i) |
377
|
|
|
if str(connect._cmd("mode")) == "GPU": |
378
|
|
|
with pytest.raises(Exception) as e: |
379
|
|
|
relpy = connect.set_config("gpu.gpu_search_threshold", i) |
380
|
|
|
|
381
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
382
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
383
|
|
|
def reset_configs(self, connect): |
384
|
|
|
''' |
385
|
|
|
reset configs so the tests are stable |
386
|
|
|
''' |
387
|
|
|
relpy = connect.set_config("gpu.cache_size", 1) |
388
|
|
|
config_value = connect.get_config("gpu.cache_size") |
389
|
|
|
assert config_value == '1' |
390
|
|
|
|
391
|
|
|
# follows can not be changed |
392
|
|
|
# relpy = connect.set_config("gpu", "enable", "true") |
393
|
|
|
# config_value = connect.get_config("gpu", "enable") |
394
|
|
|
# assert config_value == "true" |
395
|
|
|
# relpy = connect.set_config("gpu", "search_devices", "gpu0") |
396
|
|
|
# config_value = connect.get_config("gpu", "search_devices") |
397
|
|
|
# assert config_value == 'gpu0' |
398
|
|
|
# relpy = connect.set_config("gpu", "build_index_devices", "gpu0") |
399
|
|
|
# config_value = connect.get_config("gpu", "build_index_devices") |
400
|
|
|
# assert config_value == 'gpu0' |
401
|
|
|
|
402
|
|
View Code Duplication |
@pytest.mark.timeout(CONFIG_TIMEOUT) |
|
|
|
|
403
|
|
|
def test_get_gpu_enable_invalid_parent_key(self, connect, collection): |
404
|
|
|
''' |
405
|
|
|
target: get invalid parent key |
406
|
|
|
method: call get_config without parent_key: gpu |
407
|
|
|
expected: status not ok |
408
|
|
|
''' |
409
|
|
|
if str(connect._cmd("mode")) == "CPU": |
410
|
|
|
pytest.skip("Only support GPU mode") |
411
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
412
|
|
|
"gpu_resource"] |
413
|
|
|
for config in invalid_configs: |
414
|
|
|
with pytest.raises(Exception) as e: |
415
|
|
|
config_value = connect.get_config(config + ".enable") |
416
|
|
|
|
417
|
|
View Code Duplication |
@pytest.mark.timeout(CONFIG_TIMEOUT) |
|
|
|
|
418
|
|
|
def test_get_gpu_enable_invalid_child_key(self, connect, collection): |
419
|
|
|
''' |
420
|
|
|
target: get invalid child key |
421
|
|
|
method: call get_config without child_key: enable |
422
|
|
|
expected: status not ok |
423
|
|
|
''' |
424
|
|
|
if str(connect._cmd("mode")) == "CPU": |
425
|
|
|
pytest.skip("Only support GPU mode") |
426
|
|
|
invalid_configs = ["Enab_le", "enab_le ", "disable", "true"] |
427
|
|
|
for config in invalid_configs: |
428
|
|
|
with pytest.raises(Exception) as e: |
429
|
|
|
config_value = connect.get_config("gpu." + config) |
430
|
|
|
|
431
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
432
|
|
|
def test_get_gpu_enable_valid(self, connect, collection): |
433
|
|
|
''' |
434
|
|
|
target: get enable status |
435
|
|
|
method: call get_config correctly |
436
|
|
|
expected: status ok |
437
|
|
|
''' |
438
|
|
|
if str(connect._cmd("mode")) == "CPU": |
439
|
|
|
pytest.skip("Only support GPU mode") |
440
|
|
|
config_value = connect.get_config("gpu.enable") |
441
|
|
|
assert config_value == "true" or config_value == "false" |
442
|
|
|
|
443
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
444
|
|
|
def test_get_cache_size_invalid_parent_key(self, connect, collection): |
445
|
|
|
''' |
446
|
|
|
target: get invalid parent key |
447
|
|
|
method: call get_config without parent_key: gpu |
448
|
|
|
expected: status not ok |
449
|
|
|
''' |
450
|
|
|
if str(connect._cmd("mode")) == "CPU": |
451
|
|
|
pytest.skip("Only support GPU mode") |
452
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
453
|
|
|
"gpu_resource"] |
454
|
|
|
for config in invalid_configs: |
455
|
|
|
with pytest.raises(Exception) as e: |
456
|
|
|
config_value = connect.get_config(config + ".cache_size") |
457
|
|
|
|
458
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
459
|
|
|
def test_get_cache_size_invalid_child_key(self, connect, collection): |
460
|
|
|
''' |
461
|
|
|
target: get invalid child key |
462
|
|
|
method: call get_config without child_key: cache_size |
463
|
|
|
expected: status not ok |
464
|
|
|
''' |
465
|
|
|
if str(connect._cmd("mode")) == "CPU": |
466
|
|
|
pytest.skip("Only support GPU mode") |
467
|
|
|
invalid_configs = ["Cache_capacity", "cachecapacity"] |
468
|
|
|
for config in invalid_configs: |
469
|
|
|
with pytest.raises(Exception) as e: |
470
|
|
|
config_value = connect.get_config("gpu." + config) |
471
|
|
|
|
472
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
473
|
|
|
def test_get_cache_size_valid(self, connect, collection): |
474
|
|
|
''' |
475
|
|
|
target: get cache_size |
476
|
|
|
method: call get_config correctly |
477
|
|
|
expected: status ok |
478
|
|
|
''' |
479
|
|
|
if str(connect._cmd("mode")) == "CPU": |
480
|
|
|
pytest.skip("Only support GPU mode") |
481
|
|
|
config_value = connect.get_config("gpu.cache_size") |
482
|
|
|
|
483
|
|
View Code Duplication |
@pytest.mark.timeout(CONFIG_TIMEOUT) |
|
|
|
|
484
|
|
|
def test_get_search_devices_invalid_parent_key(self, connect, collection): |
485
|
|
|
''' |
486
|
|
|
target: get invalid parent key |
487
|
|
|
method: call get_config without parent_key: gpu |
488
|
|
|
expected: status not ok |
489
|
|
|
''' |
490
|
|
|
if str(connect._cmd("mode")) == "CPU": |
491
|
|
|
pytest.skip("Only support GPU mode") |
492
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
493
|
|
|
"gpu_resource"] |
494
|
|
|
for config in invalid_configs: |
495
|
|
|
with pytest.raises(Exception) as e: |
496
|
|
|
config_value = connect.get_config(config + ".search_devices") |
497
|
|
|
|
498
|
|
View Code Duplication |
@pytest.mark.timeout(CONFIG_TIMEOUT) |
|
|
|
|
499
|
|
|
def test_get_search_devices_invalid_child_key(self, connect, collection): |
500
|
|
|
''' |
501
|
|
|
target: get invalid child key |
502
|
|
|
method: call get_config without child_key: search_devices |
503
|
|
|
expected: status not ok |
504
|
|
|
''' |
505
|
|
|
if str(connect._cmd("mode")) == "CPU": |
506
|
|
|
pytest.skip("Only support GPU mode") |
507
|
|
|
invalid_configs = ["Search_resources"] |
508
|
|
|
for config in invalid_configs: |
509
|
|
|
with pytest.raises(Exception) as e: |
510
|
|
|
config_value = connect.get_config("gpu." + config) |
511
|
|
|
|
512
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
513
|
|
|
def test_get_search_devices_valid(self, connect, collection): |
514
|
|
|
''' |
515
|
|
|
target: get search_devices |
516
|
|
|
method: call get_config correctly |
517
|
|
|
expected: status ok |
518
|
|
|
''' |
519
|
|
|
if str(connect._cmd("mode")) == "CPU": |
520
|
|
|
pytest.skip("Only support GPU mode") |
521
|
|
|
config_value = connect.get_config("gpu.search_devices") |
522
|
|
|
logging.getLogger().info(config_value) |
523
|
|
|
|
524
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
525
|
|
|
def test_get_build_index_devices_invalid_parent_key(self, connect, collection): |
526
|
|
|
''' |
527
|
|
|
target: get invalid parent key |
528
|
|
|
method: call get_config without parent_key: gpu |
529
|
|
|
expected: status not ok |
530
|
|
|
''' |
531
|
|
|
if str(connect._cmd("mode")) == "CPU": |
532
|
|
|
pytest.skip("Only support GPU mode") |
533
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
534
|
|
|
"gpu_resource"] |
535
|
|
|
for config in invalid_configs: |
536
|
|
|
with pytest.raises(Exception) as e: |
537
|
|
|
config_value = connect.get_config(config + ".build_index_devices") |
538
|
|
|
|
539
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
540
|
|
|
def test_get_build_index_devices_invalid_child_key(self, connect, collection): |
541
|
|
|
''' |
542
|
|
|
target: get invalid child key |
543
|
|
|
method: call get_config without child_key: build_index_devices |
544
|
|
|
expected: status not ok |
545
|
|
|
''' |
546
|
|
|
if str(connect._cmd("mode")) == "CPU": |
547
|
|
|
pytest.skip("Only support GPU mode") |
548
|
|
|
invalid_configs = ["Build_index_resources"] |
549
|
|
|
for config in invalid_configs: |
550
|
|
|
with pytest.raises(Exception) as e: |
551
|
|
|
config_value = connect.get_config("gpu." + config) |
552
|
|
|
|
553
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
554
|
|
|
def test_get_build_index_devices_valid(self, connect, collection): |
555
|
|
|
''' |
556
|
|
|
target: get build_index_devices |
557
|
|
|
method: call get_config correctly |
558
|
|
|
expected: status ok |
559
|
|
|
''' |
560
|
|
|
if str(connect._cmd("mode")) == "CPU": |
561
|
|
|
pytest.skip("Only support GPU mode") |
562
|
|
|
config_value = connect.get_config("gpu.build_index_devices") |
563
|
|
|
logging.getLogger().info(config_value) |
564
|
|
|
assert config_value |
565
|
|
|
|
566
|
|
|
""" |
567
|
|
|
****************************************************************** |
568
|
|
|
The following cases are used to test `set_config` function |
569
|
|
|
****************************************************************** |
570
|
|
|
""" |
571
|
|
|
|
572
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
573
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
574
|
|
|
def test_set_gpu_enable_invalid_parent_key(self, connect, collection): |
575
|
|
|
''' |
576
|
|
|
target: set invalid parent key |
577
|
|
|
method: call set_config without parent_key: gpu |
578
|
|
|
expected: status not ok |
579
|
|
|
''' |
580
|
|
|
if str(connect._cmd("mode")) == "CPU": |
581
|
|
|
pytest.skip("Only support GPU mode") |
582
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
583
|
|
|
"gpu_resource"] |
584
|
|
|
for config in invalid_configs: |
585
|
|
|
with pytest.raises(Exception) as e: |
586
|
|
|
relpy = connect.set_config(config + ".enable", "true") |
587
|
|
|
|
588
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
589
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
590
|
|
|
def test_set_gpu_invalid_child_key(self, connect, collection): |
591
|
|
|
''' |
592
|
|
|
target: set invalid child key |
593
|
|
|
method: call set_config with invalid child_key |
594
|
|
|
expected: status not ok |
595
|
|
|
''' |
596
|
|
|
if str(connect._cmd("mode")) == "CPU": |
597
|
|
|
pytest.skip("Only support GPU mode") |
598
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
599
|
|
|
"gpu_resource"] |
600
|
|
|
for config in invalid_configs: |
601
|
|
|
with pytest.raises(Exception) as e: |
602
|
|
|
relpy = connect.set_config("gpu." + config, "true") |
603
|
|
|
|
604
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
605
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
606
|
|
|
def test_set_gpu_enable_invalid_values(self, connect, collection): |
607
|
|
|
''' |
608
|
|
|
target: set "enable" param |
609
|
|
|
method: call set_config with invalid child values |
610
|
|
|
expected: status not ok |
611
|
|
|
''' |
612
|
|
|
if str(connect._cmd("mode")) == "CPU": |
613
|
|
|
pytest.skip("Only support GPU mode") |
614
|
|
|
for i in [-1, -2, 100]: |
615
|
|
|
with pytest.raises(Exception) as e: |
616
|
|
|
relpy = connect.set_config("gpu.enable", i) |
617
|
|
|
|
618
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
619
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
620
|
|
|
def test_set_gpu_enable_valid(self, connect, collection): |
621
|
|
|
''' |
622
|
|
|
target: set "enable" param |
623
|
|
|
method: call set_config correctly |
624
|
|
|
expected: status ok |
625
|
|
|
''' |
626
|
|
|
if str(connect._cmd("mode")) == "CPU": |
627
|
|
|
pytest.skip("Only support GPU mode") |
628
|
|
|
valid_configs = ["off", "False", "0", "nO", "on", "True", 1, "yES"] |
629
|
|
|
for config in valid_configs: |
630
|
|
|
with pytest.raises(Exception) as e: |
631
|
|
|
relpy = connect.set_config("gpu.enable", config) |
632
|
|
|
|
633
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
634
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
635
|
|
|
def test_set_cache_size_invalid_parent_key(self, connect, collection): |
636
|
|
|
''' |
637
|
|
|
target: set invalid parent key |
638
|
|
|
method: call set_config without parent_key: gpu |
639
|
|
|
expected: status not ok |
640
|
|
|
''' |
641
|
|
|
if str(connect._cmd("mode")) == "CPU": |
642
|
|
|
pytest.skip("Only support GPU mode") |
643
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
644
|
|
|
"gpu_resource"] |
645
|
|
|
for config in invalid_configs: |
646
|
|
|
with pytest.raises(Exception) as e: |
647
|
|
|
relpy = connect.set_config(config + ".cache_size", 2) |
648
|
|
|
|
649
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
650
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
651
|
|
|
def test_set_cache_size_valid(self, connect, collection): |
652
|
|
|
''' |
653
|
|
|
target: set cache_size |
654
|
|
|
method: call set_config correctly |
655
|
|
|
expected: status ok |
656
|
|
|
''' |
657
|
|
|
if str(connect._cmd("mode")) == "CPU": |
658
|
|
|
pytest.skip("Only support GPU mode") |
659
|
|
|
relpy = connect.set_config("gpu.cache_size", 2) |
660
|
|
|
|
661
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
662
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
663
|
|
|
def test_set_cache_size_invalid_values(self, connect, collection): |
664
|
|
|
''' |
665
|
|
|
target: set cache_size |
666
|
|
|
method: call set_config with invalid child values |
667
|
|
|
expected: status not ok |
668
|
|
|
''' |
669
|
|
|
if str(connect._cmd("mode")) == "CPU": |
670
|
|
|
pytest.skip("Only support GPU mode") |
671
|
|
|
self.reset_configs(connect) |
672
|
|
|
for i in [-1, "1\n", "1\t"]: |
673
|
|
|
logging.getLogger().info(i) |
674
|
|
|
with pytest.raises(Exception) as e: |
675
|
|
|
relpy = connect.set_config("gpu", "cache_size", i) |
676
|
|
|
|
677
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
678
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
679
|
|
|
def test_set_search_devices_invalid_parent_key(self, connect, collection): |
680
|
|
|
''' |
681
|
|
|
target: set invalid parent key |
682
|
|
|
method: call set_config without parent_key: gpu |
683
|
|
|
expected: status not ok |
684
|
|
|
''' |
685
|
|
|
if str(connect._cmd("mode")) == "CPU": |
686
|
|
|
pytest.skip("Only support GPU mode") |
687
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
688
|
|
|
"gpu_resource"] |
689
|
|
|
for config in invalid_configs: |
690
|
|
|
with pytest.raises(Exception) as e: |
691
|
|
|
relpy = connect.set_config(config, "search_devices", "gpu0") |
692
|
|
|
|
693
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
694
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
695
|
|
|
def test_set_search_devices_valid(self, connect, collection): |
696
|
|
|
''' |
697
|
|
|
target: set search_devices |
698
|
|
|
method: call set_config correctly |
699
|
|
|
expected: status ok |
700
|
|
|
''' |
701
|
|
|
if str(connect._cmd("mode")) == "CPU": |
702
|
|
|
pytest.skip("Only support GPU mode") |
703
|
|
|
with pytest.raises(Exception) as e: |
704
|
|
|
relpy = connect.set_config("gpu", "search_devices", "gpu0") |
705
|
|
|
|
706
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
707
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
708
|
|
|
def test_set_search_devices_invalid_values(self, connect, collection): |
709
|
|
|
''' |
710
|
|
|
target: set search_devices |
711
|
|
|
method: call set_config with invalid child values |
712
|
|
|
expected: status not ok |
713
|
|
|
''' |
714
|
|
|
if str(connect._cmd("mode")) == "CPU": |
715
|
|
|
pytest.skip("Only support GPU mode") |
716
|
|
|
for i in [-1, "10", "gpu-1", "gpu0, gpu1", "gpu22,gpu44", "gpu10000", "gpu 0", "-gpu0"]: |
717
|
|
|
with pytest.raises(Exception) as e: |
718
|
|
|
relpy = connect.set_config("gpu", "search_devices", i) |
719
|
|
|
|
720
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
721
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
722
|
|
|
def test_set_build_index_devices_invalid_parent_key(self, connect, collection): |
723
|
|
|
''' |
724
|
|
|
target: set invalid parent key |
725
|
|
|
method: call set_config without parent_key: gpu |
726
|
|
|
expected: status not ok |
727
|
|
|
''' |
728
|
|
|
if str(connect._cmd("mode")) == "CPU": |
729
|
|
|
pytest.skip("Only support GPU mode") |
730
|
|
|
invalid_configs = ["Gpu_resource_config", "gpu resource config", \ |
731
|
|
|
"gpu_resource"] |
732
|
|
|
for config in invalid_configs: |
733
|
|
|
with pytest.raises(Exception) as e: |
734
|
|
|
relpy = connect.set_config(config, "build_index_devices", "gpu0") |
735
|
|
|
|
736
|
|
View Code Duplication |
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
|
|
|
|
737
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
738
|
|
|
def test_set_build_index_devices_valid(self, connect, collection): |
739
|
|
|
''' |
740
|
|
|
target: set build_index_devices |
741
|
|
|
method: call set_config correctly |
742
|
|
|
expected: status ok |
743
|
|
|
''' |
744
|
|
|
if str(connect._cmd("mode")) == "CPU": |
745
|
|
|
pytest.skip("Only support GPU mode") |
746
|
|
|
with pytest.raises(Exception) as e: |
747
|
|
|
relpy = connect.set_config("gpu", "build_index_devices", "gpu0") |
748
|
|
|
|
749
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
750
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
751
|
|
|
def test_set_build_index_devices_invalid_values(self, connect, collection): |
752
|
|
|
''' |
753
|
|
|
target: set build_index_devices |
754
|
|
|
method: call set_config with invalid child values |
755
|
|
|
expected: status not ok |
756
|
|
|
''' |
757
|
|
|
if str(connect._cmd("mode")) == "CPU": |
758
|
|
|
pytest.skip("Only support GPU mode") |
759
|
|
|
for i in [-1, "10", "gpu-1", "gpu0, gpu1", "gpu22,gpu44", "gpu10000", "gpu 0", "-gpu0"]: |
760
|
|
|
with pytest.raises(Exception) as e: |
761
|
|
|
relpy = connect.set_config("gpu", "build_index_devices", i) |
762
|
|
|
self.reset_configs(connect) |
763
|
|
|
|
764
|
|
|
|
765
|
|
|
class TestNetworkConfig: |
766
|
|
|
""" |
767
|
|
|
****************************************************************** |
768
|
|
|
The following cases are used to test `get_config` function |
769
|
|
|
****************************************************************** |
770
|
|
|
""" |
771
|
|
|
|
772
|
|
|
@pytest.fixture(scope="function", autouse=True) |
773
|
|
|
def skip_http_check(self, args): |
774
|
|
|
if args["handler"] == "HTTP": |
775
|
|
|
pytest.skip("skip in http mode") |
776
|
|
|
|
777
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
778
|
|
|
def test_get_address_invalid_child_key(self, connect, collection): |
779
|
|
|
''' |
780
|
|
|
target: get invalid child key |
781
|
|
|
method: call get_config without child_key: address |
782
|
|
|
expected: status not ok |
783
|
|
|
''' |
784
|
|
|
invalid_configs = ["Address", "addresses", "address "] |
785
|
|
|
for config in invalid_configs: |
786
|
|
|
with pytest.raises(Exception) as e: |
787
|
|
|
config_value = connect.get_config("network." + config) |
788
|
|
|
|
789
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
790
|
|
|
def test_get_address_valid(self, connect, collection): |
791
|
|
|
''' |
792
|
|
|
target: get address |
793
|
|
|
method: call get_config correctly |
794
|
|
|
expected: status ok |
795
|
|
|
''' |
796
|
|
|
config_value = connect.get_config("network.bind.address") |
797
|
|
|
|
798
|
|
|
@pytest.mark.level(2) |
799
|
|
|
def test_get_port_invalid_child_key(self, connect, collection): |
800
|
|
|
''' |
801
|
|
|
target: get invalid child key |
802
|
|
|
method: call get_config without child_key: port |
803
|
|
|
expected: status not ok |
804
|
|
|
''' |
805
|
|
|
invalid_configs = ["Port", "PORT", "port "] |
806
|
|
|
for config in invalid_configs: |
807
|
|
|
with pytest.raises(Exception) as e: |
808
|
|
|
config_value = connect.get_config("network." + config) |
809
|
|
|
|
810
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
811
|
|
|
def test_get_port_valid(self, connect, collection): |
812
|
|
|
''' |
813
|
|
|
target: get port |
814
|
|
|
method: call get_config correctly |
815
|
|
|
expected: status ok |
816
|
|
|
''' |
817
|
|
|
config_value = connect.get_config("network.http.port") |
818
|
|
|
assert config_value |
819
|
|
|
|
820
|
|
|
@pytest.mark.level(2) |
821
|
|
|
def test_get_http_port_invalid_child_key(self, connect, collection): |
822
|
|
|
''' |
823
|
|
|
target: get invalid child key |
824
|
|
|
method: call get_config without child_key: http.port |
825
|
|
|
expected: status not ok |
826
|
|
|
''' |
827
|
|
|
invalid_configs = ["webport", "Web_port", "http port "] |
828
|
|
|
for config in invalid_configs: |
829
|
|
|
with pytest.raises(Exception) as e: |
830
|
|
|
config_value = connect.get_config("network." + config) |
831
|
|
|
|
832
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
833
|
|
|
def test_get_http_port_valid(self, connect, collection): |
834
|
|
|
''' |
835
|
|
|
target: get http.port |
836
|
|
|
method: call get_config correctly |
837
|
|
|
expected: status ok |
838
|
|
|
''' |
839
|
|
|
config_value = connect.get_config("network.http.port") |
840
|
|
|
assert config_value |
841
|
|
|
|
842
|
|
|
""" |
843
|
|
|
****************************************************************** |
844
|
|
|
The following cases are used to test `set_config` function |
845
|
|
|
****************************************************************** |
846
|
|
|
""" |
847
|
|
|
|
848
|
|
|
def gen_valid_timezones(self): |
849
|
|
|
timezones = [] |
850
|
|
|
for i in range(0, 13): |
851
|
|
|
timezones.append("UTC+" + str(i)) |
852
|
|
|
timezones.append("UTC-" + str(i)) |
853
|
|
|
timezones.extend(["UTC+13", "UTC+14"]) |
854
|
|
|
return timezones |
855
|
|
|
|
856
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
857
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
858
|
|
|
def test_set_network_invalid_child_key(self, connect, collection): |
859
|
|
|
''' |
860
|
|
|
target: set invalid child key |
861
|
|
|
method: call set_config with invalid child_key |
862
|
|
|
expected: status not ok |
863
|
|
|
''' |
864
|
|
|
with pytest.raises(Exception) as e: |
865
|
|
|
relpy = connect.set_config("network.child_key", 19530) |
866
|
|
|
|
867
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
868
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
869
|
|
|
def test_set_address_valid(self, connect, collection): |
870
|
|
|
''' |
871
|
|
|
target: set address |
872
|
|
|
method: call set_config correctly |
873
|
|
|
expected: status ok, set successfully |
874
|
|
|
''' |
875
|
|
|
relpy = connect.set_config("network.bind.address", '0.0.0.0') |
876
|
|
|
|
877
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
878
|
|
|
def test_set_port_valid(self, connect, collection): |
879
|
|
|
''' |
880
|
|
|
target: set port |
881
|
|
|
method: call set_config correctly |
882
|
|
|
expected: status ok, set successfully |
883
|
|
|
''' |
884
|
|
|
for valid_port in [1025, 65534, 12345, "19530"]: |
885
|
|
|
relpy = connect.set_config("network.http.port", valid_port) |
886
|
|
|
|
887
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
888
|
|
|
def test_set_port_invalid(self, connect, collection): |
889
|
|
|
''' |
890
|
|
|
target: set port |
891
|
|
|
method: call set_config with port number out of range(1024, 65535) |
892
|
|
|
expected: status not ok |
893
|
|
|
''' |
894
|
|
|
for invalid_port in [1024, 65535, "0", "True", "100000"]: |
895
|
|
|
logging.getLogger().info(invalid_port) |
896
|
|
|
with pytest.raises(Exception) as e: |
897
|
|
|
relpy = connect.set_config("network.http.port", invalid_port) |
898
|
|
|
|
899
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
900
|
|
|
def test_set_http_port_valid(self, connect, collection): |
901
|
|
|
''' |
902
|
|
|
target: set http.port |
903
|
|
|
method: call set_config correctly |
904
|
|
|
expected: status ok, set successfully |
905
|
|
|
''' |
906
|
|
|
for valid_http_port in [1025, 65534, "12345", 19121]: |
907
|
|
|
relpy = connect.set_config("network.http.port", valid_http_port) |
908
|
|
|
|
909
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
910
|
|
|
def test_set_http_port_invalid(self, connect, collection): |
911
|
|
|
''' |
912
|
|
|
target: set http.port |
913
|
|
|
method: call set_config with http.port number out of range(1024, 65535) |
914
|
|
|
expected: status not ok |
915
|
|
|
''' |
916
|
|
|
for invalid_http_port in [1024, 65535, "0", "True", "1000000"]: |
917
|
|
|
with pytest.raises(Exception) as e: |
918
|
|
|
relpy = connect.set_config("network.http.port", invalid_http_port) |
919
|
|
|
|
920
|
|
|
|
921
|
|
|
class TestGeneralConfig: |
922
|
|
|
""" |
923
|
|
|
****************************************************************** |
924
|
|
|
The following cases are used to test `get_config` function |
925
|
|
|
****************************************************************** |
926
|
|
|
""" |
927
|
|
|
|
928
|
|
|
@pytest.fixture(scope="function", autouse=True) |
929
|
|
|
def skip_http_check(self, args): |
930
|
|
|
if args["handler"] == "HTTP": |
931
|
|
|
pytest.skip("skip in http mode") |
932
|
|
|
|
933
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
934
|
|
|
def test_get_meta_uri_invalid_child_key(self, connect, collection): |
935
|
|
|
''' |
936
|
|
|
target: get invalid child key |
937
|
|
|
method: call get_config without child_key: meta_uri |
938
|
|
|
expected: status not ok |
939
|
|
|
''' |
940
|
|
|
invalid_configs = ["backend_Url", "backend-url", "meta uri "] |
941
|
|
|
for config in invalid_configs: |
942
|
|
|
with pytest.raises(Exception) as e: |
943
|
|
|
config_value = connect.get_config("general." + config) |
944
|
|
|
|
945
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
946
|
|
|
def test_get_meta_uri_valid(self, connect, collection): |
947
|
|
|
''' |
948
|
|
|
target: get meta_uri |
949
|
|
|
method: call get_config correctly |
950
|
|
|
expected: status ok |
951
|
|
|
''' |
952
|
|
|
config_value = connect.get_config("general.meta_uri") |
953
|
|
|
assert config_value |
954
|
|
|
|
955
|
|
|
@pytest.mark.level(2) |
956
|
|
|
def test_get_timezone_invalid_child_key(self, connect, collection): |
957
|
|
|
''' |
958
|
|
|
target: get invalid child key |
959
|
|
|
method: call get_config without child_key: timezone |
960
|
|
|
expected: status not ok |
961
|
|
|
''' |
962
|
|
|
invalid_configs = ["time", "time_zone "] |
963
|
|
|
for config in invalid_configs: |
964
|
|
|
with pytest.raises(Exception) as e: |
965
|
|
|
config_value = connect.get_config("general." + config) |
966
|
|
|
|
967
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
968
|
|
|
def test_get_timezone_valid(self, connect, collection): |
969
|
|
|
''' |
970
|
|
|
target: get timezone |
971
|
|
|
method: call get_config correctly |
972
|
|
|
expected: status ok |
973
|
|
|
''' |
974
|
|
|
config_value = connect.get_config("general.timezone") |
975
|
|
|
assert "UTC" in config_value |
976
|
|
|
|
977
|
|
|
""" |
978
|
|
|
****************************************************************** |
979
|
|
|
The following cases are used to test `set_config` function |
980
|
|
|
****************************************************************** |
981
|
|
|
""" |
982
|
|
|
|
983
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
984
|
|
|
def test_set_timezone_invalid(self, connect, collection): |
985
|
|
|
''' |
986
|
|
|
target: set timezone |
987
|
|
|
method: call set_config with invalid timezone |
988
|
|
|
expected: status not ok |
989
|
|
|
''' |
990
|
|
|
for invalid_timezone in ["utc++8", "UTC++8"]: |
991
|
|
|
logging.getLogger().info(invalid_timezone) |
992
|
|
|
with pytest.raises(Exception) as e: |
993
|
|
|
relpy = connect.set_config("general.timezone", invalid_timezone) |
994
|
|
|
|
995
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
996
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
997
|
|
|
def test_set_general_invalid_child_key(self, connect, collection): |
998
|
|
|
''' |
999
|
|
|
target: set invalid child key |
1000
|
|
|
method: call set_config with invalid child_key |
1001
|
|
|
expected: status not ok |
1002
|
|
|
''' |
1003
|
|
|
with pytest.raises(Exception) as e: |
1004
|
|
|
relpy = connect.set_config("general.child_key", 1) |
1005
|
|
|
|
1006
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1007
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1008
|
|
|
def test_set_meta_uri_valid(self, connect, collection): |
1009
|
|
|
''' |
1010
|
|
|
target: set meta_uri |
1011
|
|
|
method: call set_config correctly |
1012
|
|
|
expected: status ok, set successfully |
1013
|
|
|
''' |
1014
|
|
|
relpy = connect.set_config("general.meta_uri", 'sqlite://:@:/') |
1015
|
|
|
|
1016
|
|
|
|
1017
|
|
|
class TestStorageConfig: |
1018
|
|
|
""" |
1019
|
|
|
****************************************************************** |
1020
|
|
|
The following cases are used to test `get_config` function |
1021
|
|
|
****************************************************************** |
1022
|
|
|
""" |
1023
|
|
|
|
1024
|
|
|
@pytest.fixture(scope="function", autouse=True) |
1025
|
|
|
def skip_http_check(self, args): |
1026
|
|
|
if args["handler"] == "HTTP": |
1027
|
|
|
pytest.skip("skip in http mode") |
1028
|
|
|
|
1029
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1030
|
|
|
def test_get_path_invalid_child_key(self, connect, collection): |
1031
|
|
|
''' |
1032
|
|
|
target: get invalid child key |
1033
|
|
|
method: call get_config without child_key: path |
1034
|
|
|
expected: status not ok |
1035
|
|
|
''' |
1036
|
|
|
invalid_configs = ["Primary_path", "primarypath", "pa_th "] |
1037
|
|
|
for config in invalid_configs: |
1038
|
|
|
with pytest.raises(Exception) as e: |
1039
|
|
|
config_value = connect.get_config("storage." + config) |
1040
|
|
|
|
1041
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1042
|
|
|
def test_get_path_valid(self, connect, collection): |
1043
|
|
|
''' |
1044
|
|
|
target: get path |
1045
|
|
|
method: call get_config correctly |
1046
|
|
|
expected: status ok |
1047
|
|
|
''' |
1048
|
|
|
config_value = connect.get_config("storage.path") |
1049
|
|
|
assert config_value |
1050
|
|
|
|
1051
|
|
|
@pytest.mark.level(2) |
1052
|
|
|
def test_get_auto_flush_interval_invalid_child_key(self, connect, collection): |
1053
|
|
|
''' |
1054
|
|
|
target: get invalid child key |
1055
|
|
|
method: call get_config without child_key: auto_flush_interval |
1056
|
|
|
expected: status not ok |
1057
|
|
|
''' |
1058
|
|
|
invalid_configs = ["autoFlushInterval", "auto_flush", "auto_flush interval "] |
1059
|
|
|
for config in invalid_configs: |
1060
|
|
|
with pytest.raises(Exception) as e: |
1061
|
|
|
config_value = connect.get_config("storage." + config) |
1062
|
|
|
|
1063
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1064
|
|
|
def test_get_auto_flush_interval_valid(self, connect, collection): |
1065
|
|
|
''' |
1066
|
|
|
target: get auto_flush_interval |
1067
|
|
|
method: call get_config correctly |
1068
|
|
|
expected: status ok |
1069
|
|
|
''' |
1070
|
|
|
config_value = connect.get_config("storage.auto_flush_interval") |
1071
|
|
|
|
1072
|
|
|
""" |
1073
|
|
|
****************************************************************** |
1074
|
|
|
The following cases are used to test `set_config` function |
1075
|
|
|
****************************************************************** |
1076
|
|
|
""" |
1077
|
|
|
|
1078
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1079
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1080
|
|
|
def test_set_storage_invalid_child_key(self, connect, collection): |
1081
|
|
|
''' |
1082
|
|
|
target: set invalid child key |
1083
|
|
|
method: call set_config with invalid child_key |
1084
|
|
|
expected: status not ok |
1085
|
|
|
''' |
1086
|
|
|
with pytest.raises(Exception) as e: |
1087
|
|
|
relpy = connect.set_config("storage.child_key", "") |
1088
|
|
|
|
1089
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1090
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1091
|
|
|
def test_set_path_valid(self, connect, collection): |
1092
|
|
|
''' |
1093
|
|
|
target: set path |
1094
|
|
|
method: call set_config correctly |
1095
|
|
|
expected: status ok, set successfully |
1096
|
|
|
''' |
1097
|
|
|
relpy = connect.set_config("storage.path", '/var/lib/milvus') |
1098
|
|
|
|
1099
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1100
|
|
|
def test_set_auto_flush_interval_valid(self, connect, collection): |
1101
|
|
|
''' |
1102
|
|
|
target: set auto_flush_interval |
1103
|
|
|
method: call set_config correctly |
1104
|
|
|
expected: status ok, set successfully |
1105
|
|
|
''' |
1106
|
|
|
for valid_auto_flush_interval in [2, 1]: |
1107
|
|
|
logging.getLogger().info(valid_auto_flush_interval) |
1108
|
|
|
relpy = connect.set_config("storage.auto_flush_interval", valid_auto_flush_interval) |
1109
|
|
|
config_value = connect.get_config("storage.auto_flush_interval") |
1110
|
|
|
assert config_value == str(valid_auto_flush_interval) |
1111
|
|
|
|
1112
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1113
|
|
|
def test_set_auto_flush_interval_invalid(self, connect, collection): |
1114
|
|
|
''' |
1115
|
|
|
target: set auto_flush_interval |
1116
|
|
|
method: call set_config with invalid auto_flush_interval |
1117
|
|
|
expected: status not ok |
1118
|
|
|
''' |
1119
|
|
|
for invalid_auto_flush_interval in [-1, "1.5", "invalid", "1+2"]: |
1120
|
|
|
with pytest.raises(Exception) as e: |
1121
|
|
|
relpy = connect.set_config("storage.auto_flush_interval", invalid_auto_flush_interval) |
1122
|
|
|
|
1123
|
|
|
class TestWALConfig: |
1124
|
|
|
""" |
1125
|
|
|
****************************************************************** |
1126
|
|
|
The following cases are used to test `get_config` function |
1127
|
|
|
****************************************************************** |
1128
|
|
|
""" |
1129
|
|
|
|
1130
|
|
|
@pytest.fixture(scope="function", autouse=True) |
1131
|
|
|
def skip_http_check(self, args): |
1132
|
|
|
if args["handler"] == "HTTP": |
1133
|
|
|
pytest.skip("skip in http mode") |
1134
|
|
|
|
1135
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1136
|
|
|
def test_get_enable_invalid_child_key(self, connect, collection): |
1137
|
|
|
''' |
1138
|
|
|
target: get invalid child key |
1139
|
|
|
method: call get_config without child_key: enable |
1140
|
|
|
expected: status not ok |
1141
|
|
|
''' |
1142
|
|
|
invalid_configs = ["enabled", "Enab_le", "enable_"] |
1143
|
|
|
for config in invalid_configs: |
1144
|
|
|
with pytest.raises(Exception) as e: |
1145
|
|
|
config_value = connect.get_config("wal." + config) |
1146
|
|
|
|
1147
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1148
|
|
|
def test_get_enable_valid(self, connect, collection): |
1149
|
|
|
''' |
1150
|
|
|
target: get enable |
1151
|
|
|
method: call get_config correctly |
1152
|
|
|
expected: status ok |
1153
|
|
|
''' |
1154
|
|
|
config_value = connect.get_config("wal.enable") |
1155
|
|
|
assert config_value |
1156
|
|
|
|
1157
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1158
|
|
|
def test_get_recovery_error_ignore_invalid_child_key(self, connect, collection): |
1159
|
|
|
''' |
1160
|
|
|
target: get invalid child key |
1161
|
|
|
method: call get_config without child_key: recovery_error_ignore |
1162
|
|
|
expected: status not ok |
1163
|
|
|
''' |
1164
|
|
|
invalid_configs = ["recovery-error-ignore", "Recovery error_ignore", "recoveryxerror_ignore "] |
1165
|
|
|
for config in invalid_configs: |
1166
|
|
|
with pytest.raises(Exception) as e: |
1167
|
|
|
config_value = connect.get_config("wal." + config) |
1168
|
|
|
|
1169
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1170
|
|
|
def test_get_recovery_error_ignore_valid(self, connect, collection): |
1171
|
|
|
''' |
1172
|
|
|
target: get recovery_error_ignore |
1173
|
|
|
method: call get_config correctly |
1174
|
|
|
expected: status ok |
1175
|
|
|
''' |
1176
|
|
|
config_value = connect.get_config("wal.recovery_error_ignore") |
1177
|
|
|
assert config_value |
1178
|
|
|
|
1179
|
|
|
@pytest.mark.level(2) |
1180
|
|
|
def test_get_buffer_size_invalid_child_key(self, connect, collection): |
1181
|
|
|
''' |
1182
|
|
|
target: get invalid child key |
1183
|
|
|
method: call get_config without child_key: buffer_size |
1184
|
|
|
expected: status not ok |
1185
|
|
|
''' |
1186
|
|
|
invalid_configs = ["buffersize", "Buffer size", "buffer size "] |
1187
|
|
|
for config in invalid_configs: |
1188
|
|
|
with pytest.raises(Exception) as e: |
1189
|
|
|
config_value = connect.get_config("wal." + config) |
1190
|
|
|
|
1191
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1192
|
|
|
def test_get_buffer_size_valid(self, connect, collection): |
1193
|
|
|
''' |
1194
|
|
|
target: get buffer_size |
1195
|
|
|
method: call get_config correctly |
1196
|
|
|
expected: status ok |
1197
|
|
|
''' |
1198
|
|
|
config_value = connect.get_config("wal.buffer_size") |
1199
|
|
|
assert config_value |
1200
|
|
|
|
1201
|
|
|
@pytest.mark.level(2) |
1202
|
|
|
def test_get_wal_path_invalid_child_key(self, connect, collection): |
1203
|
|
|
''' |
1204
|
|
|
target: get invalid child key |
1205
|
|
|
method: call get_config without child_key: wal_path |
1206
|
|
|
expected: status not ok |
1207
|
|
|
''' |
1208
|
|
|
invalid_configs = ["wal", "Wal_path", "wal_path "] |
1209
|
|
|
for config in invalid_configs: |
1210
|
|
|
with pytest.raises(Exception) as e: |
1211
|
|
|
config_value = connect.get_config("wal." + config) |
1212
|
|
|
|
1213
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1214
|
|
|
def test_get_wal_path_valid(self, connect, collection): |
1215
|
|
|
''' |
1216
|
|
|
target: get wal_path |
1217
|
|
|
method: call get_config correctly |
1218
|
|
|
expected: status ok |
1219
|
|
|
''' |
1220
|
|
|
config_value = connect.get_config("wal.path") |
1221
|
|
|
assert config_value |
1222
|
|
|
|
1223
|
|
|
""" |
1224
|
|
|
****************************************************************** |
1225
|
|
|
The following cases are used to test `set_config` function |
1226
|
|
|
****************************************************************** |
1227
|
|
|
""" |
1228
|
|
|
|
1229
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1230
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1231
|
|
|
def test_set_wal_invalid_child_key(self, connect, collection): |
1232
|
|
|
''' |
1233
|
|
|
target: set invalid child key |
1234
|
|
|
method: call set_config with invalid child_key |
1235
|
|
|
expected: status not ok |
1236
|
|
|
''' |
1237
|
|
|
with pytest.raises(Exception) as e: |
1238
|
|
|
relpy = connect.set_config("wal.child_key", 256) |
1239
|
|
|
|
1240
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1241
|
|
|
def test_set_enable_valid(self, connect, collection): |
1242
|
|
|
''' |
1243
|
|
|
target: set enable |
1244
|
|
|
method: call set_config correctly |
1245
|
|
|
expected: status ok, set successfully |
1246
|
|
|
''' |
1247
|
|
|
for valid_enable in ["false", "true"]: |
1248
|
|
|
relpy = connect.set_config("wal.enable", valid_enable) |
1249
|
|
|
|
1250
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1251
|
|
|
def test_set_recovery_error_ignore_valid(self, connect, collection): |
1252
|
|
|
''' |
1253
|
|
|
target: set recovery_error_ignore |
1254
|
|
|
method: call set_config correctly |
1255
|
|
|
expected: status ok, set successfully |
1256
|
|
|
''' |
1257
|
|
|
for valid_recovery_error_ignore in ["false", "true"]: |
1258
|
|
|
relpy = connect.set_config("wal.recovery_error_ignore", valid_recovery_error_ignore) |
1259
|
|
|
|
1260
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1261
|
|
|
def test_set_buffer_size_valid_A(self, connect, collection): |
1262
|
|
|
''' |
1263
|
|
|
target: set buffer_size |
1264
|
|
|
method: call set_config correctly |
1265
|
|
|
expected: status ok, set successfully |
1266
|
|
|
''' |
1267
|
|
|
for valid_buffer_size in ["64MB", "128MB", "4096MB", "1000MB", "256MB"]: |
1268
|
|
|
relpy = connect.set_config("wal.buffer_size", valid_buffer_size) |
1269
|
|
|
|
1270
|
|
|
@pytest.mark.skip(reason="overwrite config file is not supported in ci yet.") |
1271
|
|
|
@pytest.mark.timeout(CONFIG_TIMEOUT) |
1272
|
|
|
def test_set_wal_path_valid(self, connect, collection, args): |
1273
|
|
|
''' |
1274
|
|
|
target: set wal_path |
1275
|
|
|
method: call set_config correctly |
1276
|
|
|
expected: status ok, set successfully |
1277
|
|
|
''' |
1278
|
|
|
relpy = connect.set_config("wal.path", "/var/lib/milvus/wal") |
1279
|
|
|
|