1
|
|
|
import pdb |
2
|
|
|
import copy |
3
|
|
|
import logging |
4
|
|
|
import itertools |
5
|
|
|
from time import sleep |
6
|
|
|
import threading |
7
|
|
|
from multiprocessing import Process |
8
|
|
|
import sklearn.preprocessing |
9
|
|
|
|
10
|
|
|
import pytest |
11
|
|
|
from utils import * |
12
|
|
|
|
13
|
|
|
nb = 6000 |
14
|
|
|
dim = 128 |
15
|
|
|
tag = "tag" |
16
|
|
|
collection_id = "count_collection" |
17
|
|
|
add_interval_time = 3 |
18
|
|
|
segment_row_count = 5000 |
19
|
|
|
default_fields = gen_default_fields() |
|
|
|
|
20
|
|
|
entities = gen_entities(nb) |
|
|
|
|
21
|
|
|
raw_vectors, binary_entities = gen_binary_entities(nb) |
|
|
|
|
22
|
|
|
field_name = "fload_vector" |
23
|
|
|
index_name = "index_name" |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
class TestCollectionCount: |
27
|
|
|
""" |
28
|
|
|
params means different nb, the nb value may trigger merge, or not |
29
|
|
|
""" |
30
|
|
|
@pytest.fixture( |
31
|
|
|
scope="function", |
32
|
|
|
params=[ |
33
|
|
|
1, |
34
|
|
|
4000, |
35
|
|
|
6001 |
36
|
|
|
], |
37
|
|
|
) |
38
|
|
|
def insert_count(self, request): |
39
|
|
|
yield request.param |
40
|
|
|
|
41
|
|
|
""" |
42
|
|
|
generate valid create_index params |
43
|
|
|
""" |
44
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
45
|
|
|
scope="function", |
46
|
|
|
params=gen_simple_index() |
|
|
|
|
47
|
|
|
) |
48
|
|
|
def get_simple_index(self, request, connect): |
49
|
|
|
if str(connect._cmd("mode")[1]) == "CPU": |
50
|
|
|
if request.param["index_type"] in index_cpu_not_support(): |
|
|
|
|
51
|
|
|
pytest.skip("sq8h not support in cpu mode") |
52
|
|
|
request.param.update({"metric_type": "L2"}) |
53
|
|
|
return request.param |
54
|
|
|
|
55
|
|
|
def test_collection_count(self, connect, collection, insert_count): |
56
|
|
|
''' |
57
|
|
|
target: test collection rows_count is correct or not |
58
|
|
|
method: create collection and add vectors in it, |
59
|
|
|
assert the value returned by count_entities method is equal to length of vectors |
60
|
|
|
expected: the count is equal to the length of vectors |
61
|
|
|
''' |
62
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
63
|
|
|
res = connect.insert(collection, entities) |
64
|
|
|
connect.flush([collection]) |
65
|
|
|
res = connect.count_entities(collection) |
66
|
|
|
assert res == insert_count |
67
|
|
|
|
68
|
|
|
def test_collection_count_partition(self, connect, collection, insert_count): |
69
|
|
|
''' |
70
|
|
|
target: test collection rows_count is correct or not |
71
|
|
|
method: create collection, create partition and add vectors in it, |
72
|
|
|
assert the value returned by count_entities method is equal to length of vectors |
73
|
|
|
expected: the count is equal to the length of vectors |
74
|
|
|
''' |
75
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
76
|
|
|
connect.create_partition(collection, tag) |
77
|
|
|
res_ids = connect.insert(collection, entities, partition_tag=tag) |
78
|
|
|
connect.flush([collection]) |
79
|
|
|
res = connect.count_entities(collection) |
80
|
|
|
assert res == insert_count |
81
|
|
|
|
82
|
|
|
def test_collection_count_multi_partitions_A(self, connect, collection, insert_count): |
83
|
|
|
''' |
84
|
|
|
target: test collection rows_count is correct or not |
85
|
|
|
method: create collection, create partitions and add entities in it, |
86
|
|
|
assert the value returned by count_entities method is equal to length of entities |
87
|
|
|
expected: the count is equal to the length of entities |
88
|
|
|
''' |
89
|
|
|
new_tag = "new_tag" |
90
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
91
|
|
|
connect.create_partition(collection, tag) |
92
|
|
|
connect.create_partition(collection, new_tag) |
93
|
|
|
res_ids = connect.insert(collection, entities) |
94
|
|
|
connect.flush([collection]) |
95
|
|
|
res = connect.count_entities(collection) |
96
|
|
|
assert res == insert_count |
97
|
|
|
|
98
|
|
|
def test_collection_count_multi_partitions_B(self, connect, collection, insert_count): |
99
|
|
|
''' |
100
|
|
|
target: test collection rows_count is correct or not |
101
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
102
|
|
|
assert the value returned by count_entities method is equal to length of entities |
103
|
|
|
expected: the count is equal to the length of entities |
104
|
|
|
''' |
105
|
|
|
new_tag = "new_tag" |
106
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
107
|
|
|
connect.create_partition(collection, tag) |
108
|
|
|
connect.create_partition(collection, new_tag) |
109
|
|
|
res_ids = connect.insert(collection, entities, partition_tag=tag) |
110
|
|
|
connect.flush([collection]) |
111
|
|
|
res = connect.count_entities(collection) |
112
|
|
|
assert res == insert_count |
113
|
|
|
|
114
|
|
|
def test_collection_count_multi_partitions_C(self, connect, collection, insert_count): |
115
|
|
|
''' |
116
|
|
|
target: test collection rows_count is correct or not |
117
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
118
|
|
|
assert the value returned by count_entities method is equal to length of entities |
119
|
|
|
expected: the count is equal to the length of vectors |
120
|
|
|
''' |
121
|
|
|
new_tag = "new_tag" |
122
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
123
|
|
|
connect.create_partition(collection, tag) |
124
|
|
|
connect.create_partition(collection, new_tag) |
125
|
|
|
res_ids = connect.insert(collection, entities) |
126
|
|
|
res_ids_2 = connect.insert(collection, entities, partition_tag=tag) |
127
|
|
|
connect.flush([collection]) |
128
|
|
|
res = connect.count_entities(collection) |
129
|
|
|
assert res == insert_count * 2 |
130
|
|
|
|
131
|
|
|
def test_collection_count_multi_partitions_D(self, connect, collection, insert_count): |
132
|
|
|
''' |
133
|
|
|
target: test collection rows_count is correct or not |
134
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
135
|
|
|
assert the value returned by count_entities method is equal to length of entities |
136
|
|
|
expected: the collection count is equal to the length of entities |
137
|
|
|
''' |
138
|
|
|
new_tag = "new_tag" |
139
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
140
|
|
|
connect.create_partition(collection, tag) |
141
|
|
|
connect.create_partition(collection, new_tag) |
142
|
|
|
res_ids = connect.insert(collection, entities, partition_tag=tag) |
143
|
|
|
res_ids2 = connect.insert(collection, entities, partition_tag=new_tag) |
144
|
|
|
connect.flush([collection]) |
145
|
|
|
res = connect.count_entities(collection) |
146
|
|
|
assert res == insert_count * 2 |
147
|
|
|
|
148
|
|
View Code Duplication |
def _test_collection_count_after_index_created(self, connect, collection, get_simple_index, insert_count): |
|
|
|
|
149
|
|
|
''' |
150
|
|
|
target: test count_entities, after index have been created |
151
|
|
|
method: add vectors in db, and create index, then calling count_entities with correct params |
152
|
|
|
expected: count_entities raise exception |
153
|
|
|
''' |
154
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
155
|
|
|
res = connect.insert(collection, entities) |
156
|
|
|
connect.flush([collection]) |
157
|
|
|
connect.create_index(collection, field_name, get_simple_index) |
158
|
|
|
res = connect.count_entities(collection) |
159
|
|
|
assert res == insert_count |
160
|
|
|
|
161
|
|
|
@pytest.mark.level(2) |
162
|
|
|
def test_count_without_connection(self, collection, dis_connect): |
163
|
|
|
''' |
164
|
|
|
target: test count_entities, without connection |
165
|
|
|
method: calling count_entities with correct params, with a disconnected instance |
166
|
|
|
expected: count_entities raise exception |
167
|
|
|
''' |
168
|
|
|
with pytest.raises(Exception) as e: |
169
|
|
|
dis_connect.count_entities(collection) |
170
|
|
|
|
171
|
|
|
def test_collection_count_no_vectors(self, connect, collection): |
172
|
|
|
''' |
173
|
|
|
target: test collection rows_count is correct or not, if collection is empty |
174
|
|
|
method: create collection and no vectors in it, |
175
|
|
|
assert the value returned by count_entities method is equal to 0 |
176
|
|
|
expected: the count is equal to 0 |
177
|
|
|
''' |
178
|
|
|
res = connect.count_entities(collection) |
179
|
|
|
assert res == 0 |
180
|
|
|
|
181
|
|
|
|
182
|
|
|
class TestCollectionCountIP: |
183
|
|
|
""" |
184
|
|
|
params means different nb, the nb value may trigger merge, or not |
185
|
|
|
""" |
186
|
|
|
@pytest.fixture( |
187
|
|
|
scope="function", |
188
|
|
|
params=[ |
189
|
|
|
1, |
190
|
|
|
4000, |
191
|
|
|
6001 |
192
|
|
|
], |
193
|
|
|
) |
194
|
|
|
def insert_count(self, request): |
195
|
|
|
yield request.param |
196
|
|
|
|
197
|
|
|
""" |
198
|
|
|
generate valid create_index params |
199
|
|
|
""" |
200
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
201
|
|
|
scope="function", |
202
|
|
|
params=gen_simple_index() |
|
|
|
|
203
|
|
|
) |
204
|
|
|
def get_simple_index(self, request, connect): |
205
|
|
|
if str(connect._cmd("mode")[1]) == "CPU": |
206
|
|
|
if request.param["index_type"] in index_cpu_not_support(): |
|
|
|
|
207
|
|
|
pytest.skip("sq8h not support in cpu mode") |
208
|
|
|
request.param.update({"metric_type": "IP"}) |
209
|
|
|
return request.param |
210
|
|
|
|
211
|
|
View Code Duplication |
def _test_collection_count_after_index_created(self, connect, collection, get_simple_index, insert_count): |
|
|
|
|
212
|
|
|
''' |
213
|
|
|
target: test count_entities, after index have been created |
214
|
|
|
method: add vectors in db, and create index, then calling count_entities with correct params |
215
|
|
|
expected: count_entities raise exception |
216
|
|
|
''' |
217
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
218
|
|
|
res = connect.insert(collection, entities) |
219
|
|
|
connect.flush([collection]) |
220
|
|
|
connect.create_index(collection, field_name, get_simple_index) |
221
|
|
|
res = connect.count_entities(collection) |
222
|
|
|
assert res == insert_count |
223
|
|
|
|
224
|
|
|
|
225
|
|
|
class TestCollectionCountBinary: |
226
|
|
|
""" |
227
|
|
|
params means different nb, the nb value may trigger merge, or not |
228
|
|
|
""" |
229
|
|
|
@pytest.fixture( |
230
|
|
|
scope="function", |
231
|
|
|
params=[ |
232
|
|
|
1, |
233
|
|
|
4000, |
234
|
|
|
6001 |
235
|
|
|
], |
236
|
|
|
) |
237
|
|
|
def insert_count(self, request): |
238
|
|
|
yield request.param |
239
|
|
|
|
240
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
241
|
|
|
scope="function", |
242
|
|
|
params=gen_simple_index() |
|
|
|
|
243
|
|
|
) |
244
|
|
|
def get_jaccard_index(self, request, connect): |
245
|
|
|
if request.param["index_type"] in binary_support(): |
|
|
|
|
246
|
|
|
request.param["metric_type"] = "JACCARD" |
247
|
|
|
return request.param |
248
|
|
|
else: |
249
|
|
|
pytest.skip("Skip index") |
250
|
|
|
|
251
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
252
|
|
|
scope="function", |
253
|
|
|
params=gen_simple_index() |
|
|
|
|
254
|
|
|
) |
255
|
|
|
def get_hamming_index(self, request, connect): |
256
|
|
|
if request.param["index_type"] in binary_support(): |
|
|
|
|
257
|
|
|
request.param["metric_type"] = "HAMMING" |
258
|
|
|
return request.param |
259
|
|
|
else: |
260
|
|
|
pytest.skip("Skip index") |
261
|
|
|
|
262
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
263
|
|
|
scope="function", |
264
|
|
|
params=gen_simple_index() |
|
|
|
|
265
|
|
|
) |
266
|
|
|
def get_substructure_index(self, request, connect): |
267
|
|
|
if request.param["index_type"] == "FLAT": |
268
|
|
|
request.param["metric_type"] = "SUBSTRUCTURE" |
269
|
|
|
return request.param |
270
|
|
|
else: |
271
|
|
|
pytest.skip("Skip index") |
272
|
|
|
|
273
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
274
|
|
|
scope="function", |
275
|
|
|
params=gen_simple_index() |
|
|
|
|
276
|
|
|
) |
277
|
|
|
def get_superstructure_index(self, request, connect): |
278
|
|
|
if request.param["index_type"] == "FLAT": |
279
|
|
|
request.param["metric_type"] = "SUPERSTRUCTURE" |
280
|
|
|
return request.param |
281
|
|
|
else: |
282
|
|
|
pytest.skip("Skip index") |
283
|
|
|
|
284
|
|
|
def test_collection_count(self, connect, binary_collection, insert_count): |
285
|
|
|
''' |
286
|
|
|
target: test collection rows_count is correct or not |
287
|
|
|
method: create collection and add entities in it, |
288
|
|
|
assert the value returned by count_entities method is equal to length of entities |
289
|
|
|
expected: the count is equal to the length of entities |
290
|
|
|
''' |
291
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
292
|
|
|
res = connect.insert(binary_collection, entities) |
293
|
|
|
logging.getLogger().info(len(res)) |
294
|
|
|
connect.flush([binary_collection]) |
295
|
|
|
res = connect.count_entities(binary_collection) |
296
|
|
|
assert res == insert_count |
297
|
|
|
|
298
|
|
|
def test_collection_count_partition(self, connect, binary_collection, insert_count): |
299
|
|
|
''' |
300
|
|
|
target: test collection rows_count is correct or not |
301
|
|
|
method: create collection, create partition and add entities in it, |
302
|
|
|
assert the value returned by count_entities method is equal to length of entities |
303
|
|
|
expected: the count is equal to the length of entities |
304
|
|
|
''' |
305
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
306
|
|
|
connect.create_partition(binary_collection, tag) |
307
|
|
|
res_ids = connect.insert(binary_collection, entities, partition_tag=tag) |
308
|
|
|
connect.flush([binary_collection]) |
309
|
|
|
res = connect.count_entities(binary_collections) |
|
|
|
|
310
|
|
|
assert res == insert_count |
311
|
|
|
|
312
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
313
|
|
|
def test_collection_count_multi_partitions_A(self, connect, binary_collection, insert_count): |
314
|
|
|
''' |
315
|
|
|
target: test collection rows_count is correct or not |
316
|
|
|
method: create collection, create partitions and add entities in it, |
317
|
|
|
assert the value returned by count_entities method is equal to length of entities |
318
|
|
|
expected: the count is equal to the length of entities |
319
|
|
|
''' |
320
|
|
|
new_tag = "new_tag" |
321
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
322
|
|
|
connect.create_partition(binary_collection, tag) |
323
|
|
|
connect.create_partition(binary_collection, new_tag) |
324
|
|
|
res_ids = connect.insert(binary_collection, entities) |
325
|
|
|
connect.flush([binary_collection]) |
326
|
|
|
res = connect.count_entities(binary_collection) |
327
|
|
|
assert res == insert_count |
328
|
|
|
|
329
|
|
View Code Duplication |
@pytest.mark.level(2) |
|
|
|
|
330
|
|
|
def test_collection_count_multi_partitions_B(self, connect, binary_collection, insert_count): |
331
|
|
|
''' |
332
|
|
|
target: test collection rows_count is correct or not |
333
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
334
|
|
|
assert the value returned by count_entities method is equal to length of entities |
335
|
|
|
expected: the count is equal to the length of entities |
336
|
|
|
''' |
337
|
|
|
new_tag = "new_tag" |
338
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
339
|
|
|
connect.create_partition(binary_collection, tag) |
340
|
|
|
connect.create_partition(binary_collection, new_tag) |
341
|
|
|
res_ids = connect.insert(binary_collection, entities, partition_tag=tag) |
342
|
|
|
connect.flush([binary_collection]) |
343
|
|
|
res = connect.count_entities(binary_collection) |
344
|
|
|
assert res == insert_count |
345
|
|
|
|
346
|
|
|
def test_collection_count_multi_partitions_C(self, connect, binary_collection, insert_count): |
347
|
|
|
''' |
348
|
|
|
target: test collection rows_count is correct or not |
349
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
350
|
|
|
assert the value returned by count_entities method is equal to length of entities |
351
|
|
|
expected: the count is equal to the length of entities |
352
|
|
|
''' |
353
|
|
|
new_tag = "new_tag" |
354
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
355
|
|
|
connect.create_partition(binary_collection, tag) |
356
|
|
|
connect.create_partition(binary_collection, new_tag) |
357
|
|
|
res_ids = connect.insert(binary_collection, entities) |
358
|
|
|
res_ids_2 = connect.insert(binary_collection, entities, partition_tag=tag) |
359
|
|
|
connect.flush([binary_collection]) |
360
|
|
|
res = connect.count_entities(binary_collection) |
361
|
|
|
assert res == insert_count * 2 |
362
|
|
|
|
363
|
|
|
@pytest.mark.level(2) |
364
|
|
|
def test_collection_count_multi_partitions_D(self, connect, binary_collection, insert_count): |
365
|
|
|
''' |
366
|
|
|
target: test collection rows_count is correct or not |
367
|
|
|
method: create collection, create partitions and add entities in one of the partitions, |
368
|
|
|
assert the value returned by count_entities method is equal to length of entities |
369
|
|
|
expected: the collection count is equal to the length of entities |
370
|
|
|
''' |
371
|
|
|
new_tag = "new_tag" |
372
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
373
|
|
|
connect.create_partition(binary_collection, tag) |
374
|
|
|
connect.create_partition(binary_collection, new_tag) |
375
|
|
|
res_ids = connect.insert(binary_collection, entities, partition_tag=tag) |
376
|
|
|
res_ids2 = connect.insert(binary_collection, entities, partition_tag=new_tag) |
377
|
|
|
connect.flush([binary_collection]) |
378
|
|
|
res = connect.count_entities(binary_collection) |
379
|
|
|
assert res == insert_count * 2 |
380
|
|
|
|
381
|
|
|
def _test_collection_count_after_index_created(self, connect, binary_collection, get_jaccard_index, insert_count): |
382
|
|
|
''' |
383
|
|
|
target: test count_entities, after index have been created |
384
|
|
|
method: add vectors in db, and create index, then calling count_entities with correct params |
385
|
|
|
expected: count_entities raise exception |
386
|
|
|
''' |
387
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
388
|
|
|
res = connect.insert(binary_collection, entities) |
389
|
|
|
connect.flush([binary_collection]) |
390
|
|
|
connect.create_index(binary_collection, field_name, get_jaccard_index) |
391
|
|
|
res = connect.count_entities(binary_collection) |
392
|
|
|
assert res == insert_count |
393
|
|
|
|
394
|
|
|
def _test_collection_count_after_index_created(self, connect, binary_collection, get_hamming_index, insert_count): |
395
|
|
|
''' |
396
|
|
|
target: test count_entities, after index have been created |
397
|
|
|
method: add vectors in db, and create index, then calling count_entities with correct params |
398
|
|
|
expected: count_entities raise exception |
399
|
|
|
''' |
400
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
401
|
|
|
res = connect.insert(binary_collection, entities) |
402
|
|
|
connect.flush([binary_collection]) |
403
|
|
|
connect.create_index(binary_collection, field_name, get_hamming_index) |
404
|
|
|
res = connect.count_entities(binary_collection) |
405
|
|
|
assert res == insert_count |
406
|
|
|
|
407
|
|
|
def test_collection_count_no_entities(self, connect, binary_collection): |
408
|
|
|
''' |
409
|
|
|
target: test collection rows_count is correct or not, if collection is empty |
410
|
|
|
method: create collection and no vectors in it, |
411
|
|
|
assert the value returned by count_entities method is equal to 0 |
412
|
|
|
expected: the count is equal to 0 |
413
|
|
|
''' |
414
|
|
|
res = connect.count_entities(binary_collection) |
415
|
|
|
assert res == 0 |
416
|
|
|
|
417
|
|
|
|
418
|
|
|
class TestCollectionMultiCollections: |
419
|
|
|
""" |
420
|
|
|
params means different nb, the nb value may trigger merge, or not |
421
|
|
|
""" |
422
|
|
|
@pytest.fixture( |
423
|
|
|
scope="function", |
424
|
|
|
params=[ |
425
|
|
|
1, |
426
|
|
|
4000, |
427
|
|
|
6001 |
428
|
|
|
], |
429
|
|
|
) |
430
|
|
|
def insert_count(self, request): |
431
|
|
|
yield request.param |
432
|
|
|
|
433
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
434
|
|
|
scope="function", |
435
|
|
|
params=gen_simple_index() |
|
|
|
|
436
|
|
|
) |
437
|
|
|
def get_jaccard_index(self, request, connect): |
438
|
|
|
if request.param["index_type"] in binary_support(): |
|
|
|
|
439
|
|
|
request.param["metric_type"] = "JACCARD" |
440
|
|
|
return request.param |
441
|
|
|
else: |
442
|
|
|
pytest.skip("Skip index") |
443
|
|
|
|
444
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
445
|
|
|
scope="function", |
446
|
|
|
params=gen_simple_index() |
|
|
|
|
447
|
|
|
) |
448
|
|
|
def get_hamming_index(self, request, connect): |
449
|
|
|
if request.param["index_type"] in binary_support(): |
|
|
|
|
450
|
|
|
request.param["metric_type"] = "HAMMING" |
451
|
|
|
return request.param |
452
|
|
|
else: |
453
|
|
|
pytest.skip("Skip index") |
454
|
|
|
|
455
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
456
|
|
|
scope="function", |
457
|
|
|
params=gen_simple_index() |
|
|
|
|
458
|
|
|
) |
459
|
|
|
def get_substructure_index(self, request, connect): |
460
|
|
|
if request.param["index_type"] == "FLAT": |
461
|
|
|
request.param["metric_type"] = "SUBSTRUCTURE" |
462
|
|
|
return request.param |
463
|
|
|
else: |
464
|
|
|
pytest.skip("Skip index") |
465
|
|
|
|
466
|
|
View Code Duplication |
@pytest.fixture( |
|
|
|
|
467
|
|
|
scope="function", |
468
|
|
|
params=gen_simple_index() |
|
|
|
|
469
|
|
|
) |
470
|
|
|
def get_superstructure_index(self, request, connect): |
471
|
|
|
if request.param["index_type"] == "FLAT": |
472
|
|
|
request.param["metric_type"] = "SUPERSTRUCTURE" |
473
|
|
|
return request.param |
474
|
|
|
else: |
475
|
|
|
pytest.skip("Skip index") |
476
|
|
|
|
477
|
|
|
def test_collection_count_multi_collections_l2(self, connect, insert_count): |
478
|
|
|
''' |
479
|
|
|
target: test collection rows_count is correct or not with multiple collections of L2 |
480
|
|
|
method: create collection and add entities in it, |
481
|
|
|
assert the value returned by count_entities method is equal to length of entities |
482
|
|
|
expected: the count is equal to the length of entities |
483
|
|
|
''' |
484
|
|
|
entities = gen_entities(insert_count) |
|
|
|
|
485
|
|
|
collection_list = [] |
486
|
|
|
collection_num = 20 |
487
|
|
|
for i in range(collection_num): |
488
|
|
|
collection_name = gen_unique_str(collection_id) |
|
|
|
|
489
|
|
|
collection_list.append(collection_name) |
490
|
|
|
connect.create_collection(collection_name, default_fields) |
491
|
|
|
res = connect.insert(collection_name, entities) |
492
|
|
|
connect.flush(collection_list) |
493
|
|
|
for i in range(collection_num): |
494
|
|
|
res = connect.count_entities(collection_list[i]) |
495
|
|
|
assert res == insert_count |
496
|
|
|
|
497
|
|
|
# TODO: |
498
|
|
|
def _test_collection_count_multi_collections_binary(self, connect, binary_collection, insert_count): |
499
|
|
|
''' |
500
|
|
|
target: test collection rows_count is correct or not with multiple collections of JACCARD |
501
|
|
|
method: create collection and add entities in it, |
502
|
|
|
assert the value returned by count_entities method is equal to length of entities |
503
|
|
|
expected: the count is equal to the length of entities |
504
|
|
|
''' |
505
|
|
|
raw_vectors, entities = gen_binary_entities(insert_count) |
|
|
|
|
506
|
|
|
res = connect.insert(binary_collection, entities) |
507
|
|
|
# logging.getLogger().info(entities) |
508
|
|
|
collection_list = [] |
509
|
|
|
collection_num = 20 |
510
|
|
|
for i in range(collection_num): |
511
|
|
|
collection_name = gen_unique_str(collection_id) |
|
|
|
|
512
|
|
|
collection_list.append(collection_name) |
513
|
|
|
connect.create_collection(collection_name, fields) |
|
|
|
|
514
|
|
|
res = connect.insert(collection_name, entities) |
515
|
|
|
connect.flush(collection_list) |
516
|
|
|
for i in range(collection_num): |
517
|
|
|
res = connect.count_entities(collection_list[i]) |
518
|
|
|
assert res == insert_count |
519
|
|
|
|
520
|
|
|
# TODO: |
521
|
|
|
def _test_collection_count_multi_collections_mix(self, connect): |
522
|
|
|
''' |
523
|
|
|
target: test collection rows_count is correct or not with multiple collections of JACCARD |
524
|
|
|
method: create collection and add entities in it, |
525
|
|
|
assert the value returned by count_entities method is equal to length of entities |
526
|
|
|
expected: the count is equal to the length of entities |
527
|
|
|
''' |
528
|
|
|
collection_list = [] |
529
|
|
|
collection_num = 20 |
530
|
|
|
for i in range(0, int(collection_num / 2)): |
531
|
|
|
collection_name = gen_unique_str(collection_id) |
|
|
|
|
532
|
|
|
collection_list.append(collection_name) |
533
|
|
|
connect.create_collection(collection_name, default_fields) |
534
|
|
|
res = connect.insert(collection_name, entities) |
535
|
|
|
for i in range(int(collection_num / 2), collection_num): |
536
|
|
|
collection_name = gen_unique_str(collection_id) |
537
|
|
|
collection_list.append(collection_name) |
538
|
|
|
connect.create_collection(collection_name, fields) |
|
|
|
|
539
|
|
|
res = connect.insert(collection_name, binary_entities) |
540
|
|
|
connect.flush(collection_list) |
541
|
|
|
for i in range(collection_num): |
542
|
|
|
res = connect.count_entities(collection_list[i]) |
543
|
|
|
assert res == nb |
544
|
|
|
|