Repository: kumahq/kuma
Pull request #1867 (2021-04-21 16:07:25)

chore(ci) enable integration tests
### Summary

Enable integration tests for `release-1.1`




Patch:
diff --git a/.circleci/config.yml b/.circleci/config.yml
index a94fdaf1a..7c70f5f53 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -532,7 +532,7 @@ jobs:
       target:
         description: The integration make target.
         type: string
-        default: test
+        default: integration
     environment:
       GOPATH: /home/circleci/.go-kuma-go
     steps:
@@ -875,7 +875,7 @@ workflows:
         requires:
         - check
         # custom parameters
-        target: -j1 test
+        target: -j1 integration test
     - images:
         <<: *commit_workflow_filters
         requires:
diff --git a/pkg/xds/topology/outbound.go b/pkg/xds/topology/outbound.go
index 691dc8d11..72004e262 100644
--- a/pkg/xds/topology/outbound.go
+++ b/pkg/xds/topology/outbound.go
@@ -179,18 +179,25 @@ func convertToEnvoy(ds *v1alpha1.DataSource, mesh string, loader datasource.Load
 }
 
 func localityFromTags(mesh *mesh_core.MeshResource, priority uint32, tags map[string]string) *core_xds.Locality {
-	if !mesh.Spec.GetRouting().GetLocalityAwareLoadBalancing() {
-		return nil
-	}
-
 	region, regionPresent := tags[mesh_proto.RegionTag]
 	zone, zonePresent := tags[mesh_proto.ZoneTag]
 	subZone, subZonePresent := tags[mesh_proto.SubZoneTag]
 
 	if !regionPresent && !zonePresent && !subZonePresent {
+		// this means that we are running in standalone since in multi-zone Kuma always adds Zone tag automatically
 		return nil
 	}
 
+	if !mesh.Spec.GetRouting().GetLocalityAwareLoadBalancing() {
+		// we want to set the Locality even when localityAwareLoadbalancing is enabled
+		// If we set the locality we have an extra visibility about this in /clusters etc.
+		// Kuma's LocalityAwareLoadBalancing feature is based only on Priority therefore when it's disabled we need to set Priority to local
+		//
+		// Setting this regardless of LocalityAwareLoadBalancing on the mesh also solves the problem that endpoints have problems when moving from one locality to another
+		// https://github.com/envoyproxy/envoy/issues/12392
+		priority = priorityLocal
+	}
+
 	return &core_xds.Locality{
 		Region:   region,
 		Zone:     zone,


Test patch:
diff --git a/mk/e2e.new.mk b/mk/e2e.new.mk
index 9a400c972..05e603007 100644
--- a/mk/e2e.new.mk
+++ b/mk/e2e.new.mk
@@ -15,6 +15,52 @@ KUMA_IN_EKS ?=
 KUMA_DEFAULT_RETRIES ?=
 KUMA_DEFAULT_TIMEOUT ?=
 
+ENV_VARS ?= API_VERSION="$(API_VERSION)"
+
+ifdef KUMA_UNIVERSAL_IMAGE
+	ENV_VARS += KUMA_UNIVERSAL_IMAGE=$(KUMA_UNIVERSAL_IMAGE)
+endif
+
+ifdef HELM_CHART_PATH
+	ENV_VARS += HELM_CHART_PATH=$(HELM_CHART_PATH)
+endif
+
+ifdef KUMA_GLOBAL_IMAGE_TAG
+	ENV_VARS += KUMA_GLOBAL_IMAGE_TAG=$(KUMA_GLOBAL_IMAGE_TAG)
+endif
+
+ifdef KUMA_GLOBAL_IMAGE_REGISTRY
+	ENV_VARS += KUMA_GLOBAL_IMAGE_REGISTRY=$(KUMA_GLOBAL_IMAGE_REGISTRY)
+endif
+
+ifdef KUMA_CP_IMAGE_REPOSITORY
+	ENV_VARS += KUMA_CP_IMAGE_REPOSITORY=$(KUMA_CP_IMAGE_REPOSITORY)
+endif
+
+ifdef KUMA_DP_IMAGE_REPOSITORY
+	ENV_VARS += KUMA_DP_IMAGE_REPOSITORY=$(KUMA_DP_IMAGE_REPOSITORY)
+endif
+
+ifdef KUMA_DP_INIT_IMAGE_REPOSITORY
+	ENV_VARS += KUMA_DP_INIT_IMAGE_REPOSITORY=$(KUMA_DP_INIT_IMAGE_REPOSITORY)
+endif
+
+ifdef KUMA_USE_LOAD_BALANCER
+	ENV_VARS += KUMA_USE_LOAD_BALANCER=$(KUMA_USE_LOAD_BALANCER)
+endif
+
+ifdef KUMA_IN_EKS
+	ENV_VARS += KUMA_IN_EKS=$(KUMA_IN_EKS)
+endif
+
+ifdef KUMA_DEFAULT_RETRIES
+	ENV_VARS += KUMA_DEFAULT_RETRIES=$(KUMA_DEFAULT_RETRIES)
+endif
+
+ifdef KUMA_DEFAULT_TIMEOUT
+	ENV_VARS += KUMA_DEFAULT_TIMEOUT=$(KUMA_DEFAULT_TIMEOUT)
+endif
+
 TEST_NAMES = $(shell ls -1 ./test/e2e)
 ALL_TESTS = $(addprefix ./test/e2e/, $(addsuffix /..., $(TEST_NAMES)))
 E2E_PKG_LIST ?= $(ALL_TESTS)
@@ -56,19 +102,8 @@ test/e2e/test:
 	for t in $(E2E_PKG_LIST); do \
 		K8SCLUSTERS="$(K8SCLUSTERS)" \
 		KUMACTLBIN=${BUILD_ARTIFACTS_DIR}/kumactl/kumactl \
-		API_VERSION="$(API_VERSION)" \
-		HELM_CHART_PATH="$(HELM_CHART_PATH)" \
-		KUMA_GLOBAL_IMAGE_TAG="$(KUMA_GLOBAL_IMAGE_TAG)" \
-		KUMA_GLOBAL_IMAGE_REGISTRY="$(KUMA_GLOBAL_IMAGE_REGISTRY)" \
-		KUMA_CP_IMAGE_REPOSITORY="$(KUMA_CP_IMAGE_REPOSITORY)" \
-		KUMA_DP_IMAGE_REPOSITORY="$(KUMA_DP_IMAGE_REPOSITORY)" \
-		KUMA_DP_INIT_IMAGE_REPOSITORY="$(KUMA_DP_INIT_IMAGE_REPOSITORY)" \
-		KUMA_USE_LOAD_BALANCER="$(KUMA_USE_LOAD_BALANCER)" \
-		KUMA_IN_EKS="$(KUMA_IN_EKS)" \
-		KUMA_UNIVERSAL_IMAGE="$(KUMA_UNIVERSAL_IMAGE)" \
-		KUMA_DEFAULT_RETRIES="$(KUMA_DEFAULT_RETRIES)" \
-        KUMA_DEFAULT_TIMEOUT="$(KUMA_DEFAULT_TIMEOUT)" \
-			$(GO_TEST) -v -timeout=45m $$t || exit; \
+		$(ENV_VARS) \
+		$(GO_TEST) -v -timeout=45m $$t || exit; \
 	done
 
 # test/e2e/debug is used for quicker feedback of E2E tests (ex. debugging flaky tests)
diff --git a/pkg/xds/topology/outbound_test.go b/pkg/xds/topology/outbound_test.go
index 33603ab22..4c806db59 100644
--- a/pkg/xds/topology/outbound_test.go
+++ b/pkg/xds/topology/outbound_test.go
@@ -59,7 +59,6 @@ var _ = Describe("TrafficRoute", func() {
 		dataSourceLoader = datasource.NewDataSourceLoader(secretManager)
 	})
 	Describe("GetOutboundTargets()", func() {
-
 		It("should pick proper dataplanes for each outbound destination", func() {
 			// given
 			backend := &mesh_core.DataplaneResource{ // dataplane that is a source of traffic
@@ -197,12 +196,18 @@ var _ = Describe("TrafficRoute", func() {
 						mesh_proto.ServiceTag: "elastic",
 						mesh_proto.RegionTag:  "eu",
 					},
+					Locality: &core_xds.Locality{
+						Region: "eu",
+					},
 					Weight: 1,
 				},
 				{
 					Target: "192.168.0.6",
 					Port:   9200,
 					Tags:   map[string]string{mesh_proto.ServiceTag: "elastic", mesh_proto.RegionTag: "us"},
+					Locality: &core_xds.Locality{
+						Region: "us",
+					},
 					Weight: 1,
 				},
 			}))
@@ -214,6 +219,9 @@ var _ = Describe("TrafficRoute", func() {
 						mesh_proto.ServiceTag: "frontend",
 						mesh_proto.RegionTag:  "eu",
 					},
+					Locality: &core_xds.Locality{
+						Region: "eu",
+					},
 					Weight: 1,
 				},
 			}))
@@ -225,6 +233,9 @@ var _ = Describe("TrafficRoute", func() {
 						mesh_proto.ServiceTag: "backend",
 						mesh_proto.RegionTag:  "eu",
 					},
+					Locality: &core_xds.Locality{
+						Region: "eu",
+					},
 					Weight: 1,
 				},
 			}))
