dev_1.0.0_yuyr_2:重新提交 PR,增加 master/agent 以及系统集成测试 (#17)
Reviewed-on: #17 Reviewed-by: sundapeng <sundp@mail.zgclab.edu.cn> Reviewed-by: xuxt <xuxt@zgclab.edu.cn>
This commit was merged in pull request #17.
This commit is contained in:
@@ -17,6 +17,7 @@ services:
|
||||
interval: 10s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
restart: always
|
||||
|
||||
kibana:
|
||||
build:
|
||||
@@ -73,13 +74,11 @@ services:
|
||||
interval: 15s
|
||||
timeout: 10s
|
||||
retries: 30
|
||||
restart: always
|
||||
|
||||
bind9:
|
||||
image: argus-bind9:latest
|
||||
ports:
|
||||
- "53:53/tcp"
|
||||
- "53:53/udp"
|
||||
volumes:
|
||||
- ./private/argus:/private/argus/
|
||||
restart: unless-stopped
|
||||
restart: always
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/../" && pwd)"
|
||||
project_root="$(cd "$root/../../.." && pwd)"
|
||||
|
||||
source "$project_root/scripts/common/build_user.sh"
|
||||
load_build_user
|
||||
|
||||
# 创建新的private目录结构 (基于argus目录结构)
|
||||
echo "[INFO] Creating private directory structure for supervisor-based containers..."
|
||||
@@ -11,9 +15,9 @@ mkdir -p "$root/private/argus/etc/"
|
||||
|
||||
# 设置数据目录权限(ES 和 Kibana 容器都使用 UID 1000)
|
||||
echo "[INFO] Setting permissions for data directories..."
|
||||
sudo chown -R 2133:2015 "$root/private/argus/log/elasticsearch" 2>/dev/null || true
|
||||
sudo chown -R 2133:2015 "$root/private/argus/log/kibana" 2>/dev/null || true
|
||||
sudo chown -R 2133:2015 "$root/private/argus/etc" 2>/dev/null || true
|
||||
chown -R "${ARGUS_BUILD_UID}:${ARGUS_BUILD_GID}" "$root/private/argus/log/elasticsearch" 2>/dev/null || true
|
||||
chown -R "${ARGUS_BUILD_UID}:${ARGUS_BUILD_GID}" "$root/private/argus/log/kibana" 2>/dev/null || true
|
||||
chown -R "${ARGUS_BUILD_UID}:${ARGUS_BUILD_GID}" "$root/private/argus/etc" 2>/dev/null || true
|
||||
|
||||
echo "[INFO] Supervisor-based containers will manage their own scripts and configurations"
|
||||
|
||||
|
||||
@@ -4,8 +4,22 @@ set -euo pipefail
|
||||
# 获取fluent-bit-host01容器名称
|
||||
container_name="logging-mvp-fluent-bit-host01-1"
|
||||
|
||||
# 检查容器是否存在并运行
|
||||
if ! docker ps | grep -q "$container_name"; then
|
||||
wait_for_container() {
|
||||
local name="$1"
|
||||
local attempts=30
|
||||
local delay=5
|
||||
local i
|
||||
for ((i = 1; i <= attempts; i++)); do
|
||||
if docker ps --format '{{.Names}}' | grep -Fx "$name" >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
echo "[INFO] 等待容器 $name 启动中... ($i/$attempts)"
|
||||
sleep "$delay"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! wait_for_container "$container_name"; then
|
||||
echo "[ERROR] Fluent Bit容器 $container_name 未运行"
|
||||
exit 1
|
||||
fi
|
||||
@@ -28,4 +42,4 @@ STACK"
|
||||
|
||||
echo "[OK] 已通过docker exec写入测试日志到 host01 容器内:"
|
||||
echo " - /logs/train/train-demo.log"
|
||||
echo " - /logs/infer/infer-demo.log"
|
||||
echo " - /logs/infer/infer-demo.log"
|
||||
|
||||
@@ -4,8 +4,22 @@ set -euo pipefail
|
||||
# 获取fluent-bit-host02容器名称
|
||||
container_name="logging-mvp-fluent-bit-host02-1"
|
||||
|
||||
# 检查容器是否存在并运行
|
||||
if ! docker ps | grep -q "$container_name"; then
|
||||
wait_for_container() {
|
||||
local name="$1"
|
||||
local attempts=30
|
||||
local delay=5
|
||||
local i
|
||||
for ((i = 1; i <= attempts; i++)); do
|
||||
if docker ps --format '{{.Names}}' | grep -Fx "$name" >/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
echo "[INFO] 等待容器 $name 启动中... ($i/$attempts)"
|
||||
sleep "$delay"
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
if ! wait_for_container "$container_name"; then
|
||||
echo "[ERROR] Fluent Bit容器 $container_name 未运行"
|
||||
exit 1
|
||||
fi
|
||||
@@ -24,4 +38,4 @@ docker exec "$container_name" sh -c "printf '%s INFO [host02] inference complete
|
||||
|
||||
echo "[OK] 已通过docker exec写入测试日志到 host02 容器内:"
|
||||
echo " - /logs/train/train-demo.log"
|
||||
echo " - /logs/infer/infer-demo.log"
|
||||
echo " - /logs/infer/infer-demo.log"
|
||||
|
||||
@@ -1,7 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
# ES endpoint and wait strategy
|
||||
ES="${ES:-http://localhost:9200}"
|
||||
es_wait_attempts="${ES_WAIT_ATTEMPTS:-60}" # total attempts to wait for ES
|
||||
es_wait_interval="${ES_WAIT_INTERVAL:-2}" # seconds between attempts
|
||||
|
||||
echo "[i] 查询 ES 端点:$ES"
|
||||
|
||||
wait_for_es() {
|
||||
local attempt=1
|
||||
while (( attempt <= es_wait_attempts )); do
|
||||
# 等待集群达到至少 yellow 状态;请求失败则重试
|
||||
if curl -fsS "$ES/_cluster/health?wait_for_status=yellow&timeout=1s" >/dev/null 2>&1; then
|
||||
echo "[ok] Elasticsearch 已就绪 (attempt=${attempt}/${es_wait_attempts})"
|
||||
return 0
|
||||
fi
|
||||
echo "[..] 等待 Elasticsearch 可用中 (${attempt}/${es_wait_attempts})"
|
||||
sleep "${es_wait_interval}"
|
||||
(( attempt++ ))
|
||||
done
|
||||
echo "[err] Elasticsearch 在 ${es_wait_attempts} 次尝试后仍不可用"
|
||||
return 1
|
||||
}
|
||||
|
||||
safe_count() {
|
||||
# 对缺失索引返回 0,避免 404 触发失败
|
||||
local pattern="$1"
|
||||
local json
|
||||
json=$(curl -fsS "$ES/${pattern}/_count?ignore_unavailable=true&allow_no_indices=true" 2>/dev/null || echo '{}')
|
||||
echo "$json" | sed -E 's/.*"count":([0-9]+).*/\1/' | awk 'NF{print $0;exit} END{if(NR==0)print 0}'
|
||||
}
|
||||
|
||||
wait_for_es
|
||||
|
||||
# 列出相关索引(可能为空,允许)
|
||||
curl -fsS "$ES/_cat/indices?v" | egrep 'train-|infer-|logstash' || true
|
||||
printf "train-* 计数:"; curl -fsS "$ES/train-*/_count" | sed -E 's/.*"count":([0-9]+).*/\1/'; echo
|
||||
printf "infer-* 计数:"; curl -fsS "$ES/infer-*/_count" | sed -E 's/.*"count":([0-9]+).*/\1/'; echo
|
||||
|
||||
# 打印计数,缺失索引按 0 处理
|
||||
printf "train-* 计数:"; safe_count "train-*"; echo
|
||||
printf "infer-* 计数:"; safe_count "infer-*"; echo
|
||||
|
||||
@@ -19,7 +19,7 @@ get_log_count() {
|
||||
# 函数:等待服务就绪
|
||||
wait_for_services() {
|
||||
echo "[INFO] Waiting for all services to be ready..."
|
||||
local max_attempts=60
|
||||
local max_attempts=${SERVICE_WAIT_ATTEMPTS:-120}
|
||||
local attempt=1
|
||||
|
||||
while [ $attempt -le $max_attempts ]; do
|
||||
|
||||
Reference in New Issue
Block a user