feat(testing): implement broker workflow integration test
Some checks failed
Integration Tests / integration-test (push) Failing after -25m42s

- Implement complete TestBrokerWorkflow that validates end-to-end broker functionality
- Test covers schema installation, broker startup, job submission, and job processing
- Add connection retry logic and proper NULL handling for database fields
- Fix Makefile docker-up and docker-down targets for consistent test database configuration
- Standardize test database credentials (port 5433, user/password, broker_test)
- Add docker-up and docker-down to .PHONY targets
This commit is contained in:
2026-01-02 23:41:06 +02:00
parent 3e64f7ae2a
commit d1598238b2
2 changed files with 321 additions and 2 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: all build clean test test-all test-integration-go test-unit-go test-connection schema-install broker-start broker-stop install deps help
.PHONY: all build clean test test-all test-integration-go test-unit-go test-connection schema-install broker-start broker-stop install deps docker-up docker-down help
# Build variables
BINARY_NAME=pgsql-broker
@@ -8,6 +8,28 @@ GO=go
GOFLAGS=-v
LDFLAGS=-w -s
# Auto-detect container runtime (Docker or Podman)
CONTAINER_RUNTIME := $(shell \
if command -v podman > /dev/null 2>&1; then \
echo "podman"; \
elif command -v docker > /dev/null 2>&1; then \
echo "docker"; \
else \
echo "none"; \
fi)
# Detect compose command
COMPOSE_CMD := $(shell \
if [ "$(CONTAINER_RUNTIME)" = "podman" ]; then \
echo "podman-compose"; \
elif command -v docker-compose > /dev/null 2>&1; then \
echo "docker-compose"; \
else \
echo "docker compose"; \
fi)
# Version information
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+2026-01-02_19:58:30')
@@ -119,6 +141,38 @@ sql-install-manual: ## Install SQL tables and procedures manually via psql
@psql -f pkg/broker/install/sql/procedures/00_install.sql
@echo "SQL schema installed"
docker-up: ## Start PostgreSQL test database
@echo "Starting PostgreSQL test database (using $(CONTAINER_RUNTIME))..."
@if [ "$(CONTAINER_RUNTIME)" = "none" ]; then \
echo "Error: Neither Docker nor Podman is installed"; \
exit 1; \
fi
@if [ "$(CONTAINER_RUNTIME)" = "podman" ]; then \
podman run -d --name pgsql-broker-test-postgres \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=broker_test \
-p 5433:5432 \
postgres:13 2>/dev/null || echo "Container already running"; \
else \
cd tests && $(COMPOSE_CMD) up -d; \
fi
@echo "Waiting for PostgreSQL to be ready..."
@sleep 3
@echo "PostgreSQL is running on port 5433"
@echo "Connection: postgres://user:password@localhost:5433/broker_test"
docker-down: ## Stop PostgreSQL test database
@echo "Stopping PostgreSQL test database (using $(CONTAINER_RUNTIME))..."
@if [ "$(CONTAINER_RUNTIME)" = "podman" ]; then \
podman stop pgsql-broker-test-postgres 2>/dev/null || true; \
podman rm pgsql-broker-test-postgres 2>/dev/null || true; \
else \
cd tests && $(COMPOSE_CMD) down; \
fi
@echo "PostgreSQL stopped"
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""