-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
295 lines (251 loc) · 9.1 KB
/
Makefile
File metadata and controls
295 lines (251 loc) · 9.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
# shellcheck shell=sh
# Makefile for E2E testing environment
# This mirrors the GitHub Actions workflow structure
# Configuration
PORTAL_PORT ?= 8080
# Phony targets (targets that don't represent files)
.PHONY: help up down setup-env start-portal restart-portal stop-portal test clean recreate-mysql recreate-powerdns
.PHONY: verify-services logs ps e2e setup teardown _test build-portal rebuild-portal
.PHONY: start-dns stop-dns dns-logs ensure-venv setup-compliance wait-ipfs wait-powerdns
.PHONY: test-tag debug-tag test-compliance
.PHONY: _test-compliance
.PHONY: start-stripe-mock stop-stripe-mock stripe-mock-logs reset-stripe-mock
.PHONY: start-atlos-mock stop-atlos-mock atlos-mock-logs reset-atlos-mock
help:
@echo "E2E Testing Environment Commands:"
@echo ""
@echo "Service Management:"
@echo " make up - Start all Docker services"
@echo " make down - Stop all Docker services"
@echo " make restart - Restart all Docker services"
@echo " make logs - View service logs"
@echo " make ps - Show running containers"
@echo " make wait-ipfs - Wait for IPFS service to be ready"
@echo " make wait-powerdns - Wait for PowerDNS service to be ready"
@echo " make verify-services - Wait for all services to be ready"
@echo " make recreate-mysql - Recreate MySQL container to wipe data"
@echo " make recreate-powerdns - Recreate PowerDNS container to wipe data"
@echo " make reset-stripe-mock - Reset stripe-mock-server state"
@echo ""
@echo "DNS Server:"
@echo " make start-dns - Start dynamic DNS server (routes to localhost)"
@echo " make stop-dns - Stop DNS server"
@echo " make dns-logs - View DNS server logs"
@echo " make ensure-venv - Ensure Python venv with dnserver is installed"
@echo ""
@echo "Portal Build & Run:"
@echo " make build-portal - Build portal"
@echo " make rebuild-portal - Force rebuild of portal"
@echo " make setup-env - Generate environment variables from configs"
@echo " make start-portal - Build and run portal in background"
@echo " make restart-portal - Restart the portal"
@echo " make stop-portal - Stop running portal"
@echo ""
@echo "Testing & Cycles:"
@echo " make test - Full e2e test cycle with teardown (includes compliance)"
@echo " make e2e - Quick e2e test (up -> _test -> down)"
@echo " make e2e-debug - Quick e2e test in debug mode (with Delve on :2345)"
@echo " make test-tag TAG=@tag Run a single tag test (no debugger)"
@echo " make debug-tag TAG=@tag Run a single tag test with Delve debugger"
@echo " make test-compliance - Run IPFS compliance tests only (requires running portal)"
@echo " make setup-compliance - Setup compliance testing environment (npm package)"
@echo " make setup - Setup environment (no teardown)"
@echo " make teardown - Tear down environment"
@echo ""
@echo "Cleanup:"
@echo " make clean - Clean up all resources"
# Service Management
up:
@echo "Starting services..."
docker compose up -d services-ready
@echo "Waiting for services to be healthy..."
@docker compose ps
@echo "[OK] Services are ready!"
wait-ipfs:
@./scripts/wait-ipfs.sh
wait-powerdns:
@./scripts/wait-powerdns.sh
verify-services:
@./scripts/wait-mysql.sh
@./scripts/wait-gofakes3.sh
@./scripts/wait-ipfs.sh
@./scripts/wait-powerdns.sh
recreate-mysql:
@echo "Recreating MySQL container to wipe data..."
@-docker compose stop mysql
@-docker compose rm -f mysql
@docker compose up -d mysql
@echo "Waiting for MySQL to be ready..."
@docker compose ps
@echo "[OK] MySQL recreated with clean state"
recreate-powerdns:
@echo "Recreating PowerDNS container to wipe data..."
@-docker compose stop powerdns
@-docker compose rm -f powerdns
@docker compose up -d powerdns
@echo "Waiting for PowerDNS to be ready..."
@docker compose ps
@echo "[OK] PowerDNS recreated with clean state"
down:
@echo "Stopping services..."
docker compose down
@echo "[OK] Services stopped"
restart: down up
logs:
docker compose logs -f
ps:
docker compose ps
# Portal Build & Run
# Note: portal-plugins.yaml is updated automatically but only triggers rebuild if ./dist/portal is missing
build-portal:
@echo "Checking portal build status..."
@./scripts/create-plugin-manifest.sh || echo "[WARN] Failed to create plugin manifest"
@if [ ! -f ./dist/portal ]; then \
echo "Building portal with plugins using portal-builder..."; \
docker run --rm \
-v "$(PWD):/workspace" \
-v "$(PWD)/dist:/dist" \
ghcr.io/lumeweb/portal-builder:ubuntu \
build-portal; \
echo "[OK] Portal built successfully"; \
else \
echo "[OK] Portal is ready"; \
fi
rebuild-portal:
@echo "Rebuilding portal..."
@rm -rf dist portal-plugins.yaml
@$(MAKE) build-portal
@echo "[OK] Portal rebuilt successfully"
setup-env: recreate-mysql
@echo "Generating environment variables..."
@./scripts/setup-env.sh mysql false
@echo "[OK] Environment configured"
start-portal: build-portal setup-env
@./scripts/setup-kubo-bootstrap.sh
@./scripts/start-portal.sh .portal.log
restart-portal: stop-portal start-portal
# Internal test target
_test:
@echo "Running e2e tests..."
@./scripts/wait-portal.sh
@./scripts/run-tests.sh $(EXTRA_ARGS) || true
# Internal debug test target (uses Delve debugger)
_test-debug:
@echo "Running e2e tests in debug mode..."
@./scripts/wait-portal.sh
@TEST_DEBUG=1 ./scripts/run-tests.sh $(EXTRA_ARGS) || true
# Internal compliance test target
_test-compliance: setup-compliance
@echo "Running IPFS compliance tests..."
@./scripts/wait-portal.sh
@./scripts/run-compliance-tests.sh || true
# Full Cycles
e2e: up build-portal setup-env start-dns start-stripe-mock start-atlos-mock start-portal
@echo "Running e2e test cycle..."
@$(MAKE) _test || true
@$(MAKE) down || true
e2e-debug: up
@echo "Running e2e test cycle in debug mode..."
@echo "Delve debugger listening on :2345"
@echo "Connect with: dlv connect :2345"
@$(MAKE) _test-debug || true
@$(MAKE) down || true
# Run a single tag without debugger
# Usage: make test-tag TAG=@your-tag
test-tag:
@if [ -z "$(TAG)" ]; then \
echo "Error: TAG parameter is required"; \
echo "Usage: make test-tag TAG=@your-tag"; \
exit 1; \
fi
@echo "Running test with tag: $(TAG)"
$(MAKE) _test EXTRA_ARGS="--godog.tags=$(TAG)"
# Run a single tag in debug mode with Delve
# Usage: make debug-tag TAG=@your-tag
debug-tag:
@if [ -z "$(TAG)" ]; then \
echo "Error: TAG parameter is required"; \
echo "Usage: make debug-tag TAG=@your-tag"; \
exit 1; \
fi
@echo "Running test with tag: $(TAG) in debug mode..."
@echo "Delve debugger listening on :2345"
@echo "Connect with: dlv connect :2345"
$(MAKE) _test-debug EXTRA_ARGS="--godog.tags=$(TAG)"
# Run IPFS compliance tests only
# Usage: make test-compliance
# Prerequisites: Portal must be running (use 'make setup' first)
test-compliance:
@echo "Running IPFS compliance tests..."
$(MAKE) _test-compliance || true
# Full complete cycle: setup, test, teardown
test: up build-portal setup-env start-dns start-stripe-mock start-atlos-mock start-portal
@echo "Running tests against running portal..."
@$(MAKE) _test || true
@echo "Running compliance tests..."
@$(MAKE) _test-compliance || true
@echo "Tests complete, tearing down..."
@$(MAKE) stop-portal || true
@$(MAKE) stop-stripe-mock || true
@$(MAKE) stop-atlos-mock || true
@$(MAKE) stop-dns || true
@$(MAKE) down || true
@echo "[OK] Full cycle completed"
# Setup only (no teardown)
setup: up build-portal setup-env start-dns start-stripe-mock start-atlos-mock start-portal
@echo "[OK] Environment is ready for manual testing"
# Teardown only
teardown: down stop-portal stop-stripe-mock stop-atlos-mock stop-dns
@echo "[OK] Environment torn down"
# Stop portal
stop-portal:
@./scripts/wait-stop-portal.sh
# Compliance testing setup
setup-compliance:
@./scripts/setup-compliance.sh
# DNS Server Management
ensure-venv:
@./scripts/ensure-venv.sh
start-dns: ensure-venv
@./scripts/start-dns.sh
stop-dns:
@./scripts/stop-dns.sh
dns-logs:
@if [ -f .dns.log ]; then \
tail -f .dns.log; \
else \
echo "No DNS log file found. Start DNS server first with: make start-dns"; \
fi
# Cleanup
clean:
@echo "Cleaning up..."
@$(MAKE) down
@rm -rf dist .env portal portal-mysql.yml portal-plugins.yaml .venv
@rm -f .portal.pid .dns.pid .dns.log .stripe-mock.pid .stripe-mock.log .atlos-mock.pid .atlos-mock.log
@echo "[OK] Cleanup complete"
# Stripe Mock Server Management
start-stripe-mock:
@./scripts/start-stripe-mock.sh
stop-stripe-mock:
@./scripts/stop-stripe-mock.sh
stripe-mock-logs:
@if [ -f .stripe-mock.log ]; then \
tail -f .stripe-mock.log; \
else \
echo "No stripe-mock log file found. Start stripe-mock server first with: make start-stripe-mock"; \
fi
reset-stripe-mock:
@./scripts/reset-stripe-mock.sh
# Atlos Mock Server Management
start-atlos-mock:
@./scripts/start-atlos-mock.sh
stop-atlos-mock:
@./scripts/stop-atlos-mock.sh
atlos-mock-logs:
@if [ -f .atlos-mock.log ]; then \
tail -f .atlos-mock.log; \
else \
echo "No atlos-mock log file found. Start atlos-mock server first with: make start-atlos-mock"; \
fi
reset-atlos-mock:
@./scripts/reset-atlos-mock.sh