* fix: Replace curl list backend with dbg command #9716 Signed-off-by: Son Bui <sonbv00@gmail.com> * fix: Remove curl dependencies in e2e tests #9716 Signed-off-by: Son Bui <sonbv00@gmail.com> --------- Signed-off-by: Son Bui <sonbv00@gmail.com>
This commit is contained in:
parent
53c2f2742f
commit
a92e7b4857
4 changed files with 25 additions and 31 deletions
|
@ -25,8 +25,6 @@ import (
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/nginx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var _ = framework.DescribeAnnotation("service-upstream", func() {
|
var _ = framework.DescribeAnnotation("service-upstream", func() {
|
||||||
|
@ -59,10 +57,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {
|
||||||
|
|
||||||
ginkgo.By("checking if the Service Cluster IP and Port are used")
|
ginkgo.By("checking if the Service Cluster IP and Port are used")
|
||||||
s := f.GetService(f.Namespace, framework.EchoService)
|
s := f.GetService(f.Namespace, framework.EchoService)
|
||||||
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
|
dbgCmd := "/dbg backends all"
|
||||||
output, err := f.ExecIngressPod(curlCmd)
|
output, err := f.ExecIngressPod(dbgCmd)
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -88,10 +86,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {
|
||||||
|
|
||||||
ginkgo.By("checking if the Service Cluster IP and Port are used")
|
ginkgo.By("checking if the Service Cluster IP and Port are used")
|
||||||
s := f.GetService(f.Namespace, framework.EchoService)
|
s := f.GetService(f.Namespace, framework.EchoService)
|
||||||
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
|
dbgCmd := "/dbg backends all"
|
||||||
output, err := f.ExecIngressPod(curlCmd)
|
output, err := f.ExecIngressPod(dbgCmd)
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -119,10 +117,10 @@ var _ = framework.DescribeAnnotation("service-upstream", func() {
|
||||||
|
|
||||||
ginkgo.By("checking if the Service Cluster IP and Port are not used")
|
ginkgo.By("checking if the Service Cluster IP and Port are not used")
|
||||||
s := f.GetService(f.Namespace, framework.EchoService)
|
s := f.GetService(f.Namespace, framework.EchoService)
|
||||||
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
|
dbgCmd := "/dbg backends all"
|
||||||
output, err := f.ExecIngressPod(curlCmd)
|
output, err := f.ExecIngressPod(dbgCmd)
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
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))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
@ -28,7 +28,6 @@ import (
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/nginx"
|
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -72,8 +71,8 @@ var _ = framework.IngressNginxDescribeSerial("[TopologyHints] topology aware rou
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
curlCmd := fmt.Sprintf("curl --fail --silent http://localhost:%v/configuration/backends", nginx.StatusPort)
|
dbgCmd := "/dbg backends all"
|
||||||
status, err := f.ExecIngressPod(curlCmd)
|
status, err := f.ExecIngressPod(dbgCmd)
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
assert.Nil(ginkgo.GinkgoT(), err)
|
||||||
var backends []map[string]interface{}
|
var backends []map[string]interface{}
|
||||||
err = json.Unmarshal([]byte(status), &backends)
|
err = json.Unmarshal([]byte(status), &backends)
|
||||||
|
|
|
@ -30,7 +30,6 @@ import (
|
||||||
networking "k8s.io/api/networking/v1"
|
networking "k8s.io/api/networking/v1"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
"k8s.io/ingress-nginx/internal/nginx"
|
|
||||||
"k8s.io/ingress-nginx/test/e2e/framework"
|
"k8s.io/ingress-nginx/test/e2e/framework"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -330,17 +329,13 @@ var _ = framework.IngressNginxDescribe("[Service] Type ExternalName", func() {
|
||||||
assert.Contains(ginkgo.GinkgoT(), body, `"X-Forwarded-Host": "echo"`)
|
assert.Contains(ginkgo.GinkgoT(), body, `"X-Forwarded-Host": "echo"`)
|
||||||
|
|
||||||
ginkgo.By("checking the service is updated to use new host")
|
ginkgo.By("checking the service is updated to use new host")
|
||||||
curlCmd := fmt.Sprintf(
|
dbgCmd := "/dbg backends all"
|
||||||
"curl --fail --silent http://localhost:%v/configuration/backends",
|
output, err := f.ExecIngressPod(dbgCmd)
|
||||||
nginx.StatusPort,
|
|
||||||
)
|
|
||||||
|
|
||||||
output, err := f.ExecIngressPod(curlCmd)
|
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
assert.Nil(ginkgo.GinkgoT(), err)
|
||||||
assert.Contains(
|
assert.Contains(
|
||||||
ginkgo.GinkgoT(),
|
ginkgo.GinkgoT(),
|
||||||
output,
|
output,
|
||||||
fmt.Sprintf("{\"address\":\"%s\"", framework.BuildNIPHost(ip)),
|
fmt.Sprintf(`"address": "%s"`, framework.BuildNIPHost(ip)),
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -170,15 +170,17 @@ var _ = framework.DescribeSetting("[SSL] TLS protocols, ciphers and headers)", f
|
||||||
hstsIncludeSubdomains: "false",
|
hstsIncludeSubdomains: "false",
|
||||||
})
|
})
|
||||||
|
|
||||||
// we can not use gorequest here because it flattens the duplicate headers
|
expectResponse := f.HTTPTestClientWithTLSConfig(tlsConfig).
|
||||||
// and specifically in case of Strict-Transport-Security it ignore extra headers
|
GET("/").
|
||||||
// intead of concatenating, rightfully. And I don't know of any API it provides for getting raw headers.
|
WithURL(f.GetURL(framework.HTTPS)).
|
||||||
curlCmd := fmt.Sprintf("curl -I -k --fail --silent --resolve settings-tls:443:127.0.0.1 https://settings-tls%v", "?hsts=true")
|
WithHeader("Host", host).
|
||||||
output, err := f.ExecIngressPod(curlCmd)
|
WithQuery("hsts", "true").
|
||||||
assert.Nil(ginkgo.GinkgoT(), err)
|
Expect()
|
||||||
assert.Contains(ginkgo.GinkgoT(), output, "strict-transport-security: max-age=86400; preload")
|
|
||||||
// this is what the upstream sets
|
expectResponse.Header("Strict-Transport-Security").Equal("max-age=86400; preload")
|
||||||
assert.NotContains(ginkgo.GinkgoT(), output, "strict-transport-security: max-age=3600; preload")
|
header := expectResponse.Raw().Header
|
||||||
|
got := header["Strict-Transport-Security"]
|
||||||
|
assert.Equal(ginkgo.GinkgoT(), 1, len(got))
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue