Skip to content

Commit e6b1265

Browse files
committed
Add test to crash while condensing
This test will stop Weaviate several times right after the condensing has been detected in the logs
1 parent 6770f0b commit e6b1265

File tree

2 files changed

+149
-0
lines changed

2 files changed

+149
-0
lines changed

.github/workflows/tests.yaml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,29 @@ jobs:
23062306
run: |
23072307
./tombstones_cleanup_while_crash.sh
23082308
2309+
condensing-while-crash:
2310+
needs: [newer-or-equal-than-1_28]
2311+
if: ${{ (needs.newer-or-equal-than-1_28.outputs.check == 'true') && (github.event.inputs.test_to_run == 'condensing-while-crash' || github.event.inputs.test_to_run == '' ) }}
2312+
name: Check that condensing works while crashes happen
2313+
runs-on: ubuntu-latest
2314+
timeout-minutes: 60
2315+
env:
2316+
PERSISTENCE_LSM_ACCESS_STRATEGY: ${{inputs.lsm_access_strategy}}
2317+
steps:
2318+
- uses: actions/checkout@v3
2319+
- name: Login to Docker Hub
2320+
uses: docker/login-action@v3
2321+
with:
2322+
username: ${{secrets.DOCKER_USERNAME}}
2323+
password: ${{secrets.DOCKER_PASSWORD}}
2324+
- name: Set up Go
2325+
uses: actions/setup-go@v3
2326+
with:
2327+
go-version: '1.22'
2328+
- name: Run condensing-while-crash chaos tests
2329+
run: |
2330+
./condensing_while_crash.sh
2331+
23092332
hnsw-snapshotting-while-crash:
23102333
needs: [newer-or-equal-than-1_31]
23112334
if: ${{ (needs.newer-or-equal-than-1_31.outputs.check == 'true') && (github.event.inputs.test_to_run == 'hnsw-snapshotting-while-crash' || github.event.inputs.test_to_run == '' ) }}

condensing_while_crash.sh

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
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

Comments
 (0)