Skip to content

Commit c355f8c

Browse files
committed
fix: get admin endpoint
Signed-off-by: ashing <[email protected]>
1 parent 340f91f commit c355f8c

File tree

12 files changed

+47
-31
lines changed

12 files changed

+47
-31
lines changed

test/e2e/crds/backendtrafficpolicy.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import (
1919
. "github.com/onsi/ginkgo/v2"
2020
. "github.com/onsi/gomega"
2121

22-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2322
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2423
)
2524

@@ -216,7 +215,7 @@ spec:
216215
`
217216
var beforeEach = func() {
218217
By("create GatewayProxy")
219-
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, framework.DashboardTLSEndpoint, s.AdminKey())
218+
gatewayProxy := fmt.Sprintf(defaultGatewayProxy, s.Deployer.GetAdminEndpoint(), s.AdminKey())
220219
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
221220
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
222221

test/e2e/crds/consumer.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
2222

23-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2423
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2524
)
2625

@@ -494,7 +493,7 @@ spec:
494493
Status(404)
495494

496495
By("update GatewayProxy with new admin key")
497-
updatedProxy := fmt.Sprintf(updatedGatewayProxy, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
496+
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
498497
err = s.CreateResourceFromString(updatedProxy)
499498
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
500499
time.Sleep(5 * time.Second)

test/e2e/gatewayapi/controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
. "github.com/onsi/gomega"
2121
"github.com/stretchr/testify/assert"
2222

23-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2423
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2524
)
2625

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

103102
By("create GatewayProxy")
104-
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
103+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
105104
err = s.CreateResourceFromStringWithNamespace(gatewayProxy, gatewayName)
106105
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
107106
time.Sleep(5 * time.Second)

test/e2e/gatewayapi/gateway.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ spec:
107107

108108
It("Create Gateway", func() {
109109
By("create GatewayProxy")
110-
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
110+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
111111
err := s.CreateResourceFromString(gatewayProxy)
112112
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
113113
time.Sleep(5 * time.Second)
@@ -150,7 +150,7 @@ spec:
150150
Context("Gateway SSL", func() {
151151
It("Check if SSL resource was created", func() {
152152
By("create GatewayProxy")
153-
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
153+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
154154
err := s.CreateResourceFromString(gatewayProxy)
155155
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
156156
time.Sleep(5 * time.Second)
@@ -211,7 +211,7 @@ spec:
211211
Context("Gateway SSL with and without hostname", func() {
212212
It("Check if SSL resource was created and updated", func() {
213213
By("create GatewayProxy")
214-
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
214+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
215215
err := s.CreateResourceFromString(gatewayProxy)
216216
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
217217
time.Sleep(5 * time.Second)

test/e2e/gatewayapi/gatewayproxy.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
. "github.com/onsi/ginkgo/v2"
2121
. "github.com/onsi/gomega"
2222

23-
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2423
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2524
)
2625

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

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

@@ -234,7 +233,7 @@ spec:
234233
By("Clean up resources")
235234
_ = s.DeleteResourceFromString(fmt.Sprintf(httpRouteForTest, "apisix"))
236235
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayWithProxy, gatewayClassName))
237-
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, framework.DashboardTLSEndpoint, s.AdminKey()))
236+
_ = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithEnabledPlugin, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
238237
})
239238

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

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

@@ -277,7 +276,7 @@ spec:
277276

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

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

295294
By("Update GatewayProxy with PluginMetadata")
296-
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata1, framework.DashboardTLSEndpoint, s.AdminKey()))
295+
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata1, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
297296
Expect(err).ShouldNot(HaveOccurred())
298297
time.Sleep(5 * time.Second)
299298

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

308307
By("Delete GatewayProxy")
309-
err = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, framework.DashboardTLSEndpoint, s.AdminKey()))
308+
err = s.DeleteResourceFromString(fmt.Sprintf(gatewayProxyWithPluginMetadata0, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
310309
Expect(err).ShouldNot(HaveOccurred())
311310
time.Sleep(5 * time.Second)
312311

test/e2e/gatewayapi/httproute.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ spec:
123123

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

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

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

@@ -1688,7 +1688,7 @@ spec:
16881688
Status(404)
16891689

16901690
By("update GatewayProxy with new admin key")
1691-
updatedProxy := fmt.Sprintf(updatedGatewayProxy, framework.DashboardTLSEndpoint, resources.AdminAPIKey)
1691+
updatedProxy := fmt.Sprintf(updatedGatewayProxy, s.Deployer.GetAdminEndpoint(resources.DataplaneService), resources.AdminAPIKey)
16921692
err = s.CreateResourceFromString(updatedProxy)
16931693
Expect(err).NotTo(HaveOccurred(), "updating GatewayProxy")
16941694
time.Sleep(5 * time.Second)

test/e2e/ingress/ingress.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
Context("Ingress TLS", func() {
6868
It("Check if SSL resource was created", func() {
6969
By("create GatewayProxy")
70-
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, framework.DashboardTLSEndpoint, s.AdminKey())
70+
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
7171

7272
By("create GatewayProxy")
7373
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
@@ -202,7 +202,7 @@ spec:
202202

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

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

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

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

439439
By("create GatewayProxy")
440440
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
@@ -477,7 +477,7 @@ stringData:
477477
time.Sleep(5 * time.Second)
478478

479479
By("create GatewayProxy with Secret reference")
480-
gatewayProxy := fmt.Sprintf(gatewayProxyWithSecretYaml, framework.DashboardTLSEndpoint)
480+
gatewayProxy := fmt.Sprintf(gatewayProxyWithSecretYaml, s.Deployer.GetAdminEndpoint())
481481
err = s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
482482
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy with Secret")
483483
time.Sleep(5 * time.Second)
@@ -520,7 +520,7 @@ spec:
520520
type: AdminKey
521521
adminKey:
522522
value: "%s"
523-
`, framework.DashboardTLSEndpoint, s.AdminKey())
523+
`, s.Deployer.GetAdminEndpoint(), s.AdminKey())
524524
}
525525

526526
const ingressClassSpec = `
@@ -806,7 +806,7 @@ spec:
806806

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

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

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

