-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathMakefile
More file actions
238 lines (177 loc) · 7.35 KB
/
Makefile
File metadata and controls
238 lines (177 loc) · 7.35 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
# Smoke Testing
# ==============
SMOKE_THREADS ?= 10
venv: venv/bin/activate
venv/bin/activate: requirements.txt
test -d venv || python3 -m venv venv
. venv/bin/activate
touch venv/bin/activate
.PHONY: smoke/local
smoke/local: export USE_BFD_MOCK=true
smoke/local: export AUTH_DISABLED=false
smoke/local: start-dpc
@echo "Running Smoke Tests against Local env"
docker run --rm -v $(shell pwd)/dpc-load-testing:/src -e ENVIRONMENT=local -i grafana/k6:1.4.2 run /src/smoke-test.js
# Build commands
#
# These commands build/compile our applications and docker images.
# To start the applications, use the start-* commands below.
# ==============
api: ## Builds the Java API services
api: secure-envs
mvn clean compile -Perror-prone -B -V -ntp -T 4 -DskipTests
mvn package -Pci -ntp -T 4 -DskipTests
website: ## Builds the sandbox portal website
website:
@docker build -f dpc-web/Dockerfile . -t dpc-web
admin: ## Builds the sandbox admin website
admin:
@docker build -f dpc-admin/Dockerfile . -t dpc-web-admin
portal: ## Builds the DPC portal
portal:
mkdir -p dpc-portal/vendor/api_client
cp -r engines/api_client/ dpc-portal/vendor/api_client/
@docker build -f dpc-portal/Dockerfile . -t dpc-web-portal
api-client:
@docker compose -f docker-compose.yml -f docker-compose.api-client.yml build dpc_api_client
# Start commands
# ==============
start-dpc: ## Start all DPC API and portal services
start-dpc: start-app start-portals
start-db: ## Start the database
start-db:
@docker compose up db --wait
start-api-dependencies: # Start internal Java service dependencies, e.g. attribution and aggregation services.
start-api-dependencies:
@docker compose up attribution aggregation --wait
start-app: ## Start the API
start-app: secure-envs start-db start-api-dependencies
@docker compose up api --wait
start-api: ## Start the API
start-api: start-app
start-api-load-tests: ## Start a new API env for load tests
start-api-load-tests: secure-envs
USE_BFD_MOCK=true docker compose -p dpc-load-tests up api --wait
start-web: ## Start the sandbox portal
start-web:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up dpc_web --wait
start-admin: ## Start the sandbox admin portal
start-admin:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up dpc_admin --wait
start-portal: ## Start the DPC portal
start-portal: secure-envs
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up dpc_portal --wait
start-portals: ## Start all frontend services
start-portals: start-db start-web start-admin start-portal
start-load-tests: ## Run one iteration of DPC performance tests locally in a Docker image provided by Grafana/K6
start-load-tests: secure-envs
@TEST_TYPE=single-iteration && \
docker run --rm -v $(shell pwd)/dpc-load-testing:/src --env-file $(shell pwd)/ops/config/decrypted/local.env -e ENVIRONMENT=local -e TEST_TYPE=$$TEST_TYPE -i grafana/k6 run /src/$$TEST_TYPE.js
start-average-load-test: ## Run average load test locally in a Docker image provided by Grafana/K6
start-average-load-test: secure-envs
@TEST_TYPE=average-load-test && \
docker run --rm -v $(shell pwd)/dpc-load-testing:/src --env-file $(shell pwd)/ops/config/decrypted/local.env -e ENVIRONMENT=local -e TEST_TYPE=$$TEST_TYPE -i grafana/k6 run /src/$$TEST_TYPE.js
start-stress-test:
start-stress-test: secure-envs
@TEST_TYPE=stress-test && \
docker run --rm -v $(shell pwd)/dpc-load-testing:/src --env-file $(shell pwd)/ops/config/decrypted/local.env -e ENVIRONMENT=local -e TEST_TYPE=$$TEST_TYPE -i grafana/k6 run /src/$$TEST_TYPE.js
start-macaroon-tests: ## Test load-test macaroons
start-macaroon-tests:
@docker run --rm -v ./dpc-load-testing:/src -i grafana/k6 run /src/macaroonTests.js
start-jwt-tests: ## Test load-test jwt
start-jwt-tests:
@docker run --rm -v ./dpc-load-testing:/src -i grafana/k6 run /src/jwtTests.js
# Debug commands
# ==============
.PHONY: start-dpc-debug
start-dpc-debug: secure-envs
@docker compose down
@mvn clean install -Pci -Pdebug -DskipTests -ntp
@DEBUG_MODE=true docker compose up aggregation api --wait
@docker compose -f docker-compose.yml -f docker-compose.portals.yml -f docker-compose.override.yml up dpc_web dpc_admin dpc_portal --wait
@docker ps
.PHONY: start-app-debug
start-app-debug: secure-envs
@docker compose down
@mvn clean install -Pci -Pdebug -DskipTests -ntp
@DEBUG_MODE=true docker compose up api aggregation --wait
.PHONY: start-it-debug
start-it-debug: secure-envs
@docker compose down
@mvn clean install -Pci -Pdebug -DskipTests -ntp
@DEBUG_MODE=true docker compose up attribution aggregation --wait
# Down commands
# ==============
down-dpc: ## Shut down all services
down-dpc:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml down
down-dpc-load-tests: ## Shut down all services in the dpc-load-tests container
down-dpc-load-tests:
@docker compose -p dpc-load-tests down
down-portals: ## Shut down all services
down-portals: down-dpc
down-start-v1-portals: ## Shut down test services
down-start-v1-portals:
@docker compose -p start-v1-portals -f docker-compose.yml -f docker-compose.portals.yml down
# Utility commands
# =================
CONF_FILE = "dpc-attribution/src/test/resources/test.application.yml"
secure-envs: ## Decrypt API environment secrets
secure-envs:
@bash ops/scripts/secrets --decrypt ops/config/encrypted/bb.keystore | tail -n +2 > bbcerts/bb.keystore
@bash ops/scripts/secrets --decrypt ops/config/encrypted/local.env | tail -n +2 > ops/config/decrypted/local.env
seed-db: ## Seed attribution data for local database
seed-db:
@java -jar dpc-attribution/target/dpc-attribution.jar db migrate $(CONF_FILE)
@java -jar dpc-attribution/target/dpc-attribution.jar seed $(CONF_FILE)
maven-config: ## Translate local environment variables into maven.config for manual API installation
maven-config:
@./maven-config.sh
psql: ## Run a psql shell
@docker compose -f docker-compose.yml exec -it db psql -U postgres
portal-sh: ## Run a portal shell
@docker compose -f docker-compose.yml -f docker-compose.portals.yml exec -it dpc_portal bin/sh
portal-console: ## Run a rails console shell
@docker compose -f docker-compose.yml -f docker-compose.portals.yml exec -it dpc_portal bin/console
api-client-sh:
@docker compose -f docker-compose.api-client.yml run --remove-orphans --entrypoint "sh" dpc_api_client
# Build & Test commands
# ======================
.PHONY: docker-base
docker-base:
@docker compose -f ./docker-compose.base.yml build base
.PHONY: ci-app
ci-app: docker-base secure-envs
@./dpc-test.sh
.PHONY: ci-portals
ci-portals: secure-envs
@./dpc-portals-test.sh
.PHONY: ci-portals-v1
ci-portals-v1: secure-envs
@./dpc-portals-test.sh
.PHONY: ci-admin-portal
ci-admin-portal: secure-envs
@./dpc-admin-portal-test.sh
.PHONY: ci-portal
ci-portal: secure-envs
@./dpc-portal-test.sh
.PHONY: ci-portal-accessibility
ci-portal-accessibility: secure-envs
@./dpc-portal-accessibility-test.sh
.PHONY: ci-web-accessibility
ci-web-accessibility: secure-envs
@./dpc-web-accessibility-test.sh
.PHONY: ci-web-portal
ci-web-portal: secure-envs
@./dpc-web-portal-test.sh
.PHONY: ci-api-client
ci-api-client:
@./dpc-api-client-test.sh
.PHONY: unit-tests
unit-tests:
@bash ./dpc-unit-test.sh
.PHONY: load-tests
load-tests: start-api-load-tests start-load-tests down-dpc-load-tests
.PHONY: ci-api-client-integration
ci-api-client-integration: docker-base secure-envs
@bash ./dpc-api-client-integration-test.sh