Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion test/extended/router/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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.

Expand Down Expand Up @@ -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")
Expand Down
12 changes: 9 additions & 3 deletions test/extended/router/scoped.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument isn't in the version of curl bundled in UBI...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so old though... curl/curl@6baeb6d

In my dev clusters, the image that gets used is gcr.io/kubernetes-e2e-test-images/agnhost:2.6 which has curl 7.61.1 (x86_64-alpine-linux-musl) libcurl/7.61.1 LibreSSL/2.5.5 zlib/1.2.11 libssh2/1.8.2

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
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
Expand All @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions test/extended/router/weighted.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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"))
Expand Down