[#29] lm2测试非GPU节点通过,新增宿主机空闲端口检测,遗留网页超链接使用静态端口问题

This commit is contained in:
yuyr 2025-10-27 15:46:59 +08:00
parent 23f0f4fca4
commit cc0f9e5fed
16 changed files with 225 additions and 79 deletions

View File

@ -11,13 +11,6 @@ RUN if [ "$USE_INTRANET" = "true" ]; then \
echo "deb [trusted=yes] http://10.68.64.1/ubuntu2204/ jammy main" > /etc/apt/sources.list && \ echo "deb [trusted=yes] http://10.68.64.1/ubuntu2204/ jammy main" > /etc/apt/sources.list && \
echo 'Acquire::https::Verify-Peer "false";' > /etc/apt/apt.conf.d/99disable-ssl-check && \ echo 'Acquire::https::Verify-Peer "false";' > /etc/apt/apt.conf.d/99disable-ssl-check && \
echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99disable-ssl-check; \ echo 'Acquire::https::Verify-Host "false";' >> /etc/apt/apt.conf.d/99disable-ssl-check; \
else \
echo "Configuring fast apt sources for external network..." && \
find /etc/apt -name "sources.list*" -exec sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g' {} \; && \
find /etc/apt -name "sources.list*" -exec sed -i 's/security.ubuntu.com/mirrors.aliyun.com/g' {} \; && \
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy main restricted universe multiverse" > /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy-updates main restricted universe multiverse" >> /etc/apt/sources.list && \
echo "deb http://mirrors.aliyun.com/ubuntu/ jammy-security main restricted universe multiverse" >> /etc/apt/sources.list; \
fi fi
# 验证源配置并安装常用工具 # 验证源配置并安装常用工具

View File

@ -56,13 +56,14 @@
- 自定义 bridge`argus-sys-net`,子网 `172.31.0.0/16` - 自定义 bridge`argus-sys-net`,子网 `172.31.0.0/16`
- 固定地址bind=`172.31.0.2`master=`172.31.0.10` - 固定地址bind=`172.31.0.2`master=`172.31.0.10`
- 服务与端口 - 服务与端口(宿主机映射端口由 `01_bootstrap.sh` 自动分配并写入 `.env`
- 关键变量:`MASTER_PORT``ES_HTTP_PORT``KIBANA_PORT``NODE_A_PORT``NODE_B_PORT``PROMETHEUS_PORT``GRAFANA_PORT``ALERTMANAGER_PORT``WEB_PROXY_PORT_8080..8085``FTP_PORT``FTP_DATA_PORT``FTP_PASSIVE_HOST_RANGE`
- `bind``argus-bind9:latest`):监听 53/tcp+udp负责同步 `*.argus.com` 记录 - `bind``argus-bind9:latest`):监听 53/tcp+udp负责同步 `*.argus.com` 记录
- `master``argus-master:latest`):对外 `32300→3000`API `http://localhost:32300` - `master``argus-master:latest`):对外 `${MASTER_PORT}→3000`API `http://localhost:${MASTER_PORT}`
- `es``argus-elasticsearch:latest``9200→9200`;单节点,无安全 - `es``argus-elasticsearch:latest``${ES_HTTP_PORT}→9200`;单节点,无安全
- `kibana``argus-kibana:latest``5601→5601`;通过 `ELASTICSEARCH_HOSTS=http://es:9200` 访问 ES - `kibana``argus-kibana:latest``${KIBANA_PORT}→5601`;通过 `ELASTICSEARCH_HOSTS=http://es:9200` 访问 ES
- `node-a``ubuntu:22.04`):同时运行 Fluent Bit + argus-agent`hostname=dev-yyrshare-nbnyx10-cp2f-pod-0``2020→2020` - `node-a``ubuntu:22.04`):同时运行 Fluent Bit + argus-agent`hostname=dev-yyrshare-nbnyx10-cp2f-pod-0``${NODE_A_PORT}→2020`
- `node-b``ubuntu:22.04`):同时运行 Fluent Bit + argus-agent`hostname=dev-yyrshare-uuuu10-ep2f-pod-0``2021→2020` - `node-b``ubuntu:22.04`):同时运行 Fluent Bit + argus-agent`hostname=dev-yyrshare-uuuu10-ep2f-pod-0``${NODE_B_PORT}→2020`
- 卷与目录 - 卷与目录
- 核心服务bind/master/es/kibana共享宿主 `./private` 挂载到容器 `/private` - 核心服务bind/master/es/kibana共享宿主 `./private` 挂载到容器 `/private`

View File

