[#7] bind端到端测试使用指定端口

This commit is contained in:
yuyr 2025-09-28 07:51:03 +00:00
parent 0211760a88
commit 035ab44078
9 changed files with 42 additions and 14 deletions

View File

@ -5,3 +5,10 @@
项目文档【腾讯文档】GPU集群运维系统 项目文档【腾讯文档】GPU集群运维系统
https://docs.qq.com/doc/DQUxDdmhIZ1dpeERk https://docs.qq.com/doc/DQUxDdmhIZ1dpeERk
## 构建账号配置
镜像构建和运行账号的 UID/GID 可通过 `configs/build_user.conf` 配置,详细说明见 `doc/build-user-config.md`
## 本地端口占用提示
如需运行 BIND 模块端到端测试且宿主机 53 端口已占用,可通过环境变量 `HOST_DNS_PORT`(默认 1053指定对外映射端口例如 `HOST_DNS_PORT=12053 ./scripts/00_e2e_test.sh`

View File

@ -3,8 +3,8 @@ services:
image: argus-bind9:latest image: argus-bind9:latest
container_name: argus-bind9-test container_name: argus-bind9-test
ports: ports:
- "53:53/tcp" - "${HOST_DNS_PORT:-1053}:53/tcp"
- "53:53/udp" - "${HOST_DNS_PORT:-1053}:53/udp"
volumes: volumes:
- ./private:/private - ./private:/private
restart: unless-stopped restart: unless-stopped
@ -13,4 +13,4 @@ services:
networks: networks:
bind-test-network: bind-test-network:
driver: bridge driver: bridge

View File

@ -7,6 +7,9 @@
set -e set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
export HOST_DNS_PORT
echo "==========================================" echo "=========================================="
echo "BIND9 DNS Server End-to-End Test Suite" echo "BIND9 DNS Server End-to-End Test Suite"
@ -112,4 +115,4 @@ else
echo " - Review BIND9 configuration files" echo " - Review BIND9 configuration files"
echo " - Check system resources and port availability" echo " - Check system resources and port availability"
exit 1 exit 1
fi fi

View File

@ -7,6 +7,9 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_DIR="$(dirname "$SCRIPT_DIR")" TEST_DIR="$(dirname "$SCRIPT_DIR")"
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
export HOST_DNS_PORT
cd "$TEST_DIR" cd "$TEST_DIR"
@ -36,4 +39,4 @@ fi
echo "" echo ""
echo "BIND9 test environment is ready!" echo "BIND9 test environment is ready!"
echo "DNS server listening on localhost:53" echo "DNS server listening on localhost:${HOST_DNS_PORT}"

View File

@ -5,7 +5,10 @@
set -e set -e
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
echo "Testing DNS resolution with dig..." echo "Testing DNS resolution with dig..."
echo "Using DNS server localhost:${HOST_DNS_PORT}"
# Function to test DNS query # Function to test DNS query
test_dns_query() { test_dns_query() {
@ -19,7 +22,7 @@ test_dns_query() {
echo "Expected IP: $expected_ip" echo "Expected IP: $expected_ip"
# Perform dig query # Perform dig query
result=$(dig @localhost $hostname.argus.com A +short 2>/dev/null || echo "QUERY_FAILED") result=$(dig @localhost -p "$HOST_DNS_PORT" "$hostname".argus.com A +short 2>/dev/null || echo "QUERY_FAILED")
if [ "$result" = "QUERY_FAILED" ]; then if [ "$result" = "QUERY_FAILED" ]; then
echo "✗ DNS query failed" echo "✗ DNS query failed"
@ -69,4 +72,4 @@ if [ $failed_tests -eq 0 ]; then
else else
echo "$failed_tests test(s) failed" echo "$failed_tests test(s) failed"
exit 1 exit 1
fi fi

View File

@ -6,10 +6,13 @@
set -e set -e
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_DIR="$(dirname "$SCRIPT_DIR")" TEST_DIR="$(dirname "$SCRIPT_DIR")"
echo "=== DNS Auto-Sync Functionality Test ===" echo "=== DNS Auto-Sync Functionality Test ==="
echo "Using DNS server localhost:${HOST_DNS_PORT}"
# Check if container is running # Check if container is running
if ! docker compose ps | grep -q "Up"; then if ! docker compose ps | grep -q "Up"; then
@ -36,7 +39,7 @@ test_dns_query() {
# Wait a moment for DNS cache # Wait a moment for DNS cache
sleep 2 sleep 2
result=$(dig @localhost $hostname.argus.com A +short 2>/dev/null || echo "QUERY_FAILED") result=$(dig @localhost -p "$HOST_DNS_PORT" "$hostname".argus.com A +short 2>/dev/null || echo "QUERY_FAILED")
if [ "$result" = "$expected_ip" ]; then if [ "$result" = "$expected_ip" ]; then
echo "$result" echo "$result"
@ -90,7 +93,7 @@ echo ""
echo "Step 2: Testing initial DNS configuration..." echo "Step 2: Testing initial DNS configuration..."
# Get current IP for web.argus.com (may have been changed by previous tests) # Get current IP for web.argus.com (may have been changed by previous tests)
current_web_ip=$(dig @localhost web.argus.com A +short 2>/dev/null || echo "UNKNOWN") current_web_ip=$(dig @localhost -p "$HOST_DNS_PORT" web.argus.com A +short 2>/dev/null || echo "UNKNOWN")
echo "Current web.argus.com IP: $current_web_ip" echo "Current web.argus.com IP: $current_web_ip"
# Test that DNS is working (regardless of specific IP) # Test that DNS is working (regardless of specific IP)
@ -185,7 +188,7 @@ docker compose exec bind9 bash -c 'echo "this is not an IP address" > /private/a
wait_for_sync wait_for_sync
# Verify invalid record was not added (should fail to resolve) # Verify invalid record was not added (should fail to resolve)
result=$(dig @localhost invalid.argus.com A +short 2>/dev/null || echo "NO_RESULT") result=$(dig @localhost -p "$HOST_DNS_PORT" invalid.argus.com A +short 2>/dev/null || echo "NO_RESULT")
if [ "$result" = "NO_RESULT" ] || [ -z "$result" ]; then if [ "$result" = "NO_RESULT" ] || [ -z "$result" ]; then
echo "✓ Invalid IP correctly ignored" echo "✓ Invalid IP correctly ignored"
else else

View File

@ -5,10 +5,13 @@
set -e set -e
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_DIR="$(dirname "$SCRIPT_DIR")" TEST_DIR="$(dirname "$SCRIPT_DIR")"
echo "=== DNS Configuration Reload Test ===" echo "=== DNS Configuration Reload Test ==="
echo "Using DNS server localhost:${HOST_DNS_PORT}"
# Check if container is running # Check if container is running
if ! docker compose ps | grep -q "Up"; then if ! docker compose ps | grep -q "Up"; then
@ -32,7 +35,7 @@ test_dns_query() {
echo "Testing: $description" echo "Testing: $description"
echo "Query: $hostname.argus.com -> Expected: $expected_ip" echo "Query: $hostname.argus.com -> Expected: $expected_ip"
result=$(dig @localhost $hostname.argus.com A +short 2>/dev/null || echo "QUERY_FAILED") result=$(dig @localhost -p "$HOST_DNS_PORT" "$hostname".argus.com A +short 2>/dev/null || echo "QUERY_FAILED")
if [ "$result" = "$expected_ip" ]; then if [ "$result" = "$expected_ip" ]; then
echo "$result" echo "$result"
@ -109,4 +112,4 @@ fi
echo "" echo ""
echo "✓ DNS configuration reload test completed successfully!" echo "✓ DNS configuration reload test completed successfully!"
echo "✓ IP address changed from 12.4.5.6 to 192.168.1.100" echo "✓ IP address changed from 12.4.5.6 to 192.168.1.100"
echo "✓ Configuration persisted and reloaded correctly" echo "✓ Configuration persisted and reloaded correctly"

View File

@ -5,10 +5,13 @@
set -e set -e
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_DIR="$(dirname "$SCRIPT_DIR")" TEST_DIR="$(dirname "$SCRIPT_DIR")"
echo "=== Configuration Persistence Test ===" echo "=== Configuration Persistence Test ==="
echo "Using DNS server localhost:${HOST_DNS_PORT}"
# Check if dig is available # Check if dig is available
if ! command -v dig &> /dev/null; then if ! command -v dig &> /dev/null; then
@ -25,7 +28,7 @@ test_dns_query() {
echo "Testing: $description" echo "Testing: $description"
echo "Query: $hostname.argus.com -> Expected: $expected_ip" echo "Query: $hostname.argus.com -> Expected: $expected_ip"
result=$(dig @localhost $hostname.argus.com A +short 2>/dev/null || echo "QUERY_FAILED") result=$(dig @localhost -p "$HOST_DNS_PORT" "$hostname".argus.com A +short 2>/dev/null || echo "QUERY_FAILED")
if [ "$result" = "$expected_ip" ]; then if [ "$result" = "$expected_ip" ]; then
echo "$result" echo "$result"
@ -112,4 +115,4 @@ echo ""
echo "✓ Configuration persistence test completed successfully!" echo "✓ Configuration persistence test completed successfully!"
echo "✓ Modified IP (192.168.1.100) persisted after container restart" echo "✓ Modified IP (192.168.1.100) persisted after container restart"
echo "✓ Configuration files properly linked to persistent storage" echo "✓ Configuration files properly linked to persistent storage"
echo "✓ DNS resolution working correctly with persisted configuration" echo "✓ DNS resolution working correctly with persisted configuration"

View File

@ -7,6 +7,9 @@ set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEST_DIR="$(dirname "$SCRIPT_DIR")" TEST_DIR="$(dirname "$SCRIPT_DIR")"
HOST_DNS_PORT="${HOST_DNS_PORT:-1053}"
export HOST_DNS_PORT
# Parse command line arguments # Parse command line arguments
FULL_CLEANUP=true FULL_CLEANUP=true