-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathMakefile
More file actions
549 lines (450 loc) · 20.5 KB
/
Makefile
File metadata and controls
549 lines (450 loc) · 20.5 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
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
# Main binary configuration
CMD ?= beyla
JAVA_AGENT ?= obi-java-agent.jar
MAIN_GO_FILE ?= cmd/$(CMD)/main.go
# populated from go.mod replace, as you might need to temporarily change it during development
OBI_MODULE ?= $(shell sh -c "echo $$(grep 'replace go.opentelemetry.io/obi =>' go.mod | awk '{print $$4}')")
CACHE_CMD ?= k8s-cache
CACHE_MAIN_GO_FILE ?= cmd/$(CACHE_CMD)/main.go
GOOS ?= linux
GOARCH ?= amd64
# RELEASE_VERSION will contain the tag name, or the branch name if current commit is not a tag
RELEASE_VERSION := $(shell git describe --all | cut -d/ -f2)
RELEASE_REVISION := $(shell git rev-parse --short HEAD )
BUILDINFO_PKG ?= github.com/grafana/beyla/v3/pkg/buildinfo
TEST_OUTPUT ?= ./testoutput
IMG_REGISTRY ?= docker.io
# Set your registry username. You mustn't use 'grafana' for manual pushing.
IMG_ORG ?= grafana
IMG_NAME ?= beyla
# Container image creation
VERSION ?= dev
IMG = $(IMG_REGISTRY)/$(IMG_ORG)/$(IMG_NAME):$(VERSION)
# Override the value in `release-*` branches to a compatible version
GEN_IMG_VERSION=latest
# The generator is a container image that provides a reproducible environment for
# building eBPF binaries
GEN_IMG ?= ghcr.io/open-telemetry/obi-generator:$(GEN_IMG_VERSION)
COMPOSE_ARGS ?= -f internal/testgenerated/integration/docker-compose.yml
OCI_BIN ?= docker
# BPF code generator dependencies
CLANG ?= clang
CFLAGS := -O2 -g -Wunaligned-access -Wpacked -Wpadded -Wall -Werror $(CFLAGS)
CLANG_TIDY ?= clang-tidy
CILIUM_EBPF_VER ?= $(call gomod-version,cilium/ebpf)
# regular expressions for excluded file patterns
EXCLUDE_COVERAGE_FILES="(_bpfel.go)|(/beyla/v2/internal/test/)|(/beyla/v2/configs/)|(/v2/examples/)|(.pb.go)|(/beyla/v2/pkg/export/otel/metric/)"
.DEFAULT_GOAL := all
# go-install-tool will 'go install' any package $2 and install it locally to $1.
# This will prevent that they are installed in the $USER/go/bin folder and different
# projects ca have different versions of the tools
PROJECT_DIR := $(shell dirname $(abspath $(firstword $(MAKEFILE_LIST))))
TOOLS_DIR ?= $(PROJECT_DIR)/bin
# $(1) command name
# $(2) repo URL
# $(3) version
define go-install-tool
@[ -f "$(1)-$(3)" ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Removing any outdated version of $(1)";\
rm -f $(1)*;\
echo "Downloading $(2)@$(3)" ;\
GOBIN=$(TOOLS_DIR) GOFLAGS="-mod=mod" go install "$(2)@$(3)" ;\
touch "$(1)-$(3)";\
rm -rf $$TMP_DIR ;\
}
endef
# gomod-version returns the version number of the go.mod dependency
define gomod-version
$(shell sh -c "echo $$(grep $(1) go.mod | awk '{print $$2}')")
endef
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))
# prereqs binary dependencies
GOLANGCI_LINT = $(TOOLS_DIR)/golangci-lint
BPF2GO = $(TOOLS_DIR)/bpf2go
GO_OFFSETS_TRACKER = $(TOOLS_DIR)/go-offsets-tracker
GO_LICENSES = $(TOOLS_DIR)/go-licenses
KIND = $(TOOLS_DIR)/kind
DASHBOARD_LINTER = $(TOOLS_DIR)/dashboard-linter
GINKGO = $(TOOLS_DIR)/ginkgo
GOTESTSUM = $(TOOLS_DIR)/gotestsum
# Required for k8s-cache unit tests
ENVTEST = $(TOOLS_DIR)/setup-envtest
ENVTEST_K8S_VERSION = 1.30.0
.PHONY: obi-submodule
obi-submodule:
@echo "# Updating OBI Git submodule..."
git submodule update --init --recursive
.PHONY: install-hooks
install-hooks:
@if [ ! -f .git/hooks/pre-commit ]; then \
echo "Installing pre-commit hook..."; \
cp hooks/pre-commit .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit; \
echo "Pre-commit hook installed."; \
fi
.PHONY: bpf2go
bpf2go:
$(call go-install-tool,$(BPF2GO),github.com/cilium/ebpf/cmd/bpf2go,$(call gomod-version,cilium/ebpf))
.PHONY: prereqs
prereqs: install-hooks bpf2go
@echo "### Check if prerequisites are met, and installing missing dependencies"
mkdir -p $(TEST_OUTPUT)/run
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/v2/cmd/golangci-lint,v2.4.0)
$(call go-install-tool,$(GO_OFFSETS_TRACKER),github.com/grafana/go-offsets-tracker/cmd/go-offsets-tracker,$(call gomod-version,grafana/go-offsets-tracker))
$(call go-install-tool,$(GO_LICENSES),github.com/google/go-licenses/v2,v2.0.1)
$(call go-install-tool,$(KIND),sigs.k8s.io/kind,v0.20.0)
$(call go-install-tool,$(DASHBOARD_LINTER),github.com/grafana/dashboard-linter,latest)
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,latest)
$(call go-install-tool,$(GOTESTSUM),gotest.tools/gotestsum,v1.13.0)
.PHONY: fmt
fmt: prereqs
@echo "### Formatting code and fixing imports"
$(GOLANGCI_LINT) fmt
.PHONY: checkfmt
checkfmt:
@echo '### check correct formatting and imports'
@if [ "$(strip $(check_format))" != "" ]; then \
echo "$(check_format)"; \
echo "Above files are not properly formatted. Run 'make fmt' to fix them"; \
exit 1; \
fi
.PHONY: clang-tidy
clang-tidy:
cd bpf && find . -type f \( -name '*.c' -o -name '*.h' \) ! -path "./bpfcore/*" | xargs clang-tidy
.PHONY: lint-dashboard
lint-dashboard: prereqs
@echo "### Linting dashboard";
@if [ "$(shell sh -c 'git ls-files --modified | grep grafana/*.json ')" != "" ]; then \
for file in grafana/*.json; do \
$(DASHBOARD_LINTER) lint --strict $$file; \
done; \
else \
echo '(no git changes detected. Skipping)'; \
fi
.PHONY: lint
lint: prereqs checkfmt
@echo "### Linting code"
$(GOLANGCI_LINT) run ./... --timeout=6m
.PHONY: update-offsets
update-offsets: prereqs
@echo "### Updating pkg/internal/goexec/offsets.json"
$(GO_OFFSETS_TRACKER) -i configs/offsets/tracker_input.json pkg/internal/goexec/offsets.json
.PHONY: generate
generate: obi-submodule
@echo "### Generating files..."
@cd $(OBI_MODULE) && make generate
.PHONY: docker-generate
docker-generate: obi-submodule
@echo "### Generating files (submodule: $(OBI_MODULE))"
@cd $(OBI_MODULE) && make docker-generate
.PHONY: copy-obi-vendor
copy-obi-vendor: vendor-obi-tests
@echo "### Vendoring OBI submodule..."
go get go.opentelemetry.io/obi
go mod tidy
go mod vendor
.PHONY: vendor-obi-tests
vendor-obi-tests:
@echo "### Vendoring OBI test dependencies..."
go get -t ./internal/testgenerated/integration/...
go mod tidy
go mod vendor
.PHONY: vendor-obi
vendor-obi: obi-submodule docker-generate generate-obi-tests copy-obi-vendor
.PHONY: verify
verify: prereqs lint-dashboard vendor-obi lint test
.PHONY: build
build: vendor-obi verify compile
.PHONY: all
all: vendor-obi build
.PHONY: compile compile-cache
compile:
@echo "### Compiling Beyla"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -ldflags="-X '$(BUILDINFO_PKG).Version=$(RELEASE_VERSION)' -X '$(BUILDINFO_PKG).Revision=$(RELEASE_REVISION)'" -a -o bin/$(CMD) $(MAIN_GO_FILE)
compile-cache:
@echo "### Compiling Beyla K8s cache"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -ldflags="-X '$(BUILDINFO_PKG).Version=$(RELEASE_VERSION)' -X '$(BUILDINFO_PKG).Revision=$(RELEASE_REVISION)'" -a -o bin/$(CACHE_CMD) $(CACHE_MAIN_GO_FILE)
.PHONY: debug
debug:
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -gcflags "-N -l" -ldflags="-X '$(BUILDINFO_PKG).Version=$(RELEASE_VERSION)' -X '$(BUILDINFO_PKG).Revision=$(RELEASE_REVISION)'" -a -o bin/$(CMD) $(MAIN_GO_FILE)
.PHONY: dev
dev: prereqs generate compile-for-coverage
# Generated binary can provide coverage stats according to https://go.dev/blog/integration-test-coverage
.PHONY: compile-for-coverage compile-cache-for-coverage
compile-for-coverage:
@echo "### Compiling project to generate coverage profiles"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -ldflags="-X '$(BUILDINFO_PKG).Version=test-$(RELEASE_VERSION)' -X '$(BUILDINFO_PKG).Revision=test-$(RELEASE_REVISION)'" -cover -a -o bin/$(CMD) $(MAIN_GO_FILE)
compile-cache-for-coverage:
@echo "### Compiling K8s cache service to generate coverage profiles"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -mod vendor -cover -a -o bin/$(CACHE_CMD) $(CACHE_MAIN_GO_FILE)
# Java agent targets
JAVA_AGENT_DIR := .obi-src/pkg/internal/java
JAVA_AGENT_EMBED_DIR := vendor/go.opentelemetry.io/obi/pkg/internal/java/embedded
.PHONY: java-build
java-build:
@echo "### Building Java agent"
mkdir -p $(JAVA_AGENT_EMBED_DIR)
cd $(JAVA_AGENT_DIR) && gradle build
cp $(JAVA_AGENT_DIR)/build/$(JAVA_AGENT) $(JAVA_AGENT_EMBED_DIR)/$(JAVA_AGENT)
.PHONY: java-docker-build
java-docker-build:
@echo "### Building Java agent with Docker"
mkdir -p $(JAVA_AGENT_EMBED_DIR)
$(OCI_BIN) build --output type=local,dest=$(JAVA_AGENT_EMBED_DIR) --target=export -f javaagent.Dockerfile .
.PHONY: java-test
java-test:
@echo "### Testing Java agent"
cd $(JAVA_AGENT_DIR) && gradle test
.PHONY: java-spotless-check
java-spotless-check:
@echo "### Checking Java code formatting"
cd $(JAVA_AGENT_DIR) && gradle spotlessCheck
.PHONY: java-spotless-apply
java-spotless-apply:
@echo "### Formatting Java code"
cd $(JAVA_AGENT_DIR) && gradle spotlessApply
.PHONY: java-clean
java-clean:
@echo "### Cleaning Java agent build artifacts"
cd $(JAVA_AGENT_DIR) && gradle clean
.PHONY: java-verify
java-verify: java-spotless-check java-test java-build
.PHONY: test
test:
@echo "### Testing code"
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" go test -race -mod vendor -a ./... -coverpkg=./... -coverprofile $(TEST_OUTPUT)/cover.all.txt
.PHONY: test-privileged
test-privileged:
@echo "### Testing code with privileged tests enabled"
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" PRIVILEGED_TESTS=true go test -race -mod vendor -a ./... -coverpkg=./... -coverprofile $(TEST_OUTPUT)/cover.all.txt
.PHONY: helm-unittest
helm-unittest:
@echo "### Running Helm chart unit tests"
$(OCI_BIN) run --rm -v "$(PROJECT_DIR):/apps" -w /apps -u "$$(id -u)" helmunittest/helm-unittest -f charts/beyla/tests/unit/*.yaml charts/beyla
.PHONY: helm-docs
helm-docs:
@echo "### Generating Helm chart documentation"
cd charts && $(OCI_BIN) run --rm --volume "$$(pwd):/helm-docs" -u "$$(id -u)" jnorwood/helm-docs:v1.13.1
.PHONY: cov-exclude-generated
cov-exclude-generated:
grep -vE $(EXCLUDE_COVERAGE_FILES) $(TEST_OUTPUT)/cover.all.txt > $(TEST_OUTPUT)/cover.txt
.PHONY: cov-exclude-generated-shard
cov-exclude-generated-shard:
grep -vE $(EXCLUDE_COVERAGE_FILES) $(TEST_OUTPUT)/cover-shard-$(SHARD_ID).all.txt > $(TEST_OUTPUT)/cover-shard-$(SHARD_ID).txt
.PHONY: unit-test-matrix-json
unit-test-matrix-json:
@go list -mod vendor ./... | grep -v /internal/testgenerated/ | $(GOTESTSUM) tool ci-matrix --partitions $${PARTITIONS:-3} --timing-files=$(TEST_OUTPUT)/unit-test-shard-*.log
.PHONY: run-unit-test-shard
run-unit-test-shard:
@echo "### Running unit test shard $(SHARD_ID)"
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path)" \
$(GOTESTSUM) \
--jsonfile=$(TEST_OUTPUT)/unit-test-shard-$(SHARD_ID).log \
-- -race -mod vendor -a -coverpkg=./... \
-coverprofile $(TEST_OUTPUT)/cover-shard-$(SHARD_ID).all.txt \
$(UNIT_TEST_PACKAGES)
.PHONY: coverage-report
coverage-report: cov-exclude-generated
@echo "### Generating coverage report"
go tool cover --func=$(TEST_OUTPUT)/cover.txt
.PHONY: coverage-report-html
coverage-report-html: cov-exclude-generated
@echo "### Generating HTML coverage report"
go tool cover --html=$(TEST_OUTPUT)/cover.txt
.PHONY: image-build
image-build: vendor-obi
$(call check_defined, IMG_ORG, Your Docker repository user name)
@echo "### Building the auto-instrumenter image"
$(OCI_BIN) buildx build --build-arg GEN_IMG="$(GEN_IMG)" --platform linux/amd64,linux/arm64 -t ${IMG} .
.PHONY: dev-image-build
dev-image-build: vendor-obi
$(call check_defined, IMG_ORG, Your Docker repository user name)
@echo "### Building the auto-instrumenter dev image"
$(OCI_BIN) buildx build --build-arg GEN_IMG="$(GEN_IMG)" --build-arg DEV_OBI=1 -t ${IMG} .
.PHONY: prepare-integration-test
prepare-integration-test: vendor-obi
@echo "### Removing resources from previous integration tests, if any"
rm -rf $(TEST_OUTPUT)/* || true
$(MAKE) cleanup-integration-test
.PHONY: cleanup-integration-test
cleanup-integration-test:
@echo "### Removing integration test clusters"
$(KIND) delete cluster -n test-kind-cluster || true
@echo "### Removing docker containers and images"
$(OCI_BIN) compose $(COMPOSE_ARGS) stop || true
$(OCI_BIN) compose $(COMPOSE_ARGS) rm -f || true
$(OCI_BIN) rm -f $(shell $(OCI_BIN) ps --format '{{.Names}}' | grep 'integration-') || true
$(OCI_BIN) rmi -f $(shell $(OCI_BIN) images --format '{{.Repository}}:{{.Tag}}' | grep 'hatest-') || true
.PHONY: run-integration-test
run-integration-test:
@echo "### Running integration tests"
go clean -testcache
go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./internal/testgenerated/integration --tags=integration
.PHONY: run-integration-test-k8s
run-integration-test-k8s:
@echo "### Running K8s integration tests"
go clean -testcache
go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./internal/testgenerated/integration/k8s/... --tags=integration
.PHONY: run-integration-test-vm
run-integration-test-vm:
@echo "### Running integration tests (pattern: $(TEST_PATTERN))"
@TEST_TIMEOUT="60m"; \
TEST_PARALLEL="1"; \
if [ -f "/precompiled-tests/integration.test" ]; then \
echo "Using pre-compiled integration tests"; \
chmod +x /precompiled-tests/integration.test; \
/precompiled-tests/integration.test \
-test.parallel=$$TEST_PARALLEL \
-test.timeout=$$TEST_TIMEOUT \
-test.failfast \
-test.v \
-test.run="^($(TEST_PATTERN))\$$"; \
else \
echo "Pre-compiled tests not found, compiling in VM"; \
go test \
-p $$TEST_PARALLEL \
-timeout $$TEST_TIMEOUT \
-failfast \
-v -a \
-mod vendor \
-tags=integration \
-run="^($(TEST_PATTERN))\$$" ./internal/testgenerated/integration; \
fi
.PHONY: run-integration-test-arm
run-integration-test-arm:
@echo "### Running integration tests (ARM)"
go clean -testcache
go test -p 1 -failfast -v -timeout 90m -mod vendor -a ./internal/testgenerated/integration --tags=integration -run "^TestMultiProcess"
.PHONY: integration-test-matrix-json
integration-test-matrix-json:
@./scripts/generate-integration-matrix.sh "$${TEST_TAGS:-integration}" internal/testgenerated/integration "$${PARTITIONS:-5}"
.PHONY: vm-integration-test-matrix-json
vm-integration-test-matrix-json:
@./scripts/generate-integration-matrix.sh "$${TEST_TAGS:-integration}" internal/testgenerated/integration "$${PARTITIONS:-3}" "TestMultiProcess"
.PHONY: k8s-integration-test-matrix-json
k8s-integration-test-matrix-json:
@./scripts/generate-dir-matrix.sh internal/testgenerated/integration/k8s common
.PHONY: oats-integration-test-matrix-json
oats-integration-test-matrix-json:
@./scripts/generate-dir-matrix.sh internal/testgenerated/oats
.PHONY: beyla-integration-test-matrix-json
beyla-integration-test-matrix-json:
@WEIGHTS_FILE=scripts/beyla-integration-test-weights.generated.json \
./scripts/generate-integration-matrix.sh "$${TEST_TAGS:-integration}" internal/test/integration "$${PARTITIONS:-5}"
.PHONY: run-beyla-integration-test
run-beyla-integration-test:
@echo "### Running Beyla integration tests"
go clean -testcache
go test -p 1 -failfast -v -timeout 60m -mod vendor -a ./internal/test/integration --tags=integration
.PHONY: integration-test
integration-test: prereqs generate-obi-tests prepare-integration-test
$(MAKE) run-integration-test || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret)
$(MAKE) itest-coverage-data
$(MAKE) cleanup-integration-test
.PHONY: integration-test-k8s
integration-test-k8s: prereqs generate-obi-tests prepare-integration-test
$(MAKE) run-integration-test-k8s || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret)
$(MAKE) itest-coverage-data
$(MAKE) cleanup-integration-test
.PHONY: integration-test-arm
integration-test-arm: prereqs generate-obi-tests prepare-integration-test
$(MAKE) run-integration-test-arm || (ret=$$?; $(MAKE) cleanup-integration-test && exit $$ret)
$(MAKE) itest-coverage-data
$(MAKE) cleanup-integration-test
.PHONY: generate-obi-tests
generate-obi-tests:
@echo "### Generating OBI integration tests from .obi-src"
./scripts/generate-obi-tests.sh
.PHONY: clean-obi-tests
clean-obi-tests:
@echo "### Cleaning generated OBI tests"
./scripts/generate-obi-tests.sh --clean
.PHONY: itest-coverage-data
itest-coverage-data:
# merge coverage data from all the integration tests
mkdir -p $(TEST_OUTPUT)/merge
go tool covdata merge -i=$(TEST_OUTPUT) -o $(TEST_OUTPUT)/merge
go tool covdata textfmt -i=$(TEST_OUTPUT)/merge -o $(TEST_OUTPUT)/itest-covdata.raw.txt
# replace the unexpected /src/cmd/beyla/main.go file by the module path
sed 's/^\/src\/cmd\//github.com\/grafana\/beyla\/cmd\//' $(TEST_OUTPUT)/itest-covdata.raw.txt > $(TEST_OUTPUT)/itest-covdata.all.txt
# exclude generated files from coverage data
grep -vE $(EXCLUDE_COVERAGE_FILES) $(TEST_OUTPUT)/itest-covdata.all.txt > $(TEST_OUTPUT)/itest-covdata.txt
bin/ginkgo:
$(call go-install-tool,$(GINKGO),github.com/onsi/ginkgo/v2/ginkgo,latest)
.PHONY: oats-prereq
oats-prereq: bin/ginkgo vendor-obi
mkdir -p $(TEST_OUTPUT)/run
.PHONY: oats-test-sql
oats-test-sql: oats-prereq
mkdir -p internal/testgenerated/oats/sql/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/sql && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test-redis
oats-test-redis: oats-prereq
mkdir -p internal/testgenerated/oats/redis/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/redis && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test-kafka
oats-test-kafka: oats-prereq
mkdir -p internal/testgenerated/oats/kafka/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/kafka && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test-http
oats-test-http: oats-prereq
mkdir -p internal/testgenerated/oats/http/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/http && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test-mongo
oats-test-mongo: oats-prereq
mkdir -p internal/testgenerated/oats/mongo/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/mongo && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test-ai
oats-test-ai: oats-prereq
mkdir -p internal/testgenerated/oats/ai/$(TEST_OUTPUT)/run
cd internal/testgenerated/oats/ai && TESTCASE_TIMEOUT=5m TESTCASE_BASE_PATH=./yaml $(GINKGO) -v -r
.PHONY: oats-test
oats-test: oats-test-sql oats-test-mongo oats-test-redis oats-test-kafka oats-test-http oats-test-ai
$(MAKE) itest-coverage-data
.PHONY: oats-test-debug
oats-test-debug: oats-prereq
cd internal/testgenerated/oats/kafka && TESTCASE_BASE_PATH=./yaml TESTCASE_MANUAL_DEBUG=true TESTCASE_TIMEOUT=1h $(GINKGO) -v -r
.PHONY: update-licenses check-license
update-licenses: prereqs generate-obi-tests
@echo "### Updating third_party_licenses.csv"
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GO_LICENSES) report --ignore testing --ignore debug --ignore expvar --ignore structs --ignore go --ignore html --ignore text --ignore compress --ignore mime --ignore database --ignore unique --ignore vendor/golang.org --ignore hash --ignore embed --ignore flag --ignore weak --ignore cmp --ignore net --ignore context --ignore bufio --ignore container --ignore crypto --ignore iter --ignore path --ignore strconv --ignore strings --ignore encoding --ignore reflect --ignore fmt --ignore log --ignore maps --ignore errors --ignore io --ignore slices --ignore runtime --ignore syscall --ignore time --ignore sync --ignore sort --ignore bytes --ignore os --ignore regex --ignore internal --ignore math --ignore unicode --ignore go.opentelemetry.io/obi ./... 2>/dev/null | sed 's/\r$$//' > third_party_licenses.csv
check-licenses: update-licenses
@echo "### Checking third party licenses"
@if [ "$(strip $(shell git diff HEAD third_party_licenses.csv))" != "" ]; then \
echo "### Diff for third_party_licenses.csv"; \
git --no-pager diff -- third_party_licenses.csv; \
echo "ERROR: third_party_licenses.csv is not up to date. Run 'make update-licenses' and push the changes to your PR"; \
exit 1; \
fi
.PHONY: artifact
artifact: vendor-obi compile
@echo "### Packing generated artifact"
cp LICENSE ./bin
cp NOTICE ./bin
cp third_party_licenses.csv ./bin
tar -C ./bin -cvzf bin/beyla.tar.gz beyla LICENSE NOTICE third_party_licenses.csv
.PHONY: clean-testoutput
clean-testoutput:
@echo "### Cleaning ${TEST_OUTPUT} folder"
rm -rf ${TEST_OUTPUT}/*
.PHONY: clang-format
clang-format:
find ./bpf -type f -name "*.c" | xargs -P 0 -n 1 clang-format -i
find ./bpf -type f -name "*.h" | xargs -P 0 -n 1 clang-format -i
.PHONY: clean-ebpf-generated-files
clean-ebpf-generated-files:
find . -name "*_bpfel*" | xargs rm