Skip to content

Commit 1e49d89

Browse files
committed
(WIP) fix(ci): create/close tunnel logic
Signed-off-by: Ashing Zheng <[email protected]>
1 parent dc33d1d commit 1e49d89

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

test/e2e/framework/api7_gateway.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type API7DeployOptions struct {
6262
Replicas *int
6363
}
6464

65-
func (f *Framework) DeployGateway(opts API7DeployOptions) *corev1.Service {
65+
func (f *Framework) DeployGateway(opts *API7DeployOptions) *corev1.Service {
6666
if opts.ServiceName == "" {
6767
opts.ServiceName = "api7ee3-apisix-gateway-mtls"
6868
}

test/e2e/gatewayapi/httproute.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1921,7 +1921,7 @@ spec:
19211921
})
19221922
})
19231923

1924-
Context("Test HTTPRoute sync during startup", func() {
1924+
FContext("Test HTTPRoute sync during startup", func() {
19251925
BeforeEach(beforeEachHTTP)
19261926
var route = `
19271927
apiVersion: gateway.networking.k8s.io/v1
@@ -1988,6 +1988,7 @@ spec:
19881988
s.Deployer.ScaleDataplane(0)
19891989
s.Deployer.ScaleDataplane(1)
19901990
s.Deployer.ScaleIngress(1)
1991+
time.Sleep(10 * time.Second)
19911992

19921993
s.RequestAssert(&scaffold.RequestAssert{
19931994
Method: "GET",

test/e2e/scaffold/api7_deployer.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func (s *API7Deployer) AfterEach() {
114114
if output != "" {
115115
_, _ = fmt.Fprintln(GinkgoWriter, output)
116116
}
117+
return
117118
}
118119

119120
// Delete all additional namespaces
@@ -148,6 +149,7 @@ func (s *API7Deployer) DeployDataplane(deployOpts DeployDataplaneOptions) {
148149
ForIngressGatewayGroup: true,
149150
ServiceHTTPPort: 9080,
150151
ServiceHTTPSPort: 9443,
152+
Replicas: ptr.To(1),
151153
}
152154
if deployOpts.Namespace != "" {
153155
opts.Namespace = deployOpts.Namespace
@@ -164,13 +166,22 @@ func (s *API7Deployer) DeployDataplane(deployOpts DeployDataplaneOptions) {
164166
if deployOpts.Replicas != nil {
165167
opts.Replicas = deployOpts.Replicas
166168
}
169+
if opts.Replicas != nil && *opts.Replicas == 0 {
170+
deployOpts.SkipCreateTunnels = true
171+
}
167172

168-
svc := s.DeployGateway(opts)
173+
for _, close := range []func(){
174+
s.closeApisixHttpTunnel,
175+
s.closeApisixHttpsTunnel,
176+
} {
177+
close()
178+
}
169179

180+
svc := s.DeployGateway(&opts)
170181
s.dataplaneService = svc
171182

172183
if !deployOpts.SkipCreateTunnels {
173-
err := s.newAPISIXTunnels()
184+
err := s.newAPISIXTunnels(opts.ServiceName)
174185
Expect(err).ToNot(HaveOccurred(), "creating apisix tunnels")
175186
}
176187
}
@@ -181,8 +192,7 @@ func (s *API7Deployer) ScaleDataplane(replicas int) {
181192
})
182193
}
183194

184-
func (s *API7Deployer) newAPISIXTunnels() error {
185-
serviceName := "api7ee3-apisix-gateway-mtls"
195+
func (s *API7Deployer) newAPISIXTunnels(serviceName string) error {
186196
httpTunnel, httpsTunnel, err := s.createDataplaneTunnels(s.dataplaneService, s.kubectlOptions, serviceName)
187197
if err != nil {
188198
return err
@@ -247,7 +257,7 @@ func (s *API7Deployer) CreateAdditionalGateway(namePrefix string) (string, *core
247257
serviceName := fmt.Sprintf("api7ee3-apisix-gateway-%s", namePrefix)
248258

249259
// Deploy dataplane for this gateway group
250-
svc := s.DeployGateway(framework.API7DeployOptions{
260+
svc := s.DeployGateway(&framework.API7DeployOptions{
251261
GatewayGroupID: gatewayGroupID,
252262
Namespace: additionalNS,
253263
Name: serviceName,

0 commit comments

Comments
 (0)