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