@ririaru/mcp-gpt5-server
Version:
Enhanced MCP server for GPT-5 with advanced features
119 lines (91 loc) • 5.08 kB
JavaScript
// 統合テスト: GPT-5提案アーキテクチャの全体動作確認
import { Gpt5McpCore, MemoryCache, MemoryStats } from './packages/core/dist/index.js';
console.log('🏗️ Integration Test: Complete Architecture...');
// カスタムプロバイダでの統合テスト
const customCache = new MemoryCache();
const customStats = new MemoryStats();
const core = new Gpt5McpCore({
cache: customCache,
stats: customStats,
defaultLevel: "medium",
defaultVerbosity: "normal"
});
async function runIntegrationTests() {
console.log('\n📋 Test Suite: Integration Tests');
try {
// Test 1: プラガブル設計の確認
console.log('\n🔌 Test 1: Pluggable Architecture');
// カスタムキャッシュに直接値を設定
await customCache.set('manual-test', JSON.stringify({ text: 'manually cached value' }), 300);
// コアが同じキャッシュインスタンスを使用していることを確認
const result1 = await core.handleMessage({ prompt: 'This should be fresh' });
console.log(` ✅ Fresh request: ${!result1.cached ? 'PASS' : 'FAIL'}`);
// 手動でキャッシュされた値が取得できることを確認
const cachedValue = await customCache.get('manual-test');
console.log(` ✅ Manual cache access: ${cachedValue ? 'PASS' : 'FAIL'}`);
// Test 2: 統計プロバイダの動作確認
console.log('\n📊 Test 2: Stats Provider Integration');
// いくつかのリクエストを実行
await core.handleMessage({ prompt: 'Stats test 1' });
await core.handleMessage({ prompt: 'Stats test 2' });
await core.handleMessage({ prompt: 'Stats test 1' }); // Should be cached
const stats = await customStats.getStats();
console.log(` ✅ Request counting: ${stats.metrics.requests_total >= 3 ? 'PASS' : 'FAIL'} (${stats.metrics.requests_total} requests)`);
console.log(` ✅ Event logging: ${stats.totalEvents > 0 ? 'PASS' : 'FAIL'} (${stats.totalEvents} events)`);
// Test 3: レベル・詳細度の動的変更
console.log('\n⚙️ Test 3: Dynamic Level/Verbosity');
const scenarios = [
{ level: "low", verbosity: "concise", expected: "low/concise" },
{ level: "medium", verbosity: "normal", expected: "medium/normal" },
{ level: "high", verbosity: "verbose", expected: "high/verbose" }
];
for (const scenario of scenarios) {
const result = await core.handleMessage({
prompt: `Test ${scenario.expected}`,
level: scenario.level,
verbosity: scenario.verbosity
});
const contains = result.output.text.includes(scenario.expected);
console.log(` ✅ ${scenario.expected}: ${contains ? 'PASS' : 'FAIL'}`);
}
// Test 4: キャッシュの一貫性
console.log('\n🗄️ Test 4: Cache Consistency');
const testPrompt = 'Consistency test message';
// 最初のリクエスト
const first = await core.handleMessage({ prompt: testPrompt, level: "low" });
// 同じパラメータでの2回目のリクエスト(キャッシュヒットのはず)
const second = await core.handleMessage({ prompt: testPrompt, level: "low" });
// 異なるレベルでの3回目のリクエスト(キャッシュミスのはず)
const third = await core.handleMessage({ prompt: testPrompt, level: "high" });
console.log(` ✅ First request fresh: ${!first.cached ? 'PASS' : 'FAIL'}`);
console.log(` ✅ Second request cached: ${second.cached ? 'PASS' : 'FAIL'}`);
console.log(` ✅ Different level fresh: ${!third.cached ? 'PASS' : 'FAIL'}`);
console.log(` ✅ Content consistency: ${first.output.text === second.output.text ? 'PASS' : 'FAIL'}`);
console.log(` ✅ Level differentiation: ${first.output.text !== third.output.text ? 'PASS' : 'FAIL'}`);
// Test 5: 最終統計確認
console.log('\n📈 Test 5: Final Statistics');
const finalStats = await customStats.getStats();
const cacheStats = await customCache.getStats();
console.log(` 📊 Total requests: ${finalStats.metrics.requests_total}`);
console.log(` 📊 Total events: ${finalStats.totalEvents}`);
console.log(` 📊 Cache entries: ${cacheStats.size}`);
console.log(` 📊 Cache keys: ${cacheStats.keys.length}`);
console.log('\n🎉 Integration tests completed successfully!');
console.log('✅ All systems working as designed per GPT-5 recommendations');
return true;
} catch (error) {
console.error('❌ Integration test failed:', error.message);
console.error('Stack:', error.stack);
return false;
}
}
// Run the tests
runIntegrationTests().then(success => {
if (success) {
console.log('\n🚀 Ready for deployment!');
process.exit(0);
} else {
console.log('\n❌ Tests failed - do not deploy');
process.exit(1);
}
});