From 06aafdcd80ef09946daf86c0319570f777177507 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 10 Jan 2022 15:52:01 +0100 Subject: [PATCH] Rename bin/ and testing/ folders (#354) --- .github/workflows/test.yml | 32 +++++++---------- CHANGELOG.md | 3 +- Makefile | 16 ++++----- bin/e2e => scripts/test-e2e | 44 ++++++++++++------------ bin/release_test => scripts/test-release | 0 {testing => test/e2e}/benchmark_test.go | 0 {testing => test/e2e}/endpoint.go | 0 7 files changed, 44 insertions(+), 51 deletions(-) rename bin/e2e => scripts/test-e2e (69%) rename bin/release_test => scripts/test-release (100%) rename {testing => test/e2e}/benchmark_test.go (100%) rename {testing => test/e2e}/endpoint.go (100%) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 39e7a0d5..b1c41725 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,9 +2,9 @@ name: Test on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] jobs: test: @@ -12,48 +12,40 @@ jobs: strategy: fail-fast: true matrix: - go: [ '1.17', '1.16', '1.15', '1.14' ] + go: ["1.17", "1.16", "1.15", "1.14"] name: Go ${{ matrix.go }} steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - - - name: Setup go + - name: Setup go uses: actions/setup-go@v2 with: go-version: ${{ matrix.go }} - - - name: Tests + - name: Tests run: make test - - - name: benchmarks + - name: benchmarks run: make bench build: runs-on: ubuntu-latest steps: - - - name: Checkout + - name: Checkout uses: actions/checkout@v2 with: fetch-depth: 0 - - - name: Setup go + - name: Setup go uses: actions/setup-go@v2 with: go-version: 1.17 - - - name: E2E tests - run: make e2e + - name: E2E tests + run: make test-e2e - - - name: Build + - name: Build uses: goreleaser/goreleaser-action@5df302e5e9e4c66310a6b6493a8865b12c555af2 with: distribution: goreleaser diff --git a/CHANGELOG.md b/CHANGELOG.md index f16ff946..d806bd20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # [Unreleased] * Verify git tag on release (#347, @miry) -* Fix MacOS 12 tests for go17 with -race flag (#351 @strech) +* Fix MacOS 12 tests for go17 with -race flag (#351, @strech) +* Rename `testing/` and `bin/` folders (#354, @strech) # [2.3.0] - 2021-12-23 diff --git a/Makefile b/Makefile index 224d9d14..77a88995 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,14 @@ test: # NOTE: https://github.com/golang/go/issues/49138 $(MALLOC_ENV) go test -v -race -timeout 1m ./... +.PHONY: test-e2e +test-e2e: build + scripts/test-e2e + +.PHONY: test-release +test-release: test bench test-e2e release-dry + scripts/test-release + .PHONY: bench bench: # TODO: Investigate why benchmarks require more sockets: ulimit -n 10240 @@ -28,10 +36,6 @@ fmt: lint: golangci-lint run -.PHONY: e2e -e2e: build - bin/e2e - .PHONY: build build: dist clean go build -ldflags="-s -w" -o ./dist/toxiproxy-server ./cmd/server @@ -45,10 +49,6 @@ release: release-dry: goreleaser release --rm-dist --skip-publish --skip-validate -.PHONY: release-test -release-test: test bench e2e release-dry - bin/release_test - .PHONY: setup setup: go mod download diff --git a/bin/e2e b/scripts/test-e2e similarity index 69% rename from bin/e2e rename to scripts/test-e2e index 08cbb2bd..ed32532a 100755 --- a/bin/e2e +++ b/scripts/test-e2e @@ -5,9 +5,9 @@ set -ueo pipefail wait_for_url() { echo "--- Waiting for HTTP connection available" timeout -s TERM 30s bash -c \ - 'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]];\ - do echo "Waiting for ${0}" && sleep 2;\ - done' ${1} + 'while [[ "$(curl -s -o /dev/null -L -w ''%{http_code}'' ${0})" != "200" ]]; do \ + echo "Waiting for ${0}" && sleep 2; \ + done' ${1} curl -s -I -X GET $1 } @@ -18,7 +18,7 @@ trap 'pkill -15 -f "dist/toxiproxy-server$"; pkill -15 -f "exe/endpoint$"' EXIT echo "=== Starting Web service" -go run testing/endpoint.go 2>&1 | sed -e 's/^/[web] /' & +go run test/e2e/endpoint.go 2>&1 | sed -e 's/^/[web] /' & echo "=== Starting Toxiproxy" @@ -44,21 +44,21 @@ echo "== Benchmarking" echo echo "=== Without toxics" -go test -bench=. ./testing -v +go test -bench=. ./test/e2e -v echo -e "-----------------\n" echo "=== Latency toxic downstream" ./dist/toxiproxy-cli toxic add --downstream --type latency --toxicName "latency_downstream" \ - --attribute "latency=1000" --attribute="jitter=50" \ - --toxicity 0.99 shopify_http + --attribute "latency=1000" --attribute="jitter=50" \ + --toxicity 0.99 shopify_http ./dist/toxiproxy-cli inspect shopify_http -go test -bench=. ./testing -v +go test -bench=. ./test/e2e -v ./dist/toxiproxy-cli toxic update --toxicName "latency_downstream" --attribute="jitter=20" \ - --toxicity 0.7 shopify_http + --toxicity 0.7 shopify_http ./dist/toxiproxy-cli inspect shopify_http ./dist/toxiproxy-cli toxic delete --toxicName "latency_downstream" shopify_http @@ -68,14 +68,14 @@ echo -e "-----------------\n" echo "=== Latency toxic upstream" ./dist/toxiproxy-cli toxic add --upstream --type latency --toxicName "latency_upstream" \ - --attribute "latency=1000" --attribute "jitter=50" \ - --toxicity 1 shopify_http + --attribute "latency=1000" --attribute "jitter=50" \ + --toxicity 1 shopify_http ./dist/toxiproxy-cli inspect shopify_http -go test -bench=. ./testing -v +go test -bench=. ./test/e2e -v ./dist/toxiproxy-cli toxic update --toxicName "latency_upstream" --attribute="jitter=20" \ - --toxicity 0.3 shopify_http + --toxicity 0.3 shopify_http ./dist/toxiproxy-cli inspect shopify_http ./dist/toxiproxy-cli toxic delete --toxicName "latency_upstream" shopify_http @@ -85,11 +85,11 @@ echo -e "-----------------\n" echo "=== Bandwidth toxic" ./dist/toxiproxy-cli toxic add --type bandwidth --toxicName "bandwidth_kb_per_second" \ - --attribute "rate=1" --toxicity 0.5 shopify_http + --attribute "rate=1" --toxicity 0.5 shopify_http ./dist/toxiproxy-cli toxic update --toxicName "bandwidth_kb_per_second" --attribute="rate=10" \ - --toxicity 1.0 shopify_http + --toxicity 1.0 shopify_http -go test -bench=. ./testing -v +go test -bench=. ./test/e2e -v ./dist/toxiproxy-cli toxic delete --toxicName "bandwidth_kb_per_second" shopify_http @@ -98,7 +98,7 @@ echo -e "-----------------\n" echo "=== Timeout toxic" ./dist/toxiproxy-cli toxic add --type timeout --toxicName "timeout_ms" \ - --attribute "timeout=10" --toxicity 0.1 shopify_http + --attribute "timeout=10" --toxicity 0.1 shopify_http ./dist/toxiproxy-cli toxic delete --toxicName "timeout_ms" shopify_http echo -e "-----------------\n" @@ -106,9 +106,9 @@ echo -e "-----------------\n" echo "=== Slicer toxic" ./dist/toxiproxy-cli toxic add --type slicer --toxicName "slicer_us" \ - --attribute "average_size=64" --attribute "size_variation=32" \ - --attribute="delay=10" --toxicity 1.0 shopify_http -go test -bench=. ./testing -v + --attribute "average_size=64" --attribute "size_variation=32" \ + --attribute="delay=10" --toxicity 1.0 shopify_http +go test -bench=. ./test/e2e -v ./dist/toxiproxy-cli toxic delete --toxicName "slicer_us" shopify_http echo -e "-----------------\n" @@ -116,8 +116,8 @@ echo -e "-----------------\n" echo "=== Reset peer toxic" ./dist/toxiproxy-cli toxic add --type reset_peer --toxicName "reset_peer" \ - --attribute "timeout=2000" \ - --toxicity 1.0 shopify_http + --attribute "timeout=2000" \ + --toxicity 1.0 shopify_http ./dist/toxiproxy-cli inspect shopify_http ./dist/toxiproxy-cli toxic delete --toxicName "reset_peer" shopify_http diff --git a/bin/release_test b/scripts/test-release similarity index 100% rename from bin/release_test rename to scripts/test-release diff --git a/testing/benchmark_test.go b/test/e2e/benchmark_test.go similarity index 100% rename from testing/benchmark_test.go rename to test/e2e/benchmark_test.go diff --git a/testing/endpoint.go b/test/e2e/endpoint.go similarity index 100% rename from testing/endpoint.go rename to test/e2e/endpoint.go