|
1 | | -# Redis Test App - Development and Deployment Makefile |
2 | | -.PHONY: help dev-setup dev-start dev-stop dev-logs dev-test build push deploy clean |
| 1 | +# Redis Python Test App - Makefile |
| 2 | +.PHONY: help install-deps test test-connection build clean |
3 | 3 |
|
4 | 4 | # Default target |
5 | 5 | help: |
6 | | - @echo "Redis Test App - Available Commands:" |
| 6 | + @echo "Redis Python Test App - Available Commands:" |
7 | 7 | @echo "" |
8 | 8 | @echo "🚀 Development Commands:" |
9 | | - @echo " make dev-start - Start complete development environment" |
10 | | - @echo " make dev-start-metrics-stack - Start metrics stack only" |
11 | | - @echo " make dev-stop - Stop metrics stack" |
12 | | - @echo " make dev-logs - Show metrics stack logs" |
13 | | - @echo " make dev-test - Run Python app locally against metrics stack" |
14 | | - @echo " make dev-clean - Clean up development environment" |
| 9 | + @echo " make install-deps - Install Python dependencies" |
| 10 | + @echo " make test - Run basic test (60 seconds)" |
| 11 | + @echo " make test-connection - Test Redis connection" |
15 | 12 | @echo "" |
16 | 13 | @echo "🏗️ Build Commands:" |
17 | | - @echo " make build - Build all Docker images" |
18 | | - @echo " make build-app - Build only Python app images" |
19 | | - @echo " make build-metrics - Build only metrics stack images" |
20 | | - @echo "" |
21 | | - @echo "☁️ Deployment Commands:" |
22 | | - @echo " make push - Push images to registry" |
23 | | - @echo " make deploy-dev - Deploy to development environment" |
24 | | - @echo " make deploy-prod - Deploy to production environment" |
| 14 | + @echo " make build - Build Docker image" |
25 | 15 | @echo "" |
26 | 16 | @echo "🧹 Cleanup Commands:" |
27 | | - @echo " make clean - Clean up all containers and volumes" |
28 | | - @echo " make clean-images - Remove all built images" |
29 | | - |
30 | | -# Development Environment Variables |
31 | | -COMPOSE_FILE_DEV = docker-compose.dev.yml |
32 | | -COMPOSE_FILE_METRICS = docker-compose.metrics.yml |
33 | | -COMPOSE_FILE_FULL = docker-compose.yml |
| 17 | + @echo " make clean - Clean up Python cache and virtual environment" |
| 18 | + @echo "" |
| 19 | + @echo "📋 Prerequisites:" |
| 20 | + @echo " • Redis Metrics Stack must be running (separate repository)" |
| 21 | + @echo " • Redis accessible at localhost:6379" |
| 22 | + @echo " • OpenTelemetry Collector at localhost:4317" |
34 | 23 |
|
35 | | -# Registry and deployment variables |
36 | | -REGISTRY ?= your-registry.com |
| 24 | +# Application variables |
| 25 | +APP_NAME ?= redis-py-test-app |
37 | 26 | IMAGE_TAG ?= latest |
38 | | -NAMESPACE ?= redis-test-app |
39 | 27 |
|
40 | 28 | #============================================================================== |
41 | 29 | # Development Commands |
42 | 30 | #============================================================================== |
43 | 31 |
|
44 | | -dev-start: dev-start-metrics-stack |
45 | | - @echo "🚀 Development environment ready!" |
46 | | - @echo "" |
47 | | - @echo "📊 Grafana: http://localhost:3000 (admin/admin) - Redis Test Dashboard" |
48 | | - @echo "📈 Prometheus: http://localhost:9090" |
49 | | - @echo "🔍 Jaeger: http://localhost:16686" |
50 | | - @echo "📡 Redis: localhost:6379" |
51 | | - @echo "" |
52 | | - @echo "To run Python app locally:" |
53 | | - @echo " make dev-test" |
54 | | - @echo " ./venv/bin/python main.py run --workload-profile basic_rw --duration 60" |
55 | | - |
56 | | -dev-start-metrics-stack: |
57 | | - @echo "🚀 Starting metrics stack..." |
58 | | - docker-compose -f $(COMPOSE_FILE_METRICS) up -d |
59 | | - @echo "⏳ Waiting for services to be ready..." |
60 | | - @sleep 15 |
61 | | - @echo "✅ Metrics stack started" |
62 | | - |
63 | | -dev-stop: |
64 | | - @echo "🛑 Stopping metrics stack..." |
65 | | - docker-compose -f $(COMPOSE_FILE_METRICS) down |
66 | | - |
67 | | -dev-logs: |
68 | | - docker-compose -f $(COMPOSE_FILE_METRICS) logs -f |
69 | | - |
70 | | -dev-test: |
71 | | - @echo "🧪 Running Python app locally (60 second test)..." |
72 | | - @if [ ! -d "venv" ]; then make install-deps; fi |
73 | | - ./venv/bin/python main.py run --workload-profile basic_rw --duration 60 --host localhost |
74 | | - |
75 | | -dev-clean: dev-stop |
76 | | - @echo "🧹 Cleaning development environment..." |
77 | | - docker-compose -f $(COMPOSE_FILE_METRICS) down -v |
78 | | - docker system prune -f |
79 | | - |
80 | | -#============================================================================== |
81 | | -# Build Commands |
82 | | -#============================================================================== |
83 | | - |
84 | | -build: build-metrics build-app |
85 | | - |
86 | | -build-app: |
87 | | - @echo "🏗️ Building Python app images..." |
88 | | - docker-compose -f $(COMPOSE_FILE_FULL) build \ |
89 | | - redis-test-basic-rw \ |
90 | | - redis-test-high-throughput \ |
91 | | - redis-test-list-ops \ |
92 | | - redis-test-async-mixed |
93 | | - |
94 | | -build-metrics: |
95 | | - @echo "🏗️ Building metrics stack images..." |
96 | | - docker-compose -f $(COMPOSE_FILE_METRICS) build |
97 | | - |
| 32 | +install-deps: ## Install Python dependencies |
| 33 | + @echo "📦 Installing Python dependencies..." |
| 34 | + python3 -m pip install --upgrade pip |
| 35 | + python3 -m pip install -r requirements.txt |
| 36 | + @echo "✅ Dependencies installed" |
| 37 | + |
| 38 | +test-connection: ## Test Redis connection |
| 39 | + @echo "🔍 Testing Redis connection..." |
| 40 | + python3 main.py test-connection |
| 41 | + @echo "✅ Connection test complete" |
| 42 | + |
| 43 | +test: ## Run basic test (60 seconds) |
| 44 | + @echo "🧪 Running basic test..." |
| 45 | + python3 main.py run --workload-profile basic_rw --duration 60 |
| 46 | + @echo "✅ Test complete" |
98 | 47 | #============================================================================== |
99 | | -# Cloud Deployment Commands |
| 48 | +# Build Commands |
100 | 49 | #============================================================================== |
101 | 50 |
|
102 | | -push: build |
103 | | - @echo "📤 Pushing images to registry..." |
104 | | - docker tag redis-py-test-app-redis-test-basic-rw $(REGISTRY)/redis-test-basic-rw:$(IMAGE_TAG) |
105 | | - docker tag redis-py-test-app-redis-test-high-throughput $(REGISTRY)/redis-test-high-throughput:$(IMAGE_TAG) |
106 | | - docker tag redis-py-test-app-redis-test-list-ops $(REGISTRY)/redis-test-list-ops:$(IMAGE_TAG) |
107 | | - docker tag redis-py-test-app-redis-test-async-mixed $(REGISTRY)/redis-test-async-mixed:$(IMAGE_TAG) |
108 | | - |
109 | | - docker push $(REGISTRY)/redis-test-basic-rw:$(IMAGE_TAG) |
110 | | - docker push $(REGISTRY)/redis-test-high-throughput:$(IMAGE_TAG) |
111 | | - docker push $(REGISTRY)/redis-test-list-ops:$(IMAGE_TAG) |
112 | | - docker push $(REGISTRY)/redis-test-async-mixed:$(IMAGE_TAG) |
113 | | - |
114 | | -deploy-dev: |
115 | | - @echo "🚀 Deploying to development environment..." |
116 | | - # This will be replaced with actual deployment commands (kubectl, helm, etc.) |
117 | | - @echo "TODO: Implement development deployment" |
118 | | - |
119 | | -deploy-prod: |
120 | | - @echo "🚀 Deploying to production environment..." |
121 | | - # This will be replaced with actual deployment commands |
122 | | - @echo "TODO: Implement production deployment" |
| 51 | +build: ## Build Docker image |
| 52 | + @echo "🏗️ Building Python app image..." |
| 53 | + docker build -t $(APP_NAME):$(IMAGE_TAG) . |
| 54 | + @echo "✅ Build complete" |
123 | 55 |
|
124 | 56 | #============================================================================== |
125 | 57 | # Cleanup Commands |
126 | 58 | #============================================================================== |
127 | 59 |
|
128 | | -clean: |
129 | | - @echo "🧹 Cleaning up all containers and volumes..." |
130 | | - docker-compose -f $(COMPOSE_FILE_FULL) down -v |
131 | | - docker-compose -f $(COMPOSE_FILE_METRICS) down -v |
132 | | - docker system prune -f |
133 | | - |
134 | | -clean-images: |
135 | | - @echo "🧹 Removing built images..." |
136 | | - docker rmi -f $$(docker images "redis-py-test-app*" -q) 2>/dev/null || true |
137 | | - docker rmi -f $$(docker images "$(REGISTRY)/redis-test*" -q) 2>/dev/null || true |
138 | | - |
139 | | -#============================================================================== |
140 | | -# Utility Commands |
141 | | -#============================================================================== |
142 | | - |
143 | | -status: |
144 | | - @echo "📊 Development Environment Status:" |
145 | | - @docker-compose -f $(COMPOSE_FILE_METRICS) ps |
146 | | - |
147 | | -install-deps: |
148 | | - @echo "📦 Setting up Python virtual environment..." |
149 | | - python3 -m venv venvacti |
150 | | - @echo "📦 Installing Python dependencies..." |
151 | | - ./venv/bin/pip install -r requirements.txt |
152 | | - @echo "✅ Dependencies installed in virtual environment" |
153 | | - @echo "💡 To activate: source venv/bin/activate" |
154 | | - |
155 | | -lint: |
156 | | - @echo "🔍 Running code linting..." |
157 | | - flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics |
158 | | - flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
159 | | - |
160 | | -test-local: |
161 | | - @echo "🧪 Running local tests..." |
162 | | - @if [ ! -d "venv" ]; then make install-deps; fi |
163 | | - ./venv/bin/python -m pytest tests/ -v |
164 | | - |
165 | | -# Development shortcuts |
166 | | -dev: dev-start |
167 | | -stop: dev-stop |
168 | | -logs: dev-logs |
169 | | -test: dev-test |
| 60 | +clean: ## Clean up Python cache and virtual environment |
| 61 | + @echo "🧹 Cleaning up Python environment..." |
| 62 | + rm -rf __pycache__/ |
| 63 | + rm -rf *.pyc |
| 64 | + rm -rf .pytest_cache/ |
| 65 | + rm -rf venv/ |
| 66 | + @echo "✅ Cleanup complete" |
0 commit comments