Fixed Attempt to Fix Docker / Podman

Co-authored-by: IvanX006 <ivan@bitechsystems.co.za>
Co-authored-by: Warkanum <HEIN.PUTH@GMAIL.COM>
Co-authored-by: Hein <hein@bitechsystems.co.za>
This commit is contained in:
Hein 2025-12-19 16:42:01 +02:00
parent 84d673ce14
commit 45c463c117
5 changed files with 31 additions and 31 deletions

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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`