diff --git a/test/extended/router/metrics.go b/test/extended/router/metrics.go index a33a18aea208..fb9a09db183a 100644 --- a/test/extended/router/metrics.go +++ b/test/extended/router/metrics.go @@ -28,6 +28,8 @@ import ( "k8s.io/apimachinery/pkg/util/wait" exutil "github.com/openshift/origin/test/extended/util" + + configv1 "github.com/openshift/api/config/v1" ) var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() { @@ -38,9 +40,15 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() { username, password, bearerToken string metricsPort int32 execPodName, ns, host string + + proxyProtocol bool ) g.BeforeEach(func() { + infra, err := oc.AdminConfigClient().ConfigV1().Infrastructures().Get("cluster", metav1.GetOptions{}) + o.Expect(err).NotTo(o.HaveOccurred()) + proxyProtocol = infra.Status.PlatformStatus.Type == configv1.AWSPlatformType + // This test needs to make assertions against a single router pod, so all access // to the router should happen through a single endpoint. @@ -131,7 +139,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() { } // send a burst of traffic to the router g.By("sending traffic to a weighted route") - err = expectRouteStatusCodeRepeatedExec(ns, execPodName, fmt.Sprintf("http://%s", host), "weighted.metrics.example.com", http.StatusOK, times) + err = expectRouteStatusCodeRepeatedExec(ns, execPodName, fmt.Sprintf("http://%s", host), "weighted.metrics.example.com", http.StatusOK, times, proxyProtocol) o.Expect(err).NotTo(o.HaveOccurred()) } g.By("retrying metrics until all backend servers appear") diff --git a/test/extended/router/scoped.go b/test/extended/router/scoped.go index 37e75f5d3053..0affc5f17ba0 100644 --- a/test/extended/router/scoped.go +++ b/test/extended/router/scoped.go @@ -262,13 +262,19 @@ func waitForRouterOKResponseExec(ns, execPodName, url, host string, timeoutSecon return nil } -func expectRouteStatusCodeRepeatedExec(ns, execPodName, url, host string, statusCode int, times int) error { +func expectRouteStatusCodeRepeatedExec(ns, execPodName, url, host string, statusCode int, times int, proxy bool) error { + var extraArgs []string + if proxy { + extraArgs = append(extraArgs, "--haproxy-protocol") + } + args := strings.Join(extraArgs, " ") + cmd := fmt.Sprintf(` set -e STOP=$(($(date '+%%s') + %d)) while [ $(date '+%%s') -lt $STOP ]; do rc=0 - code=$( curl -s -m 5 -o /dev/null -w '%%{http_code}\n' --header 'Host: %s' %q ) || rc=$? + code=$( curl %s -s -m 5 -o /dev/null -w '%%{http_code}\n' --header 'Host: %s' %q ) || rc=$? if [[ "${rc:-0}" -eq 0 ]]; then echo $code if [[ $code -ne %d ]]; then @@ -278,7 +284,7 @@ func expectRouteStatusCodeRepeatedExec(ns, execPodName, url, host string, status echo "error ${rc}" 1>&2 fi done - `, times, host, url, statusCode) + `, times, args, host, url, statusCode) output, err := e2e.RunHostCmd(ns, execPodName, cmd) if err != nil { return fmt.Errorf("host command failed: %v\n%s", err, output) diff --git a/test/extended/router/weighted.go b/test/extended/router/weighted.go index f3c39ab7dc7e..b6f385b62379 100644 --- a/test/extended/router/weighted.go +++ b/test/extended/router/weighted.go @@ -12,9 +12,10 @@ import ( o "github.com/onsi/gomega" "k8s.io/kubernetes/test/e2e/framework/pod" + e2e "k8s.io/kubernetes/test/e2e/framework" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" - e2e "k8s.io/kubernetes/test/e2e/framework" exutil "github.com/openshift/origin/test/extended/util" ) @@ -77,7 +78,7 @@ var _ = g.Describe("[Conformance][Area:Networking][Feature:Router]", func() { err = waitForRouterOKResponseExec(ns, execPodName, routerURL, "weighted.example.com", changeTimeoutSeconds) o.Expect(err).NotTo(o.HaveOccurred()) // all requests should now succeed - err = expectRouteStatusCodeRepeatedExec(ns, execPodName, routerURL, "weighted.example.com", http.StatusOK, times) + err = expectRouteStatusCodeRepeatedExec(ns, execPodName, routerURL, "weighted.example.com", http.StatusOK, times, false) o.Expect(err).NotTo(o.HaveOccurred()) g.By(fmt.Sprintf("checking that there are three weighted backends in the router stats"))