@ -29,7 +29,7 @@ services:
- ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133} - ARGUS_BUILD_UID=${ARGUS_BUILD_UID:-2133}
- ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015} - ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015}
ports: ports:
- "32300:3000" - "${MASTER_PORT:-32300}:3000"
volumes: volumes:
- ./private/argus/master:/private/argus/master - ./private/argus/master:/private/argus/master
- ./private/argus/metric/prometheus:/private/argus/metric/prometheus - ./private/argus/metric/prometheus:/private/argus/metric/prometheus
@ -52,7 +52,7 @@ services:
- ./private/argus/log/elasticsearch:/private/argus/log/elasticsearch - ./private/argus/log/elasticsearch:/private/argus/log/elasticsearch
- ./private/argus/etc:/private/argus/etc - ./private/argus/etc:/private/argus/etc
ports: ports:
- "9200:9200" - "${ES_HTTP_PORT:-9200}:9200"
restart: unless-stopped restart: unless-stopped
networks: networks:
sysnet: sysnet:
@ -71,7 +71,7 @@ services:
depends_on: depends_on:
- es - es
ports: ports:
- "5601:5601" - "${KIBANA_PORT:-5601}:5601"
restart: unless-stopped restart: unless-stopped
networks: networks:
sysnet: sysnet:
@ -104,9 +104,10 @@ services:
entrypoint: entrypoint:
- /usr/local/bin/node-entrypoint.sh - /usr/local/bin/node-entrypoint.sh
dns: dns:
- 172.31.0.2 - 172.31.0.2 # internal bind for *.argus.com
- 8.8.8.8 # external fallback for apt/external domains
ports: ports:
- "2020:2020" - "${NODE_A_PORT:-2020}:2020"
restart: unless-stopped restart: unless-stopped
networks: networks:
- sysnet - sysnet
@ -139,8 +140,9 @@ services:
- /usr/local/bin/node-entrypoint.sh - /usr/local/bin/node-entrypoint.sh
dns: dns:
- 172.31.0.2 - 172.31.0.2
- 8.8.8.8
ports: ports:
- "2021:2020" - "${NODE_B_PORT:-2021}:2020"
restart: unless-stopped restart: unless-stopped
networks: networks:
- sysnet - sysnet
@ -159,7 +161,7 @@ services:
ports: ports:
- "${FTP_PORT:-21}:21" - "${FTP_PORT:-21}:21"
- "${FTP_DATA_PORT:-20}:20" - "${FTP_DATA_PORT:-20}:20"
- "21100-21110:21100-21110" - "${FTP_PASSIVE_HOST_RANGE:-21100-21110}:21100-21110"
volumes: volumes:
- ./private/argus/metric/ftp:/private/argus/ftp - ./private/argus/metric/ftp:/private/argus/ftp
- ./private/argus/etc:/private/argus/etc - ./private/argus/etc:/private/argus/etc
@ -281,6 +283,9 @@ services:
command: command:
- sleep - sleep
- infinity - infinity
dns:
- 172.31.0.2
- 8.8.8.8
networks: networks:
sysnet: sysnet:
ipv4_address: 172.31.0.50 ipv4_address: 172.31.0.50
@ -328,6 +333,9 @@ services:
command: command:
- sleep - sleep
- infinity - infinity
dns:
- 172.31.0.2
- 8.8.8.8
networks: networks:
sysnet: sysnet:
ipv4_address: 172.31.0.51 ipv4_address: 172.31.0.51
@ -351,7 +359,7 @@ services:
sysnet: sysnet:
ipv4_address: 172.31.0.82 ipv4_address: 172.31.0.82
ports: ports:
- "9093:9093" - "${ALERTMANAGER_PORT:-9093}:9093"
restart: unless-stopped restart: unless-stopped
logging: logging:
driver: "json-file" driver: "json-file"
@ -379,12 +387,12 @@ services:
sysnet: sysnet:
ipv4_address: 172.31.0.81 ipv4_address: 172.31.0.81
ports: ports:
- "8080:8080" - "${WEB_PROXY_PORT_8080:-8080}:8080"
- "8081:8081" - "${WEB_PROXY_PORT_8081:-8081}:8081"
- "8082:8082" - "${WEB_PROXY_PORT_8082:-8082}:8082"
- "8083:8083" - "${WEB_PROXY_PORT_8083:-8083}:8083"
- "8084:8084" - "${WEB_PROXY_PORT_8084:-8084}:8084"
- "8085:8085" - "${WEB_PROXY_PORT_8085:-8085}:8085"
restart: unless-stopped restart: unless-stopped
logging: logging:
driver: "json-file" driver: "json-file"

View File

@ -139,6 +139,77 @@ else
fi fi
echo "[INFO] Writing .env with UID/GID and metric configuration" echo "[INFO] Writing .env with UID/GID and metric configuration"
#############################################
# 动态分配宿主机端口并写入 .env
#############################################
# 读取现有 .env若存在用于保留密码/域名等
EXIST_DOTENV="$TEST_ROOT/.env"
if [[ -f "$EXIST_DOTENV" ]]; then
EXISTING_FTP_PASSWORD="$(grep -E '^FTP_PASSWORD=' "$EXIST_DOTENV" | tail -n1 | sed 's/^FTP_PASSWORD=//')"
EXISTING_FTP_DOMAIN="$(grep -E '^FTP_DOMAIN=' "$EXIST_DOTENV" | tail -n1 | sed 's/^FTP_DOMAIN=//')"
EXISTING_USE_INTRANET="$(grep -E '^USE_INTRANET=' "$EXIST_DOTENV" | tail -n1 | sed 's/^USE_INTRANET=//')"
else
EXISTING_FTP_PASSWORD=""
EXISTING_FTP_DOMAIN=""
EXISTING_USE_INTRANET=""
fi
is_port_free() {
local p="$1"
ss -ltnH 2>/dev/null | awk -v pat=":${p}$" '$4 ~ pat{f=1} END{exit f?1:0}'
}
find_free_port() {
local prefer="$1"; local start_scan="${2:-20000}"; local max="${3:-65000}"
if is_port_free "$prefer"; then echo "$prefer"; return 0; fi
local p
for (( p=start_scan; p<=max; p++ )); do
if is_port_free "$p"; then echo "$p"; return 0; fi
done
return 1
}
find_free_range() {
local begin="$1"; local end="$2"; local need_count=$((end-begin+1))
local try_start="$begin"
while (( try_start + need_count - 1 <= 65000 )); do
local ok=1
for (( p=try_start; p<try_start+need_count; p++ )); do
if ! is_port_free "$p"; then ok=0; break; fi
done
if (( ok==1 )); then
echo "${try_start}-$((try_start+need_count-1))"; return 0
fi
((try_start++))
done
return 1
}
# 优先端口(若占用则回退到 20000+ 的空闲)
MASTER_PORT_VAL=$(find_free_port 32300)
ES_HTTP_PORT_VAL=$(find_free_port 9200)
KIBANA_PORT_VAL=$(find_free_port 5601)
NODE_A_PORT_VAL=$(find_free_port 2020)
NODE_B_PORT_VAL=$(find_free_port 2021)
PROMETHEUS_PORT_VAL=$(find_free_port 9090)
GRAFANA_PORT_VAL=$(find_free_port 3000)
ALERTMANAGER_PORT_VAL=$(find_free_port 9093)
WEB_PROXY_PORT_8080_VAL=$(find_free_port 8080 18080 65000)
WEB_PROXY_PORT_8081_VAL=$(find_free_port 8081 18081 65000)
WEB_PROXY_PORT_8082_VAL=$(find_free_port 8082 18082 65000)
WEB_PROXY_PORT_8083_VAL=$(find_free_port 8083 18083 65000)
WEB_PROXY_PORT_8084_VAL=$(find_free_port 8084 18084 65000)
WEB_PROXY_PORT_8085_VAL=$(find_free_port 8085 18085 65000)
# FTP 控制/数据端口:若 21/20 被占用则回退到空闲
FTP_PORT_VAL=$(find_free_port 21 2121 65000)
FTP_DATA_PORT_VAL=$(find_free_port 20 2120 65000)
# FTP 被动端口范围:优先 21100-21110若被占用则向后平移
FTP_PASV_RANGE_VAL="$(find_free_range 21100 21110 || echo 22100-22110)"
# 变量持久化到 .env
cat > "$TEST_ROOT/.env" <<EOF cat > "$TEST_ROOT/.env" <<EOF
ARGUS_BUILD_UID=$ARGUS_BUILD_UID ARGUS_BUILD_UID=$ARGUS_BUILD_UID
ARGUS_BUILD_GID=$ARGUS_BUILD_GID ARGUS_BUILD_GID=$ARGUS_BUILD_GID
@ -146,20 +217,31 @@ ARGUS_BUILD_GID=$ARGUS_BUILD_GID
# GPU 配置 # GPU 配置
ENABLE_GPU=$GPU_AVAILABLE ENABLE_GPU=$GPU_AVAILABLE
# FTP 配置 # Master/日志/监控等服务的宿主机端口(自动分配)
FTP_PORT=21 MASTER_PORT=$MASTER_PORT_VAL
FTP_DATA_PORT=20 ES_HTTP_PORT=$ES_HTTP_PORT_VAL
FTP_PASSWORD=ZGClab1234! KIBANA_PORT=$KIBANA_PORT_VAL
FTP_DOMAIN=ftp.metric.argus.com NODE_A_PORT=$NODE_A_PORT_VAL
NODE_B_PORT=$NODE_B_PORT_VAL
PROMETHEUS_PORT=$PROMETHEUS_PORT_VAL
GRAFANA_PORT=$GRAFANA_PORT_VAL
ALERTMANAGER_PORT=$ALERTMANAGER_PORT_VAL
WEB_PROXY_PORT_8080=$WEB_PROXY_PORT_8080_VAL
WEB_PROXY_PORT_8081=$WEB_PROXY_PORT_8081_VAL
WEB_PROXY_PORT_8082=$WEB_PROXY_PORT_8082_VAL
WEB_PROXY_PORT_8083=$WEB_PROXY_PORT_8083_VAL
WEB_PROXY_PORT_8084=$WEB_PROXY_PORT_8084_VAL
WEB_PROXY_PORT_8085=$WEB_PROXY_PORT_8085_VAL
# Prometheus 配置 # FTP 配置自动分配若21/20占用则使用高位端口
PROMETHEUS_PORT=9090 FTP_PORT=$FTP_PORT_VAL
FTP_DATA_PORT=$FTP_DATA_PORT_VAL
# Grafana 配置 FTP_PASSIVE_HOST_RANGE=$FTP_PASV_RANGE_VAL
GRAFANA_PORT=3000 FTP_PASSWORD=${EXISTING_FTP_PASSWORD:-ZGClab1234!}
FTP_DOMAIN=${EXISTING_FTP_DOMAIN:-ftp.metric.argus.com}
# 网络配置 # 网络配置
USE_INTRANET=false USE_INTRANET=${EXISTING_USE_INTRANET:-false}
EOF EOF
echo "[OK] Bootstrap completed" echo "[OK] Bootstrap completed. Ports written to $TEST_ROOT/.env"

