Skip to content

Commit

Permalink
test: print error when create/update service fails
Browse files Browse the repository at this point in the history
When running CF CLI v8 with --wait flag, we don't see the error from the
broker if the command fails.

[#177720203](https://www.pivotaltracker.com/story/show/177720203)
  • Loading branch information
blgm authored and pivotal-marcela-campo committed Oct 28, 2021
1 parent 27d2152 commit 2763220
Showing 1 changed file with 46 additions and 14 deletions.
60 changes: 46 additions & 14 deletions acceptance-tests/helpers/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,36 @@ func CreateServiceInBroker(offering, plan, broker string, parameters ...interfac
}

func CreateService(offering, plan string, parameters ...interface{}) ServiceInstance {
switch cfVersion() {
case cfVersionV8:
return createServiceWithWait(offering, plan, parameters...)
default:
return createServiceWithPoll(offering, plan, parameters...)
}
}

func createServiceWithWait(offering, plan string, parameters ...interface{}) ServiceInstance {
name := RandomName(offering, plan)
createCommandTimeout := 5 * time.Minute // MASB is slow to start creation
args := []string{"create-service", offering, plan, name}
if cfVersion() == cfVersionV8 {
args = append(args, "--wait")
createCommandTimeout = time.Hour
args := append([]string{"create-service", offering, plan, name, "--wait"}, serviceParameters(parameters)...)

session := StartCF(args...)
Eventually(session, time.Hour).Should(Exit(0), func() string {
out, _ := CF("service", name)
return out
})

return ServiceInstance{
name: name,
offering: offering,
}
args = append(args, serviceParameters(parameters)...)
}

func createServiceWithPoll(offering, plan string, parameters ...interface{}) ServiceInstance {
name := RandomName(offering, plan)
args := append([]string{"create-service", offering, plan, name}, serviceParameters(parameters)...)

session := StartCF(args...)
Eventually(session, createCommandTimeout).Should(Exit(0))
Eventually(session, 5*time.Minute).Should(Exit(0))

Eventually(func() string {
out, _ := CF("service", name)
Expand All @@ -64,16 +83,29 @@ func CreateService(offering, plan string, parameters ...interface{}) ServiceInst
}

func (s ServiceInstance) UpdateService(parameters ...string) {
createCommandTimeout := time.Minute
args := []string{"update-service", s.name}
if cfVersion() == cfVersionV8 {
args = append(args, "--wait")
createCommandTimeout = time.Hour
switch cfVersion() {
case cfVersionV8:
s.updateServiceWithWait(parameters...)
default:
s.updateServiceWithPoll(parameters...)
}
args = append(args, parameters...)
}

func (s ServiceInstance) updateServiceWithWait(parameters ...string) {
args := append([]string{"update-service", s.name, "--wait"}, parameters...)

session := StartCF(args...)
Eventually(session, createCommandTimeout).Should(Exit(0))
Eventually(session, time.Hour).Should(Exit(0), func() string {
out, _ := CF("service", s.name)
return out
})
}

func (s ServiceInstance) updateServiceWithPoll(parameters ...string) {
args := append([]string{"update-service", s.name}, parameters...)

session := StartCF(args...)
Eventually(session, 5*time.Minute).Should(Exit(0))

Eventually(func() string {
out, _ := CF("service", s.name)
Expand Down

0 comments on commit 2763220

Please sign in to comment.