Skip to content

Commit c89ea7a

Browse files
committed
chore: add crd v2 API testing for API7
1 parent 2647195 commit c89ea7a

File tree

15 files changed

+31
-19
lines changed

15 files changed

+31
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ KIND_NAME ?= apisix-ingress-cluster
2929

3030
GATEAY_API_VERSION ?= v1.2.0
3131
DASHBOARD_VERSION ?= dev
32-
ADC_VERSION ?= 0.19.0
32+
ADC_VERSION ?= 0.20.0
3333

3434
TEST_TIMEOUT ?= 80m
3535
TEST_DIR ?= ./test/e2e/

internal/provider/adc/adc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (d *adcClient) Update(ctx context.Context, tctx *provider.TranslateContext,
194194
// This mode is full synchronization,
195195
// which only needs to be saved in cache
196196
// and triggered by a timer for synchronization
197-
if d.BackendMode == BackendModeAPISIXStandalone || d.BackendMode == BackendModeAPISIX || apiv2.Is(obj) {
197+
if d.BackendMode == BackendModeAPISIXStandalone || d.BackendMode == BackendModeAPISIX {
198198
return nil
199199
}
200200

test/e2e/apisix/e2e_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ import (
2424
. "github.com/onsi/ginkgo/v2"
2525
. "github.com/onsi/gomega"
2626

27-
_ "github.com/apache/apisix-ingress-controller/test/e2e/crds"
27+
_ "github.com/apache/apisix-ingress-controller/test/e2e/crds/v1alpha1"
28+
_ "github.com/apache/apisix-ingress-controller/test/e2e/crds/v2"
2829
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
2930
_ "github.com/apache/apisix-ingress-controller/test/e2e/gatewayapi"
3031
_ "github.com/apache/apisix-ingress-controller/test/e2e/ingress"
@@ -38,9 +39,7 @@ func TestAPISIXE2E(t *testing.T) {
3839
_ = framework.NewFramework()
3940

4041
// init newDeployer function
41-
scaffold.NewDeployer = func(s *scaffold.Scaffold) scaffold.Deployer {
42-
return scaffold.NewAPISIXDeployer(s)
43-
}
42+
scaffold.NewDeployer = scaffold.NewAPISIXDeployer
4443

4544
_, _ = fmt.Fprintf(GinkgoWriter, "Starting APISIX standalone e2e suite\n")
4645
RunSpecs(t, "apisix standalone e2e suite")
File renamed without changes.
File renamed without changes.

test/e2e/apisix/globalrule.go renamed to test/e2e/crds/v2/globalrule.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ spec:
8888

8989
Context("ApisixGlobalRule Basic Operations", func() {
9090
BeforeEach(func() {
91+
if s.Deployer.Name() == "api7ee" {
92+
Skip("GlobalRule is not supported in api7ee")
93+
}
9194
By("create GatewayProxy")
9295
gatewayProxy := fmt.Sprintf(gatewayProxyYaml, s.Deployer.GetAdminEndpoint(), s.AdminKey())
9396
err := s.CreateResourceFromStringWithNamespace(gatewayProxy, "default")
File renamed without changes.

test/e2e/apisix/route.go renamed to test/e2e/crds/v2/route.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ spec:
189189
})
190190

191191
It("Test ApisixRoute filterFunc", func() {
192+
if s.Deployer.Name() == "api7ee" {
193+
Skip("filterFunc is not supported in api7ee")
194+
}
192195
const apisixRouteSpec = `
193196
apiVersion: apisix.apache.org/v2
194197
kind: ApisixRoute

test/e2e/apisix/tls.go renamed to test/e2e/crds/v2/tls.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ var _ = Describe("Test ApisixTls", Label("apisix.apache.org", "v2", "apisixtls")
126126
err = s.DeleteResourceFromStringWithNamespace(ingressClassYamlTls, "")
127127
Expect(err).ShouldNot(HaveOccurred(), "deleting IngressClass")
128128
})
129+
normalizePEM := func(s string) string {
130+
return strings.TrimSpace(s) // 去掉首尾空白,包括末尾换行
131+
}
129132

130133
It("Basic ApisixTls test", func() {
131134
const host = "api6.com"
@@ -252,11 +255,11 @@ spec:
252255
assert.Nil(GinkgoT(), err, "list tls error")
253256
assert.Len(GinkgoT(), tls, 1, "tls number not expect")
254257
assert.Len(GinkgoT(), tls[0].Certificates, 1, "length of certificates not expect")
255-
assert.Equal(GinkgoT(), serverCert, tls[0].Certificates[0].Certificate, "tls cert not expect")
258+
assert.Equal(GinkgoT(), normalizePEM(serverCert), normalizePEM(tls[0].Certificates[0].Certificate), "tls cert not expect")
256259
assert.ElementsMatch(GinkgoT(), []string{host}, tls[0].Snis)
257260
assert.NotNil(GinkgoT(), tls[0].Client, "client configuration should not be nil")
258261
assert.NotEmpty(GinkgoT(), tls[0].Client.CA, "client CA should not be empty")
259-
assert.Equal(GinkgoT(), caCert, tls[0].Client.CA, "client CA should be test-ca-secret")
262+
assert.Equal(GinkgoT(), normalizePEM(caCert), normalizePEM(tls[0].Client.CA), "client CA should be test-ca-secret")
260263
assert.Equal(GinkgoT(), int64(1), *tls[0].Client.Depth, "client depth should be 1")
261264
})
262265

0 commit comments

Comments
 (0)