prole/tests/test_docker_build_fix.sh
chrisfu 1353882260 Update PROLE_HOME resolution and enhance iSCSI PV handling
- Implement centralized `resolve_prole_home` utility for consistent environment-based `PROLE_HOME` resolution across modules
- Replace hardcoded home paths with `resolve_prole_home`
- Refactor PV management to support iSCSI mounts and node placement from Ansible manifests
- Improve Kubernetes manifest handling to dynamically apply namespaces per document
- Adjust `knoe-db` build context path and related tests
- Add utilities for detecting and applying Ansible-defined node labels and PVs
2026-03-22 02:43:52 -07:00

115 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
echo "========================================"
echo " Docker Build Fix Verification"
echo "========================================"
echo ""
# Test 1: prole-db exists
echo "1. Testing prole-db directory..."
if [ -d "prole-db" ] && [ -f "prole-db/Dockerfile" ]; then
echo " ✓ prole-db directory with Dockerfile exists"
else
echo " ✗ prole-db directory or Dockerfile missing"
exit 1
fi
# Test 2: Spec includes prole-db
echo "2. Testing spec file includes prole-db..."
python3 scripts/generate_spec.py > /dev/null 2>&1
if grep -q "('prole-db', 'prole-db')" knoe.spec; then
echo " ✓ prole-db included in spec"
else
echo " ✗ prole-db not in spec"
exit 1
fi
# Test 3: Resource path resolution
echo "3. Testing resource path resolution..."
python3 << 'PYTEST'
import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd()))
from knoe.core.env import get_resource_path
prole_db = get_resource_path("prole-db")
if prole_db.exists() and (prole_db / "Dockerfile").exists():
print(" ✓ get_resource_path('prole-db') works")
else:
print(" ✗ Resource path resolution failed")
sys.exit(1)
PYTEST
if [ $? -ne 0 ]; then exit 1; fi
# Test 4: Build directory creation
echo "4. Testing .prole/build directory creation..."
python3 << 'PYTEST'
import sys
from pathlib import Path
import shutil
prole_home = Path.home() / ".prole"
build_dir = prole_home / "build" / "prole-db-test"
# Create and verify
build_dir.mkdir(parents=True, exist_ok=True)
if build_dir.exists():
print(f" ✓ Created: {build_dir}")
# Cleanup
shutil.rmtree(prole_home / "build" / "prole-db-test")
else:
print(" ✗ Failed to create build directory")
sys.exit(1)
PYTEST
if [ $? -ne 0 ]; then exit 1; fi
# Test 5: Copy operation
echo "5. Testing build context copy..."
python3 << 'PYTEST'
import sys
from pathlib import Path
sys.path.insert(0, str(Path.cwd()))
from knoe.core.env import get_resource_path
from knoe.core.build_context import copy_build_context_dir
prole_home = Path.home() / ".prole"
build_dir = prole_home / "build" / "prole-db-test"
source_dir = get_resource_path("prole-db")
try:
copy_build_context_dir(source_dir, build_dir)
# Verify
if (build_dir / "Dockerfile").exists():
print(f" ✓ Copied build context successfully")
# Cleanup
# Cleanup
try:
import shutil
shutil.rmtree(prole_home / "build" / "prole-db-test")
except Exception:
pass
else:
print(" ✗ Copy incomplete")
sys.exit(1)
except Exception as e:
print(f" ✗ Copy failed: {e}")
sys.exit(1)
PYTEST
if [ $? -ne 0 ]; then exit 1; fi
echo ""
echo "========================================"
echo " ✓ All Docker Build Fix Tests Passed"
echo "========================================"
echo ""
echo "The Docker build will now work correctly:"
echo " • From source: Uses PROJECT_ROOT/prole-db"
echo " • From package: Copies to ~/.prole/build/knoe-db"
echo ""
echo "Build directory: ~/.prole/build/knoe-db"
echo "Build command: docker build -t knoe-db:TAG ."
echo ""