From ee6fd604e1ab6b5a8f94a94b77320ae58d552fcc Mon Sep 17 00:00:00 2001 From: Tyler Helmuth <12352919+TylerHelmuth@users.noreply.github.com> Date: Thu, 1 Feb 2024 08:50:45 -0700 Subject: [PATCH] [chore] parallelize tests (#30901) **Description:** - Parallelize the integration tests like the unit/lint job. - Add more groups to spread out the load **Link to tracking Issue:** Related to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/30880 **Testing:** **Documentation:** --- .github/workflows/build-and-test.yml | 60 ++++++++++++++++++++++++---- Makefile | 47 ++++++++++++++++++---- 2 files changed, 92 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 58b69f7d54d1..8b1142207ce6 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -69,13 +69,17 @@ jobs: group: - receiver-0 - receiver-1 + - receiver-2 + - receiver-3 - processor - - exporter + - exporter-0 + - exporter-1 - extension - connector - internal - pkg - - cmd + - cmd-0 + - cmd-1 - other runs-on: ubuntu-latest needs: [setup-environment] @@ -130,12 +134,17 @@ jobs: group: - receiver-0 - receiver-1 + - receiver-2 + - receiver-3 - processor - - exporter + - exporter-0 + - exporter-1 - extension - connector - internal - pkg + - cmd-0 + - cmd-1 runs-on: ubuntu-latest timeout-minutes: 30 steps: @@ -231,13 +240,17 @@ jobs: group: - receiver-0 - receiver-1 + - receiver-2 + - receiver-3 - processor - - exporter + - exporter-0 + - exporter-1 - extension - connector - internal - pkg - - cmd + - cmd-0 + - cmd-1 - other runs-on: ubuntu-latest needs: [setup-environment] @@ -312,7 +325,23 @@ jobs: attempt_limit: 10 attempt_delay: 15000 - integration-tests: + integration-tests-matrix: + strategy: + matrix: + group: + - receiver-0 + - receiver-1 + - receiver-2 + - receiver-3 + - processor + - exporter-0 + - exporter-1 + - extension + - connector + - internal + - pkg + - cmd-0 + - cmd-1 runs-on: ubuntu-latest needs: [setup-environment] steps: @@ -331,7 +360,24 @@ jobs: ~/go/pkg/mod key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }} - name: Run Integration Tests - run: make integration-test + run: make gointegration-test GROUP=${{ matrix.group }} + + integration-tests: + if: ${{ github.actor != 'dependabot[bot]' && always() }} + runs-on: ubuntu-latest + needs: [ setup-environment, integration-tests-matrix ] + steps: + - name: Print result + run: echo ${{ needs.integration-tests-matrix.result }} + - name: Interpret result + run: | + if [[ success == ${{ needs.integration-tests-matrix.result }} ]] + then + echo "All matrix jobs passed!" + else + echo "One or more matrix jobs failed." + false + fi correctness-traces: runs-on: ubuntu-latest diff --git a/Makefile b/Makefile index a635b9463e49..72b37602340b 100644 --- a/Makefile +++ b/Makefile @@ -23,20 +23,25 @@ EX_CMD=-not -path "./cmd/*" # NONROOT_MODS includes ./* dirs (excludes . dir) NONROOT_MODS := $(shell find . $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -RECEIVER_MODS_0 := $(shell find ./receiver/[a-k]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -RECEIVER_MODS_1 := $(shell find ./receiver/[l-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -RECEIVER_MODS := $(RECEIVER_MODS_0) $(RECEIVER_MODS_1) +RECEIVER_MODS_0 := $(shell find ./receiver/[a-f]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +RECEIVER_MODS_1 := $(shell find ./receiver/[g-o]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +RECEIVER_MODS_2 := $(shell find ./receiver/[p]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) # Prometheus is special and gets its own section. +RECEIVER_MODS_3 := $(shell find ./receiver/[q-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +RECEIVER_MODS := $(RECEIVER_MODS_0) $(RECEIVER_MODS_1) $(RECEIVER_MODS_2) $(RECEIVER_MODS_3) PROCESSOR_MODS := $(shell find ./processor/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -EXPORTER_MODS := $(shell find ./exporter/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +EXPORTER_MODS_0 := $(shell find ./exporter/[a-m]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +EXPORTER_MODS_1 := $(shell find ./exporter/[n-z]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +EXPORTER_MODS := $(EXPORTER_MODS_0) $(EXPORTER_MODS_1) EXTENSION_MODS := $(shell find ./extension/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) CONNECTOR_MODS := $(shell find ./connector/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) INTERNAL_MODS := $(shell find ./internal/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) PKG_MODS := $(shell find ./pkg/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) -CMD_MODS := $(shell find ./cmd/* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +CMD_MODS_0 := $(shell find ./cmd/[a-m]* $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) +CMD_MODS_1 := $(shell find ./cmd/[n-z]* $(FIND_MOD_ARGS) -not -path "./cmd/otelcontribcol/*" -exec $(TO_MOD_DIR) ) +CMD_MODS := $(CMD_MODS_0) $(CMD_MODS_1) OTHER_MODS := $(shell find . $(EX_COMPONENTS) $(EX_INTERNAL) $(EX_PKG) $(EX_CMD) $(FIND_MOD_ARGS) -exec $(TO_MOD_DIR) ) $(PWD) ALL_MODS := $(RECEIVER_MODS) $(PROCESSOR_MODS) $(EXPORTER_MODS) $(EXTENSION_MODS) $(CONNECTOR_MODS) $(INTERNAL_MODS) $(PKG_MODS) $(CMD_MODS) $(OTHER_MODS) -# find -exec dirname cannot be used to process multiple matching patterns FIND_INTEGRATION_TEST_MODS={ find . -type f -name "*integration_test.go" & find . -type f -name "*e2e_test.go" -not -path "./testbed/*"; } INTEGRATION_MODS := $(shell $(FIND_INTEGRATION_TEST_MODS) | xargs $(TO_MOD_DIR) | uniq) @@ -52,14 +57,18 @@ all-modules: all-groups: @echo "receiver-0: $(RECEIVER_MODS_0)" @echo "\nreceiver-1: $(RECEIVER_MODS_1)" + @echo "\nreceiver-2: $(RECEIVER_MODS_2)" + @echo "\nreceiver-3: $(RECEIVER_MODS_3)" @echo "\nreceiver: $(RECEIVER_MODS)" @echo "\nprocessor: $(PROCESSOR_MODS)" - @echo "\nexporter: $(EXPORTER_MODS)" + @echo "\nexporter-0: $(EXPORTER_MODS_0)" + @echo "\nexporter-1: $(EXPORTER_MODS_1)" @echo "\nextension: $(EXTENSION_MODS)" @echo "\nconnector: $(CONNECTOR_MODS)" @echo "\ninternal: $(INTERNAL_MODS)" @echo "\npkg: $(PKG_MODS)" - @echo "\ncmd: $(CMD_MODS)" + @echo "\ncmd-0: $(CMD_MODS_0)" + @echo "\ncmd-1: $(CMD_MODS_1)" @echo "\nother: $(OTHER_MODS)" .PHONY: all @@ -108,6 +117,10 @@ gotest-with-cover: @$(MAKE) $(FOR_GROUP_TARGET) TARGET="test-with-cover" $(GOCMD) tool covdata textfmt -i=./coverage/unit -o ./$(GROUP)-coverage.txt +.PHONY: gointegration-test +gointegration-test: + $(MAKE) $(FOR_GROUP_TARGET) TARGET="mod-integration-test" + .PHONY: gofmt gofmt: $(MAKE) $(FOR_GROUP_TARGET) TARGET="fmt" @@ -164,12 +177,24 @@ for-receiver-0-target: $(RECEIVER_MODS_0) .PHONY: for-receiver-1-target for-receiver-1-target: $(RECEIVER_MODS_1) +.PHONY: for-receiver-2-target +for-receiver-2-target: $(RECEIVER_MODS_2) + +.PHONY: for-receiver-3-target +for-receiver-3-target: $(RECEIVER_MODS_3) + .PHONY: for-processor-target for-processor-target: $(PROCESSOR_MODS) .PHONY: for-exporter-target for-exporter-target: $(EXPORTER_MODS) +.PHONY: for-exporter-0-target +for-exporter-0-target: $(EXPORTER_MODS_0) + +.PHONY: for-exporter-1-target +for-exporter-1-target: $(EXPORTER_MODS_1) + .PHONY: for-extension-target for-extension-target: $(EXTENSION_MODS) @@ -185,6 +210,12 @@ for-pkg-target: $(PKG_MODS) .PHONY: for-cmd-target for-cmd-target: $(CMD_MODS) +.PHONY: for-cmd-0-target +for-cmd-0-target: $(CMD_MODS_0) + +.PHONY: for-cmd-1-target +for-cmd-1-target: $(CMD_MODS_1) + .PHONY: for-other-target for-other-target: $(OTHER_MODS)