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