View File

@ -15,6 +15,11 @@ compose() {
echo "[INFO] Bringing up system stack..." echo "[INFO] Bringing up system stack..."
# 加载 .env 以获取端口(由 01_bootstrap 生成)
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
REQUEST_GPU=${ARGUS_SYS_ENABLE_GPU:-false} REQUEST_GPU=${ARGUS_SYS_ENABLE_GPU:-false}
GPU_AVAILABLE=false GPU_AVAILABLE=false
GPU_CHECK_SCRIPT="$REPO_ROOT/src/metric/tests/scripts/common/check-gpu.sh" GPU_CHECK_SCRIPT="$REPO_ROOT/src/metric/tests/scripts/common/check-gpu.sh"
@ -58,7 +63,13 @@ check_port_free() {
return 0 return 0
} }
for port in 8080 8081 8082 8083 8084 8085; do for port in \
"${WEB_PROXY_PORT_8080:-8080}" \
"${WEB_PROXY_PORT_8081:-8081}" \
"${WEB_PROXY_PORT_8082:-8082}" \
"${WEB_PROXY_PORT_8083:-8083}" \
"${WEB_PROXY_PORT_8084:-8084}" \
"${WEB_PROXY_PORT_8085:-8085}"; do
check_port_free "$port" || { echo "[ERR] Required port busy: $port"; exit 1; } check_port_free "$port" || { echo "[ERR] Required port busy: $port"; exit 1; }
done done
@ -80,7 +91,7 @@ fi
popd >/dev/null popd >/dev/null
if [[ "$GPU_AVAILABLE" == true ]]; then if [[ "$GPU_AVAILABLE" == true ]]; then
echo "[OK] Services started: master:32300 es:9200 kibana:5601 node-a:2020 node-b:2021 test-gpu-node:172.31.0.51" echo "[OK] Services started: master:${MASTER_PORT:-32300} es:${ES_HTTP_PORT:-9200} kibana:${KIBANA_PORT:-5601} node-a:${NODE_A_PORT:-2020} node-b:${NODE_B_PORT:-2021} test-gpu-node:172.31.0.51"
else else
echo "[OK] Services started: master:32300 es:9200 kibana:5601 node-a:2020 node-b:2021 (gpu skipped)" echo "[OK] Services started: master:${MASTER_PORT:-32300} es:${ES_HTTP_PORT:-9200} kibana:${KIBANA_PORT:-5601} node-a:${NODE_A_PORT:-2020} node-b:${NODE_B_PORT:-2021} (gpu skipped)"
fi fi

View File

