Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions test/e2e/crds/backendtrafficpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/apache/apisix-ingress-controller/test/e2e/framework"
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)

Expand Down Expand Up @@ -216,7 +215,7 @@ spec:
`
var beforeEach = func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/crds/consumer.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/apache/apisix-ingress-controller/test/e2e/framework"
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)

Expand Down Expand Up @@ -494,7 +493,7 @@ spec:
Status(404)

By("update GatewayProxy with new admin key")
updatedProxy := fmt.Sprintf(updatedGatewayProxy, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
err = s.CreateResourceFromString(updatedProxy)
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/gatewayapi/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
. "github.com/onsi/gomega"
"github.com/stretchr/testify/assert"

"github.com/apache/apisix-ingress-controller/test/e2e/framework"
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)

Expand Down Expand Up @@ -101,7 +100,7 @@ metadata:
By(fmt.Sprintf("create GatewayClass for controller %s", s.GetControllerName()))

By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err = s.CreateResourceFromStringWithNamespace(gatewayProxy, gatewayName)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down
6 changes: 3 additions & 3 deletions test/e2e/gatewayapi/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ spec:

It("Create Gateway", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -150,7 +150,7 @@ spec:
Context("Gateway SSL", func() {
It("Check if SSL resource was created", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -211,7 +211,7 @@ spec:
Context("Gateway SSL with and without hostname", func() {
It("Check if SSL resource was created and updated", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down
13 changes: 6 additions & 7 deletions test/e2e/gatewayapi/gatewayproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/apache/apisix-ingress-controller/test/e2e/framework"
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
)

Expand Down Expand Up @@ -214,7 +213,7 @@ spec:
Expect(gcYaml).To(ContainSubstring("message: the gatewayclass has been accepted by the apisix-ingress-controller"), "checking GatewayClass condition message")

By("Create GatewayProxy with enabled plugin")
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, framework.DashboardTLSEndpoint, s.AdminKey()))
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy with enabled plugin")
time.Sleep(5 * time.Second)

Expand All @@ -234,7 +233,7 @@ spec:
By("Clean up resources")
_ = s.DeleteResourceFromString(fmt.Sprintf(httpRouteForTest, "apisix"))
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayWithProxy, gatewayClassName))
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, framework.DashboardTLSEndpoint, s.AdminKey()))
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
})

Context("Test Gateway with enabled GatewayProxy plugin", func() {
Expand All @@ -252,7 +251,7 @@ spec:
resp.Header("X-Proxy-Test").IsEqual("enabled")

By("Update GatewayProxy with disabled plugin")
err := s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithDisabledPlugin, framework.DashboardTLSEndpoint, s.AdminKey()))
err := s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithDisabledPlugin, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy with disabled plugin")
time.Sleep(5 * time.Second)

Expand All @@ -277,7 +276,7 @@ spec:

It("Should work OK with error-page", func() {
By("Update GatewayProxy with PluginMetadata")
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, framework.DashboardTLSEndpoint, s.AdminKey()))
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).ShouldNot(HaveOccurred())
time.Sleep(5 * time.Second)

Expand All @@ -293,7 +292,7 @@ spec:
Body().Contains("404 from plugin metadata")

By("Update GatewayProxy with PluginMetadata")
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata1, framework.DashboardTLSEndpoint, s.AdminKey()))
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata1, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).ShouldNot(HaveOccurred())
time.Sleep(5 * time.Second)

Expand All @@ -306,7 +305,7 @@ spec:
Body().Contains(`{"error_msg":"404 Route Not Found"}`)

By("Delete GatewayProxy")
err = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, framework.DashboardTLSEndpoint, s.AdminKey()))
err = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
Expect(err).ShouldNot(HaveOccurred())
time.Sleep(5 * time.Second)

Expand Down
8 changes: 4 additions & 4 deletions test/e2e/gatewayapi/httproute.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ spec:

var beforeEachHTTP = func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -154,7 +154,7 @@ spec:

var beforeEachHTTPS = func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -322,7 +322,7 @@ spec:
Expect(gcyaml).To(ContainSubstring(`status: "True"`), "checking additional GatewayClass condition status")
Expect(gcyaml).To(ContainSubstring("message: the gatewayclass has been accepted by the apisix-ingress-controller"), "checking additional GatewayClass condition message")

additionalGatewayProxy := fmt.Sprintf(additionalGatewayProxyYaml, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
additionalGatewayProxy := fmt.Sprintf(additionalGatewayProxyYaml, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
err = s.CreateResourceFromStringWithNamespace(additionalGatewayProxy, additionalNamespace)
Expect(err).NotTo(HaveOccurred(), "creating additional GatewayProxy")

Expand Down Expand Up @@ -1688,7 +1688,7 @@ spec:
Status(404)

By("update GatewayProxy with new admin key")
updatedProxy := fmt.Sprintf(updatedGatewayProxy, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
err = s.CreateResourceFromString(updatedProxy)
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down
20 changes: 10 additions & 10 deletions test/e2e/ingress/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
Context("Ingress TLS", func() {
It("Check if SSL resource was created", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())

By("create GatewayProxy")
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expand Down Expand Up @@ -202,7 +202,7 @@ spec:

It("Test IngressClass Selection", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand All @@ -227,7 +227,7 @@ spec:

It("Proxy External Service", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand All @@ -252,7 +252,7 @@ spec:

It("Delete Ingress during restart", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -434,7 +434,7 @@ spec:

It("Test IngressClass with GatewayProxy", func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())

By("create GatewayProxy")
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expand Down Expand Up @@ -477,7 +477,7 @@ stringData:
time.Sleep(5 * time.Second)

By("create GatewayProxy with Secret reference")
gatewayProxy := fmt.Sprintf(gatewayProxyWithSecretYaml, framework.DashboardTLSEndpoint)
gatewayProxy := fmt.Sprintf(gatewayProxyWithSecretYaml, s.Deployer.GetAdminEndpoint())
err = s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy with Secret")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -520,7 +520,7 @@ spec:
type: AdminKey
adminKey:
value: "%s"
`, framework.DashboardTLSEndpoint, s.AdminKey())
`, s.Deployer.GetAdminEndpoint(), s.AdminKey())
}

const ingressClassSpec = `
Expand Down Expand Up @@ -806,7 +806,7 @@ spec:

