refactor: clean up project structure
- Remove old review reports (keep latest only) - Move docs/ to deploy/docs-backup/ - Move performance-testing/ to deploy/ - Clean up test output files - Organize root directory
This commit is contained in:
86
deploy/performance-testing/config.js
Normal file
86
deploy/performance-testing/config.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// Sub2API Performance Test Configuration
|
||||
// 用于性能测试的环境配置
|
||||
|
||||
export const config = {
|
||||
// API 基础配置
|
||||
api: {
|
||||
baseUrl: __ENV.API_BASE_URL || 'http://localhost:8080',
|
||||
timeout: 30000, // 30 seconds
|
||||
},
|
||||
|
||||
// 测试数据配置
|
||||
testData: {
|
||||
// 管理员账户
|
||||
admin: {
|
||||
email: __ENV.ADMIN_EMAIL || 'admin@example.com',
|
||||
password: __ENV.ADMIN_PASSWORD || 'admin123',
|
||||
},
|
||||
|
||||
// 普通用户账户
|
||||
users: [
|
||||
{ email: __ENV.TEST_USER_1_EMAIL || 'user1@example.com', password: __ENV.TEST_USER_1_PASSWORD || 'password123' },
|
||||
{ email: __ENV.TEST_USER_2_EMAIL || 'user2@example.com', password: __ENV.TEST_USER_2_PASSWORD || 'password123' },
|
||||
{ email: __ENV.TEST_USER_3_EMAIL || 'user3@example.com', password: __ENV.TEST_USER_3_PASSWORD || 'password123' },
|
||||
],
|
||||
|
||||
// API Key 配置
|
||||
apiKeyPrefix: 'sk-test-perf-',
|
||||
testGroupId: parseInt(__ENV.TEST_GROUP_ID || '1', 10),
|
||||
},
|
||||
|
||||
// Prometheus 指标配置
|
||||
prometheus: {
|
||||
enabled: __ENV.ENABLE_PROMETHEUS === 'true',
|
||||
url: __ENV.PROMETHEUS_URL || 'http://localhost:9090',
|
||||
},
|
||||
|
||||
// 测试模式
|
||||
mode: {
|
||||
// 是否使用真实 API Key
|
||||
useRealAPIKey: __ENV.USE_REAL_API_KEY === 'true',
|
||||
// 是否启用 verbose 日志
|
||||
verbose: __ENV.VERBOSE === 'true',
|
||||
// 是否记录详细请求
|
||||
recordDetailedRequests: __ENV.RECORD_DETAILED_REQUESTS === 'true',
|
||||
},
|
||||
|
||||
// Gateway 测试配置
|
||||
gateway: {
|
||||
// 测试使用的平台
|
||||
platform: __ENV.GATEWAY_PLATFORM || 'openai',
|
||||
// 测试使用的模型
|
||||
model: __ENV.GATEWAY_MODEL || 'gpt-3.5-turbo',
|
||||
// 请求超时
|
||||
timeout: 60000, // 60 seconds for streaming
|
||||
},
|
||||
|
||||
// 并发配置
|
||||
concurrency: {
|
||||
// 每个 VU 的并发数
|
||||
perVU: parseInt(__ENV.CONCURRENCY_PER_VU || '1', 10),
|
||||
// 最大并发请求数
|
||||
maxConcurrent: parseInt(__ENV.MAX_CONCURRENT || '100', 10),
|
||||
},
|
||||
};
|
||||
|
||||
// 导出便捷函数
|
||||
export function getBaseUrl() {
|
||||
return config.api.baseUrl;
|
||||
}
|
||||
|
||||
export function getAdminCredentials() {
|
||||
return config.testData.admin;
|
||||
}
|
||||
|
||||
export function getRandomTestUser() {
|
||||
const users = config.testData.users;
|
||||
return users[Math.floor(Math.random() * users.length)];
|
||||
}
|
||||
|
||||
export function getGatewayConfig() {
|
||||
return {
|
||||
platform: config.gateway.platform,
|
||||
model: config.gateway.model,
|
||||
timeout: config.gateway.timeout,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user