diff --git a/comps/third_parties/nebula/deployment/docker_compose/docker-compose.yaml b/comps/third_parties/nebula/deployment/docker_compose/docker-compose.yaml new file mode 100644 index 0000000000..995c0b94d4 --- /dev/null +++ b/comps/third_parties/nebula/deployment/docker_compose/docker-compose.yaml @@ -0,0 +1,352 @@ +# Copyright (C) 2025 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +version: '3.4' +services: + metad0: + image: docker.io/vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=metad0 + - --ws_ip=metad0 + - --port=9559 + - --ws_http_port=19559 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad0:19559/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9559 + - 19559 + - 19560 + volumes: + - ./data/meta0:/data/meta + - ./logs/meta0:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + metad1: + image: docker.io/vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=metad1 + - --ws_ip=metad1 + - --port=9559 + - --ws_http_port=19559 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad1:19559/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9559 + - 19559 + - 19560 + volumes: + - ./data/meta1:/data/meta + - ./logs/meta1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + metad2: + image: docker.io/vesoft/nebula-metad:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=metad2 + - --ws_ip=metad2 + - --port=9559 + - --ws_http_port=19559 + - --data_path=/data/meta + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + healthcheck: + test: ["CMD", "curl", "-sf", "http://metad2:19559/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9559 + - 19559 + - 19560 + volumes: + - ./data/meta2:/data/meta + - ./logs/meta2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged0: + image: docker.io/vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=storaged0 + - --ws_ip=storaged0 + - --port=9779 + - --ws_http_port=19779 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged0:19779/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9779 + - 19779 + - 19780 + volumes: + - ./data/storage0:/data/storage + - ./logs/storage0:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged1: + image: docker.io/vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=storaged1 + - --ws_ip=storaged1 + - --port=9779 + - --ws_http_port=19779 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged1:19779/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9779 + - 19779 + - 19780 + volumes: + - ./data/storage1:/data/storage + - ./logs/storage1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + storaged2: + image: docker.io/vesoft/nebula-storaged:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --local_ip=storaged2 + - --ws_ip=storaged2 + - --port=9779 + - --ws_http_port=19779 + - --data_path=/data/storage + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - metad0 + - metad1 + - metad2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://storaged2:19779/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9779 + - 19779 + - 19780 + volumes: + - ./data/storage2:/data/storage + - ./logs/storage2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd: + image: docker.io/vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --port=9669 + - --local_ip=graphd + - --ws_ip=graphd + - --ws_http_port=19669 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - storaged0 + - storaged1 + - storaged2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd:19669/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - "9669:9669" + - 19669 + - 19670 + volumes: + - ./logs/graph:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd1: + image: docker.io/vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --port=9669 + - --local_ip=graphd1 + - --ws_ip=graphd1 + - --ws_http_port=19669 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - storaged0 + - storaged1 + - storaged2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd1:19669/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9669 + - 19669 + - 19670 + volumes: + - ./logs/graph1:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + graphd2: + image: docker.io/vesoft/nebula-graphd:nightly + environment: + USER: root + TZ: "${TZ}" + command: + - --meta_server_addrs=metad0:9559,metad1:9559,metad2:9559 + - --port=9669 + - --local_ip=graphd2 + - --ws_ip=graphd2 + - --ws_http_port=19669 + - --log_dir=/logs + - --v=0 + - --minloglevel=0 + depends_on: + - storaged0 + - storaged1 + - storaged2 + healthcheck: + test: ["CMD", "curl", "-sf", "http://graphd2:19669/status"] + interval: 30s + timeout: 10s + retries: 3 + start_period: 20s + ports: + - 9669 + - 19669 + - 19670 + volumes: + - ./logs/graph2:/logs + networks: + - nebula-net + restart: on-failure + cap_add: + - SYS_PTRACE + + console: + image: docker.io/vesoft/nebula-console:nightly + entrypoint: "" + command: + - sh + - -c + - | + for i in `seq 1 60`;do + var=`nebula-console -addr graphd -port 9669 -u root -p nebula -e 'ADD HOSTS "storaged0":9779,"storaged1":9779,"storaged2":9779'`; + if [[ $$? == 0 ]];then + break; + fi; + sleep 1; + echo "retry to add hosts."; + done && tail -f /dev/null; + + depends_on: + - graphd + networks: + - nebula-net + +networks: + nebula-net: diff --git a/tests/third_parties/test_third_parties_nebula_docker.sh b/tests/third_parties/test_third_parties_nebula_docker.sh new file mode 100644 index 0000000000..7ccdd48416 --- /dev/null +++ b/tests/third_parties/test_third_parties_nebula_docker.sh @@ -0,0 +1,112 @@ +# Copyright (C) 2024 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +#!/bin/bash +set +e +set -x + +# Constants +WORKPATH=$(dirname "$PWD") +LOG_PATH="$WORKPATH/tests" +MAX_ATTEMPTS=30 +SLEEP_TIME=2 + +# Function to start NebulaGraph services +start_service() { + echo "Starting NebulaGraph services..." + cd $WORKPATH/comps/third_parties/nebula/deployment/docker_compose/ + docker compose up -d + + + echo "Waiting for services to become healthy..." + for ((i=1; i<=MAX_ATTEMPTS; i++)); do + HEALTHY_COUNT=$(docker compose ps --filter "status=healthy" | wc -l) + TOTAL_COUNT=$(docker compose ps | wc -l) + + echo "Attempt $i/$MAX_ATTEMPTS: $HEALTHY_COUNT out of $TOTAL_COUNT services are healthy" + + if [ $HEALTHY_COUNT -eq $TOTAL_COUNT ]; then + echo "All services are healthy!" + break + fi + + sleep $SLEEP_TIME + echo "Still waiting... ($i/$MAX_ATTEMPTS attempts)" + done + + if [ $i -eq $MAX_ATTEMPTS ]; then + echo "Services did not become healthy within timeout period" + echo "Current service statuses:" + docker compose ps + exit 1 + fi +} + +# Function to validate database operations +validate_database() { + GRAPHD_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $(docker compose ps -q graphd)) + + if [ -z "$GRAPHD_IP" ]; then + echo "Could not determine graphd IP address" + exit 1 + fi + + echo "Using graphd IP: $GRAPHD_IP" + + echo "[ test create ] creating space..." + 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);" + + create_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1) + + if [[ $? -eq 0 ]]; then + echo "[ test create ] create space succeed" + else + echo "[ test create ] create space failed" + exit 1 + fi + + sleep $SLEEP_TIME + + echo "[ test insert ] inserting data..." + query="USE my_space; INSERT VERTEX person(name, age) VALUES 'person1':('Alice', 30); INSERT VERTEX person(name, age) VALUES 'person2':('Bob', 25);" + + insert_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1) + + if [[ $? -eq 0 ]]; then + echo "[ test insert ] insert data succeed" + else + echo "[ test insert ] insert data failed" + exit 1 + fi + + sleep $SLEEP_TIME + + echo "[ test search ] searching data..." + query="USE my_space; MATCH (p:person) RETURN p;" + + search_response=$(docker compose exec console nebula-console -addr "$GRAPHD_IP" -port 9669 -u root -p nebula -e "$query" 2>&1) + + if [[ $? -eq 0 ]]; then + echo "[ test search ] search data succeed" + else + echo "[ test search ] search data failed" + exit 1 + fi +} + +# Function to stop services +stop_service() { + echo "Stopping NebulaGraph services..." + docker compose down --remove-orphans +} + +# Main function +main() { + stop_service + start_service + validate_database + stop_service +} + +# Run main function +main "$@"