istio.io/istio@v0.0.0-20240520182934-d79c90f27776/tests/integration/tests.mk (about) 1 #----------------------------------------------------------------------------- 2 # Target: test.integration.* 3 #----------------------------------------------------------------------------- 4 5 # The following flags (in addition to ${V}) can be specified on the command-line, or the environment. This 6 # is primarily used by the CI systems. 7 _INTEGRATION_TEST_FLAGS ?= $(INTEGRATION_TEST_FLAGS) 8 9 # $(CI) specifies that the test is running in a CI system. This enables CI specific logging. 10 ifneq ($(CI),) 11 _INTEGRATION_TEST_FLAGS += --istio.test.ci 12 _INTEGRATION_TEST_FLAGS += --istio.test.pullpolicy=IfNotPresent 13 endif 14 15 ifeq ($(TEST_ENV),kind) 16 _INTEGRATION_TEST_FLAGS += --istio.test.kube.loadbalancer=false 17 endif 18 19 ifeq ($(shell uname -m),aarch64) 20 _INTEGRATION_TEST_FLAGS += --istio.test.kube.architecture=arm64 21 endif 22 23 ifneq ($(ARTIFACTS),) 24 _INTEGRATION_TEST_FLAGS += --istio.test.work_dir=$(ARTIFACTS) 25 endif 26 27 ifneq ($(HUB),) 28 _INTEGRATION_TEST_FLAGS += --istio.test.hub=$(HUB) 29 endif 30 31 ifneq ($(TAG),) 32 _INTEGRATION_TEST_FLAGS += --istio.test.tag=$(TAG) 33 endif 34 35 ifneq ($(VARIANT),) 36 _INTEGRATION_TEST_FLAGS += --istio.test.variant=$(VARIANT) 37 endif 38 39 _INTEGRATION_TEST_SELECT_FLAGS ?= --istio.test.select=$(TEST_SELECT) 40 ifneq ($(JOB_TYPE),postsubmit) 41 _INTEGRATION_TEST_SELECT_FLAGS:="$(_INTEGRATION_TEST_SELECT_FLAGS),-postsubmit" 42 endif 43 44 # both ipv6 only and dual stack support ipv6 45 support_ipv6 = 46 ifeq ($(IP_FAMILY),ipv6) 47 support_ipv6 = yes 48 else ifeq ($(IP_FAMILY),dual) 49 support_ipv6 = yes 50 _INTEGRATION_TEST_FLAGS += --istio.test.enableDualStack 51 endif 52 ifdef support_ipv6 53 _INTEGRATION_TEST_SELECT_FLAGS:="$(_INTEGRATION_TEST_SELECT_FLAGS),-ipv4" 54 # Fundamentally, VMs should support IPv6. However, our test framework uses a contrived setup to test VMs 55 # such that they run in the cluster. In particular, they configure DNS to a public DNS server. 56 # For CI, our nodes do not have IPv6 external connectivity. This means the cluster *cannot* reach these external 57 # DNS servers. 58 # Extensive work was done to try to hack around this, but ultimately nothing was able to cover all 59 # of the edge cases. This work was captured in https://github.com/howardjohn/istio/tree/tf/vm-ipv6. 60 _INTEGRATION_TEST_FLAGS += --istio.test.skipVM 61 endif 62 63 # $(INTEGRATION_TEST_KUBECONFIG) overrides all kube config settings. 64 _INTEGRATION_TEST_KUBECONFIG ?= $(INTEGRATION_TEST_KUBECONFIG) 65 66 # If $(INTEGRATION_TEST_KUBECONFIG) not specified, use $(KUBECONFIG). 67 ifeq ($(_INTEGRATION_TEST_KUBECONFIG),) 68 _INTEGRATION_TEST_KUBECONFIG = $(KUBECONFIG) 69 endif 70 71 # If neither $(INTEGRATION_TEST_KUBECONFIG) nor $(KUBECONFIG) specified, use default. 72 ifeq ($(_INTEGRATION_TEST_KUBECONFIG),) 73 _INTEGRATION_TEST_KUBECONFIG = ~/.kube/config 74 endif 75 76 _INTEGRATION_TEST_TOPOLOGY_FILE ?= $(INTEGRATION_TEST_TOPOLOGY_FILE) 77 ifneq ($(_INTEGRATION_TEST_TOPOLOGY_FILE),) 78 _INTEGRATION_TEST_FLAGS += --istio.test.kube.topology=$(_INTEGRATION_TEST_TOPOLOGY_FILE) 79 else 80 # integ-suite-kind.sh should populate the topology file with kubeconfigs 81 _INTEGRATION_TEST_FLAGS += --istio.test.kube.config=$(_INTEGRATION_TEST_KUBECONFIG) 82 endif 83 84 85 # Precompile tests before running. See https://blog.howardjohn.info/posts/go-build-times/#integration-tests. 86 define run-test 87 $(GO) test -exec=true -toolexec=$(REPO_ROOT)/tools/go-compile-without-link -vet=off -tags=integ $2 $1 88 $(GO) test -p 1 ${T} -tags=integ -vet=off -timeout 30m $2 $1 ${_INTEGRATION_TEST_FLAGS} ${_INTEGRATION_TEST_SELECT_FLAGS} 2>&1 | tee >($(JUNIT_REPORT) > $(JUNIT_OUT)) 89 endef 90 91 # Ensure that all test files are tagged properly. This ensures that we don't accidentally skip tests 92 # and that integration tests are not run as part of the unit test suite. 93 check-go-tag: 94 @go list ./tests/integration/... 2>/dev/null | xargs -r -I{} sh -c 'echo "Detected a file in tests/integration/ without a build tag set. Add // +build integ to the files: {}"; exit 2' 95 96 # Generate integration test targets for kubernetes environment. 97 test.integration.%.kube: | $(JUNIT_REPORT) check-go-tag 98 $(call run-test,./tests/integration/$(subst .,/,$*)/...) 99 100 # Generate integration fuzz test targets for kubernetes environment. 101 test.integration-fuzz.%.kube: | $(JUNIT_REPORT) check-go-tag 102 $(call run-test,./tests/integration/$(subst .,/,$*)/...,-tags="integfuzz integ") 103 104 # Generate presubmit integration test targets for each component in kubernetes environment 105 test.integration.%.kube.presubmit: 106 @make test.integration.$*.kube 107 108 # Run all tests 109 .PHONY: test.integration.kube 110 test.integration.kube: test.integration.kube.presubmit 111 @: 112 113 # Presubmit integration tests targeting Kubernetes environment. Really used for postsubmit on different k8s versions. 114 .PHONY: test.integration.kube.presubmit 115 test.integration.kube.presubmit: | $(JUNIT_REPORT) check-go-tag 116 $(call run-test,./tests/integration/...) 117 118 # Defines a target to run a standard set of tests in various different environments (IPv6, distroless, ARM, etc) 119 # In presubmit, this target runs a minimal set. In postsubmit, all tests are run 120 .PHONY: test.integration.kube.environment 121 test.integration.kube.environment: | $(JUNIT_REPORT) check-go-tag 122 ifeq (${JOB_TYPE},postsubmit) 123 $(call run-test,./tests/integration/...) 124 else 125 $(call run-test,./tests/integration/security/ ./tests/integration/pilot,-run="TestReachability|TestTraffic|TestGatewayConformance") 126 endif