# pulumi-vsphere lab suite (containers only).

COMPOSE ?= docker compose
COMPOSE_FILE ?= docker-compose.yml
COMPOSE_CMD = $(COMPOSE) -f $(COMPOSE_FILE)
PROFILE = --profile test

.PHONY: help up down build seed test-pulumi-smoke test-pulumi pulumi-tests \
	test-smoke-all test-all clean-test-resources report-open

help: ## Show targets
	@awk 'BEGIN {FS = ":.*## "}; /^[a-zA-Z0-9_-]+:.*## / {printf "%-26s %s\n", $$1, $$2}' $(MAKEFILE_LIST)

up: ## Start simulator + gateway + seed
	$(COMPOSE_CMD) up -d --build postgres
	$(COMPOSE_CMD) up --build migrate
	$(COMPOSE_CMD) up -d --build simulator api-gateway
	$(COMPOSE_CMD) up --build seed

down: ## Stop lab stack
	$(COMPOSE_CMD) --profile test down -v

build: ## Build pulumi-runner image (pulumi + pulumi-vsphere)
	$(COMPOSE_CMD) $(PROFILE) build pulumi-runner

seed: ## Re-run inventory seed
	$(COMPOSE_CMD) up --build seed

test-pulumi-smoke: up ## PU-INV + REST major-9 smoke (no VM/tags/CRUD/full SOAP)
	$(COMPOSE_CMD) $(PROFILE) run --rm -e TEST_SMOKE=1 pulumi-runner \
		python3 /suite/run_suite.py

test-pulumi: up ## Full hybrid: pulumi-vsphere + REST×6-9 + CRUD + SOAP WSDL
	$(COMPOSE_CMD) $(PROFILE) run --rm pulumi-runner \
		python3 /suite/run_suite.py

pulumi-tests: test-pulumi ## Alias used from repo root

test-smoke-all: test-pulumi-smoke ## Alias

test-all: test-pulumi ## Alias

clean-test-resources: ## Best-effort cleanup via seed reload
	$(COMPOSE_CMD) up --build seed

report-open: ## Print how to copy the HTML report
	@echo "HTML report volume: lab-reports → /reports/pulumi-report.html"
	@echo "Copy: docker compose --profile test run --rm --no-deps -v \$$(pwd)/reports:/out pulumi-runner cp /reports/pulumi-report.html /out/"
