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