github.com/franc20/ayesa_sap@v7.0.0-beta.28.0.20200124003224-302d4d52fa6c+incompatible/integration/v7/push/health_check_test.go (about) 1 package push 2 3 import ( 4 "path/filepath" 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 health check type", func() { 14 var ( 15 appName string 16 ) 17 18 BeforeEach(func() { 19 appName = helpers.NewAppName() 20 session := helpers.CF("create-app", appName) 21 Eventually(session).Should(Exit(0)) 22 }) 23 24 When("setting the app to http health check type", func() { 25 It("should update the health check http endpoint", func() { 26 helpers.WithMultiEndpointApp(func(dir string) { 27 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "http", "--endpoint", "/third_endpoint.html", "--no-start")).Should(Exit(0)) 28 }) 29 30 session := helpers.CF("get-health-check", appName) 31 Eventually(session).Should(Say("web\\s+http\\s+/third_endpoint.html")) 32 Eventually(session).Should(Exit(0)) 33 }) 34 }) 35 36 When("setting the app to port health check type", func() { 37 It("should reset the health check http endpoint", func() { 38 helpers.WithMultiEndpointApp(func(dir string) { 39 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "port", "--no-start")).Should(Exit(0)) 40 }) 41 42 session := helpers.CF("get-health-check", appName) 43 Eventually(session).Should(Say("web\\s+port\\s+1")) 44 Eventually(session).Should(Exit(0)) 45 }) 46 }) 47 48 When("setting the app to process health check type", func() { 49 It("should reset the health check http endpoint", func() { 50 helpers.WithMultiEndpointApp(func(dir string) { 51 Eventually(helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, PushCommandName, appName, "-u", "process", "--no-start")).Should(Exit(0)) 52 }) 53 54 session := helpers.CF("get-health-check", appName) 55 Eventually(session).Should(Say("web\\s+process\\s+1")) 56 Eventually(session).Should(Exit(0)) 57 }) 58 }) 59 60 When("setting the app's health check http endpoint", func() { 61 When("manifest has non-http (e.g. port) health check type", func() { 62 63 // A/C # 1 64 When("manifest has http health check type", func() { 65 When("only the endpoint flag override is specified", func() { 66 It("should update the endpoint", func() { 67 helpers.WithMultiEndpointApp(func(dir string) { 68 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 69 "applications": []map[string]string{ 70 { 71 "name": "some-app", 72 "health-check-type": "http", 73 "health-check-endpoint": "/", 74 }, 75 }, 76 }) 77 78 session := helpers.CustomCF( 79 helpers.CFEnv{WorkingDirectory: dir}, 80 PushCommandName, appName, 81 "--endpoint", "/third_endpoint.html", "--no-start") 82 Eventually(session).Should(Exit(0)) 83 }) 84 85 session := helpers.CF("get-health-check", appName) 86 Eventually(session).Should(Say("web\\s+http\\s+/third_endpoint.html")) 87 Eventually(session).Should(Exit(0)) //}) 88 }) 89 }) 90 91 When("both health check type and endpoint flag overrides are specified", func() { 92 // A/C # 2 93 When("only the endpoint flag override is specified", func() { 94 It("should fail with an error indicating that endpoint cannot be set for health check type port", func() { 95 helpers.WithMultiEndpointApp(func(dir string) { 96 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 97 "applications": []map[string]string{ 98 { 99 "name": "some-app", 100 "health-check-type": "port", 101 }, 102 }, 103 }) 104 105 session := helpers.CustomCF( 106 helpers.CFEnv{WorkingDirectory: dir}, 107 PushCommandName, appName, 108 "--endpoint", "/third_endpoint.html", "--no-start") 109 110 Eventually(session.Err).Should(Say("Incorrect Usage: The flag option --endpoint cannot be used with the manifest property health-check-type set to port")) 111 Eventually(session).Should(Exit(1)) 112 }) 113 }) 114 }) 115 116 // A/C # 3 117 It("should update the health check type and endpoint", func() { 118 helpers.WithMultiEndpointApp(func(dir string) { 119 helpers.WriteManifest(filepath.Join(dir, "manifest.yml"), map[string]interface{}{ 120 "applications": []map[string]string{ 121 { 122 "name": "some-app", 123 "health-check-type": "port", 124 }, 125 }, 126 }) 127 128 session := helpers.CustomCF( 129 helpers.CFEnv{WorkingDirectory: dir}, 130 PushCommandName, appName, 131 "--health-check-type", "http", 132 "--endpoint", "/third_endpoint.html", "--no-start") 133 Eventually(session).Should(Exit(0)) 134 }) 135 136 session := helpers.CF("get-health-check", appName) 137 Eventually(session).Should(Say("web\\s+http\\s+/third_endpoint.html")) 138 Eventually(session).Should(Exit(0)) 139 }) 140 }) 141 }) 142 }) 143 }) 144 })