claude-flow-novice 2.2.4 ā 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +9 -8
- package/scripts/.claude-flow/metrics/agent-metrics.json +1 -0
- package/scripts/.claude-flow/metrics/performance.json +9 -0
- package/scripts/.claude-flow/metrics/task-metrics.json +10 -0
- package/scripts/CLEANUP_OPTIMIZATION_REPORT.json +312 -0
- package/scripts/CLEANUP_PERFORMANCE_OPTIMIZATION.md +387 -0
- package/scripts/CLEANUP_QUICK_START.md +268 -0
- package/scripts/CLEANUP_TEST_RESULTS.md +205 -0
- package/scripts/README.md +339 -0
- package/scripts/ace-query.sh +384 -0
- package/scripts/agent-token-analysis.js +430 -0
- package/scripts/auto-setup.js +332 -0
- package/scripts/build/README.md +167 -0
- package/scripts/build/build-config.js +27 -0
- package/scripts/build/build-prompt-copier.sh +30 -0
- package/scripts/build/performance-monitor.js +869 -0
- package/scripts/build/prepare-publish.js +150 -0
- package/scripts/build/typescript-fixer.js +621 -0
- package/scripts/build/unified-builder.sh +428 -0
- package/scripts/build/update-bin-version.js +32 -0
- package/scripts/build/validate-agents.js +238 -0
- package/scripts/build-index.js +43 -0
- package/scripts/build-orchestrator.js +320 -0
- package/scripts/check-routing-stats.cjs +122 -0
- package/scripts/ci-validation.js +375 -0
- package/scripts/cleanup-blocking-coordination.sh +420 -0
- package/scripts/cleanup-idle-sessions.sh +59 -0
- package/scripts/collect-build-metrics.js +65 -0
- package/scripts/demo/README.md +79 -0
- package/scripts/demo/autoscaling-demo-simplified.js +963 -0
- package/scripts/demo/comprehensive-dashboard-test.js +693 -0
- package/scripts/demo/confidence-log.js +87 -0
- package/scripts/demo/confidence-report.js +82 -0
- package/scripts/demo/demo-multi-swarm-coordination.js +325 -0
- package/scripts/demo/demo-production-deployment.js +399 -0
- package/scripts/demo/demo-visualization-system.js +149 -0
- package/scripts/demo/performance-analysis.cjs +71 -0
- package/scripts/demo/performance-analysis.js +71 -0
- package/scripts/demo/test-autoscaling-demo.js +314 -0
- package/scripts/dependency-optimizer.js +349 -0
- package/scripts/dependency-security-assessment.js +331 -0
- package/scripts/deploy-sdk.sh +176 -0
- package/scripts/deployment-readiness-report.json +179 -0
- package/scripts/dev/README.md +264 -0
- package/scripts/dev/claude-flow-wrapper.sh +35 -0
- package/scripts/dev/claude-monitor.py +419 -0
- package/scripts/dev/claude-sparc.sh +562 -0
- package/scripts/dev/claude-wrapper.sh +17 -0
- package/scripts/dev/demo-phase3-compliance.js +172 -0
- package/scripts/dev/demo-task-system.ts +224 -0
- package/scripts/dev/deployment-validator.js +315 -0
- package/scripts/dev/spawn-claude-terminal.sh +32 -0
- package/scripts/dev/start-portal.sh +506 -0
- package/scripts/dev/start-web-ui.js +15 -0
- package/scripts/dev/stop-portal.sh +311 -0
- package/scripts/dev/validate-examples.ts +288 -0
- package/scripts/dev/validate-phase2.cjs +451 -0
- package/scripts/dev/validate-phase2.js +785 -0
- package/scripts/dev/validate-phase3.cjs +208 -0
- package/scripts/dev/validate-security-remediation.js +1 -0
- package/scripts/ecosystem.config.cjs +90 -0
- package/scripts/fix-js-extensions.js +167 -0
- package/scripts/generate-basic-types.js +73 -0
- package/scripts/generate-changelog.js +318 -0
- package/scripts/git-hooks/pre-commit.sh +143 -0
- package/scripts/health-checks.js +634 -0
- package/scripts/hook-wrapper.sh +54 -0
- package/scripts/install/README.md +375 -0
- package/scripts/install/REDIS_SETUP_VALIDATION.json +245 -0
- package/scripts/install/check-prerequisites.js +303 -0
- package/scripts/install/config-wizard.js +606 -0
- package/scripts/install/dependency-checker.js +385 -0
- package/scripts/install/health-check.js +765 -0
- package/scripts/install/install.js +256 -0
- package/scripts/install/installation-benchmark.js +461 -0
- package/scripts/install/quick-install.js +720 -0
- package/scripts/install/quick-start-wizard.js +295 -0
- package/scripts/install/redis-cli.js +289 -0
- package/scripts/install/redis-install-guides.md +407 -0
- package/scripts/install/redis-setup.js +559 -0
- package/scripts/install/redis-test.js +278 -0
- package/scripts/install/service-manager.js +672 -0
- package/scripts/install/setup.js +832 -0
- package/scripts/install/uninstall.js +526 -0
- package/scripts/install/update.js +461 -0
- package/scripts/install-pre-commit-hook.sh +127 -0
- package/scripts/legacy/README.md +272 -0
- package/scripts/legacy/batch-fix-ts.sh +54 -0
- package/scripts/legacy/build-migration.sh +105 -0
- package/scripts/legacy/build-monitor.js +209 -0
- package/scripts/legacy/build-with-filter.sh +84 -0
- package/scripts/legacy/build-workaround.sh +71 -0
- package/scripts/legacy/fix-ts-advanced.js +358 -0
- package/scripts/legacy/fix-ts-final.sh +50 -0
- package/scripts/legacy/fix-ts-targeted.sh +49 -0
- package/scripts/legacy/fix-typescript-errors.js +305 -0
- package/scripts/legacy/force-build.sh +63 -0
- package/scripts/legacy/optimize-performance.js +400 -0
- package/scripts/legacy/performance-monitor.js +263 -0
- package/scripts/legacy/performance-monitoring.js +532 -0
- package/scripts/legacy/performance-test-runner.js +645 -0
- package/scripts/legacy/quick-fix-ts.js +281 -0
- package/scripts/legacy/safe-build.sh +63 -0
- package/scripts/memory-monitor-coordinator.js +322 -0
- package/scripts/migrate-to-sdk.sh +520 -0
- package/scripts/migration/QUICK-START.md +189 -0
- package/scripts/migration/QUICK-START.md.backup-1760135091363 +189 -0
- package/scripts/migration/README.md +464 -0
- package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md +500 -0
- package/scripts/migration/TASK-1.3.2-COMPLETION-REPORT.md.backup-1760135091348 +500 -0
- package/scripts/migration/UPDATE-PATHS-README.md +464 -0
- package/scripts/migration/UPDATE-PATHS-README.md.backup-1760135091337 +464 -0
- package/scripts/migration/example-patterns.json +19 -0
- package/scripts/migration/install-arm64.js +78 -0
- package/scripts/migration/install.js +83 -0
- package/scripts/migration/migrate-hooks.js +173 -0
- package/scripts/migration/migration-examples.ts +318 -0
- package/scripts/migration/reorganize-workspace.js +504 -0
- package/scripts/migration/test-update-paths.js +359 -0
- package/scripts/migration/update-paths.js +664 -0
- package/scripts/migration/validate-migration.js +647 -0
- package/scripts/monitor-loop.sh +65 -0
- package/scripts/monitor-memory.sh +47 -0
- package/scripts/monitor-migration.js +339 -0
- package/scripts/monitor.py +43 -0
- package/scripts/monitoring/README.md +178 -0
- package/scripts/monitoring/alert-monitor.sh +220 -0
- package/scripts/monitoring/analyze-resources.sh +199 -0
- package/scripts/monitoring/dashboards/rate-limiting-dashboard.json +211 -0
- package/scripts/monitoring/dynamic-monitor.sh +85 -0
- package/scripts/monitoring/launch-stability-test.sh +184 -0
- package/scripts/monitoring/monitor-test.sh +93 -0
- package/scripts/monitoring/pre-test-validation.sh +208 -0
- package/scripts/monitoring/quick-test-alerting.sh +118 -0
- package/scripts/monitoring/quick-test-rate-limiting.sh +206 -0
- package/scripts/monitoring/rate-limiting-monitor.sh +380 -0
- package/scripts/monitoring/resource-monitor.sh +126 -0
- package/scripts/monitoring/stability-monitor.js +429 -0
- package/scripts/monitoring/test-monitor-quick.sh +54 -0
- package/scripts/monitoring/view-alerts.sh +307 -0
- package/scripts/npm-metrics-collector.js +482 -0
- package/scripts/npm-package-validation.cjs +299 -0
- package/scripts/optimization/build-optimizer.js +438 -0
- package/scripts/optimization/config-validator.js +761 -0
- package/scripts/optimization/test-optimization.js +432 -0
- package/scripts/optimization/unified-activation.js +839 -0
- package/scripts/optimize-package-swarm.js +54 -0
- package/scripts/performance/ACTIVATION_COMMANDS.md +292 -0
- package/scripts/performance/sqlite-enhanced-activation.sh +583 -0
- package/scripts/performance/test-enhanced-backend.sh +504 -0
- package/scripts/performance-monitor.js +644 -0
- package/scripts/performance-test-runner.js +698 -0
- package/scripts/post-deployment-monitoring.js +350 -0
- package/scripts/post-edit-pipeline.js +2091 -0
- package/scripts/post-install-claude-md.js +78 -0
- package/scripts/postinstall.js +79 -0
- package/scripts/pre-publish-validation.cjs +212 -0
- package/scripts/pre-publish-validation.js +429 -0
- package/scripts/redis-lua/cleanup-blocking-coordination.lua +198 -0
- package/scripts/release-announcement.js +425 -0
- package/scripts/release-notification.js +248 -0
- package/scripts/release-rollback.js +376 -0
- package/scripts/release-validation.js +460 -0
- package/scripts/rollback-sdk.sh +66 -0
- package/scripts/run-production-validation.ts +590 -0
- package/scripts/run-stability-validation.sh +687 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/deployment-validation.cjs +279 -0
- package/scripts/security/envelope-encryption-confidence-report.cjs +422 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/install-git-secrets.sh +295 -0
- package/scripts/security/rotate-api-keys.js +469 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/security/security-audit.cjs +538 -0
- package/scripts/security/setup-redis-auth.sh +397 -0
- package/scripts/security/validate-envelope-encryption.cjs +340 -0
- package/scripts/security-scan.js +492 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/agent-metrics.json +1 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/performance.json +9 -0
- package/scripts/src/web/frontend/.claude-flow/metrics/task-metrics.json +10 -0
- package/scripts/switch-api.sh +158 -0
- package/scripts/sync-agents.js +290 -0
- package/scripts/test/50-agent-test.js +625 -0
- package/scripts/test/NEW_STABILITY_TEST_GUIDE.md +407 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/STABILITY_TEST_EXAMPLE.md +347 -0
- package/scripts/test/STABILITY_TEST_README.md +480 -0
- package/scripts/test/agent-worker.js +309 -0
- package/scripts/test/ai-coordination-test.js +650 -0
- package/scripts/test/ai-mesh-coordination-test.js +416 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -0
- package/scripts/test/cli-agent-coordination-test.js +313 -0
- package/scripts/test/coordinator-multilingual-test.js +396 -0
- package/scripts/test/coordinator-transparency-demo.js +585 -0
- package/scripts/test/coverage-report.ts +692 -0
- package/scripts/test/generate-swarm-tests.js +633 -0
- package/scripts/test/integration-test-validation.cjs +253 -0
- package/scripts/test/load-test-swarm.js +576 -0
- package/scripts/test/mesh-coordination-zero-overlap-test.js +740 -0
- package/scripts/test/multilingual-hello-world-test.js +390 -0
- package/scripts/test/quick-multilingual-demo.js +464 -0
- package/scripts/test/real-agent-test.js +312 -0
- package/scripts/test/run-phase3-compliance-tests.js +427 -0
- package/scripts/test/run-stability-test-examples.sh +292 -0
- package/scripts/test/stability-results/stability-metrics.jsonl +83 -0
- package/scripts/test/stability-results/stability-test-report.json +128 -0
- package/scripts/test/stability-results/stability-test.log +1827 -0
- package/scripts/test/stability-test-50-agents.js +734 -0
- package/scripts/test/test-batch-tasks.ts +29 -0
- package/scripts/test/test-byzantine-resolution.js +246 -0
- package/scripts/test/test-claude-spawn-options.sh +63 -0
- package/scripts/test/test-cli-wizard.js +331 -0
- package/scripts/test/test-comprehensive.js +401 -0
- package/scripts/test/test-coordination-features.ts +238 -0
- package/scripts/test/test-fallback-systems.js +276 -0
- package/scripts/test/test-init-command.ts +302 -0
- package/scripts/test/test-mcp.ts +251 -0
- package/scripts/test/test-runner.ts +568 -0
- package/scripts/test/test-swarm-integration.sh +92 -0
- package/scripts/test/test-swarm.ts +142 -0
- package/scripts/test/validation-summary.ts +408 -0
- package/scripts/test-cleanup-performance.sh +416 -0
- package/scripts/test-dashboard-auth.cjs +203 -0
- package/scripts/test-docker-deployment.sh +207 -0
- package/scripts/test-npm-package.cjs +167 -0
- package/scripts/test-provider-routing.cjs +226 -0
- package/scripts/test-routing-telemetry.cjs +147 -0
- package/scripts/test-runner.cjs +154 -0
- package/scripts/test-zai-10k.cjs +81 -0
- package/scripts/test-zai-api.cjs +191 -0
- package/scripts/test-zai-diagnostic.cjs +151 -0
- package/scripts/test-zai-final.cjs +128 -0
- package/scripts/test-zai-with-env.cjs +85 -0
- package/scripts/utils/README.md +261 -0
- package/scripts/utils/clean-build-artifacts.sh +94 -0
- package/scripts/utils/cleanup-root.sh +69 -0
- package/scripts/utils/fix-cliffy-imports.js +307 -0
- package/scripts/utils/fix-duplicate-imports.js +114 -0
- package/scripts/utils/fix-error-handling.cjs +70 -0
- package/scripts/utils/fix-import-paths.js +104 -0
- package/scripts/utils/fix-imports.js +116 -0
- package/scripts/utils/fix-shebang.js +78 -0
- package/scripts/utils/fix-test-modules.js +27 -0
- package/scripts/utils/fix-timezone-issue-246.js +200 -0
- package/scripts/utils/fix-ts-comprehensive.py +182 -0
- package/scripts/utils/fix-ts-targeted-batch.js +250 -0
- package/scripts/utils/remove-benchmark-conflicts.sh +140 -0
- package/scripts/utils/simple-test-fixer.js +190 -0
- package/scripts/utils/validate-metrics-structure.cjs +144 -0
- package/scripts/validate-agent-hooks.js +506 -0
- package/scripts/validate-changelog.js +241 -0
- package/scripts/validate-coordination-cli.js +69 -0
- package/scripts/validate-coordination-toggle-integration.cjs +501 -0
- package/scripts/validate-docker-infrastructure.sh +502 -0
- package/scripts/validate-entry-points.js +300 -0
- package/scripts/validate-stage3-performance.ts +377 -0
- package/scripts/validate-template-bundling.js +180 -0
- package/scripts/validation/README.md +33 -0
- package/scripts/validation/acl-security-validation.cjs +214 -0
- package/scripts/validation/acl-security-validation.js +402 -0
- package/scripts/validation/byzantine-verification.js +407 -0
- package/scripts/validation/final-phase-2-consensus.cjs +219 -0
- package/scripts/validation/final-security-validation.js +791 -0
- package/scripts/validation/final-wasm-validation.cjs +840 -0
- package/scripts/validation/integration-test-analysis.js +105 -0
- package/scripts/validation/phase-0-comprehensive-validation.js +474 -0
- package/scripts/validation/phase-0-consensus-report.js +139 -0
- package/scripts/validation/phase-0-final-report.js +112 -0
- package/scripts/validation/phase-0-redis-consensus-report.js +129 -0
- package/scripts/validation/phase-0-validation-improved.js +490 -0
- package/scripts/validation/phase-0-validation-test.js +65 -0
- package/scripts/validation/phase-1-consensus-report.cjs +342 -0
- package/scripts/validation/phase-1-consensus-validation.cjs +551 -0
- package/scripts/validation/phase-1-consensus-validation.js +551 -0
- package/scripts/validation/phase-2-consensus-report.cjs +186 -0
- package/scripts/validation/phase-2-validation.cjs +171 -0
- package/scripts/validation/phase-2-validation.js +171 -0
- package/scripts/validation/phase-4-consensus-report.js +181 -0
- package/scripts/validation/phase-4-final-validation.js +351 -0
- package/scripts/validation/phase-5-consensus-report.cjs +113 -0
- package/scripts/validation/phase-5-consensus-report.js +113 -0
- package/scripts/validation/security-analysis.js +49 -0
- package/scripts/validation/security-validation.js +492 -0
- package/scripts/validation/simple-security-validation.js +464 -0
- package/scripts/verify-installation.js +112 -0
- package/scripts/verify-mcp-server.js +86 -0
- package/scripts/verify-sdk-phase1.cjs +293 -0
|
@@ -0,0 +1,576 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Swarm Load Testing for Claude Flow v2.0.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { spawn } from 'child_process';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { SystemIntegration } from '../dist/integration/system-integration.js';
|
|
10
|
+
import { SwarmCoordinator } from '../dist/coordination/swarm-coordinator.js';
|
|
11
|
+
import { AgentManager } from '../dist/agents/agent-manager.js';
|
|
12
|
+
import { TaskEngine } from '../dist/task/engine.js';
|
|
13
|
+
|
|
14
|
+
// Load test configuration
|
|
15
|
+
const LOAD_CONFIGS = {
|
|
16
|
+
light: {
|
|
17
|
+
swarms: 5,
|
|
18
|
+
agentsPerSwarm: 8,
|
|
19
|
+
tasksPerSwarm: 10,
|
|
20
|
+
duration: 300000, // 5 minutes
|
|
21
|
+
description: 'Light load test'
|
|
22
|
+
},
|
|
23
|
+
medium: {
|
|
24
|
+
swarms: 15,
|
|
25
|
+
agentsPerSwarm: 12,
|
|
26
|
+
tasksPerSwarm: 20,
|
|
27
|
+
duration: 600000, // 10 minutes
|
|
28
|
+
description: 'Medium load test'
|
|
29
|
+
},
|
|
30
|
+
heavy: {
|
|
31
|
+
swarms: 30,
|
|
32
|
+
agentsPerSwarm: 20,
|
|
33
|
+
tasksPerSwarm: 40,
|
|
34
|
+
duration: 1200000, // 20 minutes
|
|
35
|
+
description: 'Heavy load test'
|
|
36
|
+
},
|
|
37
|
+
extreme: {
|
|
38
|
+
swarms: 50,
|
|
39
|
+
agentsPerSwarm: 30,
|
|
40
|
+
tasksPerSwarm: 60,
|
|
41
|
+
duration: 1800000, // 30 minutes
|
|
42
|
+
description: 'Extreme load test'
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
class SwarmLoadTester {
|
|
47
|
+
constructor(config) {
|
|
48
|
+
this.config = config;
|
|
49
|
+
this.systemIntegration = null;
|
|
50
|
+
this.swarmCoordinator = null;
|
|
51
|
+
this.agentManager = null;
|
|
52
|
+
this.taskEngine = null;
|
|
53
|
+
this.metrics = {
|
|
54
|
+
startTime: 0,
|
|
55
|
+
endTime: 0,
|
|
56
|
+
swarmsCreated: 0,
|
|
57
|
+
agentsSpawned: 0,
|
|
58
|
+
tasksCreated: 0,
|
|
59
|
+
errors: [],
|
|
60
|
+
responseTimes: [],
|
|
61
|
+
throughput: 0
|
|
62
|
+
};
|
|
63
|
+
this.activeSwarms = new Set();
|
|
64
|
+
this.isRunning = false;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
log(message, level = 'info') {
|
|
68
|
+
const timestamp = new Date().toISOString();
|
|
69
|
+
const prefix = `[${timestamp}]`;
|
|
70
|
+
|
|
71
|
+
switch (level) {
|
|
72
|
+
case 'success':
|
|
73
|
+
console.log(chalk.green(`${prefix} ā
${message}`));
|
|
74
|
+
break;
|
|
75
|
+
case 'error':
|
|
76
|
+
console.log(chalk.red(`${prefix} ā ${message}`));
|
|
77
|
+
break;
|
|
78
|
+
case 'warning':
|
|
79
|
+
console.log(chalk.yellow(`${prefix} ā ļø ${message}`));
|
|
80
|
+
break;
|
|
81
|
+
case 'info':
|
|
82
|
+
default:
|
|
83
|
+
console.log(chalk.blue(`${prefix} ā¹ļø ${message}`));
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async initialize() {
|
|
89
|
+
this.log('Initializing system for load testing');
|
|
90
|
+
|
|
91
|
+
try {
|
|
92
|
+
this.systemIntegration = SystemIntegration.getInstance();
|
|
93
|
+
await this.systemIntegration.initialize({
|
|
94
|
+
logLevel: 'warn', // Reduce logging for performance
|
|
95
|
+
environment: 'testing',
|
|
96
|
+
monitoring: {
|
|
97
|
+
enabled: false, // Disable monitoring during load test
|
|
98
|
+
metrics: false,
|
|
99
|
+
realTime: false
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
this.swarmCoordinator = this.systemIntegration.getComponent('swarmCoordinator');
|
|
104
|
+
this.agentManager = this.systemIntegration.getComponent('agentManager');
|
|
105
|
+
this.taskEngine = this.systemIntegration.getComponent('taskEngine');
|
|
106
|
+
|
|
107
|
+
this.log('System initialized successfully', 'success');
|
|
108
|
+
|
|
109
|
+
} catch (error) {
|
|
110
|
+
this.log(`Failed to initialize system: ${error.message}`, 'error');
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
async runLoadTest() {
|
|
116
|
+
this.log(`Starting ${this.config.description}`);
|
|
117
|
+
this.log(`Configuration: ${this.config.swarms} swarms, ${this.config.agentsPerSwarm} agents/swarm, ${this.config.tasksPerSwarm} tasks/swarm`);
|
|
118
|
+
|
|
119
|
+
this.metrics.startTime = Date.now();
|
|
120
|
+
this.isRunning = true;
|
|
121
|
+
|
|
122
|
+
try {
|
|
123
|
+
// Phase 1: Create swarms
|
|
124
|
+
await this.createSwarms();
|
|
125
|
+
|
|
126
|
+
// Phase 2: Spawn agents
|
|
127
|
+
await this.spawnAgents();
|
|
128
|
+
|
|
129
|
+
// Phase 3: Create tasks
|
|
130
|
+
await this.createTasks();
|
|
131
|
+
|
|
132
|
+
// Phase 4: Run for duration
|
|
133
|
+
await this.runForDuration();
|
|
134
|
+
|
|
135
|
+
// Phase 5: Cleanup
|
|
136
|
+
await this.cleanup();
|
|
137
|
+
|
|
138
|
+
this.metrics.endTime = Date.now();
|
|
139
|
+
this.generateReport();
|
|
140
|
+
|
|
141
|
+
} catch (error) {
|
|
142
|
+
this.log(`Load test failed: ${error.message}`, 'error');
|
|
143
|
+
this.metrics.errors.push({
|
|
144
|
+
message: error.message,
|
|
145
|
+
timestamp: Date.now(),
|
|
146
|
+
phase: 'main'
|
|
147
|
+
});
|
|
148
|
+
throw error;
|
|
149
|
+
} finally {
|
|
150
|
+
this.isRunning = false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async createSwarms() {
|
|
155
|
+
this.log(`Phase 1: Creating ${this.config.swarms} swarms`);
|
|
156
|
+
|
|
157
|
+
const startTime = Date.now();
|
|
158
|
+
|
|
159
|
+
try {
|
|
160
|
+
const swarmPromises = Array.from({ length: this.config.swarms }, (_, i) =>
|
|
161
|
+
this.createSwarm(i)
|
|
162
|
+
);
|
|
163
|
+
|
|
164
|
+
const swarmIds = await Promise.all(swarmPromises);
|
|
165
|
+
swarmIds.forEach(id => this.activeSwarms.add(id));
|
|
166
|
+
|
|
167
|
+
this.metrics.swarmsCreated = swarmIds.length;
|
|
168
|
+
const duration = Date.now() - startTime;
|
|
169
|
+
|
|
170
|
+
this.log(`Created ${swarmIds.length} swarms in ${duration}ms`, 'success');
|
|
171
|
+
|
|
172
|
+
} catch (error) {
|
|
173
|
+
this.log(`Failed to create swarms: ${error.message}`, 'error');
|
|
174
|
+
throw error;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async createSwarm(index) {
|
|
179
|
+
const swarmStartTime = Date.now();
|
|
180
|
+
|
|
181
|
+
try {
|
|
182
|
+
const swarmId = await this.swarmCoordinator.createSwarm({
|
|
183
|
+
objective: `Load test swarm ${index}`,
|
|
184
|
+
strategy: 'auto',
|
|
185
|
+
topology: 'mesh',
|
|
186
|
+
maxAgents: this.config.agentsPerSwarm
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
const duration = Date.now() - swarmStartTime;
|
|
190
|
+
this.metrics.responseTimes.push(duration);
|
|
191
|
+
|
|
192
|
+
return swarmId;
|
|
193
|
+
|
|
194
|
+
} catch (error) {
|
|
195
|
+
this.metrics.errors.push({
|
|
196
|
+
message: error.message,
|
|
197
|
+
timestamp: Date.now(),
|
|
198
|
+
phase: 'swarm_creation',
|
|
199
|
+
index
|
|
200
|
+
});
|
|
201
|
+
throw error;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async spawnAgents() {
|
|
206
|
+
this.log(`Phase 2: Spawning ${this.config.agentsPerSwarm} agents per swarm`);
|
|
207
|
+
|
|
208
|
+
const startTime = Date.now();
|
|
209
|
+
const swarmIds = Array.from(this.activeSwarms);
|
|
210
|
+
|
|
211
|
+
try {
|
|
212
|
+
const agentPromises = swarmIds.flatMap(swarmId =>
|
|
213
|
+
Array.from({ length: this.config.agentsPerSwarm }, (_, i) =>
|
|
214
|
+
this.spawnAgent(swarmId, i)
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
const agents = await Promise.all(agentPromises);
|
|
219
|
+
this.metrics.agentsSpawned = agents.length;
|
|
220
|
+
|
|
221
|
+
const duration = Date.now() - startTime;
|
|
222
|
+
this.log(`Spawned ${agents.length} agents in ${duration}ms`, 'success');
|
|
223
|
+
|
|
224
|
+
} catch (error) {
|
|
225
|
+
this.log(`Failed to spawn agents: ${error.message}`, 'error');
|
|
226
|
+
throw error;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async spawnAgent(swarmId, index) {
|
|
231
|
+
const agentTypes = ['researcher', 'coder', 'analyst', 'tester', 'coordinator'];
|
|
232
|
+
const agentType = agentTypes[index % agentTypes.length];
|
|
233
|
+
|
|
234
|
+
const agentStartTime = Date.now();
|
|
235
|
+
|
|
236
|
+
try {
|
|
237
|
+
const agentId = await this.swarmCoordinator.spawnAgentInSwarm(swarmId, {
|
|
238
|
+
type: agentType,
|
|
239
|
+
name: `LoadAgent-${index}`,
|
|
240
|
+
capabilities: ['general', 'load-testing']
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
const duration = Date.now() - agentStartTime;
|
|
244
|
+
this.metrics.responseTimes.push(duration);
|
|
245
|
+
|
|
246
|
+
return agentId;
|
|
247
|
+
|
|
248
|
+
} catch (error) {
|
|
249
|
+
this.metrics.errors.push({
|
|
250
|
+
message: error.message,
|
|
251
|
+
timestamp: Date.now(),
|
|
252
|
+
phase: 'agent_spawning',
|
|
253
|
+
swarmId,
|
|
254
|
+
index
|
|
255
|
+
});
|
|
256
|
+
throw error;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
async createTasks() {
|
|
261
|
+
this.log(`Phase 3: Creating ${this.config.tasksPerSwarm} tasks per swarm`);
|
|
262
|
+
|
|
263
|
+
const startTime = Date.now();
|
|
264
|
+
const swarmIds = Array.from(this.activeSwarms);
|
|
265
|
+
|
|
266
|
+
try {
|
|
267
|
+
const taskPromises = swarmIds.flatMap(swarmId =>
|
|
268
|
+
Array.from({ length: this.config.tasksPerSwarm }, (_, i) =>
|
|
269
|
+
this.createTask(swarmId, i)
|
|
270
|
+
)
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
const tasks = await Promise.all(taskPromises);
|
|
274
|
+
this.metrics.tasksCreated = tasks.length;
|
|
275
|
+
|
|
276
|
+
const duration = Date.now() - startTime;
|
|
277
|
+
this.log(`Created ${tasks.length} tasks in ${duration}ms`, 'success');
|
|
278
|
+
|
|
279
|
+
} catch (error) {
|
|
280
|
+
this.log(`Failed to create tasks: ${error.message}`, 'error');
|
|
281
|
+
throw error;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
async createTask(swarmId, index) {
|
|
286
|
+
const taskStartTime = Date.now();
|
|
287
|
+
|
|
288
|
+
try {
|
|
289
|
+
const taskId = await this.taskEngine.createTask({
|
|
290
|
+
swarmId,
|
|
291
|
+
type: 'development',
|
|
292
|
+
objective: `Load test task ${index}`,
|
|
293
|
+
priority: index % 3 === 0 ? 'high' : 'medium'
|
|
294
|
+
});
|
|
295
|
+
|
|
296
|
+
const duration = Date.now() - taskStartTime;
|
|
297
|
+
this.metrics.responseTimes.push(duration);
|
|
298
|
+
|
|
299
|
+
return taskId;
|
|
300
|
+
|
|
301
|
+
} catch (error) {
|
|
302
|
+
this.metrics.errors.push({
|
|
303
|
+
message: error.message,
|
|
304
|
+
timestamp: Date.now(),
|
|
305
|
+
phase: 'task_creation',
|
|
306
|
+
swarmId,
|
|
307
|
+
index
|
|
308
|
+
});
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
async runForDuration() {
|
|
314
|
+
this.log(`Phase 4: Running load test for ${this.config.duration / 1000}s`);
|
|
315
|
+
|
|
316
|
+
const endTime = Date.now() + this.config.duration;
|
|
317
|
+
const checkInterval = 10000; // Check every 10 seconds
|
|
318
|
+
|
|
319
|
+
while (Date.now() < endTime && this.isRunning) {
|
|
320
|
+
try {
|
|
321
|
+
// Perform periodic operations to maintain load
|
|
322
|
+
await this.performPeriodicOperations();
|
|
323
|
+
|
|
324
|
+
// Report progress
|
|
325
|
+
const elapsed = Date.now() - this.metrics.startTime;
|
|
326
|
+
const remaining = endTime - Date.now();
|
|
327
|
+
|
|
328
|
+
if (elapsed % 60000 < checkInterval) { // Report every minute
|
|
329
|
+
this.log(`Load test progress: ${Math.floor(elapsed / 1000)}s elapsed, ${Math.floor(remaining / 1000)}s remaining`);
|
|
330
|
+
await this.reportCurrentMetrics();
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
await new Promise(resolve => setTimeout(resolve, checkInterval));
|
|
334
|
+
|
|
335
|
+
} catch (error) {
|
|
336
|
+
this.log(`Error during load test execution: ${error.message}`, 'warning');
|
|
337
|
+
this.metrics.errors.push({
|
|
338
|
+
message: error.message,
|
|
339
|
+
timestamp: Date.now(),
|
|
340
|
+
phase: 'execution'
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
this.log('Load test duration completed', 'success');
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
async performPeriodicOperations() {
|
|
349
|
+
// Perform random operations to maintain load
|
|
350
|
+
const operations = [
|
|
351
|
+
() => this.checkSwarmStatuses(),
|
|
352
|
+
() => this.checkAgentStatuses(),
|
|
353
|
+
() => this.checkTaskStatuses(),
|
|
354
|
+
() => this.performHealthChecks()
|
|
355
|
+
];
|
|
356
|
+
|
|
357
|
+
const randomOperation = operations[Math.floor(Math.random() * operations.length)];
|
|
358
|
+
await randomOperation();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async checkSwarmStatuses() {
|
|
362
|
+
const swarmIds = Array.from(this.activeSwarms);
|
|
363
|
+
const randomSwarmId = swarmIds[Math.floor(Math.random() * swarmIds.length)];
|
|
364
|
+
|
|
365
|
+
if (randomSwarmId) {
|
|
366
|
+
const startTime = Date.now();
|
|
367
|
+
await this.swarmCoordinator.getSwarmStatus(randomSwarmId);
|
|
368
|
+
const duration = Date.now() - startTime;
|
|
369
|
+
this.metrics.responseTimes.push(duration);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
async checkAgentStatuses() {
|
|
374
|
+
const startTime = Date.now();
|
|
375
|
+
await this.agentManager.listAgents();
|
|
376
|
+
const duration = Date.now() - startTime;
|
|
377
|
+
this.metrics.responseTimes.push(duration);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async checkTaskStatuses() {
|
|
381
|
+
const swarmIds = Array.from(this.activeSwarms);
|
|
382
|
+
const randomSwarmId = swarmIds[Math.floor(Math.random() * swarmIds.length)];
|
|
383
|
+
|
|
384
|
+
if (randomSwarmId) {
|
|
385
|
+
const startTime = Date.now();
|
|
386
|
+
await this.taskEngine.getActiveTasks(randomSwarmId);
|
|
387
|
+
const duration = Date.now() - startTime;
|
|
388
|
+
this.metrics.responseTimes.push(duration);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
async performHealthChecks() {
|
|
393
|
+
const startTime = Date.now();
|
|
394
|
+
await this.systemIntegration.getSystemHealth();
|
|
395
|
+
const duration = Date.now() - startTime;
|
|
396
|
+
this.metrics.responseTimes.push(duration);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async reportCurrentMetrics() {
|
|
400
|
+
try {
|
|
401
|
+
const health = await this.systemIntegration.getSystemHealth();
|
|
402
|
+
const avgResponseTime = this.metrics.responseTimes.length > 0
|
|
403
|
+
? this.metrics.responseTimes.reduce((sum, time) => sum + time, 0) / this.metrics.responseTimes.length
|
|
404
|
+
: 0;
|
|
405
|
+
|
|
406
|
+
this.log(`Current metrics: ${health.metrics.healthyComponents}/${health.metrics.totalComponents} components healthy, avg response: ${avgResponseTime.toFixed(2)}ms`);
|
|
407
|
+
|
|
408
|
+
} catch (error) {
|
|
409
|
+
this.log(`Failed to get current metrics: ${error.message}`, 'warning');
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
async cleanup() {
|
|
414
|
+
this.log('Phase 5: Cleaning up resources');
|
|
415
|
+
|
|
416
|
+
try {
|
|
417
|
+
// Shutdown system gracefully
|
|
418
|
+
await this.systemIntegration.shutdown();
|
|
419
|
+
this.log('Cleanup completed successfully', 'success');
|
|
420
|
+
|
|
421
|
+
} catch (error) {
|
|
422
|
+
this.log(`Cleanup failed: ${error.message}`, 'warning');
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
generateReport() {
|
|
427
|
+
const totalDuration = this.metrics.endTime - this.metrics.startTime;
|
|
428
|
+
const avgResponseTime = this.metrics.responseTimes.length > 0
|
|
429
|
+
? this.metrics.responseTimes.reduce((sum, time) => sum + time, 0) / this.metrics.responseTimes.length
|
|
430
|
+
: 0;
|
|
431
|
+
const maxResponseTime = this.metrics.responseTimes.length > 0
|
|
432
|
+
? Math.max(...this.metrics.responseTimes)
|
|
433
|
+
: 0;
|
|
434
|
+
const minResponseTime = this.metrics.responseTimes.length > 0
|
|
435
|
+
? Math.min(...this.metrics.responseTimes)
|
|
436
|
+
: 0;
|
|
437
|
+
const totalOperations = this.metrics.swarmsCreated + this.metrics.agentsSpawned + this.metrics.tasksCreated;
|
|
438
|
+
const throughput = totalOperations / (totalDuration / 1000);
|
|
439
|
+
|
|
440
|
+
console.log('\n' + '='.repeat(80));
|
|
441
|
+
console.log(chalk.bold.blue('š„ SWARM LOAD TEST REPORT'));
|
|
442
|
+
console.log('='.repeat(80));
|
|
443
|
+
|
|
444
|
+
console.log(`\nš Test Configuration:`);
|
|
445
|
+
console.log(` Description: ${this.config.description}`);
|
|
446
|
+
console.log(` Swarms: ${this.config.swarms}`);
|
|
447
|
+
console.log(` Agents per Swarm: ${this.config.agentsPerSwarm}`);
|
|
448
|
+
console.log(` Tasks per Swarm: ${this.config.tasksPerSwarm}`);
|
|
449
|
+
console.log(` Duration: ${this.config.duration / 1000}s`);
|
|
450
|
+
|
|
451
|
+
console.log(`\nā±ļø Execution Metrics:`);
|
|
452
|
+
console.log(` Total Duration: ${(totalDuration / 1000).toFixed(2)}s`);
|
|
453
|
+
console.log(` Swarms Created: ${chalk.green(this.metrics.swarmsCreated)}`);
|
|
454
|
+
console.log(` Agents Spawned: ${chalk.green(this.metrics.agentsSpawned)}`);
|
|
455
|
+
console.log(` Tasks Created: ${chalk.green(this.metrics.tasksCreated)}`);
|
|
456
|
+
console.log(` Total Operations: ${chalk.cyan(totalOperations)}`);
|
|
457
|
+
console.log(` Throughput: ${chalk.yellow(throughput.toFixed(2))} ops/sec`);
|
|
458
|
+
|
|
459
|
+
console.log(`\nš Performance Metrics:`);
|
|
460
|
+
console.log(` Average Response Time: ${chalk.cyan(avgResponseTime.toFixed(2))}ms`);
|
|
461
|
+
console.log(` Min Response Time: ${chalk.green(minResponseTime.toFixed(2))}ms`);
|
|
462
|
+
console.log(` Max Response Time: ${chalk.yellow(maxResponseTime.toFixed(2))}ms`);
|
|
463
|
+
console.log(` Total Requests: ${chalk.blue(this.metrics.responseTimes.length)}`);
|
|
464
|
+
|
|
465
|
+
if (this.metrics.errors.length > 0) {
|
|
466
|
+
console.log(`\nā Errors (${this.metrics.errors.length}):`);
|
|
467
|
+
const errorsByPhase = this.metrics.errors.reduce((acc, error) => {
|
|
468
|
+
acc[error.phase] = (acc[error.phase] || 0) + 1;
|
|
469
|
+
return acc;
|
|
470
|
+
}, {});
|
|
471
|
+
|
|
472
|
+
Object.entries(errorsByPhase).forEach(([phase, count]) => {
|
|
473
|
+
console.log(` ${phase}: ${chalk.red(count)} errors`);
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
const errorRate = (this.metrics.errors.length / totalOperations) * 100;
|
|
477
|
+
console.log(` Error Rate: ${chalk.red(errorRate.toFixed(2))}%`);
|
|
478
|
+
} else {
|
|
479
|
+
console.log(`\nā
No errors detected!`);
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// Performance assessment
|
|
483
|
+
console.log(`\nš Performance Assessment:`);
|
|
484
|
+
if (avgResponseTime < 100) {
|
|
485
|
+
console.log(` Response Time: ${chalk.green('EXCELLENT')} (< 100ms)`);
|
|
486
|
+
} else if (avgResponseTime < 500) {
|
|
487
|
+
console.log(` Response Time: ${chalk.yellow('GOOD')} (100-500ms)`);
|
|
488
|
+
} else if (avgResponseTime < 1000) {
|
|
489
|
+
console.log(` Response Time: ${chalk.yellow('ACCEPTABLE')} (500-1000ms)`);
|
|
490
|
+
} else {
|
|
491
|
+
console.log(` Response Time: ${chalk.red('POOR')} (> 1000ms)`);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
if (throughput > 50) {
|
|
495
|
+
console.log(` Throughput: ${chalk.green('EXCELLENT')} (> 50 ops/sec)`);
|
|
496
|
+
} else if (throughput > 20) {
|
|
497
|
+
console.log(` Throughput: ${chalk.yellow('GOOD')} (20-50 ops/sec)`);
|
|
498
|
+
} else if (throughput > 10) {
|
|
499
|
+
console.log(` Throughput: ${chalk.yellow('ACCEPTABLE')} (10-20 ops/sec)`);
|
|
500
|
+
} else {
|
|
501
|
+
console.log(` Throughput: ${chalk.red('POOR')} (< 10 ops/sec)`);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
const errorRate = (this.metrics.errors.length / totalOperations) * 100;
|
|
505
|
+
if (errorRate === 0) {
|
|
506
|
+
console.log(` Reliability: ${chalk.green('EXCELLENT')} (0% errors)`);
|
|
507
|
+
} else if (errorRate < 1) {
|
|
508
|
+
console.log(` Reliability: ${chalk.yellow('GOOD')} (< 1% errors)`);
|
|
509
|
+
} else if (errorRate < 5) {
|
|
510
|
+
console.log(` Reliability: ${chalk.yellow('ACCEPTABLE')} (1-5% errors)`);
|
|
511
|
+
} else {
|
|
512
|
+
console.log(` Reliability: ${chalk.red('POOR')} (> 5% errors)`);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
console.log('\n' + '='.repeat(80));
|
|
516
|
+
|
|
517
|
+
// Save detailed report to file
|
|
518
|
+
const reportData = {
|
|
519
|
+
config: this.config,
|
|
520
|
+
metrics: this.metrics,
|
|
521
|
+
summary: {
|
|
522
|
+
totalDuration,
|
|
523
|
+
avgResponseTime,
|
|
524
|
+
maxResponseTime,
|
|
525
|
+
minResponseTime,
|
|
526
|
+
totalOperations,
|
|
527
|
+
throughput,
|
|
528
|
+
errorRate
|
|
529
|
+
},
|
|
530
|
+
timestamp: new Date().toISOString()
|
|
531
|
+
};
|
|
532
|
+
|
|
533
|
+
return reportData;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
async function main() {
|
|
538
|
+
const args = process.argv.slice(2);
|
|
539
|
+
const configName = args[0] || 'light';
|
|
540
|
+
|
|
541
|
+
if (!LOAD_CONFIGS[configName]) {
|
|
542
|
+
console.error(chalk.red(`Unknown load config: ${configName}`));
|
|
543
|
+
console.log(chalk.blue('Available configs:'));
|
|
544
|
+
Object.entries(LOAD_CONFIGS).forEach(([name, config]) => {
|
|
545
|
+
console.log(` ${name}: ${config.description}`);
|
|
546
|
+
});
|
|
547
|
+
process.exit(1);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
const config = LOAD_CONFIGS[configName];
|
|
551
|
+
const tester = new SwarmLoadTester(config);
|
|
552
|
+
|
|
553
|
+
try {
|
|
554
|
+
await tester.initialize();
|
|
555
|
+
await tester.runLoadTest();
|
|
556
|
+
process.exit(0);
|
|
557
|
+
} catch (error) {
|
|
558
|
+
console.error(chalk.red('Load test failed:'), error.message);
|
|
559
|
+
process.exit(1);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Handle graceful shutdown
|
|
564
|
+
process.on('SIGINT', () => {
|
|
565
|
+
console.log(chalk.yellow('\nReceived SIGINT, shutting down gracefully...'));
|
|
566
|
+
process.exit(0);
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
process.on('SIGTERM', () => {
|
|
570
|
+
console.log(chalk.yellow('\nReceived SIGTERM, shutting down gracefully...'));
|
|
571
|
+
process.exit(0);
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
575
|
+
main();
|
|
576
|
+
}
|