mirror of https://github.com/milvus-io/milvus.git
parent
9a3ae916a2
commit
db42b0bd94
tests/milvus_python_test
|
@ -589,20 +589,18 @@ class TestAddBase:
|
||||||
expected: status ok and result length is equal to the length off added vectors
|
expected: status ok and result length is equal to the length off added vectors
|
||||||
'''
|
'''
|
||||||
collection = gen_unique_str()
|
collection = gen_unique_str()
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
param = {'collection_name': collection,
|
param = {'collection_name': collection,
|
||||||
'dimension': dim,
|
'dimension': dim,
|
||||||
'index_file_size': index_file_size,
|
'index_file_size': index_file_size,
|
||||||
'metric_type': MetricType.L2}
|
'metric_type': MetricType.L2}
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
milvus.create_collection(param)
|
milvus.create_collection(param)
|
||||||
vector = gen_single_vector(dim)
|
vector = gen_single_vector(dim)
|
||||||
process_num = 4
|
process_num = 4
|
||||||
loop_num = 5
|
loop_num = 5
|
||||||
processes = []
|
processes = []
|
||||||
def add():
|
def add():
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
milvus.connect(uri=uri)
|
||||||
i = 0
|
i = 0
|
||||||
while i < loop_num:
|
while i < loop_num:
|
||||||
|
@ -634,19 +632,16 @@ class TestAddBase:
|
||||||
thread_num = 8
|
thread_num = 8
|
||||||
threads = []
|
threads = []
|
||||||
collection = gen_unique_str()
|
collection = gen_unique_str()
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
param = {'collection_name': collection,
|
param = {'collection_name': collection,
|
||||||
'dimension': dim,
|
'dimension': dim,
|
||||||
'index_file_size': index_file_size,
|
'index_file_size': index_file_size,
|
||||||
'metric_type': MetricType.L2}
|
'metric_type': MetricType.L2}
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
milvus.create_collection(param)
|
milvus.create_collection(param)
|
||||||
vectors = gen_vectors(nb, dim)
|
vectors = gen_vectors(nb, dim)
|
||||||
def add(thread_i):
|
def add(thread_i):
|
||||||
logging.getLogger().info("In thread-%d" % thread_i)
|
logging.getLogger().info("In thread-%d" % thread_i)
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
status, result = milvus.add_vectors(collection, records=vectors)
|
status, result = milvus.add_vectors(collection, records=vectors)
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
status = milvus.flush([collection])
|
status = milvus.flush([collection])
|
||||||
|
|
|
@ -322,7 +322,6 @@ class TestCollection:
|
||||||
expected: collection_name equals with the collection name created
|
expected: collection_name equals with the collection name created
|
||||||
'''
|
'''
|
||||||
collection_name = gen_unique_str("test_collection")
|
collection_name = gen_unique_str("test_collection")
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
param = {'collection_name': collection_name,
|
param = {'collection_name': collection_name,
|
||||||
'dimension': dim,
|
'dimension': dim,
|
||||||
'index_file_size': index_file_size,
|
'index_file_size': index_file_size,
|
||||||
|
@ -336,8 +335,7 @@ class TestCollection:
|
||||||
process_num = 4
|
process_num = 4
|
||||||
processes = []
|
processes = []
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
p = Process(target=describecollection, args=(milvus,))
|
p = Process(target=describecollection, args=(milvus,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
@ -507,8 +505,6 @@ class TestCollection:
|
||||||
'''
|
'''
|
||||||
process_num = 6
|
process_num = 6
|
||||||
processes = []
|
processes = []
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
def deletecollection(milvus):
|
def deletecollection(milvus):
|
||||||
status = milvus.drop_collection(collection)
|
status = milvus.drop_collection(collection)
|
||||||
# assert not status.code==0
|
# assert not status.code==0
|
||||||
|
@ -516,8 +512,7 @@ class TestCollection:
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
p = Process(target=deletecollection, args=(milvus,))
|
p = Process(target=deletecollection, args=(milvus,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
@ -786,13 +781,11 @@ class TestCollection:
|
||||||
expected: collection_name in show collections
|
expected: collection_name in show collections
|
||||||
'''
|
'''
|
||||||
collection_name = gen_unique_str("test_collection")
|
collection_name = gen_unique_str("test_collection")
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
param = {'collection_name': collection_name,
|
param = {'collection_name': collection_name,
|
||||||
'dimension': dim,
|
'dimension': dim,
|
||||||
'index_file_size': index_file_size,
|
'index_file_size': index_file_size,
|
||||||
'metric_type': MetricType.L2}
|
'metric_type': MetricType.L2}
|
||||||
connect.create_collection(param)
|
connect.create_collection(param)
|
||||||
|
|
||||||
def showcollections(milvus):
|
def showcollections(milvus):
|
||||||
status, result = milvus.show_collections()
|
status, result = milvus.show_collections()
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
|
@ -802,8 +795,7 @@ class TestCollection:
|
||||||
processes = []
|
processes = []
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
p = Process(target=showcollections, args=(milvus,))
|
p = Process(target=showcollections, args=(milvus,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
|
|
@ -181,7 +181,6 @@ class TestCollectionCount:
|
||||||
expected: the count is equal to the length of vectors
|
expected: the count is equal to the length of vectors
|
||||||
'''
|
'''
|
||||||
nq = 2
|
nq = 2
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
vectors = gen_vectors(nq, dim)
|
vectors = gen_vectors(nq, dim)
|
||||||
res = connect.add_vectors(collection_name=collection, records=vectors)
|
res = connect.add_vectors(collection_name=collection, records=vectors)
|
||||||
time.sleep(add_time_interval)
|
time.sleep(add_time_interval)
|
||||||
|
@ -194,8 +193,7 @@ class TestCollectionCount:
|
||||||
process_num = 8
|
process_num = 8
|
||||||
processes = []
|
processes = []
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
p = Process(target=rows_count, args=(milvus, ))
|
p = Process(target=rows_count, args=(milvus, ))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
@ -326,7 +324,6 @@ class TestCollectionCountIP:
|
||||||
expected: the count is equal to the length of vectors
|
expected: the count is equal to the length of vectors
|
||||||
'''
|
'''
|
||||||
nq = 2
|
nq = 2
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
vectors = gen_vectors(nq, dim)
|
vectors = gen_vectors(nq, dim)
|
||||||
res = connect.add_vectors(collection_name=ip_collection, records=vectors)
|
res = connect.add_vectors(collection_name=ip_collection, records=vectors)
|
||||||
time.sleep(add_time_interval)
|
time.sleep(add_time_interval)
|
||||||
|
@ -339,8 +336,7 @@ class TestCollectionCountIP:
|
||||||
process_num = 8
|
process_num = 8
|
||||||
processes = []
|
processes = []
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
p = Process(target=rows_count, args=(milvus,))
|
p = Process(target=rows_count, args=(milvus,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
|
|
@ -203,19 +203,16 @@ class TestFlushBase:
|
||||||
expected: status ok
|
expected: status ok
|
||||||
'''
|
'''
|
||||||
collection = gen_unique_str()
|
collection = gen_unique_str()
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
param = {'collection_name': collection,
|
param = {'collection_name': collection,
|
||||||
'dimension': dim,
|
'dimension': dim,
|
||||||
'index_file_size': index_file_size,
|
'index_file_size': index_file_size,
|
||||||
'metric_type': MetricType.L2}
|
'metric_type': MetricType.L2}
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
milvus.create_collection(param)
|
milvus.create_collection(param)
|
||||||
vectors = gen_vector(nb, dim)
|
vectors = gen_vector(nb, dim)
|
||||||
status, ids = milvus.add_vectors(collection, vectors, ids=[i for i in range(nb)])
|
status, ids = milvus.add_vectors(collection, vectors, ids=[i for i in range(nb)])
|
||||||
def flush(collection_name):
|
def flush(collection_name):
|
||||||
milvus = get_milvus(args["handler"])
|
milvus = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
milvus.connect(uri=uri)
|
|
||||||
status = milvus.delete_by_id(collection_name, [i for i in range(nb)])
|
status = milvus.delete_by_id(collection_name, [i for i in range(nb)])
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
status = milvus.flush([collection_name])
|
status = milvus.flush([collection_name])
|
||||||
|
|
|
@ -166,11 +166,8 @@ class TestIndexBase:
|
||||||
|
|
||||||
threads_num = 8
|
threads_num = 8
|
||||||
threads = []
|
threads = []
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(threads_num):
|
for i in range(threads_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
t = threading.Thread(target=build, args=(m,))
|
t = threading.Thread(target=build, args=(m,))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
t.start()
|
t.start()
|
||||||
|
@ -197,7 +194,6 @@ class TestIndexBase:
|
||||||
threads_num = 8
|
threads_num = 8
|
||||||
loop_num = 8
|
loop_num = 8
|
||||||
threads = []
|
threads = []
|
||||||
|
|
||||||
collection = []
|
collection = []
|
||||||
j = 0
|
j = 0
|
||||||
while j < (threads_num*loop_num):
|
while j < (threads_num*loop_num):
|
||||||
|
@ -215,7 +211,6 @@ class TestIndexBase:
|
||||||
while i < loop_num:
|
while i < loop_num:
|
||||||
# assert connect.has_collection(collection[ids*process_num+i])
|
# assert connect.has_collection(collection[ids*process_num+i])
|
||||||
status, ids = connect.add_vectors(collection[ids*threads_num+i], vectors)
|
status, ids = connect.add_vectors(collection[ids*threads_num+i], vectors)
|
||||||
|
|
||||||
status = connect.create_index(collection[ids*threads_num+i], IndexType.IVFLAT, {"nlist": NLIST})
|
status = connect.create_index(collection[ids*threads_num+i], IndexType.IVFLAT, {"nlist": NLIST})
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
query_vec = [vectors[0]]
|
query_vec = [vectors[0]]
|
||||||
|
@ -226,14 +221,10 @@ class TestIndexBase:
|
||||||
assert len(result[0]) == top_k
|
assert len(result[0]) == top_k
|
||||||
assert result[0][0].distance == 0.0
|
assert result[0][0].distance == 0.0
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(threads_num):
|
for i in range(threads_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
ids = i
|
ids = i
|
||||||
t = threading.Thread(target=create_index, args=(m,ids))
|
t = threading.Thread(target=create_index, args=(m, ids))
|
||||||
threads.append(t)
|
threads.append(t)
|
||||||
t.start()
|
t.start()
|
||||||
time.sleep(0.2)
|
time.sleep(0.2)
|
||||||
|
@ -256,8 +247,7 @@ class TestIndexBase:
|
||||||
threads = []
|
threads = []
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
||||||
for i in range(threads_num):
|
for i in range(threads_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
if(i % 2 == 0):
|
if(i % 2 == 0):
|
||||||
p = threading.Thread(target=build, args=(m,))
|
p = threading.Thread(target=build, args=(m,))
|
||||||
else:
|
else:
|
||||||
|
@ -286,11 +276,8 @@ class TestIndexBase:
|
||||||
|
|
||||||
process_num = 8
|
process_num = 8
|
||||||
processes = []
|
processes = []
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
p = Process(target=build, args=(m,))
|
p = Process(target=build, args=(m,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
@ -347,11 +334,8 @@ class TestIndexBase:
|
||||||
assert result[0][0].distance == 0.0
|
assert result[0][0].distance == 0.0
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(host=args["ip"], port=args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
ids = i
|
ids = i
|
||||||
p = Process(target=create_index, args=(m,ids))
|
p = Process(target=create_index, args=(m,ids))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
|
@ -792,18 +776,15 @@ class TestIndexIP:
|
||||||
expected: return code equals to 0, and search success
|
expected: return code equals to 0, and search success
|
||||||
'''
|
'''
|
||||||
status, ids = connect.add_vectors(ip_collection, vectors)
|
status, ids = connect.add_vectors(ip_collection, vectors)
|
||||||
|
|
||||||
def build(connect):
|
def build(connect):
|
||||||
status = connect.create_index(ip_collection, IndexType.IVFLAT, {"nlist": NLIST})
|
status = connect.create_index(ip_collection, IndexType.IVFLAT, {"nlist": NLIST})
|
||||||
assert status.OK()
|
assert status.OK()
|
||||||
|
|
||||||
process_num = 8
|
process_num = 8
|
||||||
processes = []
|
processes = []
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
p = Process(target=build, args=(m,))
|
p = Process(target=build, args=(m,))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
p.start()
|
p.start()
|
||||||
|
@ -858,11 +839,8 @@ class TestIndexIP:
|
||||||
assert result[0][0].distance == 0.0
|
assert result[0][0].distance == 0.0
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
uri = "tcp://%s:%s" % (args["ip"], args["port"])
|
|
||||||
|
|
||||||
for i in range(process_num):
|
for i in range(process_num):
|
||||||
m = get_milvus(args["handler"])
|
m = get_milvus(args["ip"], args["port"], handler=args["handler"])
|
||||||
m.connect(uri=uri)
|
|
||||||
ids = i
|
ids = i
|
||||||
p = Process(target=create_index, args=(m,ids))
|
p = Process(target=create_index, args=(m,ids))
|
||||||
processes.append(p)
|
processes.append(p)
|
||||||
|
|
Loading…
Reference in New Issue