ComfyUI-Manager/tests/run_full_test_suite.sh
Dr.Lt.Data 43647249cf refactor: remove package-level caching to support dynamic installation
Remove package-level caching in cnr_utils and node_package modules to enable
proper dynamic custom node installation and version switching without ComfyUI
server restarts.

Key Changes:
- Remove @lru_cache decorators from version-sensitive functions
- Remove cached_property from NodePackage for dynamic state updates
- Add comprehensive test suite with parallel execution support
- Implement version switching tests (CNR ↔ Nightly)
- Add case sensitivity integration tests
- Improve error handling and logging

API Priority Rules (manager_core.py:1801):
- Enabled-Priority: Show only enabled version when both exist
- CNR-Priority: Show only CNR when both CNR and Nightly are disabled
- Prevents duplicate package entries in /v2/customnode/installed API
- Cross-match using cnr_id and aux_id for CNR ↔ Nightly detection

Test Infrastructure:
- 8 test files with 59 comprehensive test cases
- Parallel test execution across 5 isolated environments
- Automated test scripts with environment setup
- Configurable timeout (60 minutes default)
- Support for both master and dr-support-pip-cm branches

Bug Fixes:
- Fix COMFYUI_CUSTOM_NODES_PATH environment variable export
- Resolve test fixture regression with module-level variables
- Fix import timing issues in test configuration
- Register pytest integration marker to eliminate warnings
- Fix POSIX compliance in shell scripts (((var++)) → $((var + 1)))

Documentation:
- CNR_VERSION_MANAGEMENT_DESIGN.md v1.0 → v1.1 with API priority rules
- Add test guides and execution documentation (TESTING_PROMPT.md)
- Add security-enhanced installation guide
- Create CLI migration guides and references
- Document package version management

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 09:07:09 +09:00

223 lines
7.6 KiB
Bash
Executable File