@ -27,11 +27,16 @@ wait_http() {
echo "[INFO] Waiting for ES/Kibana/Master/Fluent Bit/Bind..." echo "[INFO] Waiting for ES/Kibana/Master/Fluent Bit/Bind..."
# 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
# ES (>= yellow) # ES (>= yellow)
attempt=1; max=120 attempt=1; max=120
ES_T0=$(date +%s) ES_T0=$(date +%s)
while (( attempt <= max )); do while (( attempt <= max )); do
if curl -fsS "http://localhost:9200/_cluster/health?wait_for_status=yellow&timeout=1s" >/dev/null 2>&1; then if curl -fsS "http://localhost:${ES_HTTP_PORT:-9200}/_cluster/health?wait_for_status=yellow&timeout=1s" >/dev/null 2>&1; then
break break
fi fi
echo "[..] waiting ES ($attempt/$max)"; sleep 5; ((attempt++)) echo "[..] waiting ES ($attempt/$max)"; sleep 5; ((attempt++))
@ -44,8 +49,8 @@ echo "[INFO] Waiting for Kibana to be available (HTTP 200)..."
kb_attempt=1; kb_max=180 kb_attempt=1; kb_max=180
KB_T0=$(date +%s) KB_T0=$(date +%s)
while (( kb_attempt <= kb_max )); do while (( kb_attempt <= kb_max )); do
body=$(curl -sS "http://localhost:5601/api/status" 2>/dev/null || true) body=$(curl -sS "http://localhost:${KIBANA_PORT:-5601}/api/status" 2>/dev/null || true)
code=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:5601/api/status" || echo 000) code=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${KIBANA_PORT:-5601}/api/status" || echo 000)
if [[ "$code" == "200" ]]; then if [[ "$code" == "200" ]]; then
if echo "$body" | grep -q '"level":"available"'; then if echo "$body" | grep -q '"level":"available"'; then
KB_T1=$(date +%s) KB_T1=$(date +%s)
@ -63,12 +68,12 @@ fi
# Master # Master
MASTER_T0=$(date +%s) MASTER_T0=$(date +%s)
wait_http "http://localhost:32300/readyz" 120 wait_http "http://localhost:${MASTER_PORT:-32300}/readyz" 120
MASTER_T1=$(date +%s); echo "[TIME] Master readyz in $((MASTER_T1-MASTER_T0))s" MASTER_T1=$(date +%s); echo "[TIME] Master readyz in $((MASTER_T1-MASTER_T0))s"
# Fluent Bit (host metrics on host ports) # Fluent Bit (host metrics on host ports)
FB1_T0=$(date +%s); wait_http "http://localhost:2020/api/v2/metrics" 120; FB1_T1=$(date +%s); echo "[TIME] FluentBit:2020 in $((FB1_T1-FB1_T0))s" FB1_T0=$(date +%s); wait_http "http://localhost:${NODE_A_PORT:-2020}/api/v2/metrics" 120; FB1_T1=$(date +%s); echo "[TIME] FluentBit:${NODE_A_PORT:-2020} in $((FB1_T1-FB1_T0))s"
FB2_T0=$(date +%s); wait_http "http://localhost:2021/api/v2/metrics" 120; FB2_T1=$(date +%s); echo "[TIME] FluentBit:2021 in $((FB2_T1-FB2_T0))s" FB2_T0=$(date +%s); wait_http "http://localhost:${NODE_B_PORT:-2021}/api/v2/metrics" 120; FB2_T1=$(date +%s); echo "[TIME] FluentBit:${NODE_B_PORT:-2021} in $((FB2_T1-FB2_T0))s"
# Bind config check # Bind config check
BIND_ID="$(service_id bind)" BIND_ID="$(service_id bind)"
@ -81,14 +86,14 @@ fi
# ========== Additional module readiness checks ========== # ========== Additional module readiness checks ==========
# Prometheus # Prometheus
PROM_T0=$(date +%s); wait_http "http://localhost:9090/-/ready" 120; PROM_T1=$(date +%s); echo "[TIME] Prometheus ready in $((PROM_T1-PROM_T0))s" PROM_T0=$(date +%s); wait_http "http://localhost:${PROMETHEUS_PORT:-9090}/-/ready" 120; PROM_T1=$(date +%s); echo "[TIME] Prometheus ready in $((PROM_T1-PROM_T0))s"
# Grafana health (database: ok) # Grafana health (database: ok)
echo "[INFO] Waiting for Grafana health..." echo "[INFO] Waiting for Grafana health..."
gf_attempt=1; gf_max=120 gf_attempt=1; gf_max=120
while (( gf_attempt <= gf_max )); do while (( gf_attempt <= gf_max )); do
gf_body=$(curl -sS "http://localhost:3000/api/health" 2>/dev/null || true) gf_body=$(curl -sS "http://localhost:${GRAFANA_PORT:-3000}/api/health" 2>/dev/null || true)
gf_code=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:3000/api/health" || echo 000) gf_code=$(curl -s -o /dev/null -w "%{http_code}" "http://localhost:${GRAFANA_PORT:-3000}/api/health" || echo 000)
if [[ "$gf_code" == "200" ]] && echo "$gf_body" | grep -q '"database"\s*:\s*"ok"'; then if [[ "$gf_code" == "200" ]] && echo "$gf_body" | grep -q '"database"\s*:\s*"ok"'; then
echo "[OK] Grafana health database=ok" echo "[OK] Grafana health database=ok"
break break
@ -101,7 +106,7 @@ if (( gf_attempt > gf_max )); then
fi fi
# Alertmanager # Alertmanager
wait_http "http://localhost:9093/api/v2/status" 120 wait_http "http://localhost:${ALERTMANAGER_PORT:-9093}/api/v2/status" 120
# Web proxy checks按端口细化 # Web proxy checks按端口细化
code_for() { curl -s -o /dev/null -w "%{http_code}" "$1" || echo 000; } code_for() { curl -s -o /dev/null -w "%{http_code}" "$1" || echo 000; }
@ -112,7 +117,7 @@ echo "[INFO] Checking web-proxy ports..."
# 8080 首页必须 200 # 8080 首页必须 200
tries=1; max=60; P8080_T0=$(date +%s) tries=1; max=60; P8080_T0=$(date +%s)
while (( tries <= max )); do while (( tries <= max )); do
c=$(code_for "http://localhost:8080/") c=$(code_for "http://localhost:${WEB_PROXY_PORT_8080:-8080}/")
if [[ "$c" == "200" ]]; then P8080_T1=$(date +%s); echo "[OK] 8080 / ($c) in $((P8080_T1-P8080_T0))s"; break; fi if [[ "$c" == "200" ]]; then P8080_T1=$(date +%s); echo "[OK] 8080 / ($c) in $((P8080_T1-P8080_T0))s"; break; fi
echo "[..] waiting 8080/ ($tries/$max), code=$c"; sleep 3; ((tries++)) echo "[..] waiting 8080/ ($tries/$max), code=$c"; sleep 3; ((tries++))
done done
@ -121,20 +126,20 @@ done
# 8083 Kibana 允许 200/302上面已就绪端口侧再快速确认 # 8083 Kibana 允许 200/302上面已就绪端口侧再快速确认
tries=1; max=40; P8083_T0=$(date +%s) tries=1; max=40; P8083_T0=$(date +%s)
while (( tries <= max )); do while (( tries <= max )); do
c=$(code_for "http://localhost:8083/") c=$(code_for "http://localhost:${WEB_PROXY_PORT_8083:-8083}/")
if [[ "$c" == "200" || "$c" == "302" ]]; then P8083_T1=$(date +%s); echo "[OK] 8083 / ($c) in $((P8083_T1-P8083_T0))s"; break; fi if [[ "$c" == "200" || "$c" == "302" ]]; then P8083_T1=$(date +%s); echo "[OK] 8083 / ($c) in $((P8083_T1-P8083_T0))s"; break; fi
echo "[..] waiting 8083/ ($tries/$max), code=$c"; sleep 3; ((tries++)) echo "[..] waiting 8083/ ($tries/$max), code=$c"; sleep 3; ((tries++))
done done
(( tries <= max )) || { echo "[ERR] 8083/ not ready" >&2; exit 1; } (( tries <= max )) || { echo "[ERR] 8083/ not ready" >&2; exit 1; }
# 8084 Alertmanager + CORS # 8084 Alertmanager + CORS
P8084_T0=$(date +%s); wait_http "http://localhost:8084/api/v2/status" 60; P8084_T1=$(date +%s) P8084_T0=$(date +%s); wait_http "http://localhost:${WEB_PROXY_PORT_8084:-8084}/api/v2/status" 60; P8084_T1=$(date +%s)
cors=$(header_val -H "Origin: http://localhost:8080" "http://localhost:8084/api/v2/status" || true) cors=$(header_val -H "Origin: http://localhost:${WEB_PROXY_PORT_8080:-8080}" "http://localhost:${WEB_PROXY_PORT_8084:-8084}/api/v2/status" || true)
if [[ -z "$cors" ]]; then echo "[ERR] 8084 CORS missing" >&2; exit 1; else echo "[OK] 8084 CORS: $cors in $((P8084_T1-P8084_T0))s"; fi if [[ -z "$cors" ]]; then echo "[ERR] 8084 CORS missing" >&2; exit 1; else echo "[OK] 8084 CORS: $cors in $((P8084_T1-P8084_T0))s"; fi
# 8085 Master /readyz + CORSAPI 走 8085 才需跨域) # 8085 Master /readyz + CORSAPI 走 8085 才需跨域)
P8085_T0=$(date +%s); wait_http "http://localhost:8085/readyz" 60; P8085_T1=$(date +%s) P8085_T0=$(date +%s); wait_http "http://localhost:${WEB_PROXY_PORT_8085:-8085}/readyz" 60; P8085_T1=$(date +%s)
cors=$(header_val -H "Origin: http://localhost:8080" "http://localhost:8085/api/v1/master/nodes" || true) cors=$(header_val -H "Origin: http://localhost:${WEB_PROXY_PORT_8080:-8080}" "http://localhost:${WEB_PROXY_PORT_8085:-8085}/api/v1/master/nodes" || true)
if [[ -z "$cors" ]]; then echo "[ERR] 8085 CORS missing" >&2; exit 1; else echo "[OK] 8085 CORS: $cors in $((P8085_T1-P8085_T0))s"; fi if [[ -z "$cors" ]]; then echo "[ERR] 8085 CORS missing" >&2; exit 1; else echo "[OK] 8085 CORS: $cors in $((P8085_T1-P8085_T0))s"; fi
echo "[OK] All services are ready" echo "[OK] All services are ready"

