Skip to content

Commit 9cc8acb

Browse files
author
Greg Weresch
authored
[main] Max in flight status tests (#3113)
* [main] Max in flight status tests * Add copy-source tests to verify max-in-flight output * Add rollback tests to verify max-in-flight output * Add restage tests to verify max-in-flight output * Add restart tests to verify max-in-flight output * Add push tests to verify max-in-flight output * Delete a flakey integration test that has unit test coverage
1 parent 835b2ca commit 9cc8acb

File tree

6 files changed

+157
-44
lines changed

6 files changed

+157
-44
lines changed

integration/v7/isolated/app_command_test.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,6 @@ applications:
272272
Eventually(session1).Should(Exit(0))
273273
})
274274
})
275-
When("the deployment is cancelled", func() {
276-
It("displays the message", func() {
277-
helpers.CF("restart", appName, "--strategy", "rolling")
278-
Eventually(func() *Session {
279-
return helpers.CF("cancel-deployment", appName).Wait()
280-
}).Should(Exit(0))
281-
282-
Eventually(func(g Gomega) {
283-
session := helpers.CF("app", appName).Wait()
284-
g.Expect(session).Should(Say("Rolling deployment currently CANCELING"))
285-
g.Expect(session).Should(Exit(0))
286-
}).Should(Succeed())
287-
})
288-
})
289275
})
290276

291277
When("the deployment strategy is canary", func() {

integration/v7/isolated/copy_source_command_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ var _ = Describe("copy-source command", func() {
374374
})
375375

376376
helpers.WithBananaPantsApp(func(appDir string) {
377-
Eventually(helpers.CF("push", targetAppName, "--no-start", "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0))
377+
Eventually(helpers.CF("push", targetAppName, "-p", appDir, "-b", "staticfile_buildpack")).Should(Exit(0))
378378
})
379379
})
380380

@@ -388,9 +388,32 @@ var _ = Describe("copy-source command", func() {
388388
Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username))
389389
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
390390
Eventually(session).Should(Say("Waiting for app to deploy..."))
391+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
392+
Eventually(session).ShouldNot(Say("max-in-flight"))
393+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName))
391394
Eventually(session).Should(Exit(0))
392395

393-
Eventually(helpers.CF("start", targetAppName)).Should(Exit(0))
396+
Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0))
397+
resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain()))
398+
Expect(err).ToNot(HaveOccurred())
399+
defer resp.Body.Close()
400+
body, err := io.ReadAll(resp.Body)
401+
Expect(err).ToNot(HaveOccurred())
402+
Expect(string(body)).To(MatchRegexp("hello world"))
403+
})
404+
405+
It("displays max-in-flight when it is not the default value", func() {
406+
username, _ := helpers.GetCredentials()
407+
session := helpers.CF("copy-source", sourceAppName, targetAppName, "--strategy", "canary", "--max-in-flight", "2")
408+
Eventually(session).Should(Say("Copying source from app %s to target app %s in org %s / space %s as %s...", sourceAppName, targetAppName, orgName, spaceName, username))
409+
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
410+
Eventually(session).Should(Say("Waiting for app to deploy..."))
411+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
412+
Eventually(session).Should(Say("max-in-flight: 2"))
413+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", targetAppName, targetAppName))
414+
Eventually(session).Should(Exit(0))
415+
416+
Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0))
394417
resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain()))
395418
Expect(err).ToNot(HaveOccurred())
396419
defer resp.Body.Close()

integration/v7/isolated/restage_command_test.go

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,32 @@ applications:
231231
})
232232
})
233233

