Skip to content

Commit 6575f99

Browse files
committed
fix
1 parent 5b653a3 commit 6575f99

File tree

4 files changed

+148
-3
lines changed

4 files changed

+148
-3
lines changed

internal/provider/api7ee/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func (d *api7eeProvider) Update(ctx context.Context, tctx *provider.TranslateCon
100100
resourceTypes = append(resourceTypes, "service")
101101
case *gatewayv1.GRPCRoute:
102102
result, err = d.translator.TranslateGRPCRoute(tctx, t.DeepCopy())
103-
resourceTypes = append(resourceTypes, adctypes.TypeService)
103+
resourceTypes = append(resourceTypes, "service")
104104
case *gatewayv1.Gateway:
105105
result, err = d.translator.TranslateGateway(tctx, t.DeepCopy())
106106
resourceTypes = append(resourceTypes, "global_rule", "ssl", "plugin_metadata")

test/conformance/api7ee/conformance_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"testing"
2323

2424
"github.com/stretchr/testify/require"
25-
"k8s.io/apimachinery/pkg/util/sets"
2625
"sigs.k8s.io/gateway-api/conformance"
2726
conformancev1 "sigs.k8s.io/gateway-api/conformance/apis/v1"
2827
"sigs.k8s.io/gateway-api/conformance/tests"
@@ -51,7 +50,6 @@ func TestGatewayAPIConformance(t *testing.T) {
5150
URL: "https://github.com/apache/apisix-ingress-controller.git",
5251
Version: "v2.0.0",
5352
}
54-
opts.ConformanceProfiles = sets.New(suite.GatewayHTTPConformanceProfileName)
5553

5654
cSuite, err := suite.NewConformanceTestSuite(opts)
5755
require.NoError(t, err)

test/e2e/crds/v2/upstream.go

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package v2
19+
20+
import (
21+
"context"
22+
"fmt"
23+
"time"
24+
25+
. "github.com/onsi/ginkgo/v2"
26+
. "github.com/onsi/gomega"
27+
"k8s.io/apimachinery/pkg/types"
28+
29+
apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
30+
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
31+
"github.com/apache/apisix-ingress-controller/test/e2e/scaffold"
32+
)
33+
34+
var _ = Describe("Test ApisixUpstream", Label("apisix.apache.org", "v2", "apisixupstream"), func() {
35+
var (
36+
s = scaffold.NewDefaultScaffold()
37+
applier = framework.NewApplier(s.GinkgoT, s.K8sClient, s.CreateResourceFromString)
38+
)
39+
BeforeEach(func() {
40+
By("create GatewayProxy")
41+
err := s.CreateResourceFromString(s.GetGatewayProxySpec())
42+
Expect(err).NotTo(HaveOccurred(), "creating GatewayProxy")
43+
time.Sleep(5 * time.Second)
44+
45+
By("create IngressClass")
46+
err = s.CreateResourceFromStringWithNamespace(s.GetIngressClassYaml(), "")
47+
Expect(err).NotTo(HaveOccurred(), "creating IngressClass")
48+
time.Sleep(5 * time.Second)
49+
})
50+
51+
Context("Health Check", func() {
52+
It("active and passive", func() {
53+
auWithHealthcheck := `
54+
apiVersion: apisix.apache.org/v2
55+
kind: ApisixUpstream
56+
metadata:
57+
name: active
58+
spec:
59+
ingressClassName: %s
60+
externalNodes:
61+
- type: Domain
62+
name: httpbin-service-e2e-test
63+
- type: Domain
64+
name: invalid.httpbin.host
65+
- type: Domain
66+
name: invalid1.httpbin.host
67+
retries: 1
68+
healthCheck:
69+
active:
70+
type: http
71+
httpPath: /ip
72+
healthy:
73+
httpCodes: [200]
74+
interval: 1s
75+
unhealthy:
76+
httpFailures: 2
77+
interval: 1s
78+
passive:
79+
healthy:
80+
httpCodes: [200]
81+
unhealthy:
82+
httpCodes: [502]
83+
`
84+
applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "active"},
85+
&apiv2.ApisixUpstream{}, fmt.Sprintf(auWithHealthcheck, s.Namespace()))
86+
87+
ar := `
88+
apiVersion: apisix.apache.org/v2
89+
kind: ApisixRoute
90+
metadata:
91+
name: httpbin-route
92+
spec:
93+
ingressClassName: %s
94+
http:
95+
- name: rule1
96+
match:
97+
hosts:
98+
- httpbin.org
99+
paths:
100+
- /*
101+
backends:
102+
- serviceName: httpbin-service-e2e-test
103+
servicePort: 80
104+
`
105+
applier.MustApplyAPIv2(types.NamespacedName{Namespace: s.Namespace(), Name: "httpbin-route"},
106+
&apiv2.ApisixRoute{}, fmt.Sprintf(ar, s.Namespace()))
107+
108+
By("triggering the health check")
109+
s.RequestAssert(&scaffold.RequestAssert{
110+
Method: "GET",
111+
Path: "/ip",
112+
Host: "httpbin.org",
113+
})
114+
time.Sleep(2 * time.Second)
115+
116+
ups, err := s.Deployer.DefaultDataplaneResource().Upstream().List(context.Background())
117+
Expect(err).ToNot(HaveOccurred(), "listing upstreams")
118+
Expect(ups).To(HaveLen(1), "the number of upstreams")
119+
Expect(ups[0].Nodes).To(HaveLen(3), "the number of upstream nodes")
120+
Expect(ups[0].Checks).ToNot(BeNil(), "the healthcheck configuration")
121+
Expect(ups[0].Checks.Active).ToNot(BeNil(), "the active healthcheck configuration")
122+
Expect(ups[0].Checks.Active.Healthy).ToNot(BeNil(), "the active healthy configuration")
123+
Expect(ups[0].Checks.Active.Unhealthy).ToNot(BeNil(), "the active unhealthy configuration")
124+
Expect(ups[0].Checks.Active.Healthy.Interval).To(Equal(1), "the healthy interval")
125+
Expect(ups[0].Checks.Active.Healthy.HTTPStatuses).To(Equal([]int{200}), "the healthy http status")
126+
Expect(ups[0].Checks.Active.Unhealthy.Interval).To(Equal(1), "the unhealthy interval")
127+
Expect(ups[0].Checks.Active.Unhealthy.HTTPFailures).To(Equal(2), "the unhealthy http failures")
128+
Expect(ups[0].Checks.Passive).ToNot(BeNil(), "the passive healthcheck configuration")
129+
Expect(ups[0].Checks.Passive.Healthy).ToNot(BeNil(), "the passive healthy configuration")
130+
Expect(ups[0].Checks.Passive.Unhealthy).ToNot(BeNil(), "the passive unhealthy configuration")
131+
Expect(ups[0].Checks.Passive.Healthy.HTTPStatuses).To(Equal([]int{200}), "the passive healthy http status")
132+
Expect(ups[0].Checks.Passive.Unhealthy.HTTPStatuses).To(Equal([]int{502}), "the passive unhealthy http status")
133+
134+
for range 100 {
135+
s.NewAPISIXClient().GET("/ip").WithHost("httpbin.org").Expect().Status(200)
136+
}
137+
})
138+
})
139+
})

test/e2e/framework/manifests/ingress.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,14 @@ rules:
188188
verbs:
189189
- get
190190
- update
191+
- apiGroups:
192+
- ""
193+
resources:
194+
- endpoints
195+
verbs:
196+
- get
197+
- list
198+
- watch
191199
---
192200
apiVersion: rbac.authorization.k8s.io/v1
193201
kind: ClusterRole

0 commit comments

Comments
 (0)