Skip to main content
Glama

firewalla-mcp-server

demo-optimization.cjs•4 kB
#!/usr/bin/env node /** * Test Optimization Demonstration * * Quick demonstration of the optimized test approach vs traditional approach. * This script shows the key differences and benefits of the optimization strategy. */ const { exec } = require('child_process'); const path = require('path'); console.log('šŸš€ Test Optimization Demonstration'); console.log('====================================\n'); console.log('šŸ“‹ TRADITIONAL APPROACH PATTERN:'); console.log(' āŒ Each test method makes individual API calls'); console.log(' āŒ Duplicate data fetching across test cases'); console.log(' āŒ Higher API rate limit consumption'); console.log(' āŒ Slower test execution due to network overhead\n'); console.log('šŸ“‹ OPTIMIZED APPROACH PATTERN:'); console.log(' āœ… Single API call in beforeAll() shared across all tests'); console.log(' āœ… Cached data reused for filtering and analysis'); console.log(' āœ… Minimal API rate limit consumption'); console.log(' āœ… Faster test execution with maintained coverage\n'); console.log('šŸ” Running optimized test suite demonstration...\n'); const testCommand = 'npm test -- tests/firewalla/client-device-optimized.test.ts --verbose'; exec(testCommand, { cwd: path.resolve(__dirname, '..') }, (error, stdout, stderr) => { if (error) { console.error('āŒ Test execution failed:', error.message); return; } // Extract key metrics from the output const output = stdout + stderr; // Extract performance metrics const apiCallsMatch = output.match(/Total API calls: (\d+)/); const testTimeMatch = output.match(/Total test time: (\d+)ms/); const testsPassedMatch = output.match(/Tests:\s+(\d+) passed/); const apiCalls = apiCallsMatch ? parseInt(apiCallsMatch[1]) : 'N/A'; const testTime = testTimeMatch ? parseInt(testTimeMatch[1]) : 'N/A'; const testsPassed = testsPassedMatch ? parseInt(testsPassedMatch[1]) : 'N/A'; console.log('šŸ“Š OPTIMIZATION RESULTS:'); console.log('========================'); console.log(`āœ… Tests Passed: ${testsPassed}`); console.log(`⚔ API Calls Used: ${apiCalls} (shared load)`); console.log(`šŸ• Execution Time: ${testTime}ms`); console.log(`šŸ“ˆ Test Coverage: Comprehensive device operations`); console.log('\nšŸŽÆ KEY BENEFITS DEMONSTRATED:'); console.log(' • Single shared API call eliminates redundancy'); console.log(' • All test scenarios covered with cached data'); console.log(' • Fast execution with minimal network overhead'); console.log(' • Maintainable test isolation and reliability'); console.log('\nšŸ’” IMPLEMENTATION PATTERN:'); console.log('```typescript'); console.log('describe("Optimized Test Suite", () => {'); console.log(' let sharedData: any[];'); console.log(' '); console.log(' beforeAll(async () => {'); console.log(' // SINGLE API CALL - shared across all tests'); console.log(' const cache = await TestDataCacheManager.loadSharedTestData(client);'); console.log(' sharedData = cache.devices;'); console.log(' });'); console.log(' '); console.log(' it("test scenario 1", () => {'); console.log(' // Use cached data - NO additional API call'); console.log(' const filtered = TestDataUtils.filterDevices(sharedData, criteria);'); console.log(' expect(filtered).toHaveLength(expected);'); console.log(' });'); console.log('});'); console.log('```'); console.log('\nšŸ† OPTIMIZATION SUCCESS:'); console.log(' This approach can be applied to other test suites for similar benefits:'); console.log(' • Alarm tests: Share alarm data across filtering scenarios'); console.log(' • Flow tests: Cache flow data for analysis and reporting tests'); console.log(' • Rule tests: Share rule configurations across validation tests'); console.log('\nšŸš€ Ready for production use!'); console.log(' Use OPTIMIZE_TESTS=true to enable optimized patterns in CI/CD'); }); console.log('ā³ Running test suite...');

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/amittell/firewalla-mcp-server'

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