#!/bin/bash
# Standalone Test Execution Script for ComfyUI Manager
# Can be run outside Claude Code in any session
# Usage: ./tests/run_full_test_suite.sh [OPTIONS]
set -e # Exit on error
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m'
echo -e "${BLUE}========================================${NC}"
echo -e "${BLUE}ComfyUI Manager Test Suite${NC}"
echo -e "${BLUE}Standalone Execution Script${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
# Default configuration
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
VENV_PATH="${VENV_PATH:-$HOME/venv}"
COMFYUI_BRANCH="${COMFYUI_BRANCH:-ltdrdata/dr-support-pip-cm}"
NUM_ENVS="${NUM_ENVS:-10}"
TEST_MODE="${TEST_MODE:-parallel}" # single or parallel
TEST_TIMEOUT="${TEST_TIMEOUT:-7200}"
# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--single)
TEST_MODE="single"
shift
;;
--parallel)
TEST_MODE="parallel"
shift
;;
--envs)
NUM_ENVS="$2"
shift 2
;;
--branch)
COMFYUI_BRANCH="$2"
shift 2
;;
--venv)
VENV_PATH="$2"
shift 2
;;
--timeout)
TEST_TIMEOUT="$2"
shift 2
;;
--help)
echo "Usage: $0 [OPTIONS]"
echo ""
echo "Options:"
echo " --single Run tests in single environment (default: parallel)"
echo " --parallel Run tests in parallel across multiple environments"
echo " --envs N Number of parallel environments (default: 10)"
echo " --branch BRANCH ComfyUI branch to use (default: ltdrdata/dr-support-pip-cm)"
echo " --venv PATH Virtual environment path (default: ~/venv)"
echo " --timeout SECONDS Test timeout in seconds (default: 7200)"
echo " --help Show this help message"
echo ""
echo "Environment Variables:"
echo " PROJECT_ROOT Project root directory (auto-detected)"
echo " VENV_PATH Virtual environment path"
echo " COMFYUI_BRANCH ComfyUI branch name"
echo " NUM_ENVS Number of parallel environments"
echo " TEST_MODE Test mode (single or parallel)"
echo " TEST_TIMEOUT Test timeout in seconds"
echo ""
echo "Examples:"
echo " $0 # Run parallel tests with defaults"
echo " $0 --single # Run in single environment"
echo " $0 --parallel --envs 5 # Run with 5 parallel environments"
echo " $0 --branch master # Use master branch (requires --enable-manager support)"
exit 0
;;
*)
echo -e "${RED}Unknown option: $1${NC}"
echo "Use --help for usage information"
exit 1
;;
esac
done
echo -e "${CYAN}Configuration:${NC}"
echo -e " Project Root: ${PROJECT_ROOT}"
echo -e " Virtual Environment: ${VENV_PATH}"
echo -e " ComfyUI Branch: ${COMFYUI_BRANCH}"
echo -e " Test Mode: ${TEST_MODE}"
if [ "$TEST_MODE" = "parallel" ]; then
echo -e " Number of Environments: ${NUM_ENVS}"
fi
echo -e " Test Timeout: ${TEST_TIMEOUT}s"
echo ""
# Change to project root
cd "$PROJECT_ROOT"
# Step 1: Validate virtual environment
echo -e "${YELLOW}Step 1: Validating virtual environment...${NC}"
if [ ! -f "${VENV_PATH}/bin/activate" ]; then
echo -e "${RED}✗ FATAL: Virtual environment not found at: ${VENV_PATH}${NC}"
echo -e "${YELLOW} Create it with: python3 -m venv ${VENV_PATH}${NC}"
exit 1
fi
source "${VENV_PATH}/bin/activate"
if [ -z "$VIRTUAL_ENV" ]; then
echo -e "${RED}✗ FATAL: Virtual environment activation failed${NC}"
exit 1
fi
echo -e "${GREEN}✓ Virtual environment activated: ${VIRTUAL_ENV}${NC}"
echo ""
# Step 2: Check prerequisites
echo -e "${YELLOW}Step 2: Checking prerequisites...${NC}"
# Check uv
if ! command -v uv &> /dev/null; then
echo -e "${YELLOW}⚠ uv not found, installing...${NC}"
pip install uv
fi
echo -e "${GREEN}✓ uv is available${NC}"
# Check pytest
if ! command -v pytest &> /dev/null; then
echo -e "${YELLOW}⚠ pytest not found, installing...${NC}"
uv pip install pytest
fi
echo -e "${GREEN}✓ pytest is available${NC}"
echo ""
# Step 3: Set up test environments
echo -e "${YELLOW}Step 3: Setting up test environment(s)...${NC}"
export COMFYUI_BRANCH="$COMFYUI_BRANCH"
if [ "$TEST_MODE" = "parallel" ]; then
export NUM_ENVS="$NUM_ENVS"
if [ ! -f "tests/setup_parallel_test_envs.sh" ]; then
echo -e "${RED}✗ FATAL: setup_parallel_test_envs.sh not found${NC}"
exit 1
fi
./tests/setup_parallel_test_envs.sh
else
if [ ! -f "tests/setup_test_env.sh" ]; then
echo -e "${RED}✗ FATAL: setup_test_env.sh not found${NC}"
exit 1
fi
./tests/setup_test_env.sh
fi
echo ""
# Step 4: Run tests
echo -e "${YELLOW}Step 4: Running tests...${NC}"
export TEST_TIMEOUT="$TEST_TIMEOUT"
if [ "$TEST_MODE" = "parallel" ]; then
if [ ! -f "tests/run_parallel_tests.sh" ]; then
echo -e "${RED}✗ FATAL: run_parallel_tests.sh not found${NC}"
exit 1
fi
echo -e "${CYAN}Running distributed parallel tests across ${NUM_ENVS} environments...${NC}"
./tests/run_parallel_tests.sh
else
if [ ! -f "tests/run_tests.sh" ]; then
echo -e "${RED}✗ FATAL: run_tests.sh not found${NC}"
exit 1
fi
echo -e "${CYAN}Running tests in single environment...${NC}"
./tests/run_tests.sh
fi
# Step 5: Show results location
echo ""
echo -e "${BLUE}========================================${NC}"
echo -e "${GREEN}✅ Test Execution Complete!${NC}"
echo -e "${BLUE}========================================${NC}"
echo ""
echo -e "${CYAN}Test Results Location:${NC}"
if [ "$TEST_MODE" = "parallel" ]; then
echo -e " Individual environment logs: ${YELLOW}/tmp/test-results-*.log${NC}"
echo -e " Server logs: ${YELLOW}/tmp/comfyui-parallel-*.log${NC}"
echo -e " Main execution log: ${YELLOW}/tmp/parallel_test_final.log${NC}"
echo ""
echo -e "${CYAN}Quick Result Summary:${NC}"
if ls /tmp/test-results-*.log 1> /dev/null 2>&1; then
total_passed=0
total_failed=0
for log in /tmp/test-results-*.log; do
if grep -q "passed" "$log"; then
passed=$(grep "passed" "$log" | tail -1 | grep -oP '\d+(?= passed)' || echo "0")
total_passed=$((total_passed + passed))
fi
if grep -q "failed" "$log"; then
failed=$(grep "failed" "$log" | tail -1 | grep -oP '\d+(?= failed)' || echo "0")
total_failed=$((total_failed + failed))
fi
done
echo -e " ${GREEN}Passed: ${total_passed}${NC}"
echo -e " ${RED}Failed: ${total_failed}${NC}"
fi
else
echo -e " Test results: ${YELLOW}/tmp/comfyui-test-results.log${NC}"
echo -e " Server log: ${YELLOW}/tmp/comfyui-server.log${NC}"
fi
echo ""
echo -e "${CYAN}View detailed results:${NC}"
if [ "$TEST_MODE" = "parallel" ]; then
echo -e " ${YELLOW}tail -100 /tmp/test-results-1.log${NC} # View environment 1 results"
echo -e " ${YELLOW}grep -E 'passed|failed|ERROR' /tmp/test-results-*.log${NC} # View all results"
else
echo -e " ${YELLOW}tail -100 /tmp/comfyui-test-results.log${NC}"
fi
echo ""