View File

@ -5,7 +5,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp" TMP_DIR="$TEST_ROOT/tmp"
API_BASE="http://localhost:32300/api/v1/master" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
API_BASE="http://localhost:${MASTER_PORT:-32300}/api/v1/master"
HOST_A="dev-yyrshare-nbnyx10-cp2f-pod-0" HOST_A="dev-yyrshare-nbnyx10-cp2f-pod-0"
HOST_B="dev-yyrshare-uuuu10-ep2f-pod-0" HOST_B="dev-yyrshare-uuuu10-ep2f-pod-0"

View File

@ -5,7 +5,12 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp" TMP_DIR="$TEST_ROOT/tmp"
API_BASE="http://localhost:32300/api/v1/master" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
API_BASE="http://localhost:${MASTER_PORT:-32300}/api/v1/master"
HOST_A="dev-yyrshare-nbnyx10-cp2f-pod-0" HOST_A="dev-yyrshare-nbnyx10-cp2f-pod-0"
HOST_B="dev-yyrshare-uuuu10-ep2f-pod-0" HOST_B="dev-yyrshare-uuuu10-ep2f-pod-0"

View File

@ -3,11 +3,17 @@ set -euo pipefail
echo "[INFO] Sending logs via node-a/node-b and asserting ES counts..." echo "[INFO] Sending logs via node-a/node-b and asserting ES counts..."
# 载入端口变量
TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
# Robust count helper: tolerates 404/503 and non-JSON responses, returns integer >=0 # Robust count helper: tolerates 404/503 and non-JSON responses, returns integer >=0
get_count() { get_count() {
local idx="$1"; local tmp; tmp=$(mktemp) local idx="$1"; local tmp; tmp=$(mktemp)
local code local code
code=$(curl -s -o "$tmp" -w "%{http_code}" "http://localhost:9200/${idx}/_count?ignore_unavailable=true&allow_no_indices=true" || true) code=$(curl -s -o "$tmp" -w "%{http_code}" "http://localhost:${ES_HTTP_PORT:-9200}/${idx}/_count?ignore_unavailable=true&allow_no_indices=true" || true)
if [[ "$code" == "200" ]]; then if [[ "$code" == "200" ]]; then
local val local val
val=$(jq -r '(.count // 0) | tonumber? // 0' "$tmp" 2>/dev/null || echo 0) val=$(jq -r '(.count // 0) | tonumber? // 0' "$tmp" 2>/dev/null || echo 0)
@ -43,8 +49,8 @@ send_logs "$node_b" "host02"
echo "[INFO] Waiting for ES to ingest..." echo "[INFO] Waiting for ES to ingest..."
# Proactively refresh indices (ignore errors if not created yet) # Proactively refresh indices (ignore errors if not created yet)
curl -s -X POST "http://localhost:9200/train-*/_refresh" >/dev/null 2>&1 || true curl -s -X POST "http://localhost:${ES_HTTP_PORT:-9200}/train-*/_refresh" >/dev/null 2>&1 || true
curl -s -X POST "http://localhost:9200/infer-*/_refresh" >/dev/null 2>&1 || true curl -s -X POST "http://localhost:${ES_HTTP_PORT:-9200}/infer-*/_refresh" >/dev/null 2>&1 || true
# Retry up to 120s for counts to increase and reach threshold (>=4) # Retry up to 120s for counts to increase and reach threshold (>=4)
final=0 final=0
@ -58,8 +64,8 @@ for attempt in {1..60}; do
fi fi
echo "[..] waiting ES counts increase to >=${threshold} ($attempt/60) current=${final} base=${base}" echo "[..] waiting ES counts increase to >=${threshold} ($attempt/60) current=${final} base=${base}"
# refresh indices again to speed up visibility # refresh indices again to speed up visibility
curl -s -X POST "http://localhost:9200/train-*/_refresh" >/dev/null 2>&1 || true curl -s -X POST "http://localhost:${ES_HTTP_PORT:-9200}/train-*/_refresh" >/dev/null 2>&1 || true
curl -s -X POST "http://localhost:9200/infer-*/_refresh" >/dev/null 2>&1 || true curl -s -X POST "http://localhost:${ES_HTTP_PORT:-9200}/infer-*/_refresh" >/dev/null 2>&1 || true
sleep 2 sleep 2
done done
echo "[INFO] final counts: train=${train1} infer=${infer1} total=${final}" echo "[INFO] final counts: train=${train1} infer=${infer1} total=${final}"
@ -76,13 +82,13 @@ if (( final < 4 )); then
fi fi
# Health endpoints # Health endpoints
es_health=$(curl -s "http://localhost:9200/_cluster/health" | grep -o '"status":"[^"]*"' | cut -d'"' -f4) es_health=$(curl -s "http://localhost:${ES_HTTP_PORT:-9200}/_cluster/health" | grep -o '"status":"[^"]*"' | cut -d'"' -f4)
if [[ "$es_health" != "green" && "$es_health" != "yellow" ]]; then if [[ "$es_health" != "green" && "$es_health" != "yellow" ]]; then
echo "[ERR] ES health not green/yellow: $es_health" >&2 echo "[ERR] ES health not green/yellow: $es_health" >&2
exit 1 exit 1
fi fi
if ! curl -fs "http://localhost:5601/api/status" >/dev/null 2>&1; then if ! curl -fs "http://localhost:${KIBANA_PORT:-5601}/api/status" >/dev/null 2>&1; then
echo "[WARN] Kibana status endpoint not available" echo "[WARN] Kibana status endpoint not available"
fi fi

View File

@ -6,7 +6,12 @@ TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp" TMP_DIR="$TEST_ROOT/tmp"
REPO_ROOT="$(cd "$TEST_ROOT/../../.." && pwd)" REPO_ROOT="$(cd "$TEST_ROOT/../../.." && pwd)"
API_BASE="http://localhost:32300/api/v1/master" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
API_BASE="http://localhost:${MASTER_PORT:-32300}/api/v1/master"
if [[ -f "$TEST_ROOT/.env" ]]; then if [[ -f "$TEST_ROOT/.env" ]]; then
set -a set -a
@ -85,7 +90,7 @@ docker run -d \
-e ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015} \ -e ARGUS_BUILD_GID=${ARGUS_BUILD_GID:-2015} \
-e ES_HOST=es \ -e ES_HOST=es \
-e ES_PORT=9200 \ -e ES_PORT=9200 \
-p 2021:2020 \ -p ${NODE_B_PORT:-2021}:2020 \
-v "$TEST_ROOT/private-nodeb/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0:/private/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0" \ -v "$TEST_ROOT/private-nodeb/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0:/private/argus/agent/dev-yyrshare-uuuu10-ep2f-pod-0" \
-v "$AGENT_BIN_PATH:/usr/local/bin/argus-agent:ro" \ -v "$AGENT_BIN_PATH:/usr/local/bin/argus-agent:ro" \
-v "$SCRIPT_DIR/node_entrypoint.sh:/usr/local/bin/node-entrypoint.sh:ro" \ -v "$SCRIPT_DIR/node_entrypoint.sh:/usr/local/bin/node-entrypoint.sh:ro" \

View File

@ -4,7 +4,13 @@ set -euo pipefail
TMP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)/tmp/metric-verify" TMP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)/tmp/metric-verify"
mkdir -p "$TMP_DIR" mkdir -p "$TMP_DIR"
PROM_BASE="http://localhost:9090/api/v1" # 载入端口变量(由 .env 提供)
TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
PROM_BASE="http://localhost:${PROMETHEUS_PORT:-9090}/api/v1"
INSTANCE="${METRIC_TEST_INSTANCE:-172.31.0.50:9100}" INSTANCE="${METRIC_TEST_INSTANCE:-172.31.0.50:9100}"
IP_ONLY="${INSTANCE%%:*}" IP_ONLY="${INSTANCE%%:*}"