234-
When("strategy canary is given", func() {
235-
It("restages successfully", func() {
234+
When("strategy canary is given without the max-in-flight flag", func() {
235+
It("restages successfully without noting max-in-flight", func() {
236236
userName, _ := helpers.GetCredentials()
237237
session := helpers.CF("restage", appName, "--strategy", "canary")
238238
Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`))
239239
Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
240240
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
241241
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
242-
Eventually(session).Should(Say("Canary deployment currently PAUSED."))
242+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
243+
Eventually(session).ShouldNot(Say("max-in-flight"))
244+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
245+
Eventually(session).Should(Exit(0))
246+
})
247+
})
248+
249+
When("strategy canary is given with a non-default max-in-flight value", func() {
250+
It("restages successfully and notes the max-in-flight value", func() {
251+
userName, _ := helpers.GetCredentials()
252+
session := helpers.CF("restage", appName, "--strategy", "canary", "--max-in-flight", "2")
253+
Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`))
254+
Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
255+
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
256+
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
257+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
258+
Eventually(session).Should(Say("max-in-flight: 2"))
259+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
243260
Eventually(session).Should(Exit(0))
244261
})
245262
})

integration/v7/isolated/restart_command_test.go

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,13 @@ var _ = Describe("restart command", func() {
117117
})
118118
})
119119

