1
+ #! /bin/bash
2
+
3
+ set -e
4
+
5
+ source common.sh
6
+
7
+ SIZE=6000
8
+
9
+ run_importer () {
10
+ local size=$1
11
+ if ! docker run \
12
+ -e ' DIMENSIONS=48' \
13
+ -e ' SHARDS=1' \
14
+ -e " SIZE=$size " \
15
+ -e ' BATCH_SIZE=128' \
16
+ -e ' ORIGIN=http://localhost:8080' \
17
+ --network host \
18
+ -t importer; then
19
+ echo " Importer failed, printing latest Weaviate logs..."
20
+ exit 1
21
+ fi
22
+ echo " Import completed successfully"
23
+ }
24
+
25
+ validate_object_count () {
26
+ local expected_count=$1
27
+ local retries=$2
28
+ local attempt=1
29
+ local sleep_time=5
30
+
31
+ while [ $attempt -le $retries ]; do
32
+ local object_count=$( curl -s ' localhost:8080/v1/graphql' -X POST \
33
+ -H ' content-type: application/json' \
34
+ -d " {\" query\" :\" {Aggregate{DemoClass{meta{count}}}}\" }" | \
35
+ jq ' .data.Aggregate.DemoClass[0].meta.count' )
36
+
37
+ if [ " $object_count " -ge " $expected_count " ]; then
38
+ echo " Object count is correct"
39
+ return 0
40
+ fi
41
+
42
+ echo " Not enough objects present, wanted $expected_count , got $object_count "
43
+ echo " Retrying in $sleep_time seconds..."
44
+ sleep $sleep_time
45
+ attempt=$(( attempt + 1 ))
46
+ done
47
+
48
+ echo " Failed to validate object count after $retries attempts"
49
+ return 1
50
+ }
51
+
52
+ wait_for_condensing () {
53
+ local retries=150
54
+ local attempt=1
55
+
56
+ while [ $attempt -le $retries ]; do
57
+ if docker compose -f apps/weaviate/docker-compose.yml logs weaviate | grep " start hnsw condensing" ; then
58
+ echo " Condensing begin detected"
59
+ return 0
60
+ fi
61
+ sleep 3
62
+ attempt=$(( attempt + 1 ))
63
+ done
64
+
65
+ echo " Failed to detect condensing begin after $retries attempts"
66
+ return 1
67
+ }
68
+
69
+ validate_logs () {
70
+
71
+ if docker compose -f apps/weaviate/docker-compose.yml logs weaviate | grep -iE " error:|panic:|runtime error:|goroutine.*\[running\]|panic@|unrecognized commit type" ; then
72
+ echo " Errors detected in logs"
73
+ return 1
74
+ fi
75
+
76
+ echo " No errors detected in logs"
77
+ return 0
78
+ }
79
+
80
+ echo " Building all required containers"
81
+ ( cd apps/importer/ && docker build -t importer . )
82
+ ( cd apps/updater/ && docker build -t updater . )
83
+
84
+ export ASYNC_INDEXING=true
85
+ export COMPOSE=" apps/weaviate/docker-compose.yml"
86
+
87
+ echo " Starting Weaviate..."
88
+ docker compose -f $COMPOSE up -d
89
+
90
+ wait_weaviate
91
+
92
+ echo " Run import script to import $SIZE objects"
93
+ run_importer $SIZE
94
+
95
+ for i in {1..10}; do
96
+ echo " Wait for the condensing to be started"
97
+ if ! wait_for_condensing; then
98
+ exit 1
99
+ fi
100
+
101
+ echo " Restart the container"
102
+ docker compose -f apps/weaviate/docker-compose.yml kill weaviate \
103
+ && docker compose -f apps/weaviate/docker-compose.yml up weaviate -d
104
+
105
+ wait_weaviate
106
+ done
107
+
108
+ echo " Validate the count is correct"
109
+ if ! validate_object_count $SIZE 3; then
110
+ sleep 60
111
+ exit 1
112
+ fi
113
+
114
+ echo " Wait some time to let the condensing be completed"
115
+ sleep 50
116
+
117
+ echo " Validate logs"
118
+ if ! validate_logs; then
119
+ exit 1
120
+ fi
121
+
122
+ sleep 60
123
+
124
+ echo " Passed!"
125
+ shutdown
126
+ ` `
0 commit comments