feat: 新增GPU测试节点argus-metric-test-gpu-node,测试安装包安装流程及与agent/master组件之间数据准确性;
refs #20
This commit is contained in:
39
src/metric/tests/client-test-gpu-node/build/Dockerfile
Normal file
39
src/metric/tests/client-test-gpu-node/build/Dockerfile
Normal file
@@ -0,0 +1,39 @@
|
||||
# 使用NVIDIA官方CUDA基础镜像
|
||||
FROM nvidia/cuda:12.2.2-runtime-ubuntu22.04
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# 设置时区
|
||||
ENV TZ=Asia/Shanghai
|
||||
|
||||
RUN apt-get update -qq && \
|
||||
apt-get install -y -qq \
|
||||
tzdata \
|
||||
curl \
|
||||
wget \
|
||||
gnupg2 \
|
||||
software-properties-common \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# 配置时区
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# 创建启动脚本,在运行时验证GPU
|
||||
COPY <<EOF /app/start.sh
|
||||
#!/bin/bash
|
||||
echo "检查GPU环境..."
|
||||
if command -v nvidia-smi &> /dev/null; then
|
||||
nvidia-smi
|
||||
echo "GPU环境正常"
|
||||
else
|
||||
echo "警告: nvidia-smi 命令不可用,请确保容器运行时启用了GPU支持"
|
||||
fi
|
||||
exec "\$@"
|
||||
EOF
|
||||
|
||||
RUN chmod +x /app/start.sh
|
||||
|
||||
CMD ["/app/start.sh", "/bin/bash"]
|
||||
@@ -142,3 +142,44 @@ services:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
test-gpu-node:
|
||||
build:
|
||||
context: ./client-test-gpu-node/build
|
||||
dockerfile: Dockerfile
|
||||
image: argus-metric-test-gpu-node:latest
|
||||
container_name: argus-metric-test-gpu-node
|
||||
hostname: test-metric-gpu-node-001
|
||||
restart: unless-stopped
|
||||
privileged: true
|
||||
runtime: nvidia
|
||||
deploy:
|
||||
resources:
|
||||
reservations:
|
||||
devices:
|
||||
- driver: nvidia
|
||||
count: all
|
||||
capabilities:
|
||||
- gpu
|
||||
depends_on:
|
||||
- ftp
|
||||
- prometheus
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- DEBIAN_FRONTEND=noninteractive
|
||||
- NVIDIA_VISIBLE_DEVICES=all
|
||||
- NVIDIA_DRIVER_CAPABILITIES=compute,utility
|
||||
- GPU_MODE=gpu
|
||||
volumes:
|
||||
- ${DATA_ROOT:-/private}/argus/agent:/private/argus/agent
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
command: sleep infinity
|
||||
networks:
|
||||
default:
|
||||
ipv4_address: 172.30.0.51
|
||||
logging:
|
||||
driver: "json-file"
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ docker ps | grep argus-ftp
|
||||
docker ps | grep argus-prometheus
|
||||
docker ps | grep argus-grafana
|
||||
docker ps | grep argus-metric-test-node
|
||||
docker ps | grep argus-metric-test-gpu-node
|
||||
|
||||
echo "[01] 所有服务已启动"
|
||||
echo "[01] 基础服务已启动"
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ else
|
||||
echo "[02] 默认路径: $OUTPUT_DIR"
|
||||
fi
|
||||
|
||||
OWNER="${FTP_UID:-2133}:${FTP_GID:-2015}"
|
||||
OWNER="${ARGUS_BUILD_UID:-2133}:${ARGUS_BUILD_GID:-2015}"
|
||||
|
||||
cd "$PLUGIN_DIR"
|
||||
|
||||
|
||||
33
src/metric/tests/scripts/04_test_gpu_node_install.sh
Executable file
33
src/metric/tests/scripts/04_test_gpu_node_install.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
FTP_SERVER="${FTP_SERVER:-172.30.0.40}"
|
||||
FTP_USER="${FTP_USER:-ftpuser}"
|
||||
FTP_PASSWORD="${FTP_PASSWORD:-ZGClab1234!}"
|
||||
FTP_PORT="${FTP_PORT:-21}"
|
||||
|
||||
FTP_HOST="${FTP_SERVER}"
|
||||
|
||||
echo "[03] 进入测试节点执行安装..."
|
||||
echo "[03] 使用 FTP 地址: ${FTP_HOST}:${FTP_PORT}"
|
||||
|
||||
docker exec argus-metric-test-gpu-node bash -c "
|
||||
set -e
|
||||
|
||||
if ! command -v curl &>/dev/null; then
|
||||
echo '[03] curl 未安装,正在安装...'
|
||||
apt-get update && apt-get install -y curl
|
||||
fi
|
||||
|
||||
cd /tmp
|
||||
echo '[03] 下载 setup.sh...'
|
||||
curl -u ${FTP_USER}:${FTP_PASSWORD} ftp://${FTP_HOST}:${FTP_PORT}/setup.sh -o setup.sh
|
||||
|
||||
echo '[03] 执行安装...'
|
||||
chmod +x setup.sh
|
||||
bash setup.sh --server ${FTP_HOST} --user ${FTP_USER} --password '${FTP_PASSWORD}' --port ${FTP_PORT}
|
||||
|
||||
echo '[03] 安装完成'
|
||||
"
|
||||
|
||||
echo "[03] 完成"
|
||||
@@ -44,6 +44,7 @@ BUILD_DIRS=(
|
||||
"../prometheus/build"
|
||||
"../grafana/build"
|
||||
"client-test-node/build"
|
||||
"client-test-gpu-node/build"
|
||||
)
|
||||
|
||||
for dir in "${BUILD_DIRS[@]}"; do
|
||||
@@ -87,7 +88,7 @@ echo "2. 准备 Docker 镜像..."
|
||||
|
||||
# 检查镜像是否存在
|
||||
IMAGE_CACHE_DIR="$TEST_DIR/images-cache"
|
||||
IMAGES=("argus-metric-ftp:latest" "argus-metric-prometheus:latest" "argus-metric-grafana:latest" "argus-metric-test-node:latest")
|
||||
IMAGES=("argus-metric-ftp:latest" "argus-metric-prometheus:latest" "argus-metric-grafana:latest" "argus-metric-test-node:latest" "argus-metric-test-gpu-node:latest")
|
||||
all_images_exist=true
|
||||
|
||||
for image in "${IMAGES[@]}"; do
|
||||
@@ -126,6 +127,9 @@ else
|
||||
"argus-metric-test-node:latest")
|
||||
cache_file="${IMAGE_CACHE_DIR}/argus-test-node.tar"
|
||||
;;
|
||||
"argus-metric-test-gpu-node:latest")
|
||||
cache_file="${IMAGE_CACHE_DIR}/argus-test-gpu-node.tar"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$cache_file" ]; then
|
||||
@@ -174,6 +178,9 @@ else
|
||||
"argus-metric-test-node:latest")
|
||||
docker save -o "${IMAGE_CACHE_DIR}/argus-test-node.tar" "$image" && echo " 已保存: argus-test-node.tar"
|
||||
;;
|
||||
"argus-metric-test-gpu-node:latest")
|
||||
docker save -o "${IMAGE_CACHE_DIR}/argus-test-gpu-node.tar" "$image" && echo " 已保存: argus-test-gpu-node.tar"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
echo "镜像已保存到: $IMAGE_CACHE_DIR/"
|
||||
@@ -185,40 +192,12 @@ else
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "3. 启动服务..."
|
||||
echo "3. 启动基础服务..."
|
||||
cd "$TEST_DIR"
|
||||
docker compose up -d
|
||||
# 启动除GPU节点外的所有服务
|
||||
docker compose up -d ftp prometheus grafana test-node test-gpu-node
|
||||
|
||||
echo ""
|
||||
echo "4. 等待服务启动..."
|
||||
sleep 5
|
||||
|
||||
echo ""
|
||||
echo "5. 检查服务状态..."
|
||||
cd "$TEST_DIR"
|
||||
docker compose ps
|
||||
|
||||
echo ""
|
||||
echo "=========================================="
|
||||
echo " 服务启动完成!"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
echo "服务访问地址:"
|
||||
echo " - FTP: ftp://localhost:${FTP_PORT:-21}"
|
||||
echo " 用户名: ftpuser"
|
||||
echo " 密码: ${FTP_PASSWORD:-ZGClab1234!}"
|
||||
echo ""
|
||||
echo " - Prometheus: http://localhost:${PROMETHEUS_PORT:-9090}"
|
||||
echo ""
|
||||
echo " - Grafana: http://localhost:${GRAFANA_PORT:-3000}"
|
||||
echo " 用户名: admin"
|
||||
echo " 密码: admin"
|
||||
echo ""
|
||||
echo "常用命令:"
|
||||
echo " 查看日志: docker compose logs -f [service]"
|
||||
echo " 停止服务: docker compose stop"
|
||||
echo " 重启服务: docker compose restart"
|
||||
echo " 停止并删除: docker compose down"
|
||||
echo " 停止并删除卷: docker compose down -v"
|
||||
echo ""
|
||||
|
||||
|
||||
@@ -24,7 +24,8 @@ declare -A IMAGES=(
|
||||
["argus-metric-ftp:latest"]="argus-ftp.tar"
|
||||
["argus-metric-prometheus:latest"]="argus-prometheus.tar"
|
||||
["argus-metric-grafana:latest"]="argus-grafana.tar"
|
||||
["ubuntu:22.04"]="test-node.tar"
|
||||
["argus-metric-test-node:latest"]="argus-test-node.tar"
|
||||
["argus-metric-test-gpu-node:latest"]="argus-test-gpu-node.tar"
|
||||
)
|
||||
|
||||
# 检查镜像是否存在并保存
|
||||
|
||||
Reference in New Issue
Block a user