@@ -362,6 +373,9 @@ var _ = Describe("TrafficRoute", func() {
 							Target: "192.168.0.100",
 							Port:   12345,
 							Tags:   map[string]string{mesh_proto.ServiceTag: "redis", "version": "v2", mesh_proto.RegionTag: "eu"},
+							Locality: &core_xds.Locality{
+								Region: "eu",
+							},
 							Weight: 2,
 						},
 						{
@@ -374,6 +388,9 @@ var _ = Describe("TrafficRoute", func() {
 							Target: "192.168.0.101",
 							Port:   12345,
 							Tags:   map[string]string{mesh_proto.ServiceTag: "redis", "version": "v2", mesh_proto.RegionTag: "eu"},
+							Locality: &core_xds.Locality{
+								Region: "eu",
+							},
 							Weight: 2,
 						},
 						{
@@ -445,6 +462,9 @@ var _ = Describe("TrafficRoute", func() {
 							Target: "192.168.0.100",
 							Port:   12345,
 							Tags:   map[string]string{mesh_proto.ServiceTag: "redis", "version": "v2", mesh_proto.RegionTag: "eu"},
+							Locality: &core_xds.Locality{
+								Region: "eu",
+							},
 							Weight: 2,
 						},
 						{
diff --git a/test/framework/env.go b/test/framework/env.go
index 8bf9732d9..7409cd207 100644
--- a/test/framework/env.go
+++ b/test/framework/env.go
@@ -36,7 +36,7 @@ func GetGlobalImageRegistry() string {
 }
 
 func HasGlobalImageRegistry() bool {
-	return envBool("KUMA_GLOBAL_IMAGE_REGISTRY")
+	return envIsPresent("KUMA_GLOBAL_IMAGE_REGISTRY")
 }
 
 func GetGlobalImageTag() string {
@@ -44,7 +44,7 @@ func GetGlobalImageTag() string {
 }
 
 func HasGlobalImageTag() bool {
-	return envBool("KUMA_GLOBAL_IMAGE_TAG")
+	return envIsPresent("KUMA_GLOBAL_IMAGE_TAG")
 }
 
 func GetCpImageRegistry() string {
@@ -52,7 +52,7 @@ func GetCpImageRegistry() string {
 }
 
 func HasCpImageRegistry() bool {
-	return envBool("KUMA_CP_IMAGE_REPOSITORY")
+	return envIsPresent("KUMA_CP_IMAGE_REPOSITORY")
 }
 
 func GetDpImageRegistry() string {
@@ -60,7 +60,7 @@ func GetDpImageRegistry() string {
 }
 
 func HasDpImageRegistry() bool {
-	return envBool("KUMA_DP_IMAGE_REPOSITORY")
+	return envIsPresent("KUMA_DP_IMAGE_REPOSITORY")
 }
 
 func GetDpInitImageRegistry() string {
@@ -68,7 +68,7 @@ func GetDpInitImageRegistry() string {
 }
 
 func HasDpInitImageRegistry() bool {
-	return envBool("KUMA_DP_INIT_IMAGE_REPOSITORY")
+	return envIsPresent("KUMA_DP_INIT_IMAGE_REPOSITORY")
 }
 
 func GetUniversalImage() string {
@@ -84,7 +84,7 @@ func GetApiVersion() string {
 }
 
 func HasApiVersion() bool {
-	return envBool(envAPIVersion)
+	return envIsPresent(envAPIVersion)
 }
 
 func GetHelmChartPath() string {
@@ -92,7 +92,7 @@ func GetHelmChartPath() string {
 }
 
 func HasHelmChartPath() bool {
-	return envBool("HELM_CHART_PATH")
+	return envIsPresent("HELM_CHART_PATH")
 }
 
 func GetCniConfName() string {
@@ -100,7 +100,7 @@ func GetCniConfName() string {
 }
 
 func HasCniConfName() bool {
-	return envBool("KUMA_CNI_CONF_NAME")
+	return envIsPresent("KUMA_CNI_CONF_NAME")
 }
 
 func UseLoadBalancer() bool {
@@ -120,8 +120,13 @@ func GetKumactlBin() string {
 }
 
 func IsK8sClustersStarted() bool {
-	_, found := os.LookupEnv(envK8SCLUSTERS)
-	return found
+	return envIsPresent(envK8SCLUSTERS)
+}
+
+func envIsPresent(env string) bool {
+	_, ok := os.LookupEnv(env)
+
+	return ok
 }
 
 func envBool(env string) bool {