-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
234 lines (177 loc) · 7.4 KB
/
Makefile
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
REPORT_COVERAGE ?= false
# 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
smoke: ## If running on Jenkins, purges JMeter's library, then copies all of dpc-smoketests dependencies into it
smoke:
@JENKINS_DIR="/var/jenkins_home/.bzt/jmeter-taurus/5.5/lib"; \
if [ -d $$JENKINS_DIR ]; then \
echo "Rebuilding JMeter lib"; \
rm $$JENKINS_DIR/*.jar; \
mvn clean install -DskipTests -Djib.skip=True -pl dpc-common -am -ntp; \
mvn dependency:copy-dependencies -pl dpc-smoketest -DoutputDirectory=$$JENKINS_DIR; \
else \
echo "Not running on Jenkins"; \
fi
@mvn clean package -DskipTests -Djib.skip=True -pl dpc-smoketest -am -ntp
.PHONY: smoke/local
smoke/local: venv smoke
@echo "Running Smoke Tests against Local env"
@read -p "`echo '\n=====\nThe Smoke Tests require an authenticated environment!\nVerify your local API environment has \"authenticationDisabled = false\" or these tests will fail.\n=====\n\nPress ENTER to run the tests...'`"
. venv/bin/activate; pip install -Ur requirements.txt; bzt src/test/local.smoke_test.yml
.PHONY: smoke/remote
smoke/remote: venv smoke
@echo "Running Smoke Tests against ${HOST_URL}"
. venv/bin/activate; bzt src/test/remote.smoke_test.yml
.PHONY: smoke/sandbox
smoke/sandbox: venv smoke
@echo "Running Smoke Tests against ${HOST_URL}"
. venv/bin/activate; bzt src/test/sandbox.smoke_test.yml
.PHONY: smoke/prod
smoke/prod: venv smoke
@echo "Running Smoke Tests against ${HOST_URL}"
. venv/bin/activate; bzt src/test/prod.smoke_test.yml
# 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
# 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 start_core_dependencies
start-api-dependencies: # Start internal Java service dependencies, e.g. attribution and aggregation services.
start-api-dependencies:
@USE_BFD_MOCK=false docker compose up start_api_dependencies
start-app: ## Start the API
start-app: secure-envs start-db start-api-dependencies
@docker compose up start_api
start-api: ## Start the API
start-api: start-app
start-web: ## Start the sandbox portal
start-web:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_web
start-admin: ## Start the sandbox admin portal
start-admin:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_admin
start-portal: ## Start the DPC portal
start-portal: secure-envs
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_portal
start-portals: ## Start all frontend services
start-portals: start-db start-web start-admin start-portal
start-load-tests: ## Run DPC performance tests locally in a Docker image provided by Grafana/K6
start-load-tests: secure-envs
@docker run --rm -v $(shell pwd)/dpc-load-testing:/src --env-file $(shell pwd)/ops/config/decrypted/local.env -e ENVIRONMENT=local -i grafana/k6 run /src/script.js
# Debug commands
# ==============
.PHONY: start-dpc-debug
start-dpc-debug: secure-envs
@mvn clean install -Pdebug -DskipTests -ntp
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_core_dependencies
@DEBUG_MODE=true USE_BFD_MOCK=false docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_api_dependencies
@DEBUG_MODE=true docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_api
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_web
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_admin
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_portal
@docker ps
.PHONY: start-app-debug
start-app-debug: secure-envs
@docker compose down
@mvn clean compile -Pdebug -DskipTests -ntp
@mvn package -Pci -ntp -DskipTests
@docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_core_dependencies
@DEBUG_MODE=true USE_BFD_MOCK=false docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_api_dependencies
@DEBUG_MODE=true docker compose -f docker-compose.yml -f docker-compose.portals.yml up start_api
.PHONY: start-it-debug
start-it-debug: secure-envs
@docker compose down
@mvn clean compile -Pdebug -B -V -ntp -DskipTests
@mvn package -Pci -ntp -DskipTests
@docker compose up start_core_dependencies
@DEBUG_MODE=true docker compose up start_api_dependencies
# Down commands
# ==============
down-dpc: ## Shut down all services
down-dpc:
@docker compose -f docker-compose.yml -f docker-compose.portals.yml 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
# 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-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