Skip to content

Commit

Permalink
[v8] Max in flight status tests (#3100)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
weresch authored Aug 14, 2024
1 parent 957bb03 commit 87d71b5
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 30 deletions.
27 changes: 25 additions & 2 deletions integration/v7/isolated/copy_source_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ var _ = Describe("copy-source command", func() {
})

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

Expand All @@ -388,9 +388,32 @@ var _ = Describe("copy-source command", func() {
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))
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
Eventually(session).Should(Say("Waiting for app to deploy..."))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).ShouldNot(Say("max-in-flight"))
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))
Eventually(session).Should(Exit(0))

Eventually(helpers.CF("start", targetAppName)).Should(Exit(0))
Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0))
resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain()))
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
Expect(err).ToNot(HaveOccurred())
Expect(string(body)).To(MatchRegexp("hello world"))
})

It("displays max-in-flight when it is not the default value", func() {
username, _ := helpers.GetCredentials()
session := helpers.CF("copy-source", sourceAppName, targetAppName, "--strategy", "canary", "--max-in-flight", "2")
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))
Eventually(session).Should(Say("Staging app %s in org %s / space %s as %s...", targetAppName, orgName, spaceName, username))
Eventually(session).Should(Say("Waiting for app to deploy..."))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).Should(Say("max-in-flight: 2"))
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))
Eventually(session).Should(Exit(0))

Eventually(helpers.CF("continue-deployment", targetAppName)).Should(Exit(0))
resp, err := http.Get(fmt.Sprintf("http://%s.%s", targetAppName, helpers.DefaultSharedDomain()))
Expect(err).ToNot(HaveOccurred())
defer resp.Body.Close()
Expand Down
23 changes: 20 additions & 3 deletions integration/v7/isolated/restage_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,32 @@ applications:
})
})

When("strategy canary is given", func() {
It("restages successfully", func() {
When("strategy canary is given without the max-in-flight flag", func() {
It("restages successfully without noting max-in-flight", func() {
userName, _ := helpers.GetCredentials()
session := helpers.CF("restage", appName, "--strategy", "canary")
Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`))
Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
Eventually(session).Should(Say("Canary deployment currently PAUSED."))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).ShouldNot(Say("max-in-flight"))
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))
Eventually(session).Should(Exit(0))
})
})

When("strategy canary is given with a non-default max-in-flight value", func() {
It("restages successfully and notes the max-in-flight value", func() {
userName, _ := helpers.GetCredentials()
session := helpers.CF("restage", appName, "--strategy", "canary", "--max-in-flight", "2")
Consistently(session.Err).ShouldNot(Say(`This action will cause app downtime\.`))
Eventually(session).Should(Say(`Restaging app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).Should(Say("max-in-flight: 2"))
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))
Eventually(session).Should(Exit(0))
})
})
Expand Down
34 changes: 32 additions & 2 deletions integration/v7/isolated/restart_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ var _ = Describe("restart command", func() {
})
})

When("strategy canary is given", func() {
When("strategy canary is given without the max-in-flight flag", func() {
BeforeEach(func() {
helpers.WithHelloWorldApp(func(appDir string) {
Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
})
})
It("creates a deploy", func() {
It("creates a deploy without noting max-in-flight", func() {
session := helpers.CF("restart", appName, "--strategy=canary")
Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
Expand All @@ -136,6 +136,36 @@ var _ = Describe("restart command", func() {
Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`))
Eventually(session).Should(Say(instanceStatsTitles))
Eventually(session).Should(Say(instanceStatsValues))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).ShouldNot(Say("max-in-flight"))
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))
Eventually(session).Should(Exit(0))
})
})

When("strategy canary is given with a non-default max-in-flight value", func() {
BeforeEach(func() {
helpers.WithHelloWorldApp(func(appDir string) {
Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, "push", appName)).Should(Exit(0))
})
})
It("creates a deploy and notes the max-in-flight value", func() {
session := helpers.CF("restart", appName, "--strategy=canary", "--max-in-flight", "3")
Eventually(session).Should(Say(`Restarting app %s in org %s / space %s as %s\.\.\.`, appName, orgName, spaceName, userName))
Eventually(session).Should(Say(`Creating deployment for app %s\.\.\.`, appName))
Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`))
Eventually(session).Should(Say(`name:\s+%s`, appName))
Eventually(session).Should(Say(`requested state:\s+started`))
Eventually(session).Should(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Eventually(session).Should(Say(`type:\s+web`))
Eventually(session).Should(Say(`instances:\s+1/1`))
Eventually(session).Should(Say(`memory usage:\s+\d+(M|G)`))
Eventually(session).Should(Say(instanceStatsTitles))
Eventually(session).Should(Say(instanceStatsValues))
Eventually(session).Should(Say("Canary deployment currently PAUSED"))
Eventually(session).Should(Say("max-in-flight: 3"))
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))
Eventually(session).Should(Exit(0))
})
})

Expand Down
26 changes: 24 additions & 2 deletions integration/v7/isolated/rollback_command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,40 @@ applications:
Expect(session).To(Say(`3\(deployed\)\s+New droplet deployed.`))
})

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

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

Expect(session).To(HaveRollbackPrompt())
Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName))
Expect(session).To(Say("Canary deployment currently PAUSED"))
Expect(session).NotTo(Say("max-in-flight"))
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))
Expect(session).To(Say("OK"))
})
})

