Skip to content

Commit 306cd51

Browse files
committed
test: 부하 테스트 환경 구축
1 parent 0d5bdcc commit 306cd51

File tree

20 files changed

+1025
-18
lines changed

20 files changed

+1025
-18
lines changed

.gitignore

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,6 @@ secrets.json
155155
*.temp
156156
~$*
157157

158-
# Media files
159-
*.wav
160-
*.mp3
161-
*.mp4
162-
*.avi
163-
*.wmv
164-
*.flv
165-
*.mkv
166-
*.webm
167-
*.m4a
168-
*.m4v
169-
*.m4b
170-
*.m4r
171-
*.m4p
172158

173159
# Data files
174160
*.csv
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Warning",
5+
"Microsoft.AspNetCore": "Warning",
6+
"Microsoft.EntityFrameworkCore": "Warning",
7+
"System": "Warning",
8+
"ProjectVG": "Warning"
9+
}
10+
},
11+
"AllowedHosts": "*",
12+
"Port": 7900,
13+
"JWT": {
14+
"Issuer": "ProjectVG",
15+
"Audience": "ProjectVG"
16+
},
17+
"LoadTestOptimizations": {
18+
"EnableDetailedLogging": false,
19+
"EnableRequestResponseLogging": false,
20+
"EnablePerformanceCounters": true,
21+
"DisableSwagger": true,
22+
"ConnectionPooling": {
23+
"MaxPoolSize": 100,
24+
"ConnectionTimeout": 30
25+
}
26+
},
27+
"ExternalServices": {
28+
"LLM": {
29+
"BaseUrl": "http://localhost:5604",
30+
"Timeout": 30000,
31+
"RetryCount": 1
32+
},
33+
"Memory": {
34+
"BaseUrl": "http://localhost:5605",
35+
"Timeout": 5000,
36+
"RetryCount": 2
37+
},
38+
"TTS": {
39+
"BaseUrl": "http://localhost:7919",
40+
"Timeout": 15000,
41+
"RetryCount": 1
42+
}
43+
}
44+
}

ProjectVG.Infrastructure/InfrastructureServiceCollectionExtensions.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ private static void AddExternalApiClients(IServiceCollection services, IConfigur
7676
client.BaseAddress = new Uri(memoryBaseUrl);
7777
});
7878

