Skip to content

Commit 6131359

Browse files
Fix nebula docker compose errors (#1786)
* fix errors Signed-off-by: siddhivelankar23 <siddhi.velankar@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * update compose file path Signed-off-by: siddhivelankar23 <siddhi.velankar@intel.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Signed-off-by: siddhivelankar23 <siddhi.velankar@intel.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 711a305 commit 6131359

2 files changed

Lines changed: 87 additions & 173 deletions

File tree

comps/third_parties/nebula/deployment/docker_compose/docker-compose.yaml

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
version: '3.4'
55
services:
66
metad0:
7-
image: docker.io/vesoft/nebula-metad:nightly
7+
image: docker.io/vesoft/nebula-metad:v3.6.0
88
environment:
99
USER: root
1010
TZ: "${TZ}"
@@ -38,7 +38,7 @@ services:
3838
- SYS_PTRACE
3939

4040
metad1:
41-
image: docker.io/vesoft/nebula-metad:nightly
41+
image: docker.io/vesoft/nebula-metad:v3.6.0
4242
environment:
4343
USER: root
4444
TZ: "${TZ}"
@@ -72,7 +72,7 @@ services:
7272
- SYS_PTRACE
7373

7474
metad2:
75-
image: docker.io/vesoft/nebula-metad:nightly
75+
image: docker.io/vesoft/nebula-metad:v3.6.0
7676
environment:
7777
USER: root
7878
TZ: "${TZ}"
@@ -106,7 +106,7 @@ services:
106106
- SYS_PTRACE
107107

108108
storaged0:
109-
image: docker.io/vesoft/nebula-storaged:nightly
109+
image: docker.io/vesoft/nebula-storaged:v3.6.0
110110
environment:
111111
USER: root
112112
TZ: "${TZ}"
@@ -144,7 +144,7 @@ services:
144144
- SYS_PTRACE
145145

146146
storaged1:
147-
image: docker.io/vesoft/nebula-storaged:nightly
147+
image: docker.io/vesoft/nebula-storaged:v3.6.0
148148
environment:
149149
USER: root
150150
TZ: "${TZ}"
@@ -182,7 +182,7 @@ services:
182182
- SYS_PTRACE
183183

184184
storaged2:
185-
image: docker.io/vesoft/nebula-storaged:nightly
185+
image: docker.io/vesoft/nebula-storaged:v3.6.0
186186
environment:
187187
USER: root
188188
TZ: "${TZ}"
@@ -220,7 +220,7 @@ services:
220220
- SYS_PTRACE
221221

222222
graphd:
223-
image: docker.io/vesoft/nebula-graphd:nightly
223+
image: docker.io/vesoft/nebula-graphd:v3.6.0
224224
environment:
225225
USER: root
226226
TZ: "${TZ}"
@@ -255,80 +255,8 @@ services:
255255
cap_add:
256256
- SYS_PTRACE
257257

258-
graphd1:
259-
image: docker.io/vesoft/nebula-graphd:nightly
260-
environment:
261-
USER: root
262-
TZ: "${TZ}"
263-
command:
264-
- --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559
265-
- --port=9669
266-
- --local_ip=graphd1
267-
- --ws_ip=graphd1
268-
- --ws_http_port=19669
269-
- --log_dir=/logs
270-
- --v=0
271-
- --minloglevel=0
272-
depends_on:
273-
- storaged0
274-
- storaged1
275-
- storaged2
276-
healthcheck:
277-
test: ["CMD", "curl", "-sf", "http://graphd1:19669/status"]
278-
interval: 30s
279-
timeout: 10s
280-
retries: 3
281-
start_period: 20s
282-
ports:
283-
- 9669
284-
- 19669
285-
- 19670
286-
volumes:
287-
- ./logs/graph1:/logs
288-
networks:
289-
- nebula-net
290-
restart: on-failure
291-
cap_add:
292-
- SYS_PTRACE
293-
294-
graphd2:
295-
image: docker.io/vesoft/nebula-graphd:nightly
296-
environment:
297-
USER: root
298-
TZ: "${TZ}"
299-
command:
300-
- --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559
301-
- --port=9669
302-
- --local_ip=graphd2
303-
- --ws_ip=graphd2
304-
- --ws_http_port=19669
305-
- --log_dir=/logs
306-
- --v=0
307-
- --minloglevel=0
308-
depends_on:
309-
- storaged0
310-
- storaged1
311-
- storaged2
312-
healthcheck:
313-
test: ["CMD", "curl", "-sf", "http://graphd2:19669/status"]
314-
interval: 30s
315-
timeout: 10s
316-
retries: 3
317-
start_period: 20s
318-
ports:
319-
- 9669
320-
- 19669
321-
- 19670
322-
volumes:
323-
- ./logs/graph2:/logs
324-
networks:
325-
- nebula-net
326-
restart: on-failure
327-
cap_add:
328-
- SYS_PTRACE
329-
330258
console:
331-
image: docker.io/vesoft/nebula-console:nightly
259+
image: docker.io/vesoft/nebula-console:v3.5
332260
entrypoint: ""
333261
command:
334262
- sh

tests/third_parties/test_third_parties_nebula_docker.sh

100644100755
Lines changed: 79 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -2,111 +2,97 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
#!/bin/bash
5-
set +e
5+
6+
set -euo pipefail
67
set -x
78

8-
# Constants
99
WORKPATH=$(dirname "$PWD")
10-
LOG_PATH="$WORKPATH/tests"
11-
MAX_ATTEMPTS=30
12-
SLEEP_TIME=2
13-
14-
# Function to start NebulaGraph services
15-
start_service() {
16-
echo "Starting NebulaGraph services..."
17-
cd $WORKPATH/comps/third_parties/nebula/deployment/docker_compose/
18-
docker compose up -d
19-
2010

21-
echo "Waiting for services to become healthy..."
22-
for ((i=1; i<=MAX_ATTEMPTS; i++)); do
23-
HEALTHY_COUNT=$(docker compose ps --filter "status=healthy" | wc -l)
24-
TOTAL_COUNT=$(docker compose ps | wc -l)
25-
26-
echo "Attempt $i/$MAX_ATTEMPTS: $HEALTHY_COUNT out of $TOTAL_COUNT services are healthy"
27-
28-
if [ $HEALTHY_COUNT -eq $TOTAL_COUNT ]; then
29-
echo "All services are healthy!"
30-
break
31-
fi
11+
stop_services() {
12+
echo "Stopping and cleaning up any existing Nebula services..."
13+
cd $WORKPATH
14+
cd comps/third_parties/nebula/deployment/docker_compose
15+
docker compose -f docker-compose.yaml down -v || true
16+
echo "Cleanup complete."
17+
}
3218

33-
sleep $SLEEP_TIME
34-
echo "Still waiting... ($i/$MAX_ATTEMPTS attempts)"
19+
start_services() {
20+
echo "Starting Nebula services..."
21+
cd $WORKPATH
22+
cd comps/third_parties/nebula/deployment/docker_compose
23+
docker compose -f docker-compose.yaml up -d
24+
25+
echo "Waiting for services to become healthy..."
26+
local services=("metad0" "metad1" "metad2" "storaged0" "storaged1" "storaged2" "graphd")
27+
28+
for svc in "${services[@]}"; do
29+
local container_id
30+
cd $WORKPATH
31+
cd comps/third_parties/nebula/deployment/docker_compose
32+
container_id=$(docker compose -f docker-compose.yaml ps -q "$svc")
33+
echo -n "Waiting for $svc to be healthy"
34+
until [ "$(docker inspect -f '{{.State.Health.Status}}' "$container_id")" == "healthy" ]; do
35+
echo -n "."
36+
sleep 2
3537
done
38+
echo "Start services complete"
39+
done
3640

37-
if [ $i -eq $MAX_ATTEMPTS ]; then
38-
echo "Services did not become healthy within timeout period"
39-
echo "Current service statuses:"
40-
docker compose ps
41-
exit 1
42-
fi
41+
echo "All services are healthy."
4342
}
4443

45-
# Function to validate database operations
46-
validate_database() {
47-
GRAPHD_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker compose ps -q graphd))
48-
49-
if [ -z "$GRAPHD_IP" ]; then
50-
echo "Could not determine graphd IP address"
51-
exit 1
52-
fi
53-
54-
echo "Using graphd IP: $GRAPHD_IP"
55-
56-
echo "[ test create ] creating space..."
57-
query="CREATE SPACE my_space(partition_num=10, replica_factor=1, vid_type=FIXED_STRING(32)); USE my_space; CREATE TAG person(name string, age int);"
58-
59-
create_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1)
44+
run_query() {
45+
local query="$1"
46+
local network_name="$2"
6047

61-
if [[ $? -eq 0 ]]; then
62-
echo "[ test create ] create space succeed"
63-
else
64-
echo "[ test create ] create space failed"
65-
exit 1
66-
fi
67-
68-
sleep $SLEEP_TIME
69-
70-
echo "[ test insert ] inserting data..."
71-
query="USE my_space; INSERT VERTEX person(name, age) VALUES 'person1':('Alice', 30); INSERT VERTEX person(name, age) VALUES 'person2':('Bob', 25);"
72-
73-
insert_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1)
74-
75-
if [[ $? -eq 0 ]]; then
76-
echo "[ test insert ] insert data succeed"
77-
else
78-
echo "[ test insert ] insert data failed"
79-
exit 1
80-
fi
81-
82-
sleep $SLEEP_TIME
83-
84-
echo "[ test search ] searching data..."
85-
query="USE my_space; MATCH (p:person) RETURN p;"
86-
87-
search_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1)
88-
89-
if [[ $? -eq 0 ]]; then
90-
echo "[ test search ] search data succeed"
91-
else
92-
echo "[ test search ] search data failed"
93-
exit 1
94-
fi
48+
docker run --rm --network "$network_name" docker.io/vesoft/nebula-console:v3.5 \
49+
-addr graphd -port 9669 -u root -p nebula -e "$query"
9550
}
9651