946946
By("create IngressClass")

test/e2e/scaffold/api7_deployer.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/gruntwork-io/terratest/modules/k8s"
2222
. "github.com/onsi/ginkgo/v2" //nolint:staticcheck
2323
. "github.com/onsi/gomega" //nolint:staticcheck
24+
corev1 "k8s.io/api/core/v1"
2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526

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

298299
return err
299300
}
301+
302+
func (s *API7Deployer) GetAdminEndpoint(_ ...*corev1.Service) string {
303+
// always return the default dashboard endpoint
304+
return framework.DashboardTLSEndpoint
305+
}

test/e2e/scaffold/apisix_deployer.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,10 @@ func (s *APISIXDeployer) CleanupAdditionalGateway(identifier string) error {
336336

337337
return err
338338
}
339+
340+
func (s *APISIXDeployer) GetAdminEndpoint(svc ...*corev1.Service) string {
341+
if len(svc) == 0 {
342+
return fmt.Sprintf("http://%s.%s:9180", s.dataplaneService.Name, s.dataplaneService.Namespace)
343+
}
344+
return fmt.Sprintf("http://%s.%s:9180", svc[0].Name, svc[0].Namespace)
345+
}

test/e2e/scaffold/deployer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
package scaffold
1414

15+
import corev1 "k8s.io/api/core/v1"
16+
1517
// Deployer defines the interface for deploying data plane components
1618
type Deployer interface {
1719
// Deploy deploys components for scaffold
@@ -22,6 +24,7 @@ type Deployer interface {
2224
AfterEach()
2325
CreateAdditionalGateway(namePrefix string) (string, string, error)
2426
CleanupAdditionalGateway(identifier string) error
27+
GetAdminEndpoint(...*corev1.Service) string
2528
}
2629

2730
var NewDeployer func(*Scaffold) Deployer

0 commit comments

Comments
 (0)