Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 37 additions & 25 deletions test/e2e/crds/v2/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/stretchr/testify/assert"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/utils/ptr"

apiv2 "github.com/apache/apisix-ingress-controller/api/v2"
"github.com/apache/apisix-ingress-controller/test/e2e/framework"
Expand Down Expand Up @@ -1642,6 +1643,14 @@ spec:
})

Context("complex scenarios", func() {
BeforeEach(func() {
By("deploy nginx service")
s.DeployNginx(framework.NginxOptions{
Namespace: s.Namespace(),
Replicas: ptr.To(int32(1)),
})
})

It("multiple external services in one upstream", func() {
upstreamName := s.Namespace()
routeName := s.Namespace()
Expand All @@ -1656,9 +1665,9 @@ spec:
ingressClassName: %s
externalNodes:
- type: Domain
name: httpbin.org
name: httpbin-service-e2e-test
- type: Domain
name: postman-echo.com
name: nginx
`
var upstream apiv2.ApisixUpstream
applier.MustApplyAPIv2(
Expand All @@ -1671,24 +1680,26 @@ spec:

By("verify access to multiple services")
time.Sleep(7 * time.Second)
hasEtag := false // postman-echo.com
hasNoEtag := false // httpbin.org
hasHttpbin := false
hasNginx := false
for range 20 {
headers := s.NewAPISIXClient().GET("/ip").
expect := s.NewAPISIXClient().GET("/ip").
WithHeader("Host", "httpbin.org").
WithHeader("X-Foo", "bar").
Expect().
Headers().Raw()
if _, ok := headers["Etag"]; ok {
hasEtag = true
} else {
hasNoEtag = true
Expect()

body := expect.Body().Raw()
if strings.Contains(body, "Hello") {
hasNginx = true
} else if strings.Contains(body, `"origin"`) {
hasHttpbin = true
}
if hasEtag && hasNoEtag {
if hasHttpbin && hasNginx {
break
}
time.Sleep(100 * time.Millisecond)
}
assert.True(GinkgoT(), hasEtag && hasNoEtag, "both httpbin and postman should be accessed at least once")
assert.True(GinkgoT(), hasHttpbin && hasNginx, "both httpbin and nginx should be accessed at least once")
})

It("should be able to use backends and upstreams together", func() {
Expand All @@ -1703,7 +1714,7 @@ spec:
ingressClassName: %s
externalNodes:
- type: Domain
name: postman-echo.com
name: nginx
`
var upstream apiv2.ApisixUpstream
applier.MustApplyAPIv2(
Expand Down Expand Up @@ -1742,24 +1753,25 @@ spec:
)
By("verify access to multiple services")
time.Sleep(7 * time.Second)
hasEtag := false // postman-echo.com
hasNoEtag := false // httpbin.org
hasNginx := false
hasHttpbin := false
for range 20 {
headers := s.NewAPISIXClient().GET("/ip").
expect := s.NewAPISIXClient().GET("/ip").
WithHeader("Host", "httpbin.org").
WithHeader("X-Foo", "bar").
Expect().
Headers().Raw()
if _, ok := headers["Etag"]; ok {
hasEtag = true
} else {
hasNoEtag = true
Expect()
body := expect.Body().Raw()
if strings.Contains(body, "Hello") {
hasNginx = true
} else if strings.Contains(body, `"origin"`) {
hasHttpbin = true
}
if hasEtag && hasNoEtag {
if hasNginx && hasHttpbin {
break
}
time.Sleep(100 * time.Millisecond)
}
assert.True(GinkgoT(), hasEtag && hasNoEtag, "both httpbin and postman should be accessed at least once")
assert.True(GinkgoT(), hasNginx && hasHttpbin, "both nginx and httpbin should be accessed at least once")
})
})
})
Expand Down
Loading