BeforeEach(func() {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -848,7 +848,7 @@ spec:
Expect(exists).To(BeTrue(), "additional gateway group should exist")

By("update GatewayProxy with new admin key")
updatedProxy := fmt.Sprintf(updatedGatewayProxy, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
err = s.CreateResourceFromStringWithNamespace(updatedProxy, "default")
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down Expand Up @@ -940,7 +940,7 @@ spec:
Expect(err).NotTo(HaveOccurred(), "creating secret")

By("create GatewayProxy")
err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayProxySpec, framework.DashboardTLSEndpoint), s.Namespace())
err = s.CreateResourceFromStringWithNamespace(fmt.Sprintf(gatewayProxySpec, s.Deployer.GetAdminEndpoint()), s.Namespace())
Expect(err).NotTo(HaveOccurred(), "creating gateway proxy")

By("create IngressClass")
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/scaffold/api7_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/gruntwork-io/terratest/modules/k8s"
. "github.com/onsi/ginkgo/v2" //nolint:staticcheck
. "github.com/onsi/gomega" //nolint:staticcheck
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/apache/apisix-ingress-controller/pkg/dashboard"
Expand Down Expand Up @@ -297,3 +298,8 @@ func (s *API7Deployer) CleanupAdditionalGateway(gatewayGroupID string) error {

return err
}

func (s *API7Deployer) GetAdminEndpoint(_ ...*corev1.Service) string {
// always return the default dashboard endpoint
return framework.DashboardTLSEndpoint
}
7 changes: 7 additions & 0 deletions test/e2e/scaffold/apisix_deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,3 +336,10 @@ func (s *APISIXDeployer) CleanupAdditionalGateway(identifier string) error {

return err
}

func (s *APISIXDeployer) GetAdminEndpoint(svc ...*corev1.Service) string {
if len(svc) == 0 {
return fmt.Sprintf("http://%s.%s:9180", s.dataplaneService.Name, s.dataplaneService.Namespace)
}
return fmt.Sprintf("http://%s.%s:9180", svc[0].Name, svc[0].Namespace)
}
3 changes: 3 additions & 0 deletions test/e2e/scaffold/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

package scaffold

import corev1 "k8s.io/api/core/v1"

// Deployer defines the interface for deploying data plane components
type Deployer interface {
// Deploy deploys components for scaffold
Expand All @@ -22,6 +24,7 @@ type Deployer interface {
AfterEach()
CreateAdditionalGateway(namePrefix string) (string, string, error)
CleanupAdditionalGateway(identifier string) error
GetAdminEndpoint(...*corev1.Service) string
}

var NewDeployer func(*Scaffold) Deployer
2 changes: 1 addition & 1 deletion test/e2e/scaffold/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func (s *Scaffold) ApplyDefaultGatewayResource(
defaultHTTPRoute string,
) {
By("create GatewayProxy")
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, framework.DashboardTLSEndpoint, s.AdminKey())
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, s.Deployer.GetAdminEndpoint(), s.AdminKey())
err := s.CreateResourceFromString(gatewayProxy)
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
time.Sleep(5 * time.Second)
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/scaffold/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ type GatewayResources struct {
AdminAPIKey string
}

func (g *GatewayResources) GetAdminEndpoint() string {
return fmt.Sprintf("http://%s.%s:9180", g.DataplaneService.Name, g.DataplaneService.Namespace)
}

func (s *Scaffold) AdminKey() string {
return s.opts.APISIXAdminAPIKey
}
Expand Down
Loading