Skip to content

Commit b83fd8e

Browse files
authored
fix(ci): create/close tunnel logic (#213)
Signed-off-by: Ashing Zheng <axingfly@gmail.com>
1 parent dc33d1d commit b83fd8e

7 files changed

Lines changed: 20 additions & 21 deletions

File tree

test/conformance/suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestMain(m *testing.M) {
139139
gatewayGroupId := f.CreateNewGatewayGroupWithIngress()
140140
adminKey := f.GetAdminKey(gatewayGroupId)
141141

142-
svc := f.DeployGateway(framework.API7DeployOptions{
142+
svc := f.DeployGateway(&framework.API7DeployOptions{
143143
Namespace: namespace,
144144
GatewayGroupID: gatewayGroupId,
145145
DPManagerEndpoint: framework.DPManagerTLSEndpoint,

test/e2e/crds/v1alpha1/consumer.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
. "github.com/onsi/ginkgo/v2"
2424
. "github.com/onsi/gomega"
2525

26-
"github.com/apache/apisix-ingress-controller/internal/provider/adc"
2726
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
2827
)
2928

@@ -616,9 +615,6 @@ spec:
616615
})
617616

618617
It("Should sync Consumer during startup", func() {
619-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
620-
Skip("don't need to run on api7ee mode")
621-
}
622618
Expect(s.CreateResourceFromString(consumer2)).NotTo(HaveOccurred(), "creating unused consumer")
623619
s.ResourceApplied("Consumer", "consumer-sample", consumer1, 1)
624620

test/e2e/crds/v1alpha1/gatewayproxy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ spec:
133133
`
134134
BeforeEach(func() {
135135
By("create GatewayProxy")
136-
if s.Deployer.Name() == "api7ee" {
136+
if s.Deployer.Name() == adc.BackendModeAPI7EE {
137137
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxySpecAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey()))
138138
} else {
139139
err = s.CreateResourceFromString(fmt.Sprintf(gatewayProxySpec, framework.ProviderType, s.AdminKey()))
@@ -162,7 +162,7 @@ spec:
162162

163163
Context("Test GatewayProxy update configs", func() {
164164
It("scaling apisix pods to test that the controller watches endpoints", func() {
165-
if s.Deployer.Name() == "api7ee" {
165+
if s.Deployer.Name() == adc.BackendModeAPI7EE {
166166
Skip("this case only for apisix/apisix-standalone mode")
167167
}
168168

test/e2e/crds/v2/route.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ spec:
224224
})
225225

226226
It("Test ApisixRoute filterFunc", func() {
227-
if s.Deployer.Name() == "api7ee" {
227+
if s.Deployer.Name() == adc.BackendModeAPI7EE {
228228
Skip("filterFunc is not supported in api7ee")
229229
}
230230
const apisixRouteSpec = `
@@ -711,9 +711,6 @@ spec:
711711
servicePort: 80
712712
`
713713
It("Should sync ApisixRoute during startup", func() {
714-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
715-
Skip("don't need to run on api7ee mode")
716-
}
717714
By("apply ApisixRoute")
718715
Expect(s.CreateResourceFromString(route2)).ShouldNot(HaveOccurred(), "apply ApisixRoute with nonexistent ingressClassName")
719716
Expect(s.CreateResourceFromString(route3)).ShouldNot(HaveOccurred(), "apply ApisixRoute without ingressClassName")

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: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ spec:
7575
value: "%s"
7676
`
7777
getGatewayProxySpec := func() string {
78-
if s.Deployer.Name() == "api7ee" {
78+
if s.Deployer.Name() == adc.BackendModeAPI7EE {
7979
return fmt.Sprintf(gatewayProxyYamlAPI7, s.Deployer.GetAdminEndpoint(), s.AdminKey())
8080
}
8181
return fmt.Sprintf(gatewayProxyYaml, framework.ProviderType, s.AdminKey())
@@ -1963,9 +1963,6 @@ spec:
19631963
port: 80
19641964
`
19651965
It("Should sync ApisixRoute during startup", func() {
1966-
if s.Deployer.Name() == adc.BackendModeAPI7EE {
1967-
Skip("don't need to run on api7ee mode")
1968-
}
19691966
By("apply ApisixRoute")
19701967
Expect(s.CreateResourceFromString(route2)).ShouldNot(HaveOccurred(), "applying HTTPRoute with non-existent parent")
19711968
s.ResourceApplied("HTTPRoute", "httpbin", route, 1)

test/e2e/scaffold/api7_deployer.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ func (s *API7Deployer) DeployDataplane(deployOpts DeployDataplaneOptions) {
148148
ForIngressGatewayGroup: true,
149149
ServiceHTTPPort: 9080,
150150
ServiceHTTPSPort: 9443,
151+
Replicas: ptr.To(1),
151152
}
152153
if deployOpts.Namespace != "" {
153154
opts.Namespace = deployOpts.Namespace
@@ -164,13 +165,22 @@ func (s *API7Deployer) DeployDataplane(deployOpts DeployDataplaneOptions) {
164165
if deployOpts.Replicas != nil {
165166
opts.Replicas = deployOpts.Replicas
166167
}
168+
if opts.Replicas != nil && *opts.Replicas == 0 {
169+
deployOpts.SkipCreateTunnels = true
170+
}
167171

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

179+
svc := s.DeployGateway(&opts)
170180
s.dataplaneService = svc
171181

172182
if !deployOpts.SkipCreateTunnels {
173-
err := s.newAPISIXTunnels()
183+
err := s.newAPISIXTunnels(opts.ServiceName)
174184
Expect(err).ToNot(HaveOccurred(), "creating apisix tunnels")
175185
}
176186
}
@@ -181,8 +191,7 @@ func (s *API7Deployer) ScaleDataplane(replicas int) {
181191
})
182192
}
183193

184-
func (s *API7Deployer) newAPISIXTunnels() error {
185-
serviceName := "api7ee3-apisix-gateway-mtls"
194+
func (s *API7Deployer) newAPISIXTunnels(serviceName string) error {
186195
httpTunnel, httpsTunnel, err := s.createDataplaneTunnels(s.dataplaneService, s.kubectlOptions, serviceName)
187196
if err != nil {
188197
return err
@@ -247,7 +256,7 @@ func (s *API7Deployer) CreateAdditionalGateway(namePrefix string) (string, *core
247256
serviceName := fmt.Sprintf("api7ee3-apisix-gateway-%s", namePrefix)
248257

249258
// Deploy dataplane for this gateway group
250-
svc := s.DeployGateway(framework.API7DeployOptions{
259+
svc := s.DeployGateway(&framework.API7DeployOptions{
251260
GatewayGroupID: gatewayGroupID,
252261
Namespace: additionalNS,
253262
Name: serviceName,

0 commit comments

Comments
 (0)