From 413f6660c3d4fafb5ef96aac8ac2ea61728ab37c Mon Sep 17 00:00:00 2001 From: Chun-Hung Tseng Date: Thu, 6 Jun 2024 18:54:42 +0200 Subject: [PATCH] Move to Makefile-based instead of script-based integration test execution Signed-off-by: Chun-Hung Tseng --- .github/workflows/govuln.yaml | 2 +- .github/workflows/integration_tests.yml | 7 +++---- Makefile | 19 +------------------ go.mod | 4 +--- integration/makefile.mk | 24 ++++++++++++++++++++++++ integration/sleep/execute.sh | 20 -------------------- 6 files changed, 30 insertions(+), 46 deletions(-) create mode 100644 integration/makefile.mk delete mode 100755 integration/sleep/execute.sh diff --git a/.github/workflows/govuln.yaml b/.github/workflows/govuln.yaml index 7d1ce95..904242a 100644 --- a/.github/workflows/govuln.yaml +++ b/.github/workflows/govuln.yaml @@ -3,7 +3,7 @@ name: Go Vulnerability Checker on: [push, pull_request] permissions: read-all jobs: - test: + govuln: runs-on: ubuntu-latest steps: - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 diff --git a/.github/workflows/integration_tests.yml b/.github/workflows/integration_tests.yml index bde2d9e..fee79d0 100644 --- a/.github/workflows/integration_tests.yml +++ b/.github/workflows/integration_tests.yml @@ -1,5 +1,5 @@ --- -name: integration_tests +name: Integration Tests on: push: tags: @@ -13,8 +13,7 @@ permissions: # Optional: allow read access to pull request. Use with `only-new-issues` option. # pull-requests: read jobs: - test: - name: lint + integration-test: runs-on: ubuntu-latest steps: - id: goversion @@ -25,4 +24,4 @@ jobs: - uses: actions/checkout@v4 - name: tests run: | - make run-all-integration-test + make run-all-integration-tests diff --git a/Makefile b/Makefile index 7aed263..fdbd0bf 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ SRCS=$(filter-out %_test.go, $(wildcard *.go */*.go)) +include integration/makefile.mk .PHONY: all all: gofail @@ -18,24 +19,6 @@ verify-gofmt: test: go test -v --race -cpu=1,2,4 ./code/ ./runtime/ -# run all integration tests -.PHONY: run-all-integration-test -run-all-integration-test: run-integration-test-sleep - -.PHONY: build-integration-test -build-integration-test: gofail - -.PHONY: cleanup-integration-test -cleanup-integration-test: clean - -# run integration test - sleep -.PHONY: run-integration-test-sleep -run-integration-test-sleep: build-integration-test execute-integration-test-sleep cleanup-integration-test - -.PHONY: execute-integration-test-sleep -execute-integration-test-sleep: - ./integration/sleep/execute.sh - fix: fix-gofmt .PHONY: fix-gofmt diff --git a/go.mod b/go.mod index d3765fe..59e2e61 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module go.etcd.io/gofail -go 1.21 - -toolchain go1.21.11 +go 1.21.11 require github.com/stretchr/testify v1.9.0 diff --git a/integration/makefile.mk b/integration/makefile.mk new file mode 100644 index 0000000..4d3bdf9 --- /dev/null +++ b/integration/makefile.mk @@ -0,0 +1,24 @@ +GOFAIL_BINARY = $(shell pwd)/gofail + +# run all integration tests +.PHONY: run-all-integration-tests +run-all-integration-tests: run-integration-test-sleep + +# run integration test - sleep +.PHONY: run-integration-test-sleep +run-integration-test-sleep: build-gofail execute-integration-test-sleep remove-gofail + +.PHONY: execute-integration-test-sleep +execute-integration-test-sleep: + @echo "GOFAIL_BINARY = ${GOFAIL_BINARY}" + cd ./integration/sleep/failpoints && ${GOFAIL_BINARY} enable && cd .. && go build -o integration_test_sleep . && cd failpoints && ${GOFAIL_BINARY} disable + cd ./integration/sleep && ./integration_test_sleep && rm integration_test_sleep + +# helper: build/remove gofail binaries +.PHONY: build-gofail +build-gofail: + make clean && make gofail + +.PHONY: remove-gofail +remove-gofail: + make clean diff --git a/integration/sleep/execute.sh b/integration/sleep/execute.sh deleted file mode 100755 index ebed810..0000000 --- a/integration/sleep/execute.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -GOFAIL_BINARY="$(pwd)/gofail" - -cd $(dirname $0) - -pushd failpoints -$GOFAIL_BINARY enable -popd - -go build -o integration_test_sleep . - -pushd failpoints -$GOFAIL_BINARY disable -popd - -./integration_test_sleep -rm integration_test_sleep