From 45c463c1173e5c1d7f65ae1318ac6aac322d30bd Mon Sep 17 00:00:00 2001 From: Hein Date: Fri, 19 Dec 2025 16:42:01 +0200 Subject: [PATCH] Fixed Attempt to Fix Docker / Podman Co-authored-by: IvanX006 Co-authored-by: Warkanum Co-authored-by: Hein --- Makefile | 6 +++--- pkg/tracing/README.md | 4 ++-- scripts/run-integration-tests.sh | 24 ++++++++++++------------ tests/INTEGRATION_TESTS.md | 16 ++++++++-------- tests/README_TESTS.md | 12 ++++++------ 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Makefile b/Makefile index bba4a99..de7dd55 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ test: test-unit test-integration # Start PostgreSQL for integration tests docker-up: @echo "Starting PostgreSQL container..." - @docker-compose up -d postgres-test + @podman compose up -d postgres-test @echo "Waiting for PostgreSQL to be ready..." @sleep 5 @echo "PostgreSQL is ready!" @@ -24,12 +24,12 @@ docker-up: # Stop PostgreSQL container docker-down: @echo "Stopping PostgreSQL container..." - @docker-compose down + @podman compose down # Clean up Docker volumes and test data clean: @echo "Cleaning up..." - @docker-compose down -v + @podman compose down -v @echo "Cleanup complete!" # Run integration tests with Docker (full workflow) diff --git a/pkg/tracing/README.md b/pkg/tracing/README.md index 2dea2e7..080f0c3 100644 --- a/pkg/tracing/README.md +++ b/pkg/tracing/README.md @@ -465,7 +465,7 @@ func processRequest(ctx context.Context) { 1. **Check collector is running:** ```bash - docker-compose ps + podman compose ps ``` 2. **Verify endpoint:** @@ -476,7 +476,7 @@ func processRequest(ctx context.Context) { 3. **Check logs:** ```bash - docker-compose logs otel-collector + podman compose logs otel-collector ``` ### Disable Tracing diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index f35a337..67e20f2 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -14,33 +14,33 @@ NC='\033[0m' # No Color echo -e "${GREEN}=== ResolveSpec Integration Tests ===${NC}\n" -# Check if docker-compose is available -if ! command -v docker-compose &> /dev/null; then - echo -e "${RED}Error: docker-compose is not installed${NC}" - echo "Please install docker-compose or run PostgreSQL manually" +# Check if podman compose is available +if ! command -v podman &> /dev/null; then + echo -e "${RED}Error: podman is not installed${NC}" + echo "Please install podman or run PostgreSQL manually" echo "See INTEGRATION_TESTS.md for details" exit 1 fi # Clean up any existing containers and networks from previous runs echo -e "${YELLOW}Cleaning up existing containers and networks...${NC}" -docker-compose down -v 2>/dev/null || true +podman compose down -v 2>/dev/null || true # Start PostgreSQL echo -e "${YELLOW}Starting PostgreSQL...${NC}" -docker-compose up -d postgres-test +podman compose up -d postgres-test # Wait for PostgreSQL to be ready echo -e "${YELLOW}Waiting for PostgreSQL to be ready...${NC}" max_attempts=30 attempt=0 -while ! docker-compose exec -T postgres-test pg_isready -U postgres > /dev/null 2>&1; do +while ! podman compose exec -T postgres-test pg_isready -U postgres > /dev/null 2>&1; do attempt=$((attempt + 1)) if [ $attempt -ge $max_attempts ]; then echo -e "${RED}Error: PostgreSQL failed to start after ${max_attempts} seconds${NC}" - docker-compose logs postgres-test - docker-compose down + podman compose logs postgres-test + podman compose down exit 1 fi sleep 1 @@ -51,8 +51,8 @@ echo -e "\n${GREEN}PostgreSQL is ready!${NC}\n" # Create test databases echo -e "${YELLOW}Creating test databases...${NC}" -docker-compose exec -T postgres-test psql -U postgres -c "CREATE DATABASE resolvespec_test;" 2>/dev/null || echo " resolvespec_test already exists" -docker-compose exec -T postgres-test psql -U postgres -c "CREATE DATABASE restheadspec_test;" 2>/dev/null || echo " restheadspec_test already exists" +podman compose exec -T postgres-test psql -U postgres -c "CREATE DATABASE resolvespec_test;" 2>/dev/null || echo " resolvespec_test already exists" +podman compose exec -T postgres-test psql -U postgres -c "CREATE DATABASE restheadspec_test;" 2>/dev/null || echo " restheadspec_test already exists" echo -e "${GREEN}Test databases ready!${NC}\n" # Determine which tests to run @@ -79,6 +79,6 @@ fi # Cleanup echo -e "\n${YELLOW}Stopping PostgreSQL...${NC}" -docker-compose down +podman compose down exit $EXIT_CODE diff --git a/tests/INTEGRATION_TESTS.md b/tests/INTEGRATION_TESTS.md index 664ff24..0198d54 100644 --- a/tests/INTEGRATION_TESTS.md +++ b/tests/INTEGRATION_TESTS.md @@ -19,14 +19,14 @@ Integration tests validate the full functionality of both `pkg/resolvespec` and - Go 1.19 or later - PostgreSQL 12 or later -- Docker and Docker Compose (optional, for easy setup) +- Podman and Podman Compose (optional, for easy setup) -## Quick Start with Docker +## Quick Start with Podman -### 1. Start PostgreSQL with Docker Compose +### 1. Start PostgreSQL with Podman Compose ```bash -docker-compose up -d postgres-test +podman compose up -d postgres-test ``` This starts a PostgreSQL container with the following default settings: @@ -52,7 +52,7 @@ go test -tags=integration ./pkg/restheadspec -v ### 3. Stop PostgreSQL ```bash -docker-compose down +podman compose down ``` ## Manual PostgreSQL Setup @@ -161,7 +161,7 @@ If you see "connection refused" errors: 1. Check that PostgreSQL is running: ```bash - docker-compose ps + podman compose ps ``` 2. Verify connection parameters: @@ -194,10 +194,10 @@ Each test automatically cleans up its data using `TRUNCATE`. If you need a fresh ```bash # Stop and remove containers (removes data) -docker-compose down -v +podman compose down -v # Restart -docker-compose up -d postgres-test +podman compose up -d postgres-test ``` ## CI/CD Integration diff --git a/tests/README_TESTS.md b/tests/README_TESTS.md index ae88fa2..c8813b3 100644 --- a/tests/README_TESTS.md +++ b/tests/README_TESTS.md @@ -119,13 +119,13 @@ Integration tests require a PostgreSQL database and use the `// +build integrati - PostgreSQL 12+ installed and running - Create test databases manually (see below) -### Setup with Docker +### Setup with Podman 1. **Start PostgreSQL**: ```bash make docker-up # or - docker-compose up -d postgres-test + podman compose up -d postgres-test ``` 2. **Run Tests**: @@ -141,10 +141,10 @@ Integration tests require a PostgreSQL database and use the `// +build integrati ```bash make docker-down # or - docker-compose down + podman compose down ``` -### Setup without Docker +### Setup without Podman 1. **Create Databases**: ```sql @@ -289,8 +289,8 @@ go test -tags=integration ./pkg/resolvespec -v **Problem**: "connection refused" or "database does not exist" **Solutions**: -1. Check PostgreSQL is running: `docker-compose ps` -2. Verify databases exist: `docker-compose exec postgres-test psql -U postgres -l` +1. Check PostgreSQL is running: `podman compose ps` +2. Verify databases exist: `podman compose exec postgres-test psql -U postgres -l` 3. Check environment variable: `echo $TEST_DATABASE_URL` 4. Recreate databases: `make clean && make docker-up`