Browse Source

docker compose

pull/7231/head
chrislu 2 months ago
parent
commit
a424bfa3ce
  1. 22
      test/postgres/Makefile
  2. 20
      test/postgres/run-tests.sh

22
test/postgres/Makefile

@ -41,23 +41,23 @@ all: ## Run complete test suite (start -> produce -> test)
# Development targets # Development targets
dev-start: ## Start services for development dev-start: ## Start services for development
@echo "Starting development environment..." @echo "Starting development environment..."
@docker-compose up -d seaweedfs postgres-server
@docker compose up -d seaweedfs postgres-server
@echo "Services started. Run 'make dev-logs' to watch logs." @echo "Services started. Run 'make dev-logs' to watch logs."
dev-logs: ## Follow logs for development dev-logs: ## Follow logs for development
@docker-compose logs -f seaweedfs postgres-server
@docker compose logs -f seaweedfs postgres-server
dev-rebuild: ## Rebuild and restart services dev-rebuild: ## Rebuild and restart services
@docker-compose down
@docker-compose up -d --build seaweedfs postgres-server
@docker compose down
@docker compose up -d --build seaweedfs postgres-server
# Individual service targets # Individual service targets
start-seaweedfs: ## Start only SeaweedFS start-seaweedfs: ## Start only SeaweedFS
@docker-compose up -d seaweedfs
@docker compose up -d seaweedfs
restart-postgres: ## Start only PostgreSQL server restart-postgres: ## Start only PostgreSQL server
@docker-compose down -d postgres-server
@docker-compose up -d --build seaweedfs postgres-server
@docker compose down -d postgres-server
@docker compose up -d --build seaweedfs postgres-server
# Testing targets # Testing targets
test-basic: ## Run basic connectivity test test-basic: ## Run basic connectivity test
@ -65,16 +65,16 @@ test-basic: ## Run basic connectivity test
psql -h postgres-server -p 5432 -U seaweedfs -d default -c "SELECT version();" psql -h postgres-server -p 5432 -U seaweedfs -d default -c "SELECT version();"
test-producer: ## Test data producer only test-producer: ## Test data producer only
@docker-compose up --build mq-producer
@docker compose up --build mq-producer
test-client: ## Test client only test-client: ## Test client only
@docker-compose up --build postgres-client
@docker compose up --build postgres-client
# Cleanup targets # Cleanup targets
clean-images: ## Remove Docker images clean-images: ## Remove Docker images
@docker-compose down
@docker compose down
@docker image prune -f @docker image prune -f
clean-all: ## Complete cleanup including images clean-all: ## Complete cleanup including images
@docker-compose down -v --rmi all
@docker compose down -v --rmi all
@docker system prune -f @docker system prune -f

20
test/postgres/run-tests.sh

@ -19,7 +19,7 @@ wait_for_service() {
echo -e "${YELLOW}Waiting for $service to be ready...${NC}" echo -e "${YELLOW}Waiting for $service to be ready...${NC}"
while [ $count -lt $max_wait ]; do while [ $count -lt $max_wait ]; do
if docker-compose ps $service | grep -q "healthy\|Up"; then
if docker compose ps $service | grep -q "healthy\|Up"; then
echo -e "${GREEN}$service is ready${NC}" echo -e "${GREEN}$service is ready${NC}"
return 0 return 0
fi fi
@ -36,7 +36,7 @@ wait_for_service() {
show_logs() { show_logs() {
local service=$1 local service=$1
echo -e "${BLUE}=== $service logs ===${NC}" echo -e "${BLUE}=== $service logs ===${NC}"
docker-compose logs --tail=20 $service
docker compose logs --tail=20 $service
echo echo
} }
@ -44,7 +44,7 @@ show_logs() {
case "$1" in case "$1" in
"start") "start")
echo -e "${YELLOW}Starting SeaweedFS cluster and PostgreSQL server...${NC}" echo -e "${YELLOW}Starting SeaweedFS cluster and PostgreSQL server...${NC}"
docker-compose up -d seaweedfs postgres-server
docker compose up -d seaweedfs postgres-server
wait_for_service "seaweedfs" 30 wait_for_service "seaweedfs" 30
wait_for_service "postgres-server" 15 wait_for_service "postgres-server" 15
@ -61,7 +61,7 @@ case "$1" in
"produce") "produce")
echo -e "${YELLOW}Creating MQ test data...${NC}" echo -e "${YELLOW}Creating MQ test data...${NC}"
docker-compose up --build mq-producer
docker compose up --build mq-producer
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Test data created successfully${NC}" echo -e "${GREEN}✓ Test data created successfully${NC}"
@ -75,7 +75,7 @@ case "$1" in
"test") "test")
echo -e "${YELLOW}Running PostgreSQL client tests...${NC}" echo -e "${YELLOW}Running PostgreSQL client tests...${NC}"
docker-compose up --build postgres-client
docker compose up --build postgres-client
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo -e "${GREEN}✓ Client tests completed${NC}" echo -e "${GREEN}✓ Client tests completed${NC}"
@ -87,7 +87,7 @@ case "$1" in
"psql") "psql")
echo -e "${YELLOW}Connecting to PostgreSQL with psql...${NC}" echo -e "${YELLOW}Connecting to PostgreSQL with psql...${NC}"
docker-compose run --rm psql-cli psql -h postgres-server -p 5432 -U seaweedfs -d default
docker compose run --rm psql-cli psql -h postgres-server -p 5432 -U seaweedfs -d default
;; ;;
"logs") "logs")
@ -97,18 +97,18 @@ case "$1" in
"status") "status")
echo -e "${BLUE}=== Service Status ===${NC}" echo -e "${BLUE}=== Service Status ===${NC}"
docker-compose ps
docker compose ps
;; ;;
"stop") "stop")
echo -e "${YELLOW}Stopping all services...${NC}" echo -e "${YELLOW}Stopping all services...${NC}"
docker-compose down
docker compose down
echo -e "${GREEN}✓ All services stopped${NC}" echo -e "${GREEN}✓ All services stopped${NC}"
;; ;;
"clean") "clean")
echo -e "${YELLOW}Cleaning up everything (including data)...${NC}" echo -e "${YELLOW}Cleaning up everything (including data)...${NC}"
docker-compose down -v
docker compose down -v
docker system prune -f docker system prune -f
echo -e "${GREEN}✓ Cleanup completed${NC}" echo -e "${GREEN}✓ Cleanup completed${NC}"
;; ;;
@ -119,7 +119,7 @@ case "$1" in
# Start services (wait_for_service ensures they're ready) # Start services (wait_for_service ensures they're ready)
$0 start $0 start
# Create data (docker-compose up is synchronous)
# Create data (docker compose up is synchronous)
$0 produce $0 produce
# Run tests # Run tests

Loading…
Cancel
Save