From fc5a01fed611a2f8c8ddf29e08f409fd09c5dfb0 Mon Sep 17 00:00:00 2001 From: Roman Date: Sun, 30 Oct 2022 17:06:30 -0700 Subject: [PATCH] chore: use environment variable instead of build tags to control e2e (#3179) --- Makefile | 10 +++++----- tests/e2e/e2e_setup_test.go | 9 ++++++--- tests/e2e/e2e_test.go | 3 --- tests/e2e/initialization/init_test.go | 3 --- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 5d4a5261e1d..33117381e6e 100644 --- a/Makefile +++ b/Makefile @@ -224,7 +224,7 @@ run-querygen: ############################################################################### PACKAGES_UNIT=$(shell go list ./... | grep -E -v 'tests/simulator|e2e') -PACKAGES_E2E=$(shell go list -tags e2e ./... | grep '/e2e') +PACKAGES_E2E=$(shell go list ./... | grep '/e2e') PACKAGES_SIM=$(shell go list ./... | grep '/tests/simulator') TEST_PACKAGES=./... @@ -261,25 +261,25 @@ test-sim-bench: # In that case, run `make e2e-remove-resources` # manually. # Utilizes Go cache. -test-e2e: e2e-setup test-e2e-ci +test-e2e: OSMOSIS_E2E=True e2e-setup test-e2e-ci # test-e2e-ci runs a full e2e test suite # does not do any validation about the state of the Docker environment # As a result, avoid using this locally. test-e2e-ci: - @VERSION=$(VERSION) OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) # test-e2e-debug runs a full e2e test suite but does # not attempt to delete Docker resources at the end. test-e2e-debug: e2e-setup - @VERSION=$(VERSION) OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_UPGRADE_VERSION=$(E2E_UPGRADE_VERSION) OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 # test-e2e-short runs the e2e test with only short tests. # Does not delete any of the containers after running. # Deletes any existing containers before running. # Does not use Go cache. test-e2e-short: e2e-setup - @VERSION=$(VERSION) OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_SKIP_UPGRADE=True OSMOSIS_E2E_SKIP_IBC=True OSMOSIS_E2E_SKIP_STATE_SYNC=True OSMOSIS_E2E_SKIP_CLEANUP=True go test -tags e2e -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 + @VERSION=$(VERSION) OSMOSIS_E2E=True OSMOSIS_E2E_DEBUG_LOG=True OSMOSIS_E2E_SKIP_UPGRADE=True OSMOSIS_E2E_SKIP_IBC=True OSMOSIS_E2E_SKIP_STATE_SYNC=True OSMOSIS_E2E_SKIP_CLEANUP=True go test -mod=readonly -timeout=25m -v $(PACKAGES_E2E) -count=1 test-mutation: @bash scripts/mutation-test.sh $(MODULES) diff --git a/tests/e2e/e2e_setup_test.go b/tests/e2e/e2e_setup_test.go index 774763c13a3..567441cd3c9 100644 --- a/tests/e2e/e2e_setup_test.go +++ b/tests/e2e/e2e_setup_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package e2e import ( @@ -15,6 +12,8 @@ import ( ) const ( + // Environment variable signifying whether to run e2e tests. + e2eEnabledEnv = "OSMOSIS_E2E" // Environment variable name to skip the upgrade tests skipUpgradeEnv = "OSMOSIS_E2E_SKIP_UPGRADE" // Environment variable name to skip the IBC tests @@ -40,6 +39,10 @@ type IntegrationTestSuite struct { } func TestIntegrationTestSuite(t *testing.T) { + isEnabled := os.Getenv(e2eEnabledEnv) + if isEnabled != "True" { + t.Skip(fmt.Sprintf("e2e test is disabled. To run, set %s to True", e2eEnabledEnv)) + } suite.Run(t, new(IntegrationTestSuite)) } diff --git a/tests/e2e/e2e_test.go b/tests/e2e/e2e_test.go index 43bcb62ac3c..5c9b97e0ae8 100644 --- a/tests/e2e/e2e_test.go +++ b/tests/e2e/e2e_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package e2e import ( diff --git a/tests/e2e/initialization/init_test.go b/tests/e2e/initialization/init_test.go index cc8cb8d2c95..7ff20a0e9b2 100644 --- a/tests/e2e/initialization/init_test.go +++ b/tests/e2e/initialization/init_test.go @@ -1,6 +1,3 @@ -//go:build e2e -// +build e2e - package initialization_test import (