97-
# Function to stop services
98-
stop_service() {
99-
echo "Stopping NebulaGraph services..."
100-
docker compose down --remove-orphans
52+
validate_database() {
53+
echo "Running validation queries..."
54+
55+
# Get network name from graphd container
56+
local container_id
57+
cd $WORKPATH
58+
cd comps/third_parties/nebula/deployment/docker_compose
59+
container_id=$(docker compose -f docker-compose.yaml ps -q graphd)
60+
local network_name
61+
network_name=$(docker inspect "$container_id" \
62+
--format '{{range $k, $v := .NetworkSettings.Networks}}{{$k}}{{end}}')
63+
64+
if [ -z "$network_name" ]; then
65+
echo "Could not detect the Docker network from container."
66+
exit 1
67+
fi
68+
69+
echo "[Step 1] Creating space..."
70+
run_query "CREATE SPACE my_space(partition_num=10, replica_factor=1, vid_type=FIXED_STRING(32));" "$network_name"
71+
echo "[Step 1] Space created successfully."
72+
sleep 2
73+
74+
echo "[Step 2] Creating tag..."
75+
run_query "USE my_space; CREATE TAG person(name string, age int);" "$network_name"
76+
echo "[Step 2] Tag created successfully."
77+
sleep 2
78+
79+
echo "[Step 3] Inserting data..."
80+
run_query "USE my_space; INSERT VERTEX person(name, age) VALUES 'person1':('Alice', 30), 'person2':('Bob', 25);" "$network_name"
81+
echo "[Step 3] Data inserted successfully."
82+
sleep 2
83+
84+
echo "[Step 4] Querying data..."
85+
run_query "USE my_space; MATCH (p:person) RETURN p;" "$network_name"
86+
echo "[Step 4] Data queried successfully."
87+
88+
echo "All tests successful."
10189
}
10290

103-
# Main function
104-
main() {
105-
stop_service
106-
start_service
107-
validate_database
108-
stop_service
109-
}
91+
# Main flow
92+
93+
stop_services
94+
start_services
95+
validate_database
96+
stop_services
11097

111-
# Run main function
112-
main "$@"
98+
echo "Test script completed successfully."

0 commit comments

Comments
 (0)