When("the strategy flag is provided with a non-default max-in-flight value", func() {
BeforeEach(func() {
_, err := buffer.Write([]byte("y\n"))
Expect(err).ToNot(HaveOccurred())
})

It("uses the given strategy to rollback and notes the max-in-flight value", func() {
session := helpers.CFWithStdin(buffer, "rollback", appName, "--version", "1", "--strategy", "canary", "--max-in-flight", "2")
Eventually(session).Should(Exit(0))

Expect(session).To(HaveRollbackPrompt())
Expect(session).To(HaveRollbackOutput(appName, orgName, spaceName, userName))
Expect(session).To(Say("Canary deployment currently PAUSED"))
Expect(session).To(Say("max-in-flight: 2"))
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))
Expect(session).To(Say("OK"))
})
})
Expand Down
77 changes: 56 additions & 21 deletions integration/v7/push/canary_push_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,63 @@ var _ = Describe("push with --strategy canary", func() {
})
})

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

Eventually(session).Should(Exit(0))
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
Expect(session).To(Say(`Uploading files\.\.\.`))
Expect(session).To(Say(`100.00%`))
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
Expect(session).To(Say(`name:\s+%s`, appName))
Expect(session).To(Say(`requested state:\s+started`))
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Expect(session).To(Say(`type:\s+web`))
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
Expect(session).To(Say(`#0\s+running`))
Expect(session).To(Say(`Canary deployment currently PAUSED.`))
Eventually(session).Should(Exit(0))
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
Expect(session).To(Say(`Uploading files\.\.\.`))
Expect(session).To(Say(`100.00%`))
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
Expect(session).To(Say(`name:\s+%s`, appName))
Expect(session).To(Say(`requested state:\s+started`))
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Expect(session).To(Say(`type:\s+web`))
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
Expect(session).To(Say(`#0\s+running`))
Expect(session).To(Say(`Canary deployment currently PAUSED`))
Expect(session).ToNot(Say("max-in-flight"))
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))
Expect(session).To(Exit(0))
})
})
})

When("the max-in-flight flag is given with a non-default value", func() {
It("pushes the app and creates a new deployment and notes the max-in-flight value", func() {
helpers.WithHelloWorldApp(func(appDir string) {
session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir},
PushCommandName, appName, "--strategy", "canary", "--max-in-flight", "2",
)

Eventually(session).Should(Exit(0))
Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName))
Expect(session).To(Say(`Packaging files to upload\.\.\.`))
Expect(session).To(Say(`Uploading files\.\.\.`))
Expect(session).To(Say(`100.00%`))
Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`))
Expect(session).To(Say(`Staging app and tracing logs\.\.\.`))
Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName))
Expect(session).To(Say(`Waiting for app to deploy\.\.\.`))
Expect(session).To(Say(`name:\s+%s`, appName))
Expect(session).To(Say(`requested state:\s+started`))
Expect(session).To(Say(`routes:\s+%s.%s`, appName, helpers.DefaultSharedDomain()))
Expect(session).To(Say(`type:\s+web`))
Expect(session).To(Say(`start command:\s+%s`, helpers.StaticfileBuildpackStartCommand))
Expect(session).To(Say(`#0\s+running`))
Expect(session).To(Say(`Canary deployment currently PAUSED`))
Expect(session).To(Say("max-in-flight: 2"))
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))
Expect(session).To(Exit(0))
})
})
})
})
Expand Down

0 comments on commit 87d71b5

Please sign in to comment.