lolly/internal/e2e/testutil/constants.go
xfy 2cb10eb749 perf(e2e): 并行化 E2E 测试,从 ~2h 降至 ~102s
- testutil: 用 sync.Once 缓存 LollyImageAvailable 结果
- testutil: 原子计数器替代时间戳避免容器名竞态
- testutil: SetupProxyTest 接受 suffix 参数生成独立 Docker 网络
- testutil: CleanupProxyTest 显式调用 network.Remove() 清理
- testutil: 移除死代码 SetupProxyTestEnv/ProxyTestEnv
- testutil: HealthCheckWaitTimeout 30s→15s, DefaultTestTimeout 180s→120s
- e2e: 所有 107 个测试函数添加 t.Parallel()
- e2e: 替换 65 处硬编码 30*time.Second 为常量
- make: test-all 三类测试并行运行,显式 PID wait 收集退出码
- make: test-e2e 添加 -parallel 4 flag

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-28 13:19:46 +08:00

71 lines
1.7 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//go:build e2e
// Package testutil 提供 E2E 测试的工具函数。
//
// 包含测试常量定义。
//
// 作者xfy
package testutil
import (
"crypto/tls"
"time"
)
// 测试超时常量。
const (
// ContainerStartupTimeout 容器启动超时。
ContainerStartupTimeout = 30 * time.Second
// HealthCheckWaitTimeout 健康检查等待超时。
HealthCheckWaitTimeout = 15 * time.Second
// HealthCheckDetectionTime 健康检查检测时间。
HealthCheckDetectionTime = 10 * time.Second
// CacheExpireBuffer 缓存过期缓冲时间。
CacheExpireBuffer = 1 * time.Second
// DefaultTestTimeout 测试上下文超时。
DefaultTestTimeout = 120 * time.Second
// DefaultClientTimeout HTTP 客户端超时。
DefaultClientTimeout = 10 * time.Second
// ConcurrentRequestTimeout 并发请求超时。
ConcurrentRequestTimeout = 30 * time.Second
// ShortTestTimeout 短测试超时(用于快速测试)。
ShortTestTimeout = 60 * time.Second
// MediumTestTimeout 中等测试超时。
MediumTestTimeout = 120 * time.Second
)
// 测试配置常量。
const (
// DefaultBackendCount 默认后端数量。
DefaultBackendCount = 2
// DefaultConcurrentRequests 并发请求数量。
DefaultConcurrentRequests = 10
// HighConcurrentRequests 高并发请求数量。
HighConcurrentRequests = 20
// CacheTestMaxAge 缓存测试过期时间。
CacheTestMaxAge = 5 * time.Minute
// CacheTestShortMaxAge 短缓存过期时间(用于过期测试)。
CacheTestShortMaxAge = 2 * time.Second
)
// TLS 版本常量(用于配置客户端)。
const (
// TLSVersion12 TLS 1.2。
TLSVersion12 = tls.VersionTLS12
// TLSVersion13 TLS 1.3。
TLSVersion13 = tls.VersionTLS13
)