View File

@ -1,8 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
PROM_DOMAIN="prom.metric.argus.com:9090" TEST_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)"
GRAF="http://localhost:3000" if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
PROM_DOMAIN="prom.metric.argus.com:${PROMETHEUS_PORT:-9090}"
GRAF="http://localhost:${GRAFANA_PORT:-3000}"
echo "[VERIFY:GRAFANA] /api/health" echo "[VERIFY:GRAFANA] /api/health"
TMP_FILE="$(cd "$(dirname "$0")"/.. && pwd)/tmp/metric-verify/graf_health.json" TMP_FILE="$(cd "$(dirname "$0")"/.. && pwd)/tmp/metric-verify/graf_health.json"

View File

@ -6,7 +6,12 @@ TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp/metric-verify" TMP_DIR="$TEST_ROOT/tmp/metric-verify"
mkdir -p "$TMP_DIR" mkdir -p "$TMP_DIR"
GRAF="http://localhost:3000" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
GRAF="http://localhost:${GRAFANA_PORT:-3000}"
HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}" HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}"
echo "[VERIFY:GRAF-PANELS] resolve Prometheus datasource UID via Grafana" echo "[VERIFY:GRAF-PANELS] resolve Prometheus datasource UID via Grafana"
@ -67,4 +72,3 @@ PY
echo "[OK] cluster node online count >= 1 via Grafana proxy" echo "[OK] cluster node online count >= 1 via Grafana proxy"
echo "[DONE] grafana panels verify" echo "[DONE] grafana panels verify"

