From ca0d62c91af21693415dc5230aa13c30e2e3fb0a Mon Sep 17 00:00:00 2001 From: Xunzhuo Date: Mon, 6 Feb 2023 13:30:51 +0800 Subject: [PATCH] chore: some clean-up to e2e tests (#162) Signed-off-by: bitliu --- Makefile.core.mk | 6 ++-- .../tests/httproute-simple-same-namespace.go | 2 +- .../conformance/utils/kubernetes/apply.go | 9 +----- test/ingress/conformance/utils/suite/suite.go | 10 +------ test/ingress/e2e_test.go | 29 +++++-------------- 5 files changed, 14 insertions(+), 42 deletions(-) diff --git a/Makefile.core.mk b/Makefile.core.mk index 918f8d440..b0ed6e034 100644 --- a/Makefile.core.mk +++ b/Makefile.core.mk @@ -182,7 +182,7 @@ gateway-conformance-test: # ingress-conformance-test runs ingress api conformance tests. .PHONY: ingress-conformance-test -ingress-conformance-test: $(tools/kind) delete-cluster create-cluster kube-load-image install-dev run-ingress-e2e-test delete-cluster +ingress-conformance-test: $(tools/kind) delete-cluster create-cluster docker-build kube-load-image install-dev run-ingress-e2e-test delete-cluster # create-cluster creates a kube cluster with kind. .PHONY: create-cluster @@ -196,7 +196,7 @@ delete-cluster: $(tools/kind) ## Delete kind cluster. # kube-load-image loads a local built docker image into kube cluster. .PHONY: kube-load-image -kube-load-image: docker-build $(tools/kind) ## Install the EG image to a kind cluster using the provided $IMAGE and $TAG. +kube-load-image: $(tools/kind) ## Install the EG image to a kind cluster using the provided $IMAGE and $TAG. tools/hack/kind-load-image.sh higress-registry.cn-hangzhou.cr.aliyuncs.com/higress/higress $(TAG) # run-ingress-e2e-test starts to run ingress e2e tests. @@ -207,4 +207,4 @@ run-ingress-e2e-test: kubectl wait --timeout=5m -n higress-system deployment/higress-controller --for=condition=Available @echo -e "\n\033[36mWaiting higress-gateway to be ready...\033[0m\n" kubectl wait --timeout=5m -n higress-system deployment/higress-gateway --for=condition=Available - go test -v -tags conformance ./test/ingress/e2e_test.go --ingress-class=higress --debug=true --use-unique-ports=true + go test -v -tags conformance ./test/ingress/e2e_test.go --ingress-class=higress --debug=true diff --git a/test/ingress/conformance/tests/httproute-simple-same-namespace.go b/test/ingress/conformance/tests/httproute-simple-same-namespace.go index c8f4dff86..36ff94d35 100644 --- a/test/ingress/conformance/tests/httproute-simple-same-namespace.go +++ b/test/ingress/conformance/tests/httproute-simple-same-namespace.go @@ -27,7 +27,7 @@ func init() { var HTTPRouteSimpleSameNamespace = suite.ConformanceTest{ ShortName: "HTTPRouteSimpleSameNamespace", - Description: "A single Ingress in the higress-conformance-infra namespace attaches to a Gateway in the same namespace", + Description: "A single Ingress in the higress-conformance-infra namespace demonstrates basic routing ability", Manifests: []string{"tests/httproute-simple-same-namespace.yaml"}, Test: func(t *testing.T, suite *suite.ConformanceTestSuite) { diff --git a/test/ingress/conformance/utils/kubernetes/apply.go b/test/ingress/conformance/utils/kubernetes/apply.go index 5608e2c29..b1c1a581a 100644 --- a/test/ingress/conformance/utils/kubernetes/apply.go +++ b/test/ingress/conformance/utils/kubernetes/apply.go @@ -39,15 +39,8 @@ import ( // them to the Kubernetes cluster. type Applier struct { NamespaceLabels map[string]string - // ValidUniqueListenerPorts maps each listener port of each Gateway in the - // manifests to a valid, unique port. There must be as many - // ValidUniqueListenerPorts as there are listeners in the set of manifests. - // For example, given two Gateways, each with 2 listeners, there should be - // four ValidUniqueListenerPorts. - // If empty or nil, ports are not modified. - ValidUniqueListenerPorts []int - // IngressClass will be used as the spec.gatewayClassName when applying Gateway resources + // IngressClass will be used as the spec.ingressClassName when applying Ingress resources IngressClass string } diff --git a/test/ingress/conformance/utils/suite/suite.go b/test/ingress/conformance/utils/suite/suite.go index 6e4d78fd1..173713dad 100644 --- a/test/ingress/conformance/utils/suite/suite.go +++ b/test/ingress/conformance/utils/suite/suite.go @@ -87,13 +87,6 @@ type Options struct { RoundTripper roundtripper.RoundTripper BaseManifests string NamespaceLabels map[string]string - // ValidUniqueListenerPorts maps each listener port of each Gateway in the - // manifests to a valid, unique port. There must be as many - // ValidUniqueListenerPorts as there are listeners in the set of manifests. - // For example, given two Gateways, each with 2 listeners, there should be - // four ValidUniqueListenerPorts. - // If empty or nil, ports are not modified. - ValidUniqueListenerPorts []int // CleanupBaseResources indicates whether or not the base test // resources such as Gateways should be cleaned up after the run. @@ -130,8 +123,7 @@ func New(s Options) *ConformanceTestSuite { BaseManifests: s.BaseManifests, GatewayAddress: s.GatewayAddress, Applier: kubernetes.Applier{ - NamespaceLabels: s.NamespaceLabels, - ValidUniqueListenerPorts: s.ValidUniqueListenerPorts, + NamespaceLabels: s.NamespaceLabels, }, SupportedFeatures: s.SupportedFeatures, TimeoutConfig: s.TimeoutConfig, diff --git a/test/ingress/e2e_test.go b/test/ingress/e2e_test.go index e2bd1c157..aa5f1cf99 100644 --- a/test/ingress/e2e_test.go +++ b/test/ingress/e2e_test.go @@ -1,6 +1,3 @@ -//go:build conformance -// +build conformance - // Copyright (c) 2022 Alibaba Group Holding Ltd. // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,8 +27,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client/config" ) -var useUniquePorts = flag.Bool("use-unique-ports", true, "whether to use unique ports") - func TestHigressConformanceTests(t *testing.T) { flag.Parse() @@ -43,28 +38,20 @@ func TestHigressConformanceTests(t *testing.T) { require.NoError(t, v1.AddToScheme(client.Scheme())) - validUniqueListenerPorts := []int{ - 80, - 443, - } - - if !*useUniquePorts { - validUniqueListenerPorts = []int{} - } - cSuite := suite.New(suite.Options{ - Client: client, - IngressClassName: *flags.IngressClassName, - Debug: *flags.ShowDebug, - CleanupBaseResources: *flags.CleanupBaseResources, - ValidUniqueListenerPorts: validUniqueListenerPorts, - SupportedFeatures: map[suite.SupportedFeature]bool{}, - GatewayAddress: "localhost", + Client: client, + IngressClassName: *flags.IngressClassName, + Debug: *flags.ShowDebug, + CleanupBaseResources: *flags.CleanupBaseResources, + SupportedFeatures: map[suite.SupportedFeature]bool{}, + GatewayAddress: "localhost", }) + cSuite.Setup(t) higressTests := []suite.ConformanceTest{ tests.HTTPRouteSimpleSameNamespace, tests.HTTPRouteHostNameSameNamespace, } + cSuite.Run(t, higressTests) }