From ba509937c787c0b629585aff997e976c088a98f3 Mon Sep 17 00:00:00 2001 From: Natalie Bennett Date: Wed, 29 Aug 2018 14:24:07 -0700 Subject: [PATCH] Bump cf-test-helpers to get auth retry logic [#160004643] Signed-off-by: Steve Taylor --- .../workflowhelpers/internal/cf_auth.go | 35 ++++++++++++++++--- .../workflowhelpers/user_context.go | 2 +- vendor/manifest | 2 +- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/internal/cf_auth.go b/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/internal/cf_auth.go index a962b0185..29d55d559 100644 --- a/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/internal/cf_auth.go +++ b/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/internal/cf_auth.go @@ -3,12 +3,39 @@ package internal import ( "github.com/cloudfoundry-incubator/cf-test-helpers/internal" "github.com/onsi/gomega/gexec" + "time" + . "github.com/onsi/gomega" ) -func CfAuth(cmdStarter internal.Starter, reporter internal.Reporter, user string, password string) *gexec.Session { - auth, err := cmdStarter.Start(reporter, "cf", "auth", user, password) - if err != nil { - panic(err) +func CfAuth(cmdStarter internal.Starter, reporter internal.Reporter, user string, password string, ) *gexec.Session { + var auth *gexec.Session + var err error + + retries := 2 + for i := 1; i <= retries; i++ { + auth, err = cmdStarter.Start(reporter, "cf", "auth", user, password) + if err != nil { + panic(err) + } + + if i < retries { + // retry timeouts if not final retry + failures := InterceptGomegaFailures(func() { + auth.Wait(5) + }) + if len(failures) != 0 { + continue + } + } else { + auth.Wait(5) + } + + returnVal := auth.ExitCode() + if returnVal == 0 { + return auth + } + time.Sleep(1 * time.Second) } + return auth } diff --git a/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/user_context.go b/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/user_context.go index b79504459..2c26c3696 100644 --- a/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/user_context.go +++ b/vendor/github.com/cloudfoundry-incubator/cf-test-helpers/workflowhelpers/user_context.go @@ -96,7 +96,7 @@ func (uc UserContext) Login() { redactingReporter := internal.NewRedactingReporter(ginkgo.GinkgoWriter, redactor) session = workflowhelpersinternal.CfAuth(uc.CommandStarter, redactingReporter, uc.TestUser.Username(), uc.TestUser.Password()) - EventuallyWithOffset(1, session, uc.Timeout).Should(Exit(0), cliErrorMessage(session)) + Expect(session).To(Exit(0), cliErrorMessage(session)) } func (uc UserContext) SetCfHomeDir() (string, string) { diff --git a/vendor/manifest b/vendor/manifest index 6a95c9344..bafb65458 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -32,7 +32,7 @@ "importpath": "github.com/cloudfoundry-incubator/cf-test-helpers", "repository": "https://github.com/cloudfoundry-incubator/cf-test-helpers", "vcs": "git", - "revision": "dc453294914947b630c176d5a38923854d62bf83", + "revision": "7808036f4eddd71633f7b4957d34ab93e71a0436", "branch": "master", "notests": true },