#!/bin/bash # Isolation Validation Script # Validates that feature isolation is working correctly set -e echo "๐Ÿ” Validating BDD test isolation..." # Check feature directories exist echo "๐Ÿ“ Checking feature directory structure..." for feature in auth config greet health jwt; do if [ ! -d "features/${feature}" ]; then echo "โŒ Missing features/${feature} directory" exit 1 fi # Check for feature files if [ -z "$(find features/${feature} -name "*.feature" -type f)" ]; then echo "โŒ No feature files found in features/${feature}" exit 1 fi # Check for config files if [ ! -f "features/${feature}/${feature}-test-config.yaml" ]; then echo "โŒ Missing config file for ${feature} feature" exit 1 fi echo "โœ… ${feature} feature structure validated" done # Check for unique ports echo "๐Ÿ”Œ Checking for unique port assignments..." port_auth=$(grep "port:" "features/auth/auth-test-config.yaml" | awk '{print $2}') port_config=$(grep "port:" "features/config/config-test-config.yaml" | awk '{print $2}') port_greet=$(grep "port:" "features/greet/greet-test-config.yaml" | awk '{print $2}') port_health=$(grep "port:" "features/health/health-test-config.yaml" | awk '{print $2}') port_jwt=$(grep "port:" "features/jwt/jwt-test-config.yaml" | awk '{print $2}') # Check for port conflicts if [ "$port_auth" = "$port_config" ] || [ "$port_auth" = "$port_greet" ] || [ "$port_auth" = "$port_health" ] || [ "$port_auth" = "$port_jwt" ]; then echo "โŒ Port conflict detected with auth port $port_auth" exit 1 fi if [ "$port_config" = "$port_greet" ] || [ "$port_config" = "$port_health" ] || [ "$port_config" = "$port_jwt" ]; then echo "โŒ Port conflict detected with config port $port_config" exit 1 fi if [ "$port_greet" = "$port_health" ] || [ "$port_greet" = "$port_jwt" ]; then echo "โŒ Port conflict detected with greet port $port_greet" exit 1 fi if [ "$port_health" = "$port_jwt" ]; then echo "โŒ Port conflict detected with health port $port_health" exit 1 fi echo "โœ… All features have unique ports" # Check for unique database names echo "๐Ÿ—ƒ๏ธ Checking for unique database names..." db_auth="dance_lessons_coach_auth_test" db_config="dance_lessons_coach_config_test" db_greet="dance_lessons_coach_greet_test" db_health="dance_lessons_coach_health_test" db_jwt="dance_lessons_coach_jwt_test" # Check for database name conflicts if [ "$db_auth" = "$db_config" ] || [ "$db_auth" = "$db_greet" ] || [ "$db_auth" = "$db_health" ] || [ "$db_auth" = "$db_jwt" ]; then echo "โŒ Database conflict detected with auth database" exit 1 fi if [ "$db_config" = "$db_greet" ] || [ "$db_config" = "$db_health" ] || [ "$db_config" = "$db_jwt" ]; then echo "โŒ Database conflict detected with config database" exit 1 fi if [ "$db_greet" = "$db_health" ] || [ "$db_greet" = "$db_jwt" ]; then echo "โŒ Database conflict detected with greet database" exit 1 fi if [ "$db_health" = "$db_jwt" ]; then echo "โŒ Database conflict detected with health database" exit 1 fi echo "โœ… All features have unique database names" # Test that each feature can be run independently echo "๐Ÿงช Testing feature independence..." for feature in auth config greet health jwt; do echo "Testing ${feature} feature..." # Try to run the feature test script with setup only if ! bash scripts/test-feature.sh $feature 2>&1 | grep -q "Setting up ${feature} feature tests"; then echo "โŒ Failed to setup ${feature} feature tests" exit 1 fi echo "โœ… ${feature} feature can be set up independently" done echo "โœ… All isolation validations passed!" echo "๐ŸŽ‰ BDD test isolation is working correctly"