mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
move http2 test into ingress context. use helper method
This commit is contained in:
parent
f057be8119
commit
b3da740343
@ -382,6 +382,39 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
|
|||||||
// TODO(nikhiljindal): Check the instance group annotation value and verify with a multizone cluster.
|
// TODO(nikhiljindal): Check the instance group annotation value and verify with a multizone cluster.
|
||||||
})
|
})
|
||||||
|
|
||||||
|
It("should be able to switch between HTTPS and HTTP2 modes", func() {
|
||||||
|
httpsScheme := "request_scheme=https"
|
||||||
|
|
||||||
|
By("Create a basic HTTP2 ingress")
|
||||||
|
jig.CreateIngress(filepath.Join(framework.IngressManifestPath, "http2"), ns, map[string]string{}, map[string]string{})
|
||||||
|
jig.WaitForIngress(true)
|
||||||
|
|
||||||
|
address, err := jig.WaitForIngressAddress(jig.Client, jig.Ingress.Namespace, jig.Ingress.Name, framework.LoadBalancerPollTimeout)
|
||||||
|
|
||||||
|
By(fmt.Sprintf("Polling on address %s and verify the backend is serving HTTP2", address))
|
||||||
|
detectHttpVersionAndSchemeTest(f, jig, address, "request_version=2", httpsScheme)
|
||||||
|
|
||||||
|
By("Switch backend service to use HTTPS")
|
||||||
|
svcList, err := f.ClientSet.CoreV1().Services(ns).List(metav1.ListOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
for _, svc := range svcList.Items {
|
||||||
|
svc.Annotations[framework.ServiceApplicationProtocolKey] = `{"http2":"HTTPS"}`
|
||||||
|
_, err = f.ClientSet.CoreV1().Services(ns).Update(&svc)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
detectHttpVersionAndSchemeTest(f, jig, address, "request_version=1.1", httpsScheme)
|
||||||
|
|
||||||
|
By("Switch backend service to use HTTP2")
|
||||||
|
svcList, err = f.ClientSet.CoreV1().Services(ns).List(metav1.ListOptions{})
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
for _, svc := range svcList.Items {
|
||||||
|
svc.Annotations[framework.ServiceApplicationProtocolKey] = `{"http2":"HTTP2"}`
|
||||||
|
_, err = f.ClientSet.CoreV1().Services(ns).Update(&svc)
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
}
|
||||||
|
detectHttpVersionAndSchemeTest(f, jig, address, "request_version=2", httpsScheme)
|
||||||
|
})
|
||||||
|
|
||||||
// TODO: Implement a multizone e2e that verifies traffic reaches each
|
// TODO: Implement a multizone e2e that verifies traffic reaches each
|
||||||
// zone based on pod labels.
|
// zone based on pod labels.
|
||||||
})
|
})
|
||||||
@ -564,119 +597,6 @@ var _ = SIGDescribe("Loadbalancing: L7", func() {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Describe("GCE [Slow] [Feature:HTTP2]", func() {
|
|
||||||
var gceController *framework.GCEIngressController
|
|
||||||
|
|
||||||
// Platform specific setup
|
|
||||||
BeforeEach(func() {
|
|
||||||
framework.SkipUnlessProviderIs("gce", "gke")
|
|
||||||
By("Initializing gce controller")
|
|
||||||
gceController = &framework.GCEIngressController{
|
|
||||||
Ns: ns,
|
|
||||||
Client: jig.Client,
|
|
||||||
Cloud: framework.TestContext.CloudConfig,
|
|
||||||
}
|
|
||||||
err := gceController.Init()
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
})
|
|
||||||
|
|
||||||
// Platform specific cleanup
|
|
||||||
AfterEach(func() {
|
|
||||||
if CurrentGinkgoTestDescription().Failed {
|
|
||||||
framework.DescribeIng(ns)
|
|
||||||
}
|
|
||||||
if jig.Ingress == nil {
|
|
||||||
By("No ingress created, no cleanup necessary")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
By("Deleting ingress")
|
|
||||||
jig.TryDeleteIngress()
|
|
||||||
|
|
||||||
By("Cleaning up cloud resources")
|
|
||||||
Expect(gceController.CleanupGCEIngressController()).NotTo(HaveOccurred())
|
|
||||||
})
|
|
||||||
|
|
||||||
It("should be able to switch between HTTPS and HTTP2 modes", func() {
|
|
||||||
By("Create a basic HTTP2 ingress")
|
|
||||||
jig.CreateIngress(filepath.Join(framework.IngressManifestPath, "http2"), ns, map[string]string{}, map[string]string{})
|
|
||||||
jig.WaitForIngress(true)
|
|
||||||
|
|
||||||
address, err := jig.WaitForIngressAddress(jig.Client, jig.Ingress.Namespace, jig.Ingress.Name, framework.LoadBalancerPollTimeout)
|
|
||||||
|
|
||||||
By(fmt.Sprintf("Polling on address %s and verify the backend is serving HTTP2", address))
|
|
||||||
timeoutClient := &http.Client{Timeout: framework.IngressReqTimeout}
|
|
||||||
err = wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {
|
|
||||||
resp, err := framework.SimpleGET(timeoutClient, fmt.Sprintf("http://%s", address), "")
|
|
||||||
if err != nil {
|
|
||||||
framework.Logf("SimpleGET failed: %v", err)
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if !strings.Contains(resp, "request_version=2") {
|
|
||||||
return false, fmt.Errorf("request wasn't served by HTTP2, response body: %s", resp)
|
|
||||||
}
|
|
||||||
if !strings.Contains(resp, "request_scheme=https") {
|
|
||||||
return false, fmt.Errorf("request wasn't served by HTTPS, response body: %s", resp)
|
|
||||||
}
|
|
||||||
framework.Logf("Poll succeeded, request was served by HTTP2")
|
|
||||||
return true, nil
|
|
||||||
})
|
|
||||||
Expect(err).NotTo(HaveOccurred(), "Failed to get HTTP2")
|
|
||||||
|
|
||||||
By("Switch backend service to use HTTPS")
|
|
||||||
svcList, err := f.ClientSet.CoreV1().Services(ns).List(metav1.ListOptions{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
for _, svc := range svcList.Items {
|
|
||||||
svc.Annotations[framework.ServiceApplicationProtocolKey] = `{"http2":"HTTPS"}`
|
|
||||||
_, err = f.ClientSet.CoreV1().Services(ns).Update(&svc)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
}
|
|
||||||
|
|
||||||
resp := ""
|
|
||||||
err = wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {
|
|
||||||
resp, err = framework.SimpleGET(timeoutClient, fmt.Sprintf("http://%s", address), "")
|
|
||||||
if err != nil {
|
|
||||||
framework.Logf("SimpleGET failed: %v", err)
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if !strings.Contains(resp, "request_version=1.1") {
|
|
||||||
framework.Logf("Waiting for transition to HTTP/1")
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
framework.Logf("Poll succeeded, request was served by HTTP")
|
|
||||||
return true, nil
|
|
||||||
})
|
|
||||||
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to get HTTP, response body: %v", resp))
|
|
||||||
|
|
||||||
By("Switch backend service to use HTTP2")
|
|
||||||
svcList, err = f.ClientSet.CoreV1().Services(ns).List(metav1.ListOptions{})
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
for _, svc := range svcList.Items {
|
|
||||||
svc.Annotations[framework.ServiceApplicationProtocolKey] = `{"http2":"HTTP2"}`
|
|
||||||
_, err = f.ClientSet.CoreV1().Services(ns).Update(&svc)
|
|
||||||
Expect(err).NotTo(HaveOccurred())
|
|
||||||
}
|
|
||||||
|
|
||||||
timeoutClient = &http.Client{Timeout: framework.IngressReqTimeout}
|
|
||||||
err = wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {
|
|
||||||
resp, err = framework.SimpleGET(timeoutClient, fmt.Sprintf("http://%s", address), "")
|
|
||||||
if err != nil {
|
|
||||||
framework.Logf("SimpleGET failed: %v", err)
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if !strings.Contains(resp, "request_version=2") {
|
|
||||||
framework.Logf("Waiting for transition to HTTP/2")
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
if !strings.Contains(resp, "request_scheme=https") {
|
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
framework.Logf("Poll succeeded, request was served by HTTP2")
|
|
||||||
return true, nil
|
|
||||||
})
|
|
||||||
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to get HTTP2, response body: %v", resp))
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
Describe("GCE [Slow] [Feature:kubemci]", func() {
|
Describe("GCE [Slow] [Feature:kubemci]", func() {
|
||||||
var gceController *framework.GCEIngressController
|
var gceController *framework.GCEIngressController
|
||||||
var ipName, ipAddress string
|
var ipName, ipAddress string
|
||||||
@ -953,3 +873,25 @@ func executeBacksideBacksideHTTPSTest(f *framework.Framework, jig *framework.Ing
|
|||||||
})
|
})
|
||||||
Expect(err).NotTo(HaveOccurred(), "Failed to verify backside re-encryption ingress")
|
Expect(err).NotTo(HaveOccurred(), "Failed to verify backside re-encryption ingress")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectHttpVersionAndSchemeTest(f *framework.Framework, jig *framework.IngressTestJig, address, version, scheme string) {
|
||||||
|
timeoutClient := &http.Client{Timeout: framework.IngressReqTimeout}
|
||||||
|
resp := ""
|
||||||
|
err := wait.PollImmediate(framework.LoadBalancerPollInterval, framework.LoadBalancerPollTimeout, func() (bool, error) {
|
||||||
|
resp, err := framework.SimpleGET(timeoutClient, fmt.Sprintf("http://%s", address), "")
|
||||||
|
if err != nil {
|
||||||
|
framework.Logf("SimpleGET failed: %v", err)
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
if !strings.Contains(resp, version) {
|
||||||
|
framework.Logf("Waiting for transition to HTTP/2")
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
if !strings.Contains(resp, scheme) {
|
||||||
|
return false, nil
|
||||||
|
}
|
||||||
|
framework.Logf("Poll succeeded, request was served by HTTP2")
|
||||||
|
return true, nil
|
||||||
|
})
|
||||||
|
Expect(err).NotTo(HaveOccurred(), fmt.Sprintf("Failed to get %s or %s, response body: %s", version, scheme, resp))
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user