1
|
|
|
import pdb |
2
|
|
|
import pytest |
3
|
|
|
import logging |
4
|
|
|
import itertools |
5
|
|
|
from time import sleep |
6
|
|
|
from multiprocessing import Process |
7
|
|
|
from milvus import IndexType, MetricType |
8
|
|
|
from utils import * |
9
|
|
|
|
10
|
|
|
collection_id = "load_collection" |
11
|
|
|
index_name = "load_index_name" |
12
|
|
|
nb = 6000 |
13
|
|
|
default_fields = gen_default_fields() |
14
|
|
|
entities = gen_entities(nb) |
15
|
|
|
field_name = "fload_vector" |
16
|
|
|
|
17
|
|
|
|
18
|
|
|
class TestLoadCollection: |
19
|
|
|
|
20
|
|
|
""" |
21
|
|
|
****************************************************************** |
22
|
|
|
The following cases are used to test `load_collection` function |
23
|
|
|
****************************************************************** |
24
|
|
|
""" |
25
|
|
|
@pytest.fixture( |
26
|
|
|
scope="function", |
27
|
|
|
params=gen_simple_index() |
28
|
|
|
) |
29
|
|
|
def get_simple_index(self, request, connect): |
30
|
|
|
if str(connect._cmd("mode")) == "CPU": |
31
|
|
|
if request.param["index_type"] in index_cpu_not_support(): |
32
|
|
|
pytest.skip("sq8h not support in cpu mode") |
33
|
|
|
return request.param |
34
|
|
|
|
35
|
|
|
def test_load_collection_after_index(self, connect, collection, get_simple_index): |
36
|
|
|
''' |
37
|
|
|
target: test load collection, after index created |
38
|
|
|
method: insert and create index, load collection with correct params |
39
|
|
|
expected: describe raise exception |
40
|
|
|
''' |
41
|
|
|
connect.insert(collection, entities) |
42
|
|
|
connect.flush([collection]) |
43
|
|
|
logging.getLogger().info(get_simple_index) |
44
|
|
|
connect.create_index(collection, field_name, index_name, get_simple_index) |
45
|
|
|
connect.load_collection(collection) |
46
|
|
|
|
47
|
|
|
def load_empty_collection(self, connect, collection): |
48
|
|
|
''' |
49
|
|
|
target: test load collection |
50
|
|
|
method: no entities in collection, load collection with correct params |
51
|
|
|
expected: load success |
52
|
|
|
''' |
53
|
|
|
connect.load_collection(collection) |
54
|
|
|
|
55
|
|
|
@pytest.mark.level(1) |
56
|
|
|
def test_load_collection_dis_connect(self, dis_connect, collection): |
57
|
|
|
''' |
58
|
|
|
target: test load collection, without connection |
59
|
|
|
method: load collection with correct params, with a disconnected instance |
60
|
|
|
expected: load raise exception |
61
|
|
|
''' |
62
|
|
|
with pytest.raises(Exception) as e: |
63
|
|
|
dis_connect.load_collection(collection) |
64
|
|
|
|
65
|
|
|
@pytest.mark.level(2) |
66
|
|
|
def test_load_collection_not_existed(self, connect, collection): |
67
|
|
|
collection_name = gen_unique_str(collection_id) |
68
|
|
|
with pytest.raises(Exception) as e: |
69
|
|
|
connect.load_collection(collection_name) |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
class TestLoadCollectionInvalid(object): |
73
|
|
|
""" |
74
|
|
|
Test load collection with invalid params |
75
|
|
|
""" |
76
|
|
|
@pytest.fixture( |
77
|
|
|
scope="function", |
78
|
|
|
params=gen_invalid_strs() |
79
|
|
|
) |
80
|
|
|
def get_collection_name(self, request): |
81
|
|
|
yield request.param |
82
|
|
|
|
83
|
|
|
@pytest.mark.level(2) |
84
|
|
|
def test_load_collection_with_invalid_collectionname(self, connect, get_collection_name): |
85
|
|
|
collection_name = get_collection_name |
86
|
|
|
with pytest.raises(Exception) as e: |
87
|
|
|
connect.has_collection(collection_name) |
88
|
|
|
|