github.com/wanddynosios/cli/v8@v8.7.9-0.20240221182337-1a92e3a7017f/integration/v7/push/rolling_push_test.go (about) 1 package push 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/integration/helpers" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 . "github.com/onsi/gomega/gbytes" 10 . "github.com/onsi/gomega/gexec" 11 ) 12 13 var _ = Describe("push with --strategy rolling", func() { 14 var ( 15 appName string 16 userName string 17 ) 18 19 BeforeEach(func() { 20 appName = helpers.PrefixedRandomName("app") 21 userName, _ = helpers.GetCredentials() 22 }) 23 24 When("the app exists", func() { 25 BeforeEach(func() { 26 helpers.WithHelloWorldApp(func(appDir string) { 27 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 28 PushCommandName, appName, 29 )).Should(Exit(0)) 30 }) 31 }) 32 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", "rolling", 37 ) 38 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 }) 55 }) 56 }) 57 58 When("canceling the deployment", func() { 59 BeforeEach(func() { 60 helpers.WithHelloWorldApp(func(appDir string) { 61 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 62 PushCommandName, appName, 63 )).Should(Exit(0)) 64 }) 65 }) 66 67 It("displays the deployment cancellation message", func() { 68 helpers.WithHelloWorldApp(func(appDir string) { 69 session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 70 PushCommandName, appName, "--strategy", "rolling", 71 ) 72 73 Eventually(session).Should(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) 74 Eventually(session).Should(Say(`Packaging files to upload\.\.\.`)) 75 Eventually(session).Should(Say(`Uploading files\.\.\.`)) 76 Eventually(session).Should(Say(`100.00%`)) 77 Eventually(session).Should(Say(`Waiting for API to complete processing files\.\.\.`)) 78 Eventually(session).Should(Say(`Staging app and tracing logs\.\.\.`)) 79 Eventually(session).Should(Say(`Starting deployment for app %s\.\.\.`, appName)) 80 Eventually(session).Should(Say(`Waiting for app to deploy\.\.\.`)) 81 82 Eventually(helpers.CF("cancel-deployment", appName)).Should(Exit(0)) 83 Eventually(session).Should(Say(`FAILED`)) 84 Eventually(session.Err).Should(Say(`Deployment has been canceled`)) 85 Eventually(session).Should(Exit(1)) 86 }) 87 }) 88 }) 89 90 When("the app crashes", func() { 91 BeforeEach(func() { 92 helpers.WithHelloWorldApp(func(appDir string) { 93 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: appDir}, 94 PushCommandName, appName, 95 )).Should(Exit(0)) 96 }) 97 }) 98 99 It("times out", func() { 100 helpers.WithCrashingApp(func(appDir string) { 101 session := helpers.CustomCF(helpers.CFEnv{ 102 WorkingDirectory: appDir, 103 EnvVars: map[string]string{"CF_STARTUP_TIMEOUT": "0.1"}, 104 }, PushCommandName, appName, "--strategy", "rolling") 105 Eventually(session).Should(Exit(1)) 106 Expect(session).To(Say(`Pushing app %s to org %s / space %s as %s\.\.\.`, appName, organization, space, userName)) 107 Expect(session).To(Say(`Packaging files to upload\.\.\.`)) 108 Expect(session).To(Say(`Uploading files\.\.\.`)) 109 Expect(session).To(Say(`100.00%`)) 110 Expect(session).To(Say(`Waiting for API to complete processing files\.\.\.`)) 111 Expect(session).To(Say(`Staging app and tracing logs\.\.\.`)) 112 Expect(session).To(Say(`Starting deployment for app %s\.\.\.`, appName)) 113 Expect(session).To(Say(`Waiting for app to deploy\.\.\.`)) 114 Expect(session).To(Say(`FAILED`)) 115 Expect(session.Err).To(Say(`Start app timeout`)) 116 Expect(session.Err).To(Say(`TIP: Application must be listening on the right port\. Instead of hard coding the port, use the \$PORT environment variable\.`)) 117 Expect(session.Err).To(Say(`Use 'cf logs %s --recent' for more information`, appName)) 118 appGUID := helpers.AppGUID(appName) 119 Eventually(func() *Buffer { 120 session_deployment := helpers.CF("curl", fmt.Sprintf("/v3/deployments?app_guids=%s", appGUID)) 121 Eventually(session_deployment).Should(Exit(0)) 122 return session_deployment.Out 123 }).Should(Say(`"reason":\s*"CANCELED"`)) 124 }) 125 }) 126 }) 127 })