View File

@ -6,7 +6,12 @@ TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp/metric-verify" TMP_DIR="$TEST_ROOT/tmp/metric-verify"
mkdir -p "$TMP_DIR" mkdir -p "$TMP_DIR"
MASTER_BASE="http://localhost:32300/api/v1/master" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
MASTER_BASE="http://localhost:${MASTER_PORT:-32300}/api/v1/master"
HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}" HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}"
curl_json() { curl -fsS --max-time 5 "$1"; } curl_json() { curl -fsS --max-time 5 "$1"; }

View File

@ -6,7 +6,12 @@ TEST_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
TMP_DIR="$TEST_ROOT/tmp/metric-verify" TMP_DIR="$TEST_ROOT/tmp/metric-verify"
mkdir -p "$TMP_DIR" mkdir -p "$TMP_DIR"
PROM_BASE="http://localhost:9090/api/v1" # 载入端口变量
if [[ -f "$TEST_ROOT/.env" ]]; then
set -a; source "$TEST_ROOT/.env"; set +a
fi
PROM_BASE="http://localhost:${PROMETHEUS_PORT:-9090}/api/v1"
HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}" HOSTNAME="${METRIC_TEST_HOSTNAME:-test-metric-node-001}"
nodes_json="$TEST_ROOT/private/argus/metric/prometheus/nodes.json" nodes_json="$TEST_ROOT/private/argus/metric/prometheus/nodes.json"

View File

@ -1,10 +1,10 @@
map $http_upgrade $connection_upgrade { default upgrade; "" close; } map $http_upgrade $connection_upgrade { default upgrade; "" close; }
# 允许的跨域来源(仅用于 8084/8085 # 允许的跨域来源(仅用于 8084/8085
# 放开为任意来源:将来端口/域名变更均无需调整。
# 注意若前端需要携带凭证cookies/Authorization这种“回显 Origin”的方式比 "*" 更通用。
map $http_origin $cors_allow { map $http_origin $cors_allow {
default ""; default $http_origin;
"http://localhost:8080" "http://localhost:8080";
"http://127.0.0.1:8080" "http://127.0.0.1:8080";
} }
# 8080 - Portal # 8080 - Portal