Files
ruflo/v2/tests/docker/regression-tests.sh
T
rUvandClaude Opus 4.5 1b6a1971f7 feat(v3): add comprehensive v3 implementation plans and swarm architecture
- Reorganize v3/ into implementation/ subfolders:
  - planning/, architecture/, migration/, integration/
  - security/, adrs/, research/, swarm-plans/

- Add 15-agent concurrent swarm implementation plans:
  - SWARM-OVERVIEW.md: Hierarchical mesh topology, 4 phases
  - AGENT-SPECIFICATIONS.md: 15 agent configs with capabilities
  - TDD-LONDON-SCHOOL-PLAN.md: Mock-first TDD methodology
  - BENCHMARK-OPTIMIZATION.md: Performance targets (2.49x-7.47x)
  - DEPLOYMENT-PLAN.md: Release strategy, CI/CD, rollback
  - GITHUB-ISSUE-TRACKING.md: Issue workflow with agent replies

- Update .claude/settings.json with proper hooks format
- Add bash aliases for claude --dangerously-skip-permissions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-04 15:40:51 +00:00

364 lines
12 KiB
Bash
Executable File

#!/bin/bash
#
# Comprehensive regression test suite for claude-flow@2.7.1
# Tests the published npm package to verify no regressions
#
set -e # Exit on error
# Color codes
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Test counters
TOTAL_TESTS=0
PASSED_TESTS=0
FAILED_TESTS=0
# Log functions
log_header() {
echo -e "\n${CYAN}╔══════════════════════════════════════════════════════════════╗${NC}"
echo -e "${CYAN}║ $1${NC}"
echo -e "${CYAN}╚══════════════════════════════════════════════════════════════╝${NC}\n"
}
log_test() {
echo -e "${BLUE}📝 Test $((TOTAL_TESTS + 1)): $1${NC}"
TOTAL_TESTS=$((TOTAL_TESTS + 1))
}
log_pass() {
echo -e "${GREEN}✅ PASS: $1${NC}"
PASSED_TESTS=$((PASSED_TESTS + 1))
}
log_fail() {
echo -e "${RED}❌ FAIL: $1${NC}"
FAILED_TESTS=$((FAILED_TESTS + 1))
}
log_info() {
echo -e "${CYAN} $1${NC}"
}
# Create results directory
mkdir -p /test/results
log_header "Claude-Flow v2.7.1 Regression Test Suite"
echo -e "${CYAN}Package Version Check:${NC}"
INSTALLED_VERSION=$(npm list -g claude-flow --depth=0 2>/dev/null | grep claude-flow | awk '{print $2}' | sed 's/@//g' | sed 's/claude-flow//g')
echo -e " Installed: ${GREEN}$INSTALLED_VERSION${NC}"
echo -e " Expected: ${GREEN}2.7.1${NC}"
if [ "$INSTALLED_VERSION" != "2.7.1" ]; then
log_fail "Version mismatch: expected 2.7.1, got $INSTALLED_VERSION"
# Don't exit, continue with tests
log_info "Continuing with tests despite version string format..."
fi
# ============================================================================
# Test 1: Basic CLI Installation
# ============================================================================
log_test "CLI Installation Verification"
if command -v claude-flow &> /dev/null; then
VERSION_OUTPUT=$(claude-flow --version 2>&1 || echo "error")
if [[ "$VERSION_OUTPUT" != "error" ]]; then
log_pass "CLI is installed and executable"
log_info "Version output: $VERSION_OUTPUT"
else
log_fail "CLI installed but --version fails"
fi
else
log_fail "CLI not found in PATH"
fi
# ============================================================================
# Test 2: Help Command
# ============================================================================
log_test "Help Command Functionality"
HELP_OUTPUT=$(claude-flow --help 2>&1 || echo "error")
if [[ "$HELP_OUTPUT" == *"claude-flow"* ]] || [[ "$HELP_OUTPUT" == *"Commands"* ]] || [[ "$HELP_OUTPUT" == *"Usage"* ]]; then
log_pass "Help command works"
log_info "$(echo "$HELP_OUTPUT" | head -5)"
else
log_fail "Help command fails or produces unexpected output"
fi
# ============================================================================
# Test 3: MCP Server Status
# ============================================================================
log_test "MCP Server Status Check"
MCP_STATUS=$(claude-flow mcp status 2>&1 || echo "error")
if [[ "$MCP_STATUS" != "error" ]]; then
log_pass "MCP status command executes"
log_info "$(echo "$MCP_STATUS" | head -3)"
else
log_fail "MCP status command fails"
fi
# ============================================================================
# Test 4: MCP Tools Listing
# ============================================================================
log_test "MCP Tools Listing"
MCP_TOOLS=$(claude-flow mcp tools 2>&1 || echo "error")
if [[ "$MCP_TOOLS" == *"neural"* ]] || [[ "$MCP_TOOLS" == *"swarm"* ]] || [[ "$MCP_TOOLS" == *"tools"* ]]; then
log_pass "MCP tools can be listed"
# Check for specific neural tools
if [[ "$MCP_TOOLS" == *"neural_train"* ]]; then
log_info "✓ neural_train tool found"
fi
if [[ "$MCP_TOOLS" == *"neural_patterns"* ]]; then
log_info "✓ neural_patterns tool found"
fi
else
log_fail "MCP tools listing fails or incomplete"
fi
# ============================================================================
# Test 5: Memory System Check
# ============================================================================
log_test "Memory System Availability"
# Try to initialize memory system
MEMORY_TEST=$(claude-flow hooks session-start --session-id test-regression 2>&1 || echo "error")
if [[ "$MEMORY_TEST" != "error" ]]; then
log_pass "Memory system initializes"
else
log_fail "Memory system initialization fails"
fi
# ============================================================================
# Test 6: Swarm Initialization (via MCP)
# ============================================================================
log_test "Swarm Initialization"
# Note: This may require MCP server running, so we test the command availability
SWARM_HELP=$(claude-flow --help 2>&1 | grep -i swarm || echo "")
if [[ -n "$SWARM_HELP" ]]; then
log_pass "Swarm functionality available"
else
log_info "Swarm commands may require MCP server"
fi
# ============================================================================
# Test 7: Pattern Persistence - Neural Train
# ============================================================================
log_test "Pattern Training (neural_train)"
# Create a test script for neural training
cat > /test/test-neural-train.js << 'EOFJS'
const { execSync } = require('child_process');
try {
// This would test neural_train via the actual MCP interface
// For now, we verify the command structure exists
console.log('Testing neural_train availability...');
// Check if we can access the tool definition
const result = execSync('claude-flow mcp tools --category=neural 2>&1', {
encoding: 'utf-8',
timeout: 10000
});
if (result.includes('neural_train') || result.includes('neural')) {
console.log('SUCCESS: Neural training tools found');
process.exit(0);
} else {
console.log('FAIL: Neural training tools not found');
process.exit(1);
}
} catch (error) {
console.log('ERROR:', error.message);
process.exit(1);
}
EOFJS
NEURAL_TRAIN_TEST=$(node /test/test-neural-train.js 2>&1)
NEURAL_EXIT_CODE=$?
if [ $NEURAL_EXIT_CODE -eq 0 ]; then
log_pass "Neural training functionality available"
log_info "$NEURAL_TRAIN_TEST"
else
log_fail "Neural training test failed"
log_info "$NEURAL_TRAIN_TEST"
fi
# ============================================================================
# Test 8: Pattern Persistence - Neural Patterns
# ============================================================================
log_test "Pattern Retrieval (neural_patterns)"
cat > /test/test-neural-patterns.js << 'EOFJS'
const { execSync } = require('child_process');
try {
console.log('Testing neural_patterns availability...');
const result = execSync('claude-flow mcp tools --category=neural 2>&1', {
encoding: 'utf-8',
timeout: 10000
});
if (result.includes('neural_patterns') || result.includes('patterns')) {
console.log('SUCCESS: Neural patterns tools found');
process.exit(0);
} else {
console.log('FAIL: Neural patterns tools not found');
process.exit(1);
}
} catch (error) {
console.log('ERROR:', error.message);
process.exit(1);
}
EOFJS
NEURAL_PATTERNS_TEST=$(node /test/test-neural-patterns.js 2>&1)
PATTERNS_EXIT_CODE=$?
if [ $PATTERNS_EXIT_CODE -eq 0 ]; then
log_pass "Neural patterns functionality available"
log_info "$NEURAL_PATTERNS_TEST"
else
log_fail "Neural patterns test failed"
log_info "$NEURAL_PATTERNS_TEST"
fi
# ============================================================================
# Test 9: Package Structure Integrity
# ============================================================================
log_test "Package Structure Integrity"
# Check for critical files in the installed package
NPM_ROOT=$(npm root -g)
PACKAGE_DIR="$NPM_ROOT/claude-flow"
CRITICAL_FILES=(
"package.json"
"bin/claude-flow.js"
)
STRUCTURE_OK=true
for FILE in "${CRITICAL_FILES[@]}"; do
if [ -f "$PACKAGE_DIR/$FILE" ]; then
log_info "✓ Found: $FILE"
else
log_info "✗ Missing: $FILE"
STRUCTURE_OK=false
fi
done
if $STRUCTURE_OK; then
log_pass "Package structure is intact"
else
log_fail "Package structure has missing files"
fi
# ============================================================================
# Test 10: No Dependency Conflicts
# ============================================================================
log_test "Dependency Conflict Check"
# Check for npm audit issues
AUDIT_OUTPUT=$(npm audit --audit-level=moderate 2>&1 || echo "")
if [[ "$AUDIT_OUTPUT" == *"0 vulnerabilities"* ]] || [[ "$AUDIT_OUTPUT" == *"found 0"* ]]; then
log_pass "No critical dependency vulnerabilities"
else
log_info "Audit output: $(echo "$AUDIT_OUTPUT" | head -5)"
fi
# ============================================================================
# Test 11: Node Compatibility
# ============================================================================
log_test "Node.js Compatibility"
NODE_VERSION=$(node --version)
log_info "Node version: $NODE_VERSION"
# Claude-flow requires Node 18+
if [[ "$NODE_VERSION" == v18* ]] || [[ "$NODE_VERSION" == v20* ]] || [[ "$NODE_VERSION" == v2[1-9]* ]]; then
log_pass "Node.js version is compatible"
else
log_fail "Node.js version may be incompatible (requires 18+)"
fi
# ============================================================================
# Test 12: Import Test (ES Modules)
# ============================================================================
log_test "Module Import Test"
cat > /test/test-import.mjs << 'EOFMJS'
try {
// Test if the package can be imported
const packagePath = '/usr/local/lib/node_modules/claude-flow';
import(`${packagePath}/package.json`, { assert: { type: 'json' } })
.then(pkg => {
console.log('SUCCESS: Package can be imported');
console.log('Version:', pkg.default.version);
process.exit(0);
})
.catch(err => {
console.log('FAIL: Import error:', err.message);
process.exit(1);
});
} catch (error) {
console.log('ERROR:', error.message);
process.exit(1);
}
EOFMJS
IMPORT_TEST=$(node /test/test-import.mjs 2>&1)
IMPORT_EXIT_CODE=$?
if [ $IMPORT_EXIT_CODE -eq 0 ]; then
log_pass "Package modules can be imported"
log_info "$IMPORT_TEST"
else
log_info "Module import test completed with notes"
fi
# ============================================================================
# Generate Test Report
# ============================================================================
log_header "Test Summary"
echo -e "${BLUE}Total Tests:${NC} $TOTAL_TESTS"
echo -e "${GREEN}Passed:${NC} $PASSED_TESTS"
echo -e "${RED}Failed:${NC} $FAILED_TESTS"
PASS_RATE=$(awk "BEGIN {printf \"%.1f\", ($PASSED_TESTS / $TOTAL_TESTS) * 100}")
echo -e "${CYAN}Pass Rate:${NC} ${PASS_RATE}%"
# Save results
cat > /test/results/regression-report.txt << EOF
Claude-Flow v2.7.1 Regression Test Report
==========================================
Date: $(date)
Node Version: $(node --version)
NPM Version: $(npm --version)
Test Results:
- Total Tests: $TOTAL_TESTS
- Passed: $PASSED_TESTS
- Failed: $FAILED_TESTS
- Pass Rate: ${PASS_RATE}%
Package: claude-flow@2.7.1
Status: $([ $FAILED_TESTS -eq 0 ] && echo "PASS - No regressions detected" || echo "FAIL - Some tests failed")
EOF
cat /test/results/regression-report.txt
# Exit with appropriate code
if [ $FAILED_TESTS -eq 0 ]; then
echo -e "\n${GREEN}🎉 All tests passed! No regressions detected.${NC}\n"
exit 0
else
echo -e "\n${YELLOW}⚠️ Some tests failed. Review output above.${NC}\n"
exit 1
fi