This repository was archived by the owner on Mar 7, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquick-validation.js
More file actions
executable file
·296 lines (239 loc) · 11 KB
/
Copy pathquick-validation.js
File metadata and controls
executable file
·296 lines (239 loc) · 11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
#!/usr/bin/env node
/**
* 축약된 검증 프로세스
* 기존 복잡한 검증을 핵심 메트릭 3개로 간소화
*/
const axios = require('axios');
const fs = require('fs');
class QuickValidation {
constructor(baseUrl = 'http://localhost:3000/api/v2') {
this.baseUrl = baseUrl;
this.results = {
technicalPerformance: {},
userExperience: {},
personalization: {}
};
}
// 1. 기술적 성능 검증 (자동화)
async validateTechnicalPerformance() {
console.log('🔧 기술적 성능 검증 중...');
const requests = [];
// 10개 동시 요청으로 성능 테스트 (health 엔드포인트 사용)
for (let i = 0; i < 10; i++) {
const startTime = Date.now();
requests.push(
axios.get(`${this.baseUrl.replace('/api/v2', '')}/health`)
.then(response => ({
success: true,
responseTime: Date.now() - startTime,
status: response.status
}))
.catch(error => ({
success: false,
error: error.message,
responseTime: Date.now() - startTime
}))
);
}
const responses = await Promise.all(requests);
const successCount = responses.filter(r => r.success).length;
const avgResponseTime = responses
.filter(r => r.success)
.reduce((sum, r) => sum + r.responseTime, 0) / successCount;
this.results.technicalPerformance = {
successRate: (successCount / 10) * 100,
averageResponseTime: Math.round(avgResponseTime),
status: successCount >= 8 ? 'PASS' : 'FAIL'
};
console.log(`✅ 성공률: ${this.results.technicalPerformance.successRate}%`);
console.log(`⏱️ 평균 응답시간: ${this.results.technicalPerformance.averageResponseTime}ms`);
}
// 2. 개인화 효과 검증 (샘플 테스트)
async validatePersonalization() {
console.log('🎯 개인화 효과 검증 중...');
// 샘플 사용자 프로필들
const testProfiles = [
{ age_group: 'SENIOR', education_level: 'HIGH_SCHOOL', gender: 'MALE', marital_status: 'MARRIED' },
{ age_group: 'ADULT', education_level: 'UNIVERSITY_GRADUATE', gender: 'FEMALE', marital_status: 'SINGLE' },
{ age_group: 'YOUNG_ADULT', education_level: 'UNIVERSITY_STUDENT', gender: 'NONE', marital_status: 'SINGLE' }
];
const personalizationScores = [];
for (const profile of testProfiles) {
try {
// 기본 질문 vs 개인화 질문 비교
const basicResponse = await this.generateQuestion(null);
const personalizedResponse = await this.generateQuestion(profile);
// 간단한 개인화 점수 계산 (키워드 매칭 기반)
const score = this.calculatePersonalizationScore(personalizedResponse, profile);
personalizationScores.push(score);
} catch (error) {
console.log(`⚠️ 프로필 테스트 실패: ${error.message}`);
}
}
const avgPersonalizationScore = personalizationScores.length > 0
? personalizationScores.reduce((sum, score) => sum + score, 0) / personalizationScores.length
: 0;
this.results.personalization = {
averageScore: Math.round(avgPersonalizationScore * 10) / 10,
testCount: personalizationScores.length,
status: avgPersonalizationScore >= 6.0 ? 'PASS' : 'FAIL'
};
console.log(`🎯 개인화 점수: ${this.results.personalization.averageScore}/10`);
}
// 3. 사용자 경험 검증 (시뮬레이션)
async validateUserExperience() {
console.log('👤 사용자 경험 검증 중...');
try {
// 전체 플로우 시뮬레이션
const deviceId = `test-device-${Date.now()}`;
// 1. 디바이스 등록
const authResponse = await axios.post(`${this.baseUrl}/auth/device-id-register`, {
device_id: deviceId
});
const userId = authResponse.data.user_id;
// 2. 메타데이터 설정
await axios.post(`${this.baseUrl}/user/metadata`, {
user_id: userId,
age_group: 'ADULT',
education_level: 'UNIVERSITY_GRADUATE',
gender: 'NONE',
marital_status: 'SINGLE'
});
// 3. 챕터 1 시작
const conversationResponse = await axios.post(`${this.baseUrl}/conversation/1`, {
user_id: userId,
message: "안녕하세요, 인터뷰를 시작하고 싶습니다."
});
this.results.userExperience = {
flowCompletion: true,
responseReceived: !!conversationResponse.data.ai_response,
status: 'PASS'
};
console.log('✅ 사용자 플로우 완료');
} catch (error) {
this.results.userExperience = {
flowCompletion: false,
error: error.message,
status: 'FAIL'
};
console.log(`❌ 사용자 플로우 실패: ${error.message}`);
}
}
// 개인화 점수 계산 (간단한 키워드 매칭)
calculatePersonalizationScore(response, profile) {
if (!response || !response.ai_response) return 0;
const text = response.ai_response.toLowerCase();
let score = 5; // 기본 점수
// 연령대별 키워드
const ageKeywords = {
'SENIOR': ['경험', '인생', '지혜', '추억'],
'ADULT': ['직업', '가족', '책임', '성취'],
'YOUNG_ADULT': ['꿈', '미래', '도전', '성장']
};
// 교육수준별 키워드
const educationKeywords = {
'HIGH_SCHOOL': ['학교', '친구', '선생님'],
'UNIVERSITY_GRADUATE': ['대학', '전공', '학문'],
'UNIVERSITY_STUDENT': ['공부', '시험', '과제']
};
// 키워드 매칭으로 점수 조정
const ageWords = ageKeywords[profile.age_group] || [];
const eduWords = educationKeywords[profile.education_level] || [];
ageWords.forEach(keyword => {
if (text.includes(keyword)) score += 0.5;
});
eduWords.forEach(keyword => {
if (text.includes(keyword)) score += 0.5;
});
return Math.min(score, 10); // 최대 10점
}
// AI 질문 생성 (테스트용)
async generateQuestion(profile = null) {
const payload = {
user_id: `test-user-${Date.now()}`,
message: "첫 질문을 해주세요."
};
if (profile) {
// 실제로는 메타데이터가 AI 서비스에서 활용됨
payload.metadata = profile;
}
// API 경로 수정
return await axios.post(`${this.baseUrl}/conversation/1`, payload);
}
// 검증 결과 출력
printResults() {
console.log('\n📊 축약된 검증 결과');
console.log('='.repeat(50));
console.log('\n🔧 기술적 성능:');
console.log(` 성공률: ${this.results.technicalPerformance.successRate}%`);
console.log(` 응답시간: ${this.results.technicalPerformance.averageResponseTime}ms`);
console.log(` 상태: ${this.results.technicalPerformance.status}`);
console.log('\n🎯 개인화 효과:');
console.log(` 개인화 점수: ${this.results.personalization.averageScore}/10`);
console.log(` 테스트 수: ${this.results.personalization.testCount}`);
console.log(` 상태: ${this.results.personalization.status}`);
console.log('\n👤 사용자 경험:');
console.log(` 플로우 완료: ${this.results.userExperience.flowCompletion ? '성공' : '실패'}`);
console.log(` 응답 수신: ${this.results.userExperience.responseReceived ? '성공' : '실패'}`);
console.log(` 상태: ${this.results.userExperience.status}`);
// 전체 결과
const allPassed = [
this.results.technicalPerformance.status,
this.results.personalization.status,
this.results.userExperience.status
].every(status => status === 'PASS');
console.log('\n🎯 전체 검증 결과:');
console.log(` ${allPassed ? '✅ 통과' : '❌ 실패'}`);
if (allPassed) {
console.log('\n🚀 배포 권장: 모든 핵심 메트릭이 기준을 충족합니다.');
} else {
console.log('\n⚠️ 개선 필요: 일부 메트릭이 기준에 미달합니다.');
}
}
// 결과를 파일로 저장
saveResults() {
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
const filename = `validation-result-${timestamp}.json`;
const report = {
timestamp: new Date().toISOString(),
summary: {
technicalPerformance: this.results.technicalPerformance.status,
personalization: this.results.personalization.status,
userExperience: this.results.userExperience.status
},
details: this.results,
recommendation: this.getRecommendation()
};
fs.writeFileSync(filename, JSON.stringify(report, null, 2));
console.log(`\n💾 결과 저장: ${filename}`);
}
getRecommendation() {
const allPassed = [
this.results.technicalPerformance.status,
this.results.personalization.status,
this.results.userExperience.status
].every(status => status === 'PASS');
return allPassed ? 'DEPLOY' : 'IMPROVE';
}
// 전체 검증 실행
async runValidation() {
console.log('🚀 축약된 검증 프로세스 시작');
console.log('기존 복잡한 검증 → 핵심 메트릭 3개로 간소화\n');
try {
await this.validateTechnicalPerformance();
await this.validatePersonalization();
await this.validateUserExperience();
this.printResults();
this.saveResults();
} catch (error) {
console.error('❌ 검증 프로세스 실패:', error.message);
}
}
}
// 실행
if (require.main === module) {
const baseUrl = process.argv[2] || 'http://localhost:3000/api/v2';
const validator = new QuickValidation(baseUrl);
validator.runValidation();
}
module.exports = QuickValidation;