120-
When("strategy canary is given", func() {
120+
When("strategy canary is given without the max-in-flight flag", func() {
121121
BeforeEach(func() {
122122
helpers.WithHelloWorldApp(func(appDir string) {
123123
Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
124124
})
125125
})
126-
It("creates a deploy", func() {
126+
It("creates a deploy without noting max-in-flight", func() {
127127
session := helpers.CF("restart", appName, "--strategy=canary")
128128
Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
129129
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
@@ -136,6 +136,36 @@ var _ = Describe("restart command", func() {
136136
Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`))
137137
Eventually(session).Should(Say(instanceStatsTitles))
138138
Eventually(session).Should(Say(instanceStatsValues))
139+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
140+
Eventually(session).ShouldNot(Say("max-in-flight"))
141+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
142+
Eventually(session).Should(Exit(0))
143+
})
144+
})
145+
146+
When("strategy canary is given with a non-default max-in-flight value", func() {
147+
BeforeEach(func() {
148+
helpers.WithHelloWorldApp(func(appDir string) {
149+
Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
150+
})
151+
})
152+
It("creates a deploy and notes the max-in-flight value", func() {
153+
session := helpers.CF("restart", appName, "--strategy=canary", "--max-in-flight", "3")
154+
Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
155+
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
156+
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
157+
Eventually(session).Should(Say(`name:\s+%s`, appName))
158+
Eventually(session).Should(Say(`requested state:\s+started`))
159+
Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
160+
Eventually(session).Should(Say(`type:\s+web`))
161+
Eventually(session).Should(Say(`instances:\s+1/1`))
162+
Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`))
163+
Eventually(session).Should(Say(instanceStatsTitles))
164+
Eventually(session).Should(Say(instanceStatsValues))
165+
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
166+
Eventually(session).Should(Say("max-in-flight: 3"))
167+
Eventually(session).Should(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
168+
Eventually(session).Should(Exit(0))
139169
})
140170
})
141171

integration/v7/isolated/rollback_command_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,18 +151,40 @@ applications:
151151
Expect(session).To(Say(`3\(deployed\)\s+New droplet deployed.`))
152152
})
153153

154-
When("the strategy flag is provided", func() {
154+
When("the strategy flag is provided without the max-in-flight flag", func() {
155155
BeforeEach(func() {
156156
_, err := buffer.Write([]byte("y\n"))
157157
Expect(err).ToNot(HaveOccurred())
158158
})
159159

160-
It("uses the given strategy to rollback", func() {
160+
It("uses the given strategy to rollback without noting max-in-flight", func() {
161161
session := helpers.CFWithStdin(buffer, "rollback", appName, "--version", "1", "--strategy", "canary")
162162
Eventually(session).Should(Exit(0))
163163

164164
Expect(session).To(HaveRollbackPrompt())
165165
Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName))
166+
Expect(session).To(Say("Canary deployment currently PAUSED"))
167+
Expect(session).NotTo(Say("max-in-flight"))
168+
Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
169+
Expect(session).To(Say("OK"))
170+
})
171+
})
172+
173+
When("the strategy flag is provided with a non-default max-in-flight value", func() {
174+
BeforeEach(func() {
175+
_, err := buffer.Write([]byte("y\n"))
176+
Expect(err).ToNot(HaveOccurred())
177+
})
178+
179+
It("uses the given strategy to rollback and notes the max-in-flight value", func() {
180+
session := helpers.CFWithStdin(buffer, "rollback", appName, "--version", "1", "--strategy", "canary", "--max-in-flight", "2")
181+
Eventually(session).Should(Exit(0))
182+
183+
Expect(session).To(HaveRollbackPrompt())
184+
Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName))
185+
Expect(session).To(Say("Canary deployment currently PAUSED"))
186+
Expect(session).To(Say("max-in-flight: 2"))
187+
Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
166188
Expect(session).To(Say("OK"))
167189
})
168190
})

integration/v7/push/canary_push_test.go

Lines changed: 56 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,63 @@ var _ = Describe("push with --strategy canary", func() {
3030
})
3131
})
3232

33-
It("pushes the app and creates a new deployment", func() {
34-
helpers.WithHelloWorldApp(func(appDir string) {
35-
session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
36-
PushCommandName, appName, "--strategy", "canary",
37-
)
33+
When("the max-in-flight flag is not given", func() {
34+
It("pushes the app and creates a new deployment without noting max-in-flight", func() {
35+
helpers.WithHelloWorldApp(func(appDir string) {
36+
session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
37+
PushCommandName, appName, "--strategy", "canary",
38+
)
3839

39-
Eventually(session).Should(Exit(0))
40-
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
41-
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
42-
Expect(session).To(Say(`Uploading files\.\.\.`))
43-
Expect(session).To(Say(`100.00%`))
44-
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
45-
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
46-
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
47-
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
48-
Expect(session).To(Say(`name:\s+%s`, appName))
49-
Expect(session).To(Say(`requested state:\s+started`))
50-
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
51-
Expect(session).To(Say(`type:\s+web`))
52-
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
53-
Expect(session).To(Say(`#0\s+running`))
54-
Expect(session).To(Say(`Canary deployment currently PAUSED.`))
40+
Eventually(session).Should(Exit(0))
41+
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
42+
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
43+
Expect(session).To(Say(`Uploading files\.\.\.`))
44+
Expect(session).To(Say(`100.00%`))
45+
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
46+
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
47+
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
48+
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
49+
Expect(session).To(Say(`name:\s+%s`, appName))
50+
Expect(session).To(Say(`requested state:\s+started`))
51+
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
52+
Expect(session).To(Say(`type:\s+web`))
53+
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
54+
Expect(session).To(Say(`#0\s+running`))
55+
Expect(session).To(Say(`Canary deployment currently PAUSED`))
56+
Expect(session).ToNot(Say("max-in-flight"))
57+
Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
58+
Expect(session).To(Exit(0))
59+
})
60+
})
61+
})
62+
63+
When("the max-in-flight flag is given with a non-default value", func() {
64+
It("pushes the app and creates a new deployment and notes the max-in-flight value", func() {
65+
helpers.WithHelloWorldApp(func(appDir string) {
66+
session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
67+
PushCommandName, appName, "--strategy", "canary", "--max-in-flight", "2",
68+
)
69+
70+
Eventually(session).Should(Exit(0))
71+
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
72+
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
73+
Expect(session).To(Say(`Uploading files\.\.\.`))
74+
Expect(session).To(Say(`100.00%`))
75+
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
76+
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
77+
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
78+
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
79+
Expect(session).To(Say(`name:\s+%s`, appName))
80+
Expect(session).To(Say(`requested state:\s+started`))
81+
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
82+
Expect(session).To(Say(`type:\s+web`))
83+
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
84+
Expect(session).To(Say(`#0\s+running`))
85+
Expect(session).To(Say(`Canary deployment currently PAUSED`))
86+
Expect(session).To(Say("max-in-flight: 2"))
87+
Expect(session).To(Say("Please run `cf continue-deployment %s` to promote the canary deployment, or `cf cancel-deployment %s` to rollback to the previous version.", appName, appName))
88+
Expect(session).To(Exit(0))
89+
})
5590
})
5691
})
5792
})

0 commit comments

Comments
 (0)