79+
var ttsBaseUrl = configuration.GetValue<string>("TTS:BaseUrl") ?? Environment.GetEnvironmentVariable("TTS_BASE_URL") ?? "https://supertoneapi.com";
80+
7981
services.AddHttpClient<ITextToSpeechClient, TextToSpeechClient>((sp, client) => {
80-
client.BaseAddress = new Uri("https://supertoneapi.com");
82+
client.BaseAddress = new Uri(ttsBaseUrl);
8183

8284
var apiKey = configuration.GetValue<string>("TTSApiKey") ?? Environment.GetEnvironmentVariable("TTS_API_KEY");
8385

ProjectVG.Infrastructure/Integrations/LLMClient/LLMClient.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ public LLMClient(HttpClient httpClient, ILogger<LLMClient> logger, IConfiguratio
2222
WriteIndented = false
2323
};
2424

25-
_httpClient.BaseAddress = new Uri(configuration["LLM:BaseUrl"] ?? "");
2625
_httpClient.Timeout = TimeSpan.FromSeconds(30);
2726
_httpClient.DefaultRequestHeaders.Add("Accept", "application/json");
2827
}

env.loadtest

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# ProjectVG API 부하 테스트 환경변수
2+
# 부하 테스트용 설정으로 로그 레벨을 WARN으로 올리고 더미 서버를 사용
3+
4+
# 외부 서비스 연결 (더미 서버 사용)
5+
LLM_BASE_URL=http://localhost:7808
6+
MEMORY_BASE_URL=http://localhost:7812
7+
TTS_BASE_URL=http://localhost:7816
8+
TTS_API_KEY=dummy-tts-api-key-for-loadtest
9+
10+
# 데이터베이스 연결 (부하테스트 전용 - 운영 DB와 완전 분리)
11+
DB_CONNECTION_STRING=Server=localhost,1434;Database=ProjectVG_LoadTest;User Id=sa;Password=LoadTest123!;TrustServerCertificate=true;MultipleActiveResultSets=true
12+
13+
# Redis 연결 (부하테스트 전용 - 운영 Redis와 완전 분리)
14+
REDIS_CONNECTION_STRING=localhost:6381
15+
16+
# JWT 설정
17+
JWT_SECRET_KEY=your-super-secret-jwt-key-here-minimum-32-characters
18+
JWT_ACCESS_TOKEN_LIFETIME_MINUTES=15
19+
JWT_REFRESH_TOKEN_LIFETIME_DAYS=30
20+
21+
# OAuth2 설정 (부하 테스트에서는 비활성화)
22+
OAUTH2_ENABLED=false
23+
24+
# Google OAuth2 설정 (부하 테스트용 더미 설정)
25+
GOOGLE_OAUTH_ENABLED=false
26+
GOOGLE_OAUTH_CLIENT_ID=dummy-client-id
27+
GOOGLE_OAUTH_CLIENT_SECRET=dummy-client-secret
28+
GOOGLE_OAUTH_REDIRECT_URI=http://localhost:7804/auth/oauth2/callback
29+
GOOGLE_OAUTH_AUTO_CREATE_USER=true
30+
GOOGLE_OAUTH_DEFAULT_ROLE=User
31+
32+
# 부하 테스트 전용 설정
33+
ASPNETCORE_ENVIRONMENT=LoadTest
34+
LOGGING_LEVEL=Warning

scripts/start-loadtest.ps1

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# ProjectVG Load Test Environment Start Script
2+
3+
Write-Host "Starting ProjectVG load test environment..." -ForegroundColor Green
4+
5+
# Move to project root from current script directory
6+
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
7+
$projectRoot = Split-Path -Parent $scriptPath
8+
Set-Location $projectRoot
9+
10+
# Check required files exist
11+
if (-not (Test-Path "env.loadtest")) {
12+
Write-Host "env.loadtest file not found!" -ForegroundColor Red
13+
exit 1
14+
}
15+
16+
if (-not (Test-Path "docker-compose.loadtest.yml")) {
17+
Write-Host "docker-compose.loadtest.yml file not found!" -ForegroundColor Red
18+
exit 1
19+
}
20+
21+
# Clean up existing containers
22+
Write-Host "Cleaning up existing load test containers..." -ForegroundColor Yellow
23+
docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.loadtest.yml down --remove-orphans 2>$null
24+
25+
# Remove existing images (prevent cache conflicts)
26+
docker rmi projectvg-loadtest-api:latest -f 2>$null
27+
docker rmi projectvg-dummy-llm:latest -f 2>$null
28+
docker rmi projectvg-dummy-memory:latest -f 2>$null
29+
docker rmi projectvg-dummy-tts:latest -f 2>$null
30+
31+
# Build and start load test environment
32+
Write-Host "Building load test environment..." -ForegroundColor Yellow
33+
docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.loadtest.yml build --no-cache 2>$null
34+
docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.loadtest.yml up -d
35+
36+
# Wait for services to start
37+
Write-Host "Waiting for services to start..." -ForegroundColor Yellow
38+
Start-Sleep -Seconds 3
39+
40+
# Check service status
41+
Write-Host "Checking service status..." -ForegroundColor Yellow
42+
43+
$services = @(
44+
@{Name="LLM Server"; Url="http://localhost:7808/health"},
45+
@{Name="Memory Server"; Url="http://localhost:7812/health"},
46+
@{Name="TTS Server"; Url="http://localhost:7816/health"},
47+
@{Name="Main API"; Url="http://localhost:7804/api/v1/health"}
48+
)
49+
50+
$allHealthy = $true
51+
foreach ($service in $services) {
52+
try {
53+
$response = Invoke-RestMethod -Uri $service.Url -TimeoutSec 3
54+
if ($response.status -eq "ok" -or $response.Status -eq "Healthy") {
55+
Write-Host "$($service.Name): OK" -ForegroundColor Green
56+
} else {
57+
Write-Host "$($service.Name): FAILED" -ForegroundColor Red
58+
$allHealthy = $false
59+
}
60+
} catch {
61+
Write-Host "$($service.Name): CONNECTION FAILED" -ForegroundColor Red
62+
$allHealthy = $false
63+
}
64+
}
65+
66+
if ($allHealthy) {
67+
Write-Host "`nLoad test environment started successfully!" -ForegroundColor Green
68+
Write-Host "Service URLs:" -ForegroundColor Cyan
69+
Write-Host " - Main API: http://localhost:7804" -ForegroundColor White
70+
Write-Host " - LLM Server: http://localhost:7808" -ForegroundColor White
71+
Write-Host " - Memory Server: http://localhost:7812" -ForegroundColor White
72+
Write-Host " - TTS Server: http://localhost:7816" -ForegroundColor White
73+
74+
Write-Host "`nYou can now start load testing!" -ForegroundColor Green
75+
Write-Host "To stop: scripts\stop-loadtest.ps1" -ForegroundColor Yellow
76+
} else {
77+
Write-Host "`nSome services failed to start" -ForegroundColor Red
78+
Write-Host "Check logs: docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.loadtest.yml logs" -ForegroundColor White
79+
}

scripts/stop-loadtest.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# ProjectVG Load Test Environment Shutdown Script
2+
3+
Write-Host "Stopping ProjectVG Load Test Environment..." -ForegroundColor Yellow
4+
5+
# Navigate to project root from current script directory
6+
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
7+
$projectRoot = Split-Path -Parent $scriptPath
8+
Set-Location $projectRoot
9+
10+
Write-Host "Project Root: $projectRoot" -ForegroundColor Yellow
11+
12+
# Stop load test containers
13+
Write-Host "Stopping load test containers..." -ForegroundColor Yellow
14+
docker-compose -p projectvg-loadtest --env-file env.loadtest -f docker-compose.loadtest.yml down --remove-orphans
15+
16+
# Confirm image cleanup
17+
$cleanupImages = Read-Host "Do you want to delete load test images as well? (y/N)"
18+
if ($cleanupImages -eq "y" -or $cleanupImages -eq "Y") {
19+
Write-Host "Removing load test images..." -ForegroundColor Yellow
20+
21+
# Remove load test related images
22+
$imagesToRemove = @(
23+
"projectvg-loadtest-api:latest",
24+
"projectvg-dummy-llm:latest",
25+
"projectvg-dummy-memory:latest",
26+
"projectvg-dummy-tts:latest"
27+
)
28+
29+
foreach ($image in $imagesToRemove) {
30+
try {
31+
docker rmi $image -f
32+
Write-Host "$image image removed successfully" -ForegroundColor Green
33+
} catch {
34+
Write-Host "⚠️ $image image removal failed (not found or in use)" -ForegroundColor Yellow
35+
}
36+
}
37+
38+
# Clean up unused images
39+
Write-Host "Cleaning up unused Docker images..." -ForegroundColor Yellow
40+
docker image prune -f
41+
}
42+
43+
# Clean up network
44+
Write-Host "Cleaning up load test network..." -ForegroundColor Yellow
45+
try {
46+
docker network rm projectvg-loadtest-network
47+
Write-Host "✅ Load test network removed successfully" -ForegroundColor Green
48+
} catch {
49+
Write-Host "⚠️ Load test network removal failed (not found or in use)" -ForegroundColor Yellow
50+
}
51+
52+
Write-Host "`n✅ Load test environment stopped successfully!" -ForegroundColor Green
53+
Write-Host "To restart, run scripts\start-loadtest.ps1" -ForegroundColor Cyan

test-clients/ai-chat-client/script.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// 환경에 따른 포트 설정
22
// Development 환경(7901)에서 실행되면 7901 사용, 아니면 기본값 7900 사용
33
const currentPort = window.location.port;
4-
const isDevelopment = currentPort === '7901';
5-
const serverPort = isDevelopment ? '7901' : '7900';
4+
const isDevelopment = currentPort === '7804';
5+
const serverPort = isDevelopment ? '7804' : '7804';
66
const currentHost = window.location.hostname || 'localhost';
77
const ENDPOINT = `${currentHost}:${serverPort}`;
88
const WS_URL = `ws://${ENDPOINT}/ws`;

0 commit comments

Comments
 (0)