v1.0.0 发布合并回master (#52)

Co-authored-by: sundapeng <sundp@mail.zgclab.edu.cn>
Co-authored-by: xuxt <xuxt@zgclab.edu.cn>
Reviewed-on: #52
This commit was merged in pull request #52.
This commit is contained in:
2025-11-25 16:00:50 +08:00
parent 9e1336d13e
commit 7430896fab
464 changed files with 45636 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
version: "3.8"
services:
es:
build:
context: ../elasticsearch/build
dockerfile: Dockerfile
image: argus-elasticsearch:latest
environment:
- discovery.type=single-node
- xpack.security.enabled=false
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- ./private/argus/:/private/argus/
ports: ["9200:9200"]
healthcheck:
test: ["CMD-SHELL", "curl -fs http://localhost:9200 >/dev/null || exit 1"]
interval: 10s
timeout: 5s
retries: 30
restart: always
kibana:
build:
context: ../kibana/build
dockerfile: Dockerfile
image: argus-kibana:latest
environment:
- ELASTICSEARCH_HOSTS=http://es.log.argus.com:9200
volumes:
- ./private/argus/:/private/argus/
ports: ["5601:5601"]
depends_on:
es:
condition: service_healthy
fluent-bit-host01:
image: ubuntu:22.04
environment:
- CLUSTER=local
- RACK=dev
- HOSTNAME=host01
- ES_HOST=es
- ES_PORT=9200
volumes:
- ../fluent-bit/build:/private/
ports: ["2020:2020"]
depends_on:
es:
condition: service_healthy
command: /private/start-fluent-bit.sh
healthcheck:
test: ["CMD-SHELL", "curl -fs http://localhost:2020/api/v2/metrics >/dev/null || exit 1"]
interval: 15s
timeout: 10s
retries: 30
fluent-bit-host02:
image: ubuntu:22.04
environment:
- CLUSTER=local
- RACK=dev
- HOSTNAME=host02
- ES_HOST=es
- ES_PORT=9200
volumes:
- ../fluent-bit/build:/private/
ports: ["2021:2020"]
depends_on:
es:
condition: service_healthy
command: /private/start-fluent-bit.sh
healthcheck:
test: ["CMD-SHELL", "curl -fs http://localhost:2020/api/v2/metrics >/dev/null || exit 1"]
interval: 15s
timeout: 10s
retries: 30
restart: always
bind9:
image: argus-bind9:latest
volumes:
- ./private/argus:/private/argus/
restart: always

View File

@@ -0,0 +1,73 @@
#!/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..."
mkdir -p "$root/private/argus/log/elasticsearch"
mkdir -p "$root/private/argus/log/kibana"
mkdir -p "$root/private/argus/etc/"
# 设置数据目录权限(ES 和 Kibana 容器都使用 UID 1000)
echo "[INFO] Setting permissions for data directories..."
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"
# 检查fluent-bit相关文件是否存在
if [[ ! -f "$root/../fluent-bit/fluent-bit-bundle.tar.gz" ]]; then
echo "[WARN] fluent-bit/fluent-bit-bundle.tar.gz 不存在,请确保已创建该文件"
fi
if [[ ! -f "$root/../fluent-bit/start-fluent-bit.sh" ]]; then
echo "[WARN] fluent-bit/start-fluent-bit.sh 不存在,请确保已创建该启动脚本"
fi
echo "[OK] 初始化完成: private/argus/log/{elasticsearch,kibana}"
echo "[INFO] Fluent-bit files should be in fluent-bit/ directory"
# 准备 Fluent Bit 离线依赖(从 metric all-in-one-full 复制 deb 到 ../fluent-bit/build/packages)
FLB_BUILD_PACKAGES_DIR="$root/../fluent-bit/build/packages"
mkdir -p "$FLB_BUILD_PACKAGES_DIR"
for deb in \
"$project_root/src/metric/client-plugins/all-in-one-full/plugins/fluent-bit/bin/libyaml-0-2_"*_amd64.deb \
"$project_root/src/metric/client-plugins/all-in-one-full/plugins/fluent-bit/bin/libpq5_"*_amd64.deb ; do
if ls $deb >/dev/null 2>&1; then
for f in $deb; do
base="$(basename "$f")"
if [[ ! -f "$FLB_BUILD_PACKAGES_DIR/$base" ]]; then
cp "$f" "$FLB_BUILD_PACKAGES_DIR/"
echo " [+] copied $base"
fi
done
fi
done
# 额外:从 all-in-one-full 的 ubuntu22/curl.tar.gz 解包必要依赖(libsasl2/ldap),便于离线安装
CURLOPT_TAR="$project_root/src/metric/client-plugins/all-in-one-full/deps/ubuntu22/curl.tar.gz"
if [[ -f "$CURLOPT_TAR" ]]; then
tmpdir=$(mktemp -d)
if tar -xzf "$CURLOPT_TAR" -C "$tmpdir" 2>/dev/null; then
for p in \
libsasl2-2_*_amd64.deb \
libsasl2-modules-db_*_amd64.deb \
libldap-2.5-0_*_amd64.deb \
libidn2-0_*_amd64.deb \
libbrotli1_*_amd64.deb \
libssl3_*_amd64.deb ; do
src=$(ls "$tmpdir"/curl/$p 2>/dev/null | head -n1 || true)
if [[ -n "$src" ]]; then
base="$(basename "$src")"
[[ -f "$FLB_BUILD_PACKAGES_DIR/$base" ]] || cp "$src" "$FLB_BUILD_PACKAGES_DIR/" && echo " [+] staged $base"
fi
done
fi
rm -rf "$tmpdir"
fi

10
src/log/tests/scripts/02_up.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
compose_cmd="docker compose"
if ! $compose_cmd version >/dev/null 2>&1; then
if command -v docker-compose >/dev/null 2>&1; then compose_cmd="docker-compose"; else
echo "需要 Docker Compose,请安装后重试" >&2; exit 1; fi
fi
$compose_cmd -p logging-mvp up -d --remove-orphans
echo "[OK] 服务已启动:ES http://localhost:9200 Kibana http://localhost:5601 Fluent-Bit host01 http://localhost:2020 Fluent-Bit host02 http://localhost:2021"

View File

@@ -0,0 +1,45 @@
#!/usr/bin/env bash
set -euo pipefail
# 获取fluent-bit-host01容器名称
container_name="logging-mvp-fluent-bit-host01-1"
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
# 创建日志目录
docker exec "$container_name" mkdir -p /logs/train /logs/infer
# 写入训练日志 (host01)
docker exec "$container_name" sh -c "printf '%s INFO [host01] training step=1 loss=1.23 model=bert\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/train/train-demo.log"
docker exec "$container_name" sh -c "printf '%s INFO [host01] training step=2 loss=1.15 model=bert\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/train/train-demo.log"
# 写入推理日志 (host01)
docker exec "$container_name" sh -c "printf '%s ERROR [host01] inference failed on batch=1\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/infer/infer-demo.log"
docker exec "$container_name" sh -c "cat <<'STACK' >> /logs/infer/infer-demo.log
Traceback (most recent call last):
File \"inference.py\", line 15, in <module>
raise RuntimeError(\"CUDA out of memory on host01\")
RuntimeError: CUDA out of memory on host01
STACK"
echo "[OK] 已通过docker exec写入测试日志到 host01 容器内:"
echo " - /logs/train/train-demo.log"
echo " - /logs/infer/infer-demo.log"

View File

@@ -0,0 +1,41 @@
#!/usr/bin/env bash
set -euo pipefail
# 获取fluent-bit-host02容器名称
container_name="logging-mvp-fluent-bit-host02-1"
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
# 创建日志目录
docker exec "$container_name" mkdir -p /logs/train /logs/infer
# 写入训练日志 (host02)
docker exec "$container_name" sh -c "printf '%s INFO [host02] training step=1 loss=1.45 model=gpt\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/train/train-demo.log"
docker exec "$container_name" sh -c "printf '%s INFO [host02] training step=2 loss=1.38 model=gpt\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/train/train-demo.log"
docker exec "$container_name" sh -c "printf '%s INFO [host02] training step=3 loss=1.32 model=gpt\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/train/train-demo.log"
# 写入推理日志 (host02)
docker exec "$container_name" sh -c "printf '%s WARN [host02] inference slow on batch=5 latency=2.3s\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/infer/infer-demo.log"
docker exec "$container_name" sh -c "printf '%s INFO [host02] inference completed batch=6 latency=0.8s\n' \"\$(date -u +%Y-%m-%dT%H:%M:%SZ)\" >> /logs/infer/infer-demo.log"
echo "[OK] 已通过docker exec写入测试日志到 host02 容器内:"
echo " - /logs/train/train-demo.log"
echo " - /logs/infer/infer-demo.log"

View File

@@ -0,0 +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
# 打印计数,缺失索引按 0 处理
printf "train-* 计数:"; safe_count "train-*"; echo
printf "infer-* 计数:"; safe_count "infer-*"; echo

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")/.."
compose_cmd="docker compose"
if ! $compose_cmd version >/dev/null 2>&1; then
if command -v docker-compose >/dev/null 2>&1; then compose_cmd="docker-compose"; else
echo "需要 Docker Compose,请安装后重试" >&2; exit 1; fi
fi
$compose_cmd -p logging-mvp down
echo "[OK] 已停止所有容器"
# 清理private目录内容
echo "[INFO] 清理private目录内容..."
cd "$(dirname "$0")/.."
if [ -d "private" ]; then
# 删除private目录及其所有内容
rm -rf private
echo "[OK] 已清理private目录"
else
echo "[INFO] private目录不存在,无需清理"
fi

View File

@@ -0,0 +1,208 @@
#!/usr/bin/env bash
set -euo pipefail
echo "======================================="
echo "ARGUS DNS监控功能测试"
echo "======================================="
echo ""
# 记录测试开始时间
test_start_time=$(date +%s)
# 函数:显示测试步骤
show_step() {
echo ""
echo "🔄 Step $1: $2"
echo "----------------------------------------"
}
# 函数:验证步骤结果
verify_step() {
if [ $? -eq 0 ]; then
echo "✅ $1 - SUCCESS"
else
echo "❌ $1 - FAILED"
exit 1
fi
}
# 函数:等待服务就绪
wait_for_services() {
echo "[INFO] Waiting for services to be ready..."
local max_attempts=60
local attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -fs http://localhost:9200/_cluster/health >/dev/null 2>&1 && \
curl -fs http://localhost:5601/api/status >/dev/null 2>&1; then
echo "[OK] Services are ready!"
return 0
fi
echo " Waiting for services... ($attempt/$max_attempts)"
sleep 5
((attempt++))
done
echo "[ERROR] Services not ready after $max_attempts attempts"
return 1
}
# 函数:检查容器中的/etc/resolv.conf
check_resolv_conf() {
local service_name=$1
local expected_dns=$2
echo "[INFO] 检查 $service_name 容器的 /etc/resolv.conf..."
local resolv_content=$(docker exec "${service_name}" cat /etc/resolv.conf 2>/dev/null || echo "")
if echo "$resolv_content" | grep -q "nameserver $expected_dns"; then
echo "✅ $service_name resolv.conf contains nameserver $expected_dns"
return 0
else
echo "❌ $service_name resolv.conf does not contain nameserver $expected_dns"
echo "实际内容:"
echo "$resolv_content"
return 1
fi
}
# 函数:检查DNS监控日志
check_dns_monitor_logs() {
local service_name=$1
echo "[INFO] 检查 $service_name 的DNS监控日志..."
local dns_logs=$(docker exec "$service_name" tail -n 20 /var/log/supervisor/dns-monitor.log 2>/dev/null || echo "")
if [ -n "$dns_logs" ]; then
echo "✅ $service_name DNS监控日志存在"
echo "最近的日志:"
echo "$dns_logs"
return 0
else
echo "❌ $service_name DNS监控日志为空或不存在"
return 1
fi
}
# 函数:确保目录结构存在
ensure_directories() {
echo "[INFO] 确保目录结构存在..."
# 确保目录存在
mkdir -p ./private/argus/etc/
echo "✅ 目录结构准备完成(注:使用真实的update-dns.sh脚本)"
}
# 开始DNS监控测试
show_step "1" "Bootstrap - Initialize environment"
./scripts/01_bootstrap.sh
verify_step "Bootstrap"
# 确保目录结构
ensure_directories
show_step "2" "Startup - Start all services"
./scripts/02_up.sh
verify_step "Service startup"
# 等待服务完全就绪
wait_for_services || exit 1
show_step "3" "Create initial DNS configuration"
# 创建初始的DNS配置文件 - 只有一个IP
echo "[INFO] 创建初始的dns.conf文件 (8.8.8.8)..."
cat > ./private/argus/etc/dns.conf << 'EOF'
8.8.8.8
EOF
echo "✅ 初始dns.conf文件创建成功 (8.8.8.8)"
verify_step "Initial DNS configuration creation"
# 等待DNS监控检测到配置文件
echo "[INFO] 等待DNS监控检测并处理初始配置..."
sleep 15
show_step "4" "Verify initial DNS configuration processing"
# 检查两个容器的DNS监控日志
check_dns_monitor_logs "logging-mvp-es-1"
verify_step "Elasticsearch DNS monitor logs"
check_dns_monitor_logs "logging-mvp-kibana-1"
verify_step "Kibana DNS monitor logs"
# 检查resolv.conf是否包含新的DNS服务器
check_resolv_conf "logging-mvp-es-1" "8.8.8.8"
verify_step "Elasticsearch resolv.conf initial check"
check_resolv_conf "logging-mvp-kibana-1" "8.8.8.8"
verify_step "Kibana resolv.conf initial check"
show_step "5" "Modify DNS configuration and test auto-update"
# 修改DNS配置文件 - 改为另一个IP
echo "[INFO] 修改dns.conf文件,改为1.1.1.1..."
cat > ./private/argus/etc/dns.conf << 'EOF'
1.1.1.1
EOF
echo "✅ dns.conf文件更新成功,改为1.1.1.1"
# 等待DNS监控检测到配置变化
echo "[INFO] 等待DNS监控检测配置变化并执行更新..."
sleep 15
show_step "6" "Verify DNS configuration auto-update"
# 再次检查DNS监控日志,应该看到配置变化检测
echo "[INFO] 检查DNS监控是否检测到配置变化..."
# 检查elasticsearch容器
echo "[INFO] 检查elasticsearch容器的DNS监控日志(最近30行)..."
docker exec logging-mvp-es-1 tail -n 30 /var/log/supervisor/dns-monitor.log || true
# 检查kibana容器
echo "[INFO] 检查kibana容器的DNS监控日志(最近30行)..."
docker exec logging-mvp-kibana-1 tail -n 30 /var/log/supervisor/dns-monitor.log || true
# 验证新的DNS服务器是否被添加到resolv.conf
check_resolv_conf "logging-mvp-es-1" "1.1.1.1"
verify_step "Elasticsearch resolv.conf after update"
check_resolv_conf "logging-mvp-kibana-1" "1.1.1.1"
verify_step "Kibana resolv.conf after update"
show_step "7" "Final verification - Check DNS configuration"
# 最终验证DNS配置
echo "[INFO] 最终验证elasticsearch容器的resolv.conf..."
docker exec logging-mvp-es-1 cat /etc/resolv.conf
echo "[INFO] 最终验证kibana容器的resolv.conf..."
docker exec logging-mvp-kibana-1 cat /etc/resolv.conf
echo "[INFO] 最终dns.conf内容:"
cat ./private/argus/etc/dns.conf
verify_step "Final DNS configuration verification"
show_step "8" "Cleanup - Stop all services"
./scripts/05_down.sh
verify_step "Service cleanup"
# 清理测试文件
rm -f ./private/argus/etc/dns.conf
# 注:不删除update-dns.sh,因为这是真实的脚本
# 计算总测试时间
test_end_time=$(date +%s)
total_time=$((test_end_time - test_start_time))
echo ""
echo "======================================="
echo "🎉 DNS监控功能测试完成!"
echo "======================================="
echo "📊 测试总结:"
echo " • 总耗时: ${total_time}秒"
echo " • 初始DNS配置: 8.8.8.8"
echo " • 更新DNS配置: 1.1.1.1"
echo " • DNS监控脚本正常工作"
echo " • 容器resolv.conf自动覆盖更新成功"
echo ""
echo "✅ DNS自动更新功能测试通过!"
echo ""

188
src/log/tests/scripts/e2e_test.sh Executable file
View File

@@ -0,0 +1,188 @@
#!/usr/bin/env bash
set -euo pipefail
echo "======================================="
echo "ARGUS Log System End-to-End Test"
echo "======================================="
echo ""
# 记录测试开始时间
test_start_time=$(date +%s)
# 函数:获取ES中的日志计数
get_log_count() {
local train_count=$(curl -s "http://localhost:9200/train-*/_count" 2>/dev/null | grep -o '"count":[0-9]*' | cut -d':' -f2 || echo "0")
local infer_count=$(curl -s "http://localhost:9200/infer-*/_count" 2>/dev/null | grep -o '"count":[0-9]*' | cut -d':' -f2 || echo "0")
echo "$((train_count + infer_count))"
}
# 函数:等待服务就绪
wait_for_services() {
echo "[INFO] Waiting for all services to be ready..."
local max_attempts=${SERVICE_WAIT_ATTEMPTS:-120}
local attempt=1
while [ $attempt -le $max_attempts ]; do
if curl -fs http://localhost:9200/_cluster/health >/dev/null 2>&1 && \
curl -fs http://localhost:5601/api/status >/dev/null 2>&1 && \
curl -fs http://localhost:2020/api/v2/metrics >/dev/null 2>&1 && \
curl -fs http://localhost:2021/api/v2/metrics >/dev/null 2>&1; then
echo "[OK] All services are ready!"
return 0
fi
echo " Waiting for services... ($attempt/$max_attempts)"
sleep 5
((attempt++))
done
echo "[ERROR] Services not ready after $max_attempts attempts"
return 1
}
# 函数:显示测试步骤
show_step() {
echo ""
echo "🔄 Step $1: $2"
echo "----------------------------------------"
}
# 函数:验证步骤结果
verify_step() {
if [ $? -eq 0 ]; then
echo "✅ $1 - SUCCESS"
else
echo "❌ $1 - FAILED"
exit 1
fi
}
# 开始端到端测试
show_step "1" "Bootstrap - Initialize environment"
./scripts/01_bootstrap.sh
verify_step "Bootstrap"
show_step "2" "Startup - Start all services"
./scripts/02_up.sh
verify_step "Service startup"
# 等待服务完全就绪
wait_for_services || exit 1
# 记录发送测试数据前的日志计数
initial_count=$(get_log_count)
echo "[INFO] Initial log count: $initial_count"
show_step "3a" "Send test data - Host01"
./scripts/03_send_test_host01.sh
verify_step "Test data sending (host01)"
show_step "3b" "Send test data - Host02"
./scripts/03_send_test_host02.sh
verify_step "Test data sending (host02)"
# 等待数据被处理
echo "[INFO] Waiting for data to be processed..."
sleep 10
show_step "4" "Verify data - Query Elasticsearch"
./scripts/04_query_es.sh
verify_step "Data verification"
# 记录发送测试数据后的日志计数
final_count=$(get_log_count)
echo "[INFO] Final log count: $final_count"
# 验证日志数量是否增加
if [ "$final_count" -gt "$initial_count" ]; then
added_logs=$((final_count - initial_count))
echo "✅ Log count verification - SUCCESS: Added $added_logs logs (from $initial_count to $final_count)"
else
echo "❌ Log count verification - FAILED: Expected count to increase, but got $initial_count -> $final_count"
exit 1
fi
# 验证预期的最小日志数量(每个主机应该发送一些日志)
expected_min_logs=4 # 至少应该有几条日志
if [ "$final_count" -ge "$expected_min_logs" ]; then
echo "✅ Minimum log threshold - SUCCESS: $final_count logs (>= $expected_min_logs expected)"
else
echo "❌ Minimum log threshold - FAILED: Only $final_count logs (>= $expected_min_logs expected)"
exit 1
fi
# 检查服务健康状态
show_step "Health" "Check service health"
echo "[INFO] Checking service health..."
# 检查 Elasticsearch 健康状态
health_check_ok=1
es_health=$(curl -s "http://localhost:9200/_cluster/health" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
if [ "$es_health" = "green" ] || [ "$es_health" = "yellow" ]; then
echo "✅ Elasticsearch health: $es_health"
else
echo "❌ Elasticsearch health: $es_health"
health_check_ok=0
fi
# 检查 Kibana 状态
if curl -fs "http://localhost:5601/api/status" >/dev/null 2>&1; then
kb_status="available"
echo "✅ Kibana status: $kb_status"
data_views_json=$(curl -fs "http://localhost:5601/api/data_views" -H 'kbn-xsrf: true' 2>/dev/null || true)
if echo "$data_views_json" | grep -F '"title":"train-*"' >/dev/null 2>&1 && \
echo "$data_views_json" | grep -F '"title":"infer-*"' >/dev/null 2>&1; then
echo "✅ Kibana data views: train-* and infer-* present"
else
echo "❌ Kibana data views missing: train-* or infer-*"
health_check_ok=0
fi
else
kb_status="unavailable"
echo "⚠️ Kibana status: $kb_status"
health_check_ok=0
fi
# 检查 Fluent-Bit 指标
fb_host01_uptime=$(curl -s "http://localhost:2020/api/v2/metrics" | grep "fluentbit_uptime" | head -1 | grep -o "[0-9]\+$" || echo "0")
fb_host02_uptime=$(curl -s "http://localhost:2021/api/v2/metrics" | grep "fluentbit_uptime" | head -1 | grep -o "[0-9]\+$" || echo "0")
if [ "$fb_host01_uptime" -gt 0 ] && [ "$fb_host02_uptime" -gt 0 ]; then
echo "✅ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
else
echo "⚠️ Fluent-Bit services: host01 uptime=${fb_host01_uptime}s, host02 uptime=${fb_host02_uptime}s"
health_check_ok=0
fi
if [ "$health_check_ok" -eq 1 ]; then
true
else
false
fi
verify_step "Service health check"
show_step "5" "Cleanup - Stop all services"
./scripts/05_down.sh
verify_step "Service cleanup"
# 计算总测试时间
test_end_time=$(date +%s)
total_time=$((test_end_time - test_start_time))
echo ""
echo "======================================="
echo "🎉 END-TO-END TEST COMPLETED SUCCESSFULLY!"
echo "======================================="
echo "📊 Test Summary:"
echo " • Initial logs: $initial_count"
echo " • Final logs: $final_count"
echo " • Added logs: $added_logs"
echo " • Total time: ${total_time}s"
echo " • ES health: $es_health"
echo " • Kibana status: $kb_status"
echo " • DNS resolv: ✅ Passed (ES domain verified)"
echo " • All services started and stopped successfully"
echo ""
echo "✅ The ARGUS log system is working correctly!"
echo ""