Skip to content

Commit

Permalink
fix: Replace curl list backend with dbg command kubernetes#9716
Browse files Browse the repository at this point in the history
Signed-off-by: Son Bui <[email protected]>
  • Loading branch information
sonbui00 committed Aug 11, 2023
1 parent 5d8185c commit 061d4d8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 22 deletions.
20 changes: 9 additions & 11 deletions test/e2e/annotations/serviceupstream.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import (
"github.com/stretchr/testify/assert"

"k8s.io/ingress-nginx/test/e2e/framework"

"k8s.io/ingress-nginx/internal/nginx"
)

var _ = framework.DescribeAnnotation("service-upstream", func() {
Expand Down Expand Up @@ -59,10 +57,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {

ginkgo.By("checking if the Service Cluster IP and Port are used")
s := f.GetService(f.Namespace, framework.EchoService)
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
output, err := f.ExecIngressPod(curlCmd)
dbgCmd := "/dbg backends all"
output, err := f.ExecIngressPod(dbgCmd)
assert.Nil(ginkgo.GinkgoT(), err)
assert.Contains(ginkgo.GinkgoT(), output, fmt.Sprintf(`{"address":"%s"`, s.Spec.ClusterIP))
assert.Contains(ginkgo.GinkgoT(), output, fmt.Sprintf(`"address": "%s"`, s.Spec.ClusterIP))
})
})

Expand All @@ -88,10 +86,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {

ginkgo.By("checking if the Service Cluster IP and Port are used")
s := f.GetService(f.Namespace, framework.EchoService)
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
output, err := f.ExecIngressPod(curlCmd)
dbgCmd := "/dbg backends all"
output, err := f.ExecIngressPod(dbgCmd)
assert.Nil(ginkgo.GinkgoT(), err)
assert.Contains(ginkgo.GinkgoT(), output, fmt.Sprintf(`{"address":"%s"`, s.Spec.ClusterIP))
assert.Contains(ginkgo.GinkgoT(), output, fmt.Sprintf(`"address": "%s"`, s.Spec.ClusterIP))
})
})

Expand Down Expand Up @@ -119,10 +117,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {

ginkgo.By("checking if the Service Cluster IP and Port are not used")
s := f.GetService(f.Namespace, framework.EchoService)
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
output, err := f.ExecIngressPod(curlCmd)
dbgCmd := "/dbg backends all"
output, err := f.ExecIngressPod(dbgCmd)
assert.Nil(ginkgo.GinkgoT(), err)
assert.NotContains(ginkgo.GinkgoT(), output, fmt.Sprintf(`{"address":"%s"`, s.Spec.ClusterIP))
assert.NotContains(ginkgo.GinkgoT(), output, fmt.Sprintf(`"address": "%s"`, s.Spec.ClusterIP))
})
})
})
5 changes: 2 additions & 3 deletions test/e2e/endpointslices/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/onsi/ginkgo/v2"
"github.com/stretchr/testify/assert"

"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/test/e2e/framework"
)

Expand Down Expand Up @@ -72,8 +71,8 @@ var _ = framework.IngressNginxDescribeSerial("[TopologyHints] topology aware rou
}
}

curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
status, err := f.ExecIngressPod(curlCmd)
dbgCmd := "/dbg backends all"
status, err := f.ExecIngressPod(dbgCmd)
assert.Nil(ginkgo.GinkgoT(), err)
var backends []map[string]interface{}
err = json.Unmarshal([]byte(status), &backends)
Expand Down
11 changes: 3 additions & 8 deletions test/e2e/servicebackend/service_externalname.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
networking "k8s.io/api/networking/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"k8s.io/ingress-nginx/internal/nginx"
"k8s.io/ingress-nginx/test/e2e/framework"
)

Expand Down Expand Up @@ -330,17 +329,13 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
assert.Contains(ginkgo.GinkgoT(), body, `"X-Forwarded-Host": "echo"`)

ginkgo.By("checking the service is updated to use new host")
curlCmd := fmt.Sprintf(
"curl --fail --silent http://localhost:%v/configuration/backends",
nginx.StatusPort,
)

output, err := f.ExecIngressPod(curlCmd)
dbgCmd := "/dbg backends all"
output, err := f.ExecIngressPod(dbgCmd)
assert.Nil(ginkgo.GinkgoT(), err)
assert.Contains(
ginkgo.GinkgoT(),
output,
fmt.Sprintf("{\"address\":\"%s\"", framework.BuildNIPHost(ip)),
fmt.Sprintf(`"address": "%s"`, framework.BuildNIPHost(ip)),
)
})

Expand Down

0 comments on commit 061d4d8

Please sign in to comment.