forked from milvus-io/milvus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe2e-restful.sh
executable file
·115 lines (98 loc) · 3.03 KB
/
e2e-restful.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# Exit immediately for non zero status
set -e
# Print commands
set -x
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
ROOT="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
DATA_PATH="${ROOT}/tests/scripts/restful-data/"
MILVUS_CLUSTER_ENABLED="${MILVUS_CLUSTER_ENABLED:-false}"
MILVUS_SERVICE_NAME=$(echo "${MILVUS_HELM_RELEASE_NAME}-milvus.${MILVUS_HELM_NAMESPACE}" | tr -d '\n')
MILVUS_SERVICE_ADDRESS="${MILVUS_SERVICE_NAME}:9091"
# Create a collection
curl -X 'POST' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${DATA_PATH}/create-collection.json
# Has collection
curl -X 'GET' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection/existence" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book"
}'
# Check collection details
curl -X 'GET' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book"
}'
# Load collection
curl -X 'POST' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection/load" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book"
}'
### Data
# Insert Data
curl -X 'POST' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/entities" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${DATA_PATH}/insert-data.json
# Build Index
curl -X 'POST' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/index" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book",
"field_name": "book_intro",
"extra_params":[
{"key": "metric_type", "value": "L2"},
{"key": "index_type", "value": "IVF_FLAT"},
{"key": "params", "value": "{\"nlist\":1024}"}
]
}'
# KNN Search
curl -X 'POST' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/search" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d @${DATA_PATH}/search.json
# Drop Index
curl -X 'DELETE' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/index" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book",
"field_name": "book_intro"
}'
# Release collection
curl -X 'DELETE' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection/load" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book"
}'
# Drop collection
curl -X 'DELETE' \
"http://${MILVUS_SERVICE_ADDRESS}/api/v1/collection" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"collection_name": "book"
}'