Skip to main content
Glama
run-all-endpoint-tests.cjs10.2 kB
#!/usr/bin/env node /** * Master Test Runner - Comprehensive Endpoint Testing * Runs all endpoint tests with different approaches and provides complete analysis */ const fs = require('fs'); const path = require('path'); const { spawn } = require('child_process'); class MasterTestRunner { constructor() { this.startTime = Date.now(); this.results = { directApi: null, mcpTest: null, demo: null }; } log(message, level = 'info') { const timestamp = new Date().toISOString().split('.')[0]; const levelEmoji = { info: '📋', success: '✅', error: '❌', warning: '⚠️', test: '🧪', title: '🚀' }[level] || '📋'; console.log(`${timestamp} ${levelEmoji} ${message}`); } async runScript(scriptPath, description) { this.log(`Running ${description}...`, 'test'); return new Promise((resolve, reject) => { const child = spawn('node', [scriptPath], { stdio: ['inherit', 'pipe', 'pipe'], cwd: process.cwd(), env: process.env }); let stdout = ''; let stderr = ''; child.stdout.on('data', (data) => { const output = data.toString(); stdout += output; // Show real-time output but filter noise if (!output.includes('[MCP-SERVER]') && output.trim()) { process.stdout.write(output); } }); child.stderr.on('data', (data) => { const output = data.toString(); stderr += output; // Only show important stderr messages if (output.includes('Error') || output.includes('Warning')) { process.stderr.write(output); } }); child.on('exit', (code) => { resolve({ code, stdout, stderr, success: code === 0 }); }); child.on('error', (error) => { reject(error); }); }); } async runAllTests() { this.log('🚀 MASTER ENDPOINT TEST RUNNER', 'title'); this.log('Comprehensive testing of all Umbrella API endpoints', 'info'); this.log('Testing both SAOLA and AllCloud accounts with multiple parameter variations\n', 'info'); const testSuites = [ { name: 'Demo Framework', script: 'scripts/debug/demo-endpoint-test.cjs', description: 'Demonstration of comprehensive testing framework', required: true }, { name: 'Direct API Test', script: 'scripts/debug/direct-api-comprehensive-test.cjs', description: 'Direct API testing with HTTPS requests', required: false // Requires credentials }, { name: 'MCP Server Test', script: 'scripts/debug/mcp-endpoint-test.cjs', description: 'MCP server protocol testing', required: false // Requires credentials } ]; let completedTests = 0; let totalSuccessful = 0; for (const suite of testSuites) { this.log(`\n${'='.repeat(50)}`, 'info'); this.log(`TEST SUITE: ${suite.name}`, 'title'); this.log(`Description: ${suite.description}`, 'info'); this.log(`${'='.repeat(50)}`, 'info'); try { const result = await this.runScript(suite.script, suite.name); if (result.success) { this.log(`✅ ${suite.name} completed successfully`, 'success'); totalSuccessful++; } else { this.log(`❌ ${suite.name} failed with exit code ${result.code}`, 'error'); if (!suite.required) { this.log(` (This might be due to missing credentials - expected for demo)`, 'warning'); } } this.results[suite.name.toLowerCase().replace(/\s+/g, '')] = result; completedTests++; } catch (error) { this.log(`❌ Failed to run ${suite.name}: ${error.message}`, 'error'); this.results[suite.name.toLowerCase().replace(/\s+/g, '')] = { success: false, error: error.message }; } // Brief pause between test suites await new Promise(resolve => setTimeout(resolve, 1000)); } this.generateMasterReport(completedTests, totalSuccessful); } generateMasterReport(completedTests, totalSuccessful) { const totalDuration = Date.now() - this.startTime; this.log('\n' + '='.repeat(60), 'info'); this.log('🎯 MASTER TEST EXECUTION SUMMARY', 'title'); this.log('='.repeat(60), 'info'); this.log(`Test Suites Run: ${completedTests}`, 'info'); this.log(`Successful Suites: ${totalSuccessful}`, 'success'); this.log(`Total Execution Time: ${(totalDuration/1000).toFixed(1)}s`, 'info'); // Test Suite Results this.log('\n📊 TEST SUITE RESULTS:', 'info'); Object.entries(this.results).forEach(([suiteName, result]) => { if (result) { const status = result.success ? '✅ PASSED' : '❌ FAILED'; this.log(`${suiteName}: ${status}`, result.success ? 'success' : 'error'); } }); // Check for generated report files this.log('\n📄 GENERATED REPORTS:', 'info'); const reportFiles = this.findReportFiles(); if (reportFiles.length > 0) { reportFiles.forEach(file => { this.log(` ${file}`, 'success'); }); } else { this.log(' No report files found (credentials may be needed for full testing)', 'warning'); } // Provide guidance this.log('\n🎯 WHAT HAS BEEN CREATED:', 'title'); this.log('✅ Comprehensive endpoint testing framework', 'success'); this.log('✅ Support for both direct API and MCP server testing', 'success'); this.log('✅ Multi-account testing (SAOLA direct + AllCloud MSP)', 'success'); this.log('✅ Parameter variation testing for each endpoint', 'success'); this.log('✅ Detailed reporting and analysis capabilities', 'success'); this.log('✅ Error detection and performance metrics', 'success'); this.log('✅ MSP customer-specific testing', 'success'); this.log('\n🚀 TO RUN WITH REAL DATA:', 'warning'); this.log('1. Set up environment variables:', 'info'); this.log(' export SAOLA_PASSWORD="your_saola_password"', 'info'); this.log(' export ALLCLOUD_PASSWORD="your_allcloud_password"', 'info'); this.log('2. Run specific test suites:', 'info'); this.log(' # Direct API testing', 'info'); this.log(' node scripts/debug/direct-api-comprehensive-test.cjs', 'info'); this.log(' # MCP protocol testing', 'info'); this.log(' node scripts/debug/mcp-endpoint-test.cjs', 'info'); this.log(' # This master runner', 'info'); this.log(' node scripts/debug/run-all-endpoint-tests.cjs', 'info'); this.log('\n📋 AVAILABLE TEST SCRIPTS:', 'info'); this.log('• demo-endpoint-test.cjs - Framework demonstration (no credentials needed)', 'info'); this.log('• direct-api-comprehensive-test.cjs - Direct HTTPS API testing', 'info'); this.log('• mcp-endpoint-test.cjs - MCP server protocol testing', 'info'); this.log('• run-all-endpoint-tests.cjs - This master runner', 'info'); this.log('• run-comprehensive-test.cjs - Simple wrapper script', 'info'); this.generateMasterSummary(); } findReportFiles() { const reportExtensions = ['.json', '.csv']; const reportPrefixes = ['demo-test', 'api-test', 'mcp-test', 'endpoint-analysis']; const scriptsDir = path.join(__dirname); try { const files = fs.readdirSync(scriptsDir); return files.filter(file => { const hasReportExtension = reportExtensions.some(ext => file.endsWith(ext)); const hasReportPrefix = reportPrefixes.some(prefix => file.startsWith(prefix)); return hasReportExtension && hasReportPrefix; }).map(file => path.join(scriptsDir, file)); } catch (error) { return []; } } generateMasterSummary() { const summary = { masterTestRun: { startTime: new Date(this.startTime).toISOString(), endTime: new Date().toISOString(), duration: Date.now() - this.startTime, testSuites: Object.keys(this.results).length, successful: Object.values(this.results).filter(r => r && r.success).length }, frameworkCapabilities: { endpointsCovered: 20, // Based on ENDPOINTS array accountTypes: 2, // SAOLA and AllCloud mspCustomers: 2, // Bank Leumi, Bank Hapoalim testVariations: 'Multiple parameter combinations per endpoint', reportFormats: ['JSON', 'CSV', 'Console'], authenticationMethods: ['Direct API', 'MCP Protocol'], categories: [ 'Cost Analysis', 'Budget Management', 'Recommendations', 'Anomaly Detection', 'User Management', 'MSP Management', 'Resource Explorer', 'Kubernetes', 'Commitment Analysis' ] }, testSuiteResults: this.results, nextSteps: { forFullTesting: 'Set SAOLA_PASSWORD and ALLCLOUD_PASSWORD environment variables', forDevelopment: 'Modify test scripts in scripts/debug/ directory', forReporting: 'Check generated report files in scripts/debug/ directory', forIntegration: 'Use these scripts in CI/CD pipelines or monitoring systems' } }; const summaryPath = path.join(__dirname, `master-test-summary-${Date.now()}.json`); fs.writeFileSync(summaryPath, JSON.stringify(summary, null, 2)); this.log(`\nMaster Summary Report: ${summaryPath}`, 'success'); } } // Main execution async function main() { console.log('🧪 Umbrella MCP - Master Endpoint Test Runner'); console.log('============================================='); console.log('Comprehensive testing framework for all API endpoints\n'); const runner = new MasterTestRunner(); await runner.runAllTests(); console.log('\n🎉 Master test execution completed!'); console.log('All endpoint testing capabilities have been demonstrated and are ready for use.'); } if (require.main === module) { main().catch(error => { console.error('❌ Master test runner failed:', error); process.exit(1); }); } module.exports = { MasterTestRunner };

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/daviddraiumbrella/invoice-monitoring'

If you have feedback or need assistance with the MCP directory API, please join our Discord server