Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ 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!"

# 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)
Expand Down
4 changes: 2 additions & 2 deletions pkg/tracing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ func processRequest(ctx context.Context) {

1. **Check collector is running:**
```bash
docker-compose ps
podman compose ps
```

2. **Verify endpoint:**
Expand All @@ -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
Expand Down
24 changes: 12 additions & 12 deletions scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -79,6 +79,6 @@ fi

# Cleanup
echo -e "\n${YELLOW}Stopping PostgreSQL...${NC}"
docker-compose down
podman compose down

exit $EXIT_CODE
16 changes: 8 additions & 8 deletions tests/INTEGRATION_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -52,7 +52,7 @@ go test -tags=integration ./pkg/restheadspec -v
### 3. Stop PostgreSQL

```bash
docker-compose down
podman compose down
```

## Manual PostgreSQL Setup
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions tests/README_TESTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**:
Expand All @@ -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
Expand Down Expand Up @@ -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`

Expand Down
Loading