claude-flow-novice 1.3.0 ā 1.3.2
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/.claude-flow-novice/preferences/generation.json +147 -0
- package/.claude-flow-novice/preferences/language-configs/javascript.json +51 -0
- package/.claude-flow-novice/preferences/language-configs/python.json +50 -0
- package/.claude-flow-novice/preferences/language-configs/rust.json +237 -0
- package/.claude-flow-novice/preferences/language-configs/typescript.json +54 -0
- package/.claude-flow-novice/preferences/project-local.json +91 -0
- package/.claude-flow-novice/preferences/resource-delegation.json +120 -0
- package/.claude-flow-novice/preferences/team-shared.json +195 -0
- package/.claude-flow-novice/preferences/user-global.json +247 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-JAVASCRIPT.md +769 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-PYTHON.md +1214 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-RUST.md +475 -0
- package/.claude-flow-novice/templates/claude-md-templates/CLAUDE-TYPESCRIPT.md +851 -0
- package/.claude-flow-novice/templates/claude-md-templates/README.md +263 -0
- package/CLAUDE.md +81 -0
- package/README-NPM.md +0 -0
- package/package.json +11 -7
- 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/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/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/migration/README.md +434 -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/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/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-test-runner.js +698 -0
- package/scripts/security/README.md +339 -0
- package/scripts/security/install-git-hooks.sh +132 -0
- package/scripts/security/ruv-swarm-safe.js +74 -0
- package/scripts/test/README.md +236 -0
- package/scripts/test/check-links.ts +274 -0
- package/scripts/test/check-performance-regression.ts +168 -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/run-phase3-compliance-tests.js +427 -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/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/verify-mcp-server.js +86 -0
- package/src/cli/simple-commands/__tests__/agent.test.js +291 -0
- package/src/cli/simple-commands/__tests__/memory.test.js +8 -0
- package/src/cli/simple-commands/__tests__/swarm.test.js +371 -0
- package/src/cli/simple-commands/__tests__/task.test.js +8 -0
- package/src/cli/simple-commands/agent.js +216 -0
- package/src/cli/simple-commands/analysis.js +570 -0
- package/src/cli/simple-commands/automation-executor.js +1603 -0
- package/src/cli/simple-commands/automation.js +627 -0
- package/src/cli/simple-commands/batch-manager.js +338 -0
- package/src/cli/simple-commands/claude-telemetry.js +311 -0
- package/src/cli/simple-commands/claude-track.js +102 -0
- package/src/cli/simple-commands/concurrent-display.js +348 -0
- package/src/cli/simple-commands/config.js +319 -0
- package/src/cli/simple-commands/coordination.js +307 -0
- package/src/cli/simple-commands/enhanced-ui-views.js +654 -0
- package/src/cli/simple-commands/enhanced-webui-complete.js +1038 -0
- package/src/cli/simple-commands/fix-hook-variables.js +363 -0
- package/src/cli/simple-commands/github/gh-coordinator.js +605 -0
- package/src/cli/simple-commands/github/github-api.js +624 -0
- package/src/cli/simple-commands/github/init.js +543 -0
- package/src/cli/simple-commands/github.js +377 -0
- package/src/cli/simple-commands/goal.js +145 -0
- package/src/cli/simple-commands/hive-mind/auto-save-middleware.js +311 -0
- package/src/cli/simple-commands/hive-mind/communication.js +740 -0
- package/src/cli/simple-commands/hive-mind/core.js +1031 -0
- package/src/cli/simple-commands/hive-mind/db-optimizer.js +872 -0
- package/src/cli/simple-commands/hive-mind/mcp-wrapper.js +1364 -0
- package/src/cli/simple-commands/hive-mind/memory.js +1292 -0
- package/src/cli/simple-commands/hive-mind/performance-optimizer.js +618 -0
- package/src/cli/simple-commands/hive-mind/performance-test.js +373 -0
- package/src/cli/simple-commands/hive-mind/queen.js +809 -0
- package/src/cli/simple-commands/hive-mind/session-manager.js +1223 -0
- package/src/cli/simple-commands/hive-mind-optimize.js +361 -0
- package/src/cli/simple-commands/hive-mind-wizard.js +281 -0
- package/src/cli/simple-commands/hive-mind.js +3112 -0
- package/src/cli/simple-commands/hive.js +140 -0
- package/src/cli/simple-commands/hook-safety.js +671 -0
- package/src/cli/simple-commands/hooks.js +1268 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224542.json +7 -0
- package/src/cli/simple-commands/init/.claude/checkpoints/1756224544.json +8 -0
- package/src/cli/simple-commands/init/README.md +106 -0
- package/src/cli/simple-commands/init/VALIDATION_ROLLBACK.md +488 -0
- package/src/cli/simple-commands/init/agent-copier.js +347 -0
- package/src/cli/simple-commands/init/batch-init.js +663 -0
- package/src/cli/simple-commands/init/claude-commands/claude-flow-commands.js +438 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-claude-flow-commands.js +876 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-slash-commands.js +356 -0
- package/src/cli/simple-commands/init/claude-commands/optimized-sparc-commands.js +501 -0
- package/src/cli/simple-commands/init/claude-commands/slash-commands.js +57 -0
- package/src/cli/simple-commands/init/claude-commands/sparc-commands.js +296 -0
- package/src/cli/simple-commands/init/copy-revised-templates.js +175 -0
- package/src/cli/simple-commands/init/executable-wrapper.js +122 -0
- package/src/cli/simple-commands/init/gitignore-updater.js +137 -0
- package/src/cli/simple-commands/init/help.js +110 -0
- package/src/cli/simple-commands/init/hive-mind-init.js +749 -0
- package/src/cli/simple-commands/init/index.js +1953 -0
- package/src/cli/simple-commands/init/performance-monitor.js +344 -0
- package/src/cli/simple-commands/init/rollback/backup-manager.js +542 -0
- package/src/cli/simple-commands/init/rollback/index.js +399 -0
- package/src/cli/simple-commands/init/rollback/recovery-manager.js +778 -0
- package/src/cli/simple-commands/init/rollback/rollback-executor.js +521 -0
- package/src/cli/simple-commands/init/rollback/state-tracker.js +486 -0
- package/src/cli/simple-commands/init/sparc/roo-readme.js +61 -0
- package/src/cli/simple-commands/init/sparc/roomodes-config.js +102 -0
- package/src/cli/simple-commands/init/sparc/workflows.js +40 -0
- package/src/cli/simple-commands/init/sparc-structure.js +68 -0
- package/src/cli/simple-commands/init/template-copier.js +640 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md +1185 -0
- package/src/cli/simple-commands/init/templates/CLAUDE.md.optimized +265 -0
- package/src/cli/simple-commands/init/templates/claude-flow-universal +81 -0
- package/src/cli/simple-commands/init/templates/claude-flow.bat +18 -0
- package/src/cli/simple-commands/init/templates/claude-flow.ps1 +24 -0
- package/src/cli/simple-commands/init/templates/claude-md.js +1101 -0
- package/src/cli/simple-commands/init/templates/commands/analysis/bottleneck-detect.md +162 -0
- package/src/cli/simple-commands/init/templates/commands/automation/auto-agent.md +122 -0
- package/src/cli/simple-commands/init/templates/commands/coordination/swarm-init.md +85 -0
- package/src/cli/simple-commands/init/templates/commands/github/github-swarm.md +121 -0
- package/src/cli/simple-commands/init/templates/commands/helpers/standard-checkpoint-hooks.sh +179 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/notification.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-command.md +116 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-edit.md +117 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/post-task.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-command.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-edit.md +113 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-search.md +112 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/pre-task.md +111 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-end.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-restore.md +118 -0
- package/src/cli/simple-commands/init/templates/commands/hooks/session-start.md +117 -0
- package/src/cli/simple-commands/init/templates/coordination-md.js +340 -0
- package/src/cli/simple-commands/init/templates/coordination.md +16 -0
- package/src/cli/simple-commands/init/templates/enhanced-templates.js +2347 -0
- package/src/cli/simple-commands/init/templates/github-safe-enhanced.js +331 -0
- package/src/cli/simple-commands/init/templates/github-safe.js +106 -0
- package/src/cli/simple-commands/init/templates/memory-bank-md.js +259 -0
- package/src/cli/simple-commands/init/templates/memory-bank.md +16 -0
- package/src/cli/simple-commands/init/templates/readme-files.js +72 -0
- package/src/cli/simple-commands/init/templates/safe-hook-patterns.js +430 -0
- package/src/cli/simple-commands/init/templates/settings.json +109 -0
- package/src/cli/simple-commands/init/templates/settings.json.enhanced +35 -0
- package/src/cli/simple-commands/init/templates/sparc-modes.js +1401 -0
- package/src/cli/simple-commands/init/templates/verification-claude-md.js +432 -0
- package/src/cli/simple-commands/init/validation/config-validator.js +354 -0
- package/src/cli/simple-commands/init/validation/health-checker.js +599 -0
- package/src/cli/simple-commands/init/validation/index.js +388 -0
- package/src/cli/simple-commands/init/validation/mode-validator.js +387 -0
- package/src/cli/simple-commands/init/validation/post-init-validator.js +390 -0
- package/src/cli/simple-commands/init/validation/pre-init-validator.js +290 -0
- package/src/cli/simple-commands/init/validation/test-runner.js +488 -0
- package/src/cli/simple-commands/init.js +4 -0
- package/src/cli/simple-commands/mcp-health.js +163 -0
- package/src/cli/simple-commands/mcp-integration-layer.js +689 -0
- package/src/cli/simple-commands/mcp.js +420 -0
- package/src/cli/simple-commands/memory-consolidation.js +631 -0
- package/src/cli/simple-commands/memory.js +345 -0
- package/src/cli/simple-commands/migrate-hooks.js +63 -0
- package/src/cli/simple-commands/monitor.js +417 -0
- package/src/cli/simple-commands/neural.js +148 -0
- package/src/cli/simple-commands/pair-autofix-only.js +755 -0
- package/src/cli/simple-commands/pair-basic.js +751 -0
- package/src/cli/simple-commands/pair-old.js +623 -0
- package/src/cli/simple-commands/pair-working.js +849 -0
- package/src/cli/simple-commands/pair.js +849 -0
- package/src/cli/simple-commands/performance-hooks.js +149 -0
- package/src/cli/simple-commands/performance-metrics.js +601 -0
- package/src/cli/simple-commands/process-ui-enhanced.js +821 -0
- package/src/cli/simple-commands/process-ui.js +274 -0
- package/src/cli/simple-commands/realtime-update-system.js +659 -0
- package/src/cli/simple-commands/sparc/architecture.js +1750 -0
- package/src/cli/simple-commands/sparc/commands.js +575 -0
- package/src/cli/simple-commands/sparc/completion.js +1831 -0
- package/src/cli/simple-commands/sparc/coordinator.js +1045 -0
- package/src/cli/simple-commands/sparc/index.js +321 -0
- package/src/cli/simple-commands/sparc/phase-base.js +430 -0
- package/src/cli/simple-commands/sparc/pseudocode.js +984 -0
- package/src/cli/simple-commands/sparc/refinement.js +1856 -0
- package/src/cli/simple-commands/sparc/specification.js +736 -0
- package/src/cli/simple-commands/sparc-modes/architect.js +125 -0
- package/src/cli/simple-commands/sparc-modes/ask.js +126 -0
- package/src/cli/simple-commands/sparc-modes/code.js +148 -0
- package/src/cli/simple-commands/sparc-modes/debug.js +112 -0
- package/src/cli/simple-commands/sparc-modes/devops.js +137 -0
- package/src/cli/simple-commands/sparc-modes/docs-writer.js +38 -0
- package/src/cli/simple-commands/sparc-modes/generic.js +34 -0
- package/src/cli/simple-commands/sparc-modes/index.js +201 -0
- package/src/cli/simple-commands/sparc-modes/integration.js +55 -0
- package/src/cli/simple-commands/sparc-modes/mcp.js +38 -0
- package/src/cli/simple-commands/sparc-modes/monitoring.js +38 -0
- package/src/cli/simple-commands/sparc-modes/optimization.js +38 -0
- package/src/cli/simple-commands/sparc-modes/security-review.js +130 -0
- package/src/cli/simple-commands/sparc-modes/sparc-orchestrator.js +167 -0
- package/src/cli/simple-commands/sparc-modes/spec-pseudocode.js +38 -0
- package/src/cli/simple-commands/sparc-modes/supabase-admin.js +149 -0
- package/src/cli/simple-commands/sparc-modes/swarm.js +436 -0
- package/src/cli/simple-commands/sparc-modes/tdd.js +112 -0
- package/src/cli/simple-commands/sparc-modes/tutorial.js +277 -0
- package/src/cli/simple-commands/sparc.js +530 -0
- package/src/cli/simple-commands/start-ui.js +147 -0
- package/src/cli/simple-commands/start-wrapper.js +285 -0
- package/src/cli/simple-commands/start.js +2 -0
- package/src/cli/simple-commands/status.js +303 -0
- package/src/cli/simple-commands/stream-chain-clean.js +221 -0
- package/src/cli/simple-commands/stream-chain-fixed.js +89 -0
- package/src/cli/simple-commands/stream-chain-real.js +408 -0
- package/src/cli/simple-commands/stream-chain-working.js +323 -0
- package/src/cli/simple-commands/stream-chain.js +491 -0
- package/src/cli/simple-commands/stream-processor.js +340 -0
- package/src/cli/simple-commands/swarm-executor.js +253 -0
- package/src/cli/simple-commands/swarm-metrics-integration.js +371 -0
- package/src/cli/simple-commands/swarm-ui.js +741 -0
- package/src/cli/simple-commands/swarm-webui-integration.js +311 -0
- package/src/cli/simple-commands/swarm.js +2277 -0
- package/src/cli/simple-commands/task.js +228 -0
- package/src/cli/simple-commands/templates/mle-star-workflow.json +294 -0
- package/src/cli/simple-commands/timestamp-fix.js +104 -0
- package/src/cli/simple-commands/token-tracker.js +372 -0
- package/src/cli/simple-commands/tool-execution-framework.js +555 -0
- package/src/cli/simple-commands/train-and-stream.js +354 -0
- package/src/cli/simple-commands/training-pipeline.js +874 -0
- package/src/cli/simple-commands/training.js +288 -0
- package/src/cli/simple-commands/verification-hooks.js +336 -0
- package/src/cli/simple-commands/verification-integration.js +464 -0
- package/src/cli/simple-commands/verification-training-integration.js +646 -0
- package/src/cli/simple-commands/verification.js +551 -0
- package/src/cli/simple-commands/web-server.js +929 -0
- package/src/cli/simple-commands/webui-validator.js +136 -0
- package/src/language/README.md +503 -0
- package/src/language/claude-md-generator.js +618 -0
- package/src/language/cli.js +422 -0
- package/src/language/example.js +347 -0
- package/src/language/integration-system.js +619 -0
- package/src/language/language-detector.js +581 -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
|
+
}
|