Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
319 lines (286 loc) · 16.6 KB
/
Copy pathMakefile
File metadata and controls
319 lines (286 loc) · 16.6 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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
help:
@echo 'Welcome!'
@echo ''
@echo 'This Makefile is designed to make the development work go smoothly.'
@echo 'In-depth description of how to use this Makefile can be found in the README.md'
bootstrap: go-version-check docker-version-check
@for dir in sda sda-download; do \
cd $$dir; \
go get ./...; \
cd ..; \
done
@if ! command -v curl >/dev/null; then \
echo "Can't install golangci-lint because curl is missing."; \
exit 1; \
fi
@curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
sh -s -- -b $$(go env GOPATH)/bin
go install golang.org/x/tools/cmd/goimports@latest
# build containers
build-all: build-postgresql build-rabbitmq build-sda build-sda-download build-sda-sftp-inbox build-sda-admin build-sda-validator-orchestrator
build-postgresql:
@cd postgresql && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-postgres .
build-rabbitmq:
@cd rabbitmq && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-rabbitmq .
build-sda:
@cd sda && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F) .
build-sda-download:
@cd sda-download && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-download .
build-sda-sftp-inbox:
@cd sda-sftp-inbox && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-sftp-inbox .
build-sda-admin:
@cd sda-admin && go build
build-sda-doa:
@cd sda-doa && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-doa .
build-sda-validator-orchestrator:
@cd sda-validator/orchestrator && docker build -t ghcr.io/neicnordic/sensitive-data-archive:PR$$(date +%F)-validator-orchestrator .
go-version-check: SHELL:=/bin/bash
go-version-check:
@GO_VERSION_MIN=$$(grep GOLANG_VERSION $(CURDIR)/sda/Dockerfile | cut -d '-' -f2 | tr -d '}'); \
GO_VERSION=$$(go version | grep -o 'go[0-9]\+\.[0-9]\+\(\.[0-9]\+\)\?' | tr -d 'go'); \
IFS="." read -r -a GO_VERSION_ARR <<< "$${GO_VERSION}"; \
IFS="." read -r -a GO_VERSION_REQ <<< "$${GO_VERSION_MIN}"; \
if [[ $${GO_VERSION_ARR[0]} -lt $${GO_VERSION_REQ[0]} ||\
( $${GO_VERSION_ARR[0]} -eq $${GO_VERSION_REQ[0]} &&\
( $${GO_VERSION_ARR[1]} -lt $${GO_VERSION_REQ[1]} ||\
( $${GO_VERSION_ARR[1]} -eq $${GO_VERSION_REQ[1]} && $${GO_VERSION_ARR[2]} -lt $${GO_VERSION_REQ[2]} )))\
]]; then\
echo "SDA requires go $${GO_VERSION_MIN} to build; found $${GO_VERSION}."; \
exit 1; \
fi; \
echo "GO version: $${GO_VERSION}."
docker-version-check:
@DOCKER_VERSION=$$(docker version -f "{{.Server.Version}}" | cut -d'.' -f 1); \
DOCKER_COMPOSE_VERSION=$$(docker compose version | cut -d'v' -f 3 | cut -d'.' -f 1); \
if [ $${DOCKER_VERSION} -lt 24 ]; then \
echo "Docker version less than 24 can't continue"; \
exit 1;\
fi; \
if [ $${DOCKER_COMPOSE_VERSION} -lt 2 ]; then \
echo "Docker compose version less than 2 can't continue"; \
exit 1;\
fi; \
if [ ! $$(docker buildx version | cut -d' ' -f 2) ]; then \
echo "Docker buildx does not exist can't continue"; \
exit 1;\
fi; \
echo "Docker version: $${DOCKER_VERSION}."; \
echo "Docker Compose version: $${DOCKER_COMPOSE_VERSION}."
# bring up the services
sda-s3-up:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml up -d
sda-posix-up:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml up -d
sda-sync-up:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml up -d
# bring down the services
sda-s3-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml down -v --remove-orphans
sda-posix-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml down -v --remove-orphans
sda-sync-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml down -v --remove-orphans
# run intrgration tests, same as being run in Github Actions during a PR
integrationtest-postgres: build-postgresql
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/postgres.yml run tests
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/postgres.yml down -v --remove-orphans
integrationtest-postgres-run: build-postgresql
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/postgres.yml run tests
integrationtest-postgres-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/postgres.yml down -v --remove-orphans
integrationtest-rabbitmq: build-rabbitmq build-sda
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/rabbitmq-federation.yml run federation_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/rabbitmq-federation.yml down -v --remove-orphans
integrationtest-sda: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml down -v --remove-orphans
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml down -v --remove-orphans
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml down -v --remove-orphans
integrationtest-sda-posix: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml down -v --remove-orphans
integrationtest-sda-posix-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml run integration_test
integrationtest-sda-posix-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-posix-integration.yml down -v --remove-orphans
integrationtest-sda-s3: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml down -v --remove-orphans
integrationtest-sda-s3-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml run integration_test
integrationtest-sda-s3-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-s3-integration.yml down -v --remove-orphans
integrationtest-sda-sync: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml down -v --remove-orphans
integrationtest-sda-sync-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml run integration_test
integrationtest-sda-sync-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-sync-integration.yml down -v --remove-orphans
integrationtest-sda-doa-posix: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-posix-outbox.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-posix-outbox.yml down -v --remove-orphans
integrationtest-sda-doa-posix-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-posix-outbox.yml run integration_test
integrationtest-sda-doa-posix-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-posix-outbox.yml down -v --remove-orphans
integrationtest-sda-doa-s3: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-s3-outbox.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-s3-outbox.yml down -v --remove-orphans
integrationtest-sda-doa-s3-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-s3-outbox.yml run integration_test
integrationtest-sda-doa-s3-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-doa-s3-outbox.yml down -v --remove-orphans
integrationtest-sda-validator-orchestrator: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-validator-orchestrator-integration.yml run integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-validator-orchestrator-integration.yml down -v --remove-orphans
integrationtest-sda-validator-orchestrator-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-validator-orchestrator-integration.yml run integration_test
integrationtest-sda-validator-orchestrator-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-validator-orchestrator-integration.yml down -v --remove-orphans
# Download v2 integration tests (sda/cmd/download, Go-based)
# Prerequisite: run `make build-all` first if container images are not already built.
integrationtest-sda-download-v2:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml up -d
@sleep 10
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml run --rm integration_test
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml down -v --remove-orphans
integrationtest-sda-download-v2-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml run --rm integration_test
integrationtest-sda-download-v2-up: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml up -d
integrationtest-sda-download-v2-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-download-v2-integration.yml down -v --remove-orphans
# Lightweight dev stack for download API v2 (webapp development)
dev-download-v2-up: build-all
@PR_NUMBER=$$(date +%F) docker compose -f dev-tools/download-v2-dev/compose.yml up -d
@echo ""
@echo "Download API v2 ready at http://localhost:8085"
@echo "Get a token: TOKEN=\$$(curl -s http://localhost:8000/tokens | jq -r '.[0]')"
@echo "Try it: curl -H \"Authorization: Bearer \$$TOKEN\" http://localhost:8085/datasets"
dev-download-v2-down:
@PR_NUMBER=$$(date +%F) docker compose -f dev-tools/download-v2-dev/compose.yml down -v --remove-orphans
# Download benchmark (compares old vs new public endpoints)
# Uses sda-benchmark.yml which extends sda-s3-integration.yml with benchmark services
# The benchmark runs in a container with auto-configuration from the environment
benchmark-download-up: build-all
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-benchmark.yml up -d
benchmark-download-run:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-benchmark.yml --profile benchmark run --rm benchmark
benchmark-download-run-validated:
@PR_NUMBER=$$(date +%F) BENCHMARK_MODE=validated-payload docker compose -f .github/integration/sda-benchmark.yml --profile benchmark run --rm benchmark
benchmark-download-down:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-benchmark.yml down --remove-orphans
# Force cleanup of benchmark resources.
# NOTE: intentionally scoped to the benchmark compose file; avoid broad name-based container deletes.
benchmark-download-clean:
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-benchmark.yml down -v --remove-orphans
# Seed only the minimal data needed for benchmarking (uses simpler benchmark-specific script)
benchmark-download-seed:
@echo "Seeding minimal test data for benchmark..."
@PR_NUMBER=$$(date +%F) docker compose -f .github/integration/sda-benchmark.yml run --rm integration_test /scripts/seed_benchmark_data.sh
benchmark-download:
@$(MAKE) benchmark-download-clean
@$(MAKE) benchmark-download-up
@echo "Waiting for services to become healthy..."
@printf " waiting for download..."; retries=0; \
until curl -sf http://localhost:$$(docker port download 8080 | head -1 | cut -d: -f2)/health/ready > /dev/null 2>&1; do \
retries=$$((retries + 1)); if [ $$retries -ge 60 ]; then echo " TIMEOUT"; exit 1; fi; sleep 1; done; echo " ok"
@printf " waiting for download-old..."; retries=0; \
until curl -sf http://localhost:$$(docker port download-old 8080 | head -1 | cut -d: -f2)/health > /dev/null 2>&1; do \
retries=$$((retries + 1)); if [ $$retries -ge 60 ]; then echo " TIMEOUT"; exit 1; fi; sleep 1; done; echo " ok"
@$(MAKE) benchmark-download-seed
@echo "Running benchmark..."
@$(MAKE) benchmark-download-run
@$(MAKE) benchmark-download-down
benchmark-download-validated:
@$(MAKE) benchmark-download-clean
@$(MAKE) benchmark-download-up
@echo "Waiting for services to become healthy..."
@printf " waiting for download..."; retries=0; \
until curl -sf http://localhost:$$(docker port download 8080 | head -1 | cut -d: -f2)/health/ready > /dev/null 2>&1; do \
retries=$$((retries + 1)); if [ $$retries -ge 60 ]; then echo " TIMEOUT"; exit 1; fi; sleep 1; done; echo " ok"
@printf " waiting for download-old..."; retries=0; \
until curl -sf http://localhost:$$(docker port download-old 8080 | head -1 | cut -d: -f2)/health > /dev/null 2>&1; do \
retries=$$((retries + 1)); if [ $$retries -ge 60 ]; then echo " TIMEOUT"; exit 1; fi; sleep 1; done; echo " ok"
@$(MAKE) benchmark-download-seed
@echo "Running validated benchmark..."
@$(MAKE) benchmark-download-run-validated
@$(MAKE) benchmark-download-down
# lint go code
lint-all: lint-sda lint-sda-download lint-sda-admin
lint-sda:
@echo 'Running golangci-lint in the `sda` folder'
@cd sda && golangci-lint run
lint-sda-download:
@echo 'Running golangci-lint in the `sda-download` folder'
@cd sda-download && golangci-lint run
lint-sda-admin:
@echo 'Running golangci-lint in the `sda-admin` folder'
@cd sda-admin && golangci-lint run
# run static code tests
test-all: test-sda test-sda-download test-sda-sftp-inbox
test-sda:
@cd sda && go test ./... -count=1
test-sda-download:
@cd sda-download && go test ./... -count=1
test-sda-sftp-inbox:
@docker run --rm -v ./sda-sftp-inbox:/inbox maven:3.9.4-eclipse-temurin-21-alpine sh -c "cd /inbox && mvn test -B"
test-sda-admin:
@cd sda-admin && go test ./... -count=1
# local k8s with k3d
k3d-version-check: SHELL:=/bin/bash
k3d-version-check:
@K3D_VERSION=$$(k3d version | cut -d'v' -f 3 | head -n 1); \
IFS="." read -r -a K3D_VERSION_ARR <<< "$${K3D_VERSION}"; \
IFS="." read -r -a K3D_VERSION_REQ <<< 5.8.0; \
if [[ $${K3D_VERSION_ARR[0]} -lt $${K3D_VERSION_REQ[0]} ||\
( $${K3D_VERSION_ARR[0]} -eq $${K3D_VERSION_REQ[0]} &&\
( $${K3D_VERSION_ARR[1]} -lt $${K3D_VERSION_REQ[1]} ||\
( $${K3D_VERSION_ARR[1]} -eq $${K3D_VERSION_REQ[1]} && $${K3D_VERSION_ARR[2]} -lt $${K3D_VERSION_REQ[2]} )))\
]]; then\
echo "Helm chart testing requires k3d $${K3D_VERSION_MIN}.";\
exit 1;\
fi; \
echo "detected k3d version: $${K3D_VERSION}"
@if [ ! $$(command -v kubectl) ]; then\
echo "kubectl is missing";\
fi
k3d-create-cluster:
@k3d cluster create --agents 2 --image rancher/k3s:v1.34.2-k3s1 \
--port "80:80@loadbalancer" \
--port "443:443@loadbalancer"
k3d-delete-cluster:
@k3d cluster delete
k3d-deploy-dependencies-federated:
@bash .github/integration/scripts/charts/dependencies.sh local federated
k3d-deploy-dependencies-isolated:
@bash .github/integration/scripts/charts/dependencies.sh local isolated
k3d-deploy-dependencies-s3:
@bash .github/integration/scripts/charts/dependencies.sh local s3 false
k3d-deploy-dependencies-s3-tls:
@bash .github/integration/scripts/charts/dependencies.sh local s3 true
k3d-import-images: build-all
@bash .github/integration/scripts/charts/import_local_images.sh k3s-default
k3d-deploy-postgres:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-db "$$(date +%F)" false
k3d-deploy-postgres-tls:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-db "$$(date +%F)" true
k3d-deploy-rabbitmq-federated:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-mq "$$(date +%F)" false federated
k3d-deploy-rabbitmq-isolated:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-mq "$$(date +%F)" false isolated
k3d-deploy-rabbitmq-isolated-tls:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-mq "$$(date +%F)" true isolated
k3d-deploy-sda-s3-federated:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-svc "$$(date +%F)" false s3 federated
k3d-deploy-sda-s3-isolated:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-svc "$$(date +%F)" false s3 isolated
k3d-deploy-sda-s3-isolated-tls:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-svc "$$(date +%F)" true s3 isolated
k3d-deploy-sda-posix:
@bash .github/integration/scripts/charts/deploy_charts.sh sda-svc "$$(date +%F)" false posix
k3d-cleanup-all-deployments:
@bash .github/integration/scripts/charts/cleanup.sh