Skip to content

Commit 28400e3

Browse files
authored
Make restage test less flakey (#3453)
This command had different behaviour depending on if the deployment would complete in time for the CANCEL command to be issued. Instead we use a canary, which requires a manual continue, so the deployment is always in a cancellable state. We also then make sure through the API that this command calls cancel when the deployment fails.
1 parent c0bc8b6 commit 28400e3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

integration/v7/isolated/restage_command_test.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,19 +141,27 @@ var _ = Describe("restage command", func() {
141141
Eventually(session).Should(Exit(1))
142142
})
143143

144-
When("strategy rolling is given", func() {
144+
When("a deployment strategy is used", func() {
145145
It("fails and displays the deployment failure message", func() {
146146
userName, _ := helpers.GetCredentials()
147147
session := helpers.CustomCF(helpers.CFEnv{
148148
EnvVars: map[string]string{"CF_STARTUP_TIMEOUT": "0.1"},
149-
}, "restage", appName, "--strategy", "rolling", "--max-in-flight", "3")
149+
}, "restage", appName, "--strategy", "canary", "--max-in-flight", "3")
150150
Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`))
151151
Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
152152
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
153153
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
154-
Eventually(session.Err).Should(Say(`Cannot cancel a deployment with status: FINALIZED and reason: DEPLOYED`))
154+
Eventually(session.Err).Should(Say(`Start app timeout`))
155+
Eventually(session.Err).Should(Say(`TIP: Application must be listening on the right port\.`))
155156
Eventually(session).Should(Say("FAILED"))
156157
Eventually(session).Should(Exit(1))
158+
159+
appGUID := helpers.AppGUID(appName)
160+
Eventually(func() *Buffer {
161+
session_deployment := helpers.CF("curl", fmt.Sprintf("/v3/deployments?app_guids=%s", appGUID))
162+
Eventually(session_deployment).Should(Exit(0))
163+
return session_deployment.Out
164+
}).Should(Say(`"reason":\s*"CANCELED"`))
157165
})
158166
})
159167
})

0 commit comments

Comments
 (0)