|
| 1 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 2 | +// you may not use this file except in compliance with the License. |
| 3 | +// You may obtain a copy of the License at |
| 4 | +// |
| 5 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +// |
| 7 | +// Unless required by applicable law or agreed to in writing, software |
| 8 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 9 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 10 | +// See the License for the specific language governing permissions and |
| 11 | +// limitations under the License. |
| 12 | + |
| 13 | +package apisix |
| 14 | + |
| 15 | +import ( |
| 16 | + . "github.com/onsi/ginkgo/v2" |
| 17 | + . "github.com/onsi/gomega" |
| 18 | + |
| 19 | + "github.com/apache/apisix-ingress-controller/test/e2e/scaffold" |
| 20 | +) |
| 21 | + |
| 22 | +var _ = Describe("Test ApisixUpstream", func() { |
| 23 | + var ( |
| 24 | + s = scaffold.NewScaffold(&scaffold.Options{ |
| 25 | + ControllerName: "apisix.apache.org/apisix-ingress-controller", |
| 26 | + }) |
| 27 | + err error |
| 28 | + ) |
| 29 | + |
| 30 | + Context("Test ApisixUpstream validation", func() { |
| 31 | + It("validation of externalNodes and discovery", func() { |
| 32 | + const apisixUpstreamSpec0 = ` |
| 33 | +apiVersion: apisix.apache.org/v2 |
| 34 | +kind: ApisixUpstream |
| 35 | +metadata: |
| 36 | + name: default-upstream |
| 37 | +spec: |
| 38 | + ingressClassName: apisix |
| 39 | + externalNodes: |
| 40 | + - type: Service |
| 41 | + name: httpbin-service-e2e-test |
| 42 | + discovery: |
| 43 | + serviceName: xx |
| 44 | + type: nacos |
| 45 | +` |
| 46 | + const apisixUpstreamSpec1 = ` |
| 47 | +apiVersion: apisix.apache.org/v2 |
| 48 | +kind: ApisixUpstream |
| 49 | +metadata: |
| 50 | + name: default-upstream |
| 51 | +spec: |
| 52 | + ingressClassName: apisix |
| 53 | +` |
| 54 | + err = s.CreateResourceFromString(apisixUpstreamSpec0) |
| 55 | + Expect(err).Should(HaveOccurred()) |
| 56 | + Expect(err.Error()).Should(ContainSubstring("failed rule: has(self.externalNodes)!=has(self.discovery)")) |
| 57 | + |
| 58 | + err = s.CreateResourceFromString(apisixUpstreamSpec1) |
| 59 | + Expect(err).Should(HaveOccurred()) |
| 60 | + Expect(err.Error()).Should(ContainSubstring("failed rule: has(self.externalNodes)!=has(self.discovery)")) |
| 61 | + |
| 62 | + }) |
| 63 | + |
| 64 | + It("", func() {}) |
| 65 | + |
| 66 | + It("", func() {}) |
| 67 | + |
| 68 | + It("", func() {}) |
| 69 | + |
| 70 | + It("", func() {}) |
| 71 | + |
| 72 | + It("", func() {}) |
| 73 | + }) |
| 74 | +}) |
0 commit comments