diff --git a/Makefile b/Makefile index f979fa3e4f0..7af029d1a51 100644 --- a/Makefile +++ b/Makefile @@ -3,20 +3,14 @@ SHELL := /bin/bash JAEGER_IMPORT_PATH = github.com/jaegertracing/jaeger -STORAGE_PKGS = ./plugin/storage/integration/... -JAEGER_V2_STORAGE_PKGS = ./cmd/jaeger/internal/integration -# These DOCKER_xxx vars are used when building Docker images. -DOCKER_NAMESPACE?=jaegertracing -DOCKER_TAG?=latest +# PLATFORMS is a list of all supported platforms +PLATFORMS="linux/amd64,linux/arm64,linux/s390x,linux/ppc64le,darwin/amd64,darwin/arm64,windows/amd64" +LINUX_PLATFORMS=$(shell echo "$(PLATFORMS)" | tr ',' '\n' | grep linux | tr '\n' ',' | sed 's/,$$/\n/') # SRC_ROOT is the top of the source tree. SRC_ROOT := $(shell git rev-parse --show-toplevel) -# TODO we can compartmentalize this Makefile better, by separting: -# - integration tests -# - all the binary building targets - ifeq ($(DEBUG_BINARY),) DISABLE_OPTIMIZATIONS = SUFFIX = @@ -67,7 +61,6 @@ SED=sed GO=go GOOS ?= $(shell $(GO) env GOOS) GOARCH ?= $(shell $(GO) env GOARCH) -GOBUILD=CGO_ENABLED=0 installsuffix=cgo $(GO) build -trimpath GOTEST_QUIET=$(GO) test $(RACE) GOTEST=$(GOTEST_QUIET) -v COVEROUT=cover.out @@ -77,9 +70,11 @@ IMPORT_LOG=.import.log COLORIZE ?= | $(SED) 's/PASS/✅ PASS/g' | $(SED) 's/FAIL/❌ FAIL/g' | $(SED) 's/SKIP/🔕 SKIP/g' # import other Makefiles after the variables are defined -include docker/Makefile +include Makefile.BuildBinaries.mk include Makefile.BuildInfo.mk include Makefile.Crossdock.mk +include Makefile.Docker.mk +include Makefile.IntegrationTests.mk include Makefile.Protobuf.mk include Makefile.Thrift.mk include Makefile.Tools.mk @@ -98,6 +93,14 @@ echo-v1: echo-v2: @echo "$(GIT_CLOSEST_TAG_V2)" +.PHONY: echo-platforms +echo-platforms: + @echo "$(PLATFORMS)" + +.PHONY: echo-linux-platforms +echo-linux-platforms: + @echo "$(LINUX_PLATFORMS)" + .PHONY: echo-all-pkgs echo-all-pkgs: @echo $(ALL_PKGS) | tr ' ' '\n' | sort @@ -112,58 +115,12 @@ clean: jaeger-ui/packages/jaeger-ui/build find ./cmd/query/app/ui/actual -type f -name '*.gz' -delete GOCACHE=$(GOCACHE) go clean -cache -testcache - find cmd -type f -executable | xargs -I{} sh -c '(git ls-files --error-unmatch {} 2>/dev/null || rm -v {})' + bash scripts/clean-binaries.sh .PHONY: test test: bash -c "set -e; set -o pipefail; $(GOTEST) -tags=memory_storage_integration ./... $(COLORIZE)" -.PHONY: all-in-one-integration-test -all-in-one-integration-test: - TEST_MODE=integration $(GOTEST) ./cmd/all-in-one/ - -# A general integration tests for jaeger-v2 storage backends, -# these tests placed at `./cmd/jaeger/internal/integration/*_test.go`. -# The integration tests are filtered by STORAGE env, -# currently the available STORAGE variable is: -# - grpc -.PHONY: jaeger-v2-storage-integration-test -jaeger-v2-storage-integration-test: - (cd cmd/jaeger/ && go build .) - # Expire tests results for jaeger storage integration tests since the environment might change - # even though the code remains the same. - go clean -testcache - bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(JAEGER_V2_STORAGE_PKGS) $(COLORIZE)" - -.PHONY: storage-integration-test -storage-integration-test: - # Expire tests results for storage integration tests since the environment might change - # even though the code remains the same. - go clean -testcache - bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(STORAGE_PKGS) $(COLORIZE)" - -.PHONY: badger-storage-integration-test -badger-storage-integration-test: - STORAGE=badger $(MAKE) storage-integration-test - -.PHONY: grpc-storage-integration-test -grpc-storage-integration-test: - STORAGE=grpc $(MAKE) storage-integration-test - -# this test assumes STORAGE environment variable is set to elasticsearch|opensearch -.PHONY: index-cleaner-integration-test -index-cleaner-integration-test: docker-images-elastic - $(MAKE) storage-integration-test COVEROUT=cover-index-cleaner.out - -# this test assumes STORAGE environment variable is set to elasticsearch|opensearch -.PHONY: index-rollover-integration-test -index-rollover-integration-test: docker-images-elastic - $(MAKE) storage-integration-test COVEROUT=cover-index-rollover.out - -.PHONY: tail-sampling-integration-test -tail-sampling-integration-test: - SAMPLING=tail $(MAKE) jaeger-v2-storage-integration-test - .PHONY: cover cover: nocover bash -c "set -e; set -o pipefail; STORAGE=memory $(GOTEST) -timeout 5m -coverprofile $(COVEROUT) ./... | tee test-results.json" @@ -217,200 +174,10 @@ lint-goleak: lint-go: $(LINT) $(LINT) -v run -.PHONY: build-examples -build-examples: - $(GOBUILD) -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go - -.PHONY: build-tracegen -build-tracegen: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/tracegen/tracegen-$(GOOS)-$(GOARCH) ./cmd/tracegen/ - -.PHONY: build-anonymizer -build-anonymizer: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) ./cmd/anonymizer/ - -.PHONY: build-esmapping-generator -build-esmapping-generator: - $(GOBUILD) $(BUILD_INFO) -o ./plugin/storage/es/esmapping-generator-$(GOOS)-$(GOARCH) ./cmd/esmapping-generator/ - -.PHONY: build-esmapping-generator-linux -build-esmapping-generator-linux: - GOOS=linux $(BUILD_INFO) GOARCH=amd64 $(GOBUILD) -o ./plugin/storage/es/esmapping-generator ./cmd/esmapping-generator/ - -.PHONY: build-es-index-cleaner -build-es-index-cleaner: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/ - -.PHONY: build-es-rollover -build-es-rollover: - $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/ - -.PHONY: docker-hotrod -docker-hotrod: - GOOS=linux $(MAKE) build-examples - docker build -t $(DOCKER_NAMESPACE)/example-hotrod:${DOCKER_TAG} ./examples/hotrod --build-arg TARGETARCH=$(GOARCH) - .PHONY: run-all-in-one run-all-in-one: build-ui go run -tags ui ./cmd/all-in-one --log-level debug -build-ui: cmd/query/app/ui/actual/index.html.gz - -cmd/query/app/ui/actual/index.html.gz: jaeger-ui/packages/jaeger-ui/build/index.html - # do not delete dot-files - rm -rf cmd/query/app/ui/actual/* - cp -r jaeger-ui/packages/jaeger-ui/build/* cmd/query/app/ui/actual/ - find cmd/query/app/ui/actual -type f | grep -v .gitignore | xargs gzip --no-name - # copy the timestamp for index.html.gz from the original file - touch -t $$(date -r jaeger-ui/packages/jaeger-ui/build/index.html '+%Y%m%d%H%M.%S') cmd/query/app/ui/actual/index.html.gz - ls -lF cmd/query/app/ui/actual/ - -jaeger-ui/packages/jaeger-ui/build/index.html: - $(MAKE) rebuild-ui - -.PHONY: rebuild-ui -rebuild-ui: - bash ./scripts/rebuild-ui.sh - @echo "NOTE: This target only rebuilds the UI assets inside jaeger-ui/packages/jaeger-ui/build/." - @echo "NOTE: To make them usable from query-service run 'make build-ui'." - -.PHONY: build-all-in-one-linux -build-all-in-one-linux: - GOOS=linux $(MAKE) build-all-in-one - -# Requires variables: $(BIN_NAME) $(BIN_PATH) $(GO_TAGS) $(DISABLE_OPTIMIZATIONS) $(SUFFIX) $(GOOS) $(GOARCH) $(BUILD_INFO) -# Other targets can depend on this one but with a unique suffix to ensure it is always executed. -BIN_PATH = ./cmd/$(BIN_NAME) -.PHONY: _build-a-binary -_build-a-binary-%: - $(GOBUILD) $(DISABLE_OPTIMIZATIONS) $(GO_TAGS) -o $(BIN_PATH)/$(BIN_NAME)$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) $(BIN_PATH) - -.PHONY: build-jaeger -build-jaeger: BIN_NAME = jaeger -build-jaeger: GO_TAGS = -tags ui -build-jaeger: BUILD_INFO = $(BUILD_INFO_V2) -build-jaeger: build-ui _build-a-binary-jaeger$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-all-in-one -build-all-in-one: BIN_NAME = all-in-one -build-all-in-one: GO_TAGS = -tags ui -build-all-in-one: build-ui _build-a-binary-all-in-one$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-agent -build-agent: BIN_NAME = agent -build-agent: _build-a-binary-agent$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-query -build-query: BIN_NAME = query -build-query: GO_TAGS = -tags ui -build-query: build-ui _build-a-binary-query$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-collector -build-collector: BIN_NAME = collector -build-collector: _build-a-binary-collector$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-ingester -build-ingester: BIN_NAME = ingester -build-ingester: _build-a-binary-ingester$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-remote-storage -build-remote-storage: BIN_NAME = remote-storage -build-remote-storage: _build-a-binary-remote-storage$(SUFFIX)-$(GOOS)-$(GOARCH) - -.PHONY: build-binaries-linux -build-binaries-linux: build-binaries-amd64 - -.PHONY: build-binaries-amd64 -build-binaries-amd64: - GOOS=linux GOARCH=amd64 $(MAKE) _build-platform-binaries - -# helper targets defined in Makefile.Windows.mk -.PHONY: build-binaries-windows -build-binaries-windows: - $(MAKE) _build-syso - GOOS=windows GOARCH=amd64 $(MAKE) _build-platform-binaries - $(MAKE) _clean-syso - -.PHONY: build-binaries-darwin -build-binaries-darwin: - GOOS=darwin GOARCH=amd64 $(MAKE) _build-platform-binaries - -.PHONY: build-binaries-darwin-arm64 -build-binaries-darwin-arm64: - GOOS=darwin GOARCH=arm64 $(MAKE) _build-platform-binaries - -.PHONY: build-binaries-s390x -build-binaries-s390x: - GOOS=linux GOARCH=s390x $(MAKE) _build-platform-binaries - -.PHONY: build-binaries-arm64 -build-binaries-arm64: - GOOS=linux GOARCH=arm64 $(MAKE) _build-platform-binaries - -.PHONY: build-binaries-ppc64le -build-binaries-ppc64le: - GOOS=linux GOARCH=ppc64le $(MAKE) _build-platform-binaries - -# build all binaries for one specific platform GOOS/GOARCH -.PHONY: _build-platform-binaries -_build-platform-binaries: build-agent \ - build-all-in-one \ - build-collector \ - build-query \ - build-ingester \ - build-jaeger \ - build-remote-storage \ - build-examples \ - build-tracegen \ - build-anonymizer \ - build-esmapping-generator \ - build-es-index-cleaner \ - build-es-rollover - $(MAKE) _build-platform-binaries-debug GOOS=$(GOOS) GOARCH=$(GOARCH) DEBUG_BINARY=1 - -# build binaries that support DEBUG release, for one specific platform GOOS/GOARCH -.PHONY: _build-platform-binaries-debug -_build-platform-binaries-debug: build-agent \ - build-collector \ - build-query \ - build-ingester \ - build-remote-storage \ - build-all-in-one \ - -.PHONY: build-all-platforms -build-all-platforms: \ - build-binaries-linux \ - build-binaries-windows \ - build-binaries-darwin \ - build-binaries-darwin-arm64 \ - build-binaries-s390x \ - build-binaries-arm64 \ - build-binaries-ppc64le - -.PHONY: docker-images-cassandra -docker-images-cassandra: - docker build -t $(DOCKER_NAMESPACE)/jaeger-cassandra-schema:${DOCKER_TAG} plugin/storage/cassandra/ - @echo "Finished building jaeger-cassandra-schema ==============" - -.PHONY: docker-images-elastic -docker-images-elastic: create-baseimg - GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-esmapping-generator - GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-es-index-cleaner - GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-es-rollover - docker build -t $(DOCKER_NAMESPACE)/jaeger-es-index-cleaner:${DOCKER_TAG} --build-arg base_image=$(BASE_IMAGE) --build-arg TARGETARCH=$(GOARCH) cmd/es-index-cleaner - docker build -t $(DOCKER_NAMESPACE)/jaeger-es-rollover:${DOCKER_TAG} --build-arg base_image=$(BASE_IMAGE) --build-arg TARGETARCH=$(GOARCH) cmd/es-rollover - @echo "Finished building jaeger-es-indices-clean ==============" - -.PHONY: docker-images-tracegen -docker-images-tracegen: - docker build -t $(DOCKER_NAMESPACE)/jaeger-tracegen:${DOCKER_TAG} cmd/tracegen/ --build-arg TARGETARCH=$(GOARCH) - @echo "Finished building jaeger-tracegen ==============" - -.PHONY: docker-images-anonymizer -docker-images-anonymizer: - docker build -t $(DOCKER_NAMESPACE)/jaeger-anonymizer:${DOCKER_TAG} cmd/anonymizer/ --build-arg TARGETARCH=$(GOARCH) - @echo "Finished building jaeger-anonymizer ==============" - .PHONY: changelog changelog: ./scripts/release-notes.py --exclude-dependabot --verbose diff --git a/Makefile.BuildBinaries.mk b/Makefile.BuildBinaries.mk new file mode 100644 index 00000000000..f82d3d4042d --- /dev/null +++ b/Makefile.BuildBinaries.mk @@ -0,0 +1,179 @@ +# Copyright (c) 2023 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +GOBUILD=CGO_ENABLED=0 installsuffix=cgo $(GO) build -trimpath + +ifeq ($(DEBUG_BINARY),) + DISABLE_OPTIMIZATIONS = + SUFFIX = + TARGET = release +else + DISABLE_OPTIMIZATIONS = -gcflags="all=-N -l" + SUFFIX = -debug + TARGET = debug +endif + +build-ui: cmd/query/app/ui/actual/index.html.gz + +cmd/query/app/ui/actual/index.html.gz: jaeger-ui/packages/jaeger-ui/build/index.html + # do not delete dot-files + rm -rf cmd/query/app/ui/actual/* + cp -r jaeger-ui/packages/jaeger-ui/build/* cmd/query/app/ui/actual/ + find cmd/query/app/ui/actual -type f | grep -v .gitignore | xargs gzip --no-name + # copy the timestamp for index.html.gz from the original file + touch -t $$(date -r jaeger-ui/packages/jaeger-ui/build/index.html '+%Y%m%d%H%M.%S') cmd/query/app/ui/actual/index.html.gz + ls -lF cmd/query/app/ui/actual/ + +jaeger-ui/packages/jaeger-ui/build/index.html: + $(MAKE) rebuild-ui + +.PHONY: rebuild-ui +rebuild-ui: + bash ./scripts/rebuild-ui.sh + @echo "NOTE: This target only rebuilds the UI assets inside jaeger-ui/packages/jaeger-ui/build/." + @echo "NOTE: To make them usable from query-service run 'make build-ui'." + +.PHONY: build-all-in-one-linux +build-all-in-one-linux: + GOOS=linux $(MAKE) build-all-in-one + +.PHONY: build-examples +build-examples: + $(GOBUILD) -o ./examples/hotrod/hotrod-$(GOOS)-$(GOARCH) ./examples/hotrod/main.go + +.PHONY: build-tracegen +build-tracegen: + $(GOBUILD) $(BUILD_INFO) -o ./cmd/tracegen/tracegen-$(GOOS)-$(GOARCH) ./cmd/tracegen/ + +.PHONY: build-anonymizer +build-anonymizer: + $(GOBUILD) $(BUILD_INFO) -o ./cmd/anonymizer/anonymizer-$(GOOS)-$(GOARCH) ./cmd/anonymizer/ + +.PHONY: build-esmapping-generator +build-esmapping-generator: + $(GOBUILD) $(BUILD_INFO) -o ./plugin/storage/es/esmapping-generator-$(GOOS)-$(GOARCH) ./cmd/esmapping-generator/ + +.PHONY: build-esmapping-generator-linux +build-esmapping-generator-linux: + GOOS=linux $(BUILD_INFO) GOARCH=amd64 $(GOBUILD) -o ./plugin/storage/es/esmapping-generator ./cmd/esmapping-generator/ + +.PHONY: build-es-index-cleaner +build-es-index-cleaner: + $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-index-cleaner/es-index-cleaner-$(GOOS)-$(GOARCH) ./cmd/es-index-cleaner/ + +.PHONY: build-es-rollover +build-es-rollover: + $(GOBUILD) $(BUILD_INFO) -o ./cmd/es-rollover/es-rollover-$(GOOS)-$(GOARCH) ./cmd/es-rollover/ + +# Requires variables: $(BIN_NAME) $(BIN_PATH) $(GO_TAGS) $(DISABLE_OPTIMIZATIONS) $(SUFFIX) $(GOOS) $(GOARCH) $(BUILD_INFO) +# Other targets can depend on this one but with a unique suffix to ensure it is always executed. +BIN_PATH = ./cmd/$(BIN_NAME) +.PHONY: _build-a-binary +_build-a-binary-%: + $(GOBUILD) $(DISABLE_OPTIMIZATIONS) $(GO_TAGS) -o $(BIN_PATH)/$(BIN_NAME)$(SUFFIX)-$(GOOS)-$(GOARCH) $(BUILD_INFO) $(BIN_PATH) + +.PHONY: build-jaeger +build-jaeger: BIN_NAME = jaeger +build-jaeger: GO_TAGS = -tags ui +build-jaeger: BUILD_INFO = $(BUILD_INFO_V2) +build-jaeger: build-ui _build-a-binary-jaeger$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-all-in-one +build-all-in-one: BIN_NAME = all-in-one +build-all-in-one: GO_TAGS = -tags ui +build-all-in-one: build-ui _build-a-binary-all-in-one$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-agent +build-agent: BIN_NAME = agent +build-agent: _build-a-binary-agent$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-query +build-query: BIN_NAME = query +build-query: GO_TAGS = -tags ui +build-query: build-ui _build-a-binary-query$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-collector +build-collector: BIN_NAME = collector +build-collector: _build-a-binary-collector$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-ingester +build-ingester: BIN_NAME = ingester +build-ingester: _build-a-binary-ingester$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-remote-storage +build-remote-storage: BIN_NAME = remote-storage +build-remote-storage: _build-a-binary-remote-storage$(SUFFIX)-$(GOOS)-$(GOARCH) + +.PHONY: build-binaries-linux +build-binaries-linux: build-binaries-amd64 + +.PHONY: build-binaries-amd64 +build-binaries-amd64: + GOOS=linux GOARCH=amd64 $(MAKE) _build-platform-binaries + +# helper targets defined in Makefile.Windows.mk +.PHONY: build-binaries-windows +build-binaries-windows: + $(MAKE) _build-syso + GOOS=windows GOARCH=amd64 $(MAKE) _build-platform-binaries + $(MAKE) _clean-syso + +.PHONY: build-binaries-darwin +build-binaries-darwin: + GOOS=darwin GOARCH=amd64 $(MAKE) _build-platform-binaries + +.PHONY: build-binaries-darwin-arm64 +build-binaries-darwin-arm64: + GOOS=darwin GOARCH=arm64 $(MAKE) _build-platform-binaries + +.PHONY: build-binaries-s390x +build-binaries-s390x: + GOOS=linux GOARCH=s390x $(MAKE) _build-platform-binaries + +.PHONY: build-binaries-arm64 +build-binaries-arm64: + GOOS=linux GOARCH=arm64 $(MAKE) _build-platform-binaries + +.PHONY: build-binaries-ppc64le +build-binaries-ppc64le: + GOOS=linux GOARCH=ppc64le $(MAKE) _build-platform-binaries + +# build all binaries for one specific platform GOOS/GOARCH +.PHONY: _build-platform-binaries +_build-platform-binaries: \ + build-agent \ + build-all-in-one \ + build-collector \ + build-query \ + build-ingester \ + build-jaeger \ + build-remote-storage \ + build-examples \ + build-tracegen \ + build-anonymizer \ + build-esmapping-generator \ + build-es-index-cleaner \ + build-es-rollover +# invoke make recursively such that DEBUG_BINARY=1 can take effect + $(MAKE) _build-platform-binaries-debug GOOS=$(GOOS) GOARCH=$(GOARCH) DEBUG_BINARY=1 + +# build binaries that support DEBUG release, for one specific platform GOOS/GOARCH +.PHONY: _build-platform-binaries-debug +_build-platform-binaries-debug: \ + build-agent \ + build-collector \ + build-query \ + build-ingester \ + build-remote-storage \ + build-all-in-one \ + build-jaeger + +.PHONY: build-all-platforms +build-all-platforms: \ + build-binaries-linux \ + build-binaries-windows \ + build-binaries-darwin \ + build-binaries-darwin-arm64 \ + build-binaries-s390x \ + build-binaries-arm64 \ + build-binaries-ppc64le diff --git a/Makefile.Docker.mk b/Makefile.Docker.mk new file mode 100644 index 00000000000..3c067f03f37 --- /dev/null +++ b/Makefile.Docker.mk @@ -0,0 +1,65 @@ +# Copyright (c) 2023 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +DOCKER_NAMESPACE ?= jaegertracing +DOCKER_TAG ?= latest +DOCKER_REGISTRY ?= localhost:5000 +BASE_IMAGE ?= $(DOCKER_REGISTRY)/baseimg_alpine:latest +DEBUG_IMAGE ?= $(DOCKER_REGISTRY)/debugimg_alpine:latest + +create-baseimg-debugimg: create-baseimg create-debugimg + +create-baseimg: prepare-docker-buildx + docker buildx build -t $(BASE_IMAGE) --push \ + --platform=$(LINUX_PLATFORMS) \ + docker/base + +create-debugimg: prepare-docker-buildx + docker buildx build -t $(DEBUG_IMAGE) --push \ + --platform=$(LINUX_PLATFORMS) \ + docker/debug + +create-fake-debugimg: prepare-docker-buildx + docker buildx build -t $(DEBUG_IMAGE) --push \ + --platform=$(LINUX_PLATFORMS) \ + docker/base + +.PHONY: prepare-docker-buildx +prepare-docker-buildx: + docker buildx inspect jaeger-build > /dev/null || docker buildx create --use --name=jaeger-build --buildkitd-flags="--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host" --driver-opt="network=host" + docker inspect registry > /dev/null || docker run --rm -d -p 5000:5000 --name registry registry:2 + +.PHONY: clean-docker-buildx +clean-docker-buildx: + docker buildx rm jaeger-build + docker rm -f registry + +.PHONY: docker-hotrod +docker-hotrod: + GOOS=linux $(MAKE) build-examples + docker build -t $(DOCKER_NAMESPACE)/example-hotrod:${DOCKER_TAG} ./examples/hotrod --build-arg TARGETARCH=$(GOARCH) + @echo "Finished building hotrod ==============" + +.PHONY: docker-images-tracegen +docker-images-tracegen: + docker build -t $(DOCKER_NAMESPACE)/jaeger-tracegen:${DOCKER_TAG} cmd/tracegen/ --build-arg TARGETARCH=$(GOARCH) + @echo "Finished building jaeger-tracegen ==============" + +.PHONY: docker-images-anonymizer +docker-images-anonymizer: + docker build -t $(DOCKER_NAMESPACE)/jaeger-anonymizer:${DOCKER_TAG} cmd/anonymizer/ --build-arg TARGETARCH=$(GOARCH) + @echo "Finished building jaeger-anonymizer ==============" + +.PHONY: docker-images-cassandra +docker-images-cassandra: + docker build -t $(DOCKER_NAMESPACE)/jaeger-cassandra-schema:${DOCKER_TAG} plugin/storage/cassandra/ + @echo "Finished building jaeger-cassandra-schema ==============" + +.PHONY: docker-images-elastic +docker-images-elastic: create-baseimg + GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-esmapping-generator + GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-es-index-cleaner + GOOS=linux GOARCH=$(GOARCH) $(MAKE) build-es-rollover + docker build -t $(DOCKER_NAMESPACE)/jaeger-es-index-cleaner:${DOCKER_TAG} --build-arg base_image=$(BASE_IMAGE) --build-arg TARGETARCH=$(GOARCH) cmd/es-index-cleaner + docker build -t $(DOCKER_NAMESPACE)/jaeger-es-rollover:${DOCKER_TAG} --build-arg base_image=$(BASE_IMAGE) --build-arg TARGETARCH=$(GOARCH) cmd/es-rollover + @echo "Finished building jaeger-elasticsearch tools ==============" diff --git a/Makefile.IntegrationTests.mk b/Makefile.IntegrationTests.mk new file mode 100644 index 00000000000..f6fe85e669b --- /dev/null +++ b/Makefile.IntegrationTests.mk @@ -0,0 +1,49 @@ +# Copyright (c) 2023 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +STORAGE_PKGS = ./plugin/storage/integration/... +JAEGER_V2_STORAGE_PKGS = ./cmd/jaeger/internal/integration + +.PHONY: all-in-one-integration-test +all-in-one-integration-test: + TEST_MODE=integration $(GOTEST) ./cmd/all-in-one/ + +# A general integration tests for jaeger-v2 storage backends, +# these tests placed at `./cmd/jaeger/internal/integration/*_test.go`. +# The integration tests are filtered by STORAGE env. +.PHONY: jaeger-v2-storage-integration-test +jaeger-v2-storage-integration-test: + (cd cmd/jaeger/ && go build .) + # Expire tests results for jaeger storage integration tests since the environment might change + # even though the code remains the same. + go clean -testcache + bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(JAEGER_V2_STORAGE_PKGS) $(COLORIZE)" + +.PHONY: storage-integration-test +storage-integration-test: + # Expire tests results for storage integration tests since the environment might change + # even though the code remains the same. + go clean -testcache + bash -c "set -e; set -o pipefail; $(GOTEST) -coverpkg=./... -coverprofile $(COVEROUT) $(STORAGE_PKGS) $(COLORIZE)" + +.PHONY: badger-storage-integration-test +badger-storage-integration-test: + STORAGE=badger $(MAKE) storage-integration-test + +.PHONY: grpc-storage-integration-test +grpc-storage-integration-test: + STORAGE=grpc $(MAKE) storage-integration-test + +# this test assumes STORAGE environment variable is set to elasticsearch|opensearch +.PHONY: index-cleaner-integration-test +index-cleaner-integration-test: docker-images-elastic + $(MAKE) storage-integration-test COVEROUT=cover-index-cleaner.out + +# this test assumes STORAGE environment variable is set to elasticsearch|opensearch +.PHONY: index-rollover-integration-test +index-rollover-integration-test: docker-images-elastic + $(MAKE) storage-integration-test COVEROUT=cover-index-rollover.out + +.PHONY: tail-sampling-integration-test +tail-sampling-integration-test: + SAMPLING=tail $(MAKE) jaeger-v2-storage-integration-test diff --git a/docker/Makefile b/docker/Makefile deleted file mode 100644 index 777085d489b..00000000000 --- a/docker/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (c) 2024 The Jaeger Authors. -# SPDX-License-Identifier: Apache-2.0 - -VERSION := 1.0.0 - -DOCKER_REGISTRY ?= localhost:5000 -BASE_IMAGE ?= $(DOCKER_REGISTRY)/baseimg_alpine:latest -DEBUG_IMAGE ?= $(DOCKER_REGISTRY)/debugimg_alpine:latest -PLATFORMS ?= linux/amd64,linux/s390x,linux/ppc64le,linux/arm64 - -create-baseimg-debugimg: create-baseimg create-debugimg - -create-baseimg: prepare-docker-buildx - docker buildx build -t $(BASE_IMAGE) --push \ - --platform=$(PLATFORMS) \ - docker/base - -create-debugimg: prepare-docker-buildx - docker buildx build -t $(DEBUG_IMAGE) --push \ - --platform=$(PLATFORMS) \ - docker/debug - -create-fake-debugimg: prepare-docker-buildx - docker buildx build -t $(DEBUG_IMAGE) --push \ - --platform=$(PLATFORMS) \ - docker/base - -.PHONY: prepare-docker-buildx -prepare-docker-buildx: - docker buildx inspect jaeger-build > /dev/null || docker buildx create --use --name=jaeger-build --buildkitd-flags="--allow-insecure-entitlement security.insecure --allow-insecure-entitlement network.host" --driver-opt="network=host" - docker inspect registry > /dev/null || docker run --rm -d -p 5000:5000 --name registry registry:2 - -.PHONY: clean-docker-buildx -clean-docker-buildx: - docker buildx rm jaeger-build - docker rm -f registry diff --git a/scripts/build-all-in-one-image.sh b/scripts/build-all-in-one-image.sh index d167e40e508..c26757ddecd 100755 --- a/scripts/build-all-in-one-image.sh +++ b/scripts/build-all-in-one-image.sh @@ -16,7 +16,7 @@ print_help() { } add_debugger='Y' -platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64" +platforms="$(make echo-linux-platforms)" LOCAL_FLAG='' BINARY='all-in-one' diff --git a/scripts/build-upload-docker-images.sh b/scripts/build-upload-docker-images.sh index 635284e8c62..6775c85f217 100755 --- a/scripts/build-upload-docker-images.sh +++ b/scripts/build-upload-docker-images.sh @@ -15,7 +15,7 @@ print_help() { } add_debugger='Y' -platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64" +platforms="$(make echo-linux-platforms)" LOCAL_FLAG='' while getopts "Dhlp:" opt; do diff --git a/scripts/clean-binaries.sh b/scripts/clean-binaries.sh new file mode 100755 index 00000000000..7026bb34d58 --- /dev/null +++ b/scripts/clean-binaries.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# +# Copyright (c) 2024 The Jaeger Authors. +# SPDX-License-Identifier: Apache-2.0 + +platforms=$(make echo-platforms) +for main in ./cmd/*/main.go; do + dir=$(dirname "$main") + bin=$(basename "$dir") + rm -rf "${dir:?}/$bin" + for platform in $(echo "$platforms" | tr ',' ' ' | tr '/' '-'); do + b="${dir:?}/$bin-$platform" + echo "$b" + rm -f "$b" + done +done diff --git a/scripts/hotrod-integration-test.sh b/scripts/hotrod-integration-test.sh index 0d8b804bbff..949a8654cc1 100755 --- a/scripts/hotrod-integration-test.sh +++ b/scripts/hotrod-integration-test.sh @@ -14,7 +14,7 @@ print_help() { } docker_compose_file="./examples/hotrod/docker-compose.yml" -platforms="linux/amd64,linux/s390x,linux/ppc64le,linux/arm64" +platforms="$(make echo-linux-platforms)" current_platform="$(go env GOOS)/$(go env GOARCH)" LOCAL_FLAG='' diff --git a/scripts/package-deploy.sh b/scripts/package-deploy.sh index ca60488e92b..7453336b9fb 100755 --- a/scripts/package-deploy.sh +++ b/scripts/package-deploy.sh @@ -6,12 +6,12 @@ set -euxf -o pipefail TARCMD=${TARCMD:-tar} -dry_run="false" -while getopts "d" opt; do +platforms="$(make echo-platforms)" +while getopts "p:" opt; do # shellcheck disable=SC2220 # we don't need a *) case case "${opt}" in - d) - dry_run="true" + p) + platforms=${OPTARG} ;; esac done @@ -64,6 +64,8 @@ function package { local -r PACKAGE_NAME_V2=jaeger-${VERSION_V2}-$PLATFORM local -r TOOLS_PACKAGE_NAME=jaeger-tools-${VERSION_V1}-$PLATFORM + echo "Packaging binaries for $PLATFORM" + PACKAGES=("$PACKAGE_NAME_V1" "$PACKAGE_NAME_V2" "$TOOLS_PACKAGE_NAME") for d in "${PACKAGES[@]}"; do if [ -d "$d" ]; then @@ -111,16 +113,17 @@ fi rm -rf deploy mkdir deploy -package tar linux-amd64 -if [[ "$dry_run" == "false" ]]; then - package tar darwin-amd64 - package tar darwin-arm64 - package tar windows-amd64 .exe - package zip windows-amd64 .exe - package tar linux-s390x - package tar linux-arm64 - package tar linux-ppc64le -fi +# Loop through each platform (separated by commas) +for platform in $(echo "$platforms" | tr ',' ' '); do + os="${platform%%/*}" # Remove everything after the slash + arch=${platform##*/} # Remove everything before the last slash + if [[ "$os" == "windows" ]]; then + package tar "${os}-${arch}" .exe + package zip "${os}-${arch}" .exe + else + package tar "${os}-${arch}" + fi +done # Create a checksum file for all non-checksum files in the deploy directory. Strips the leading 'deploy/' directory from filepaths. Sort by filename. find deploy \( ! -name '*sha256sum.txt' \) -type f -exec shasum -b -a 256 {} \; \