|
| 1 | +package tests |
| 2 | + |
| 3 | +import ( |
| 4 | + "github.com/deis/workflow-e2e/tests/cmd" |
| 5 | + "github.com/deis/workflow-e2e/tests/cmd/apps" |
| 6 | + "github.com/deis/workflow-e2e/tests/cmd/auth" |
| 7 | + "github.com/deis/workflow-e2e/tests/cmd/builds" |
| 8 | + "github.com/deis/workflow-e2e/tests/model" |
| 9 | + "github.com/deis/workflow-e2e/tests/settings" |
| 10 | + |
| 11 | + . "github.com/onsi/ginkgo" |
| 12 | + . "github.com/onsi/ginkgo/extensions/table" |
| 13 | + . "github.com/onsi/gomega" |
| 14 | + . "github.com/onsi/gomega/gbytes" |
| 15 | + . "github.com/onsi/gomega/gexec" |
| 16 | +) |
| 17 | + |
| 18 | +var _ = Describe("deis healthchecks", func() { |
| 19 | + |
| 20 | + Context("with an existing user", func() { |
| 21 | + |
| 22 | + var user model.User |
| 23 | + |
| 24 | + BeforeEach(func() { |
| 25 | + user = auth.Register() |
| 26 | + }) |
| 27 | + |
| 28 | + AfterEach(func() { |
| 29 | + auth.Cancel(user) |
| 30 | + }) |
| 31 | + |
| 32 | + Context("who owns an existing app that has already been deployed", func() { |
| 33 | + |
| 34 | + var app model.App |
| 35 | + |
| 36 | + BeforeEach(func() { |
| 37 | + app = apps.Create(user, "--no-remote") |
| 38 | + builds.Create(user, app) |
| 39 | + }) |
| 40 | + |
| 41 | + AfterEach(func() { |
| 42 | + apps.Destroy(user, app) |
| 43 | + }) |
| 44 | + |
| 45 | + Specify("that user can list healthchecks on that app", func() { |
| 46 | + sess, err := cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 47 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 48 | + Expect(err).NotTo(HaveOccurred()) |
| 49 | + Eventually(sess).Should(Exit(0)) |
| 50 | + }) |
| 51 | + |
| 52 | + Specify("that user can set an exec liveness healthcheck", func() { |
| 53 | + sess, err := cmd.Start("deis healthchecks:set -a %s liveness exec -- /bin/true", &user, app.Name) |
| 54 | + Expect(err).NotTo(HaveOccurred()) |
| 55 | + Eventually(sess).Should(Say("Applying livenessProbe healthcheck...")) |
| 56 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 57 | + Eventually(sess).Should(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 58 | + Expect(err).NotTo(HaveOccurred()) |
| 59 | + Eventually(sess).Should(Exit(0)) |
| 60 | + |
| 61 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 62 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 63 | + Eventually(sess).Should(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 64 | + Expect(err).NotTo(HaveOccurred()) |
| 65 | + Eventually(sess).Should(Exit(0)) |
| 66 | + }) |
| 67 | + |
| 68 | + // disable httpGet liveness checks as it won't pass for every app |
| 69 | + // TODO(bacongobbler): somehow determine *what* port we need to set the liveness check for this app |
| 70 | + XSpecify("that user can set a httpGet liveness healthcheck", func() { |
| 71 | + sess, err := cmd.Start("deis healthchecks:set liveness httpGet -a %s 80", &user, app.Name) |
| 72 | + Eventually(sess).Should(Say("Applying livenessProbe healthcheck...")) |
| 73 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 74 | + Eventually(sess).Should(Say(`HTTP GET Probe\: Path="/" Port=80 HTTPHeaders=\[]`)) |
| 75 | + Expect(err).NotTo(HaveOccurred()) |
| 76 | + Eventually(sess).Should(Exit(0)) |
| 77 | + |
| 78 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 79 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 80 | + Eventually(sess).Should(Say(`HTTP GET Probe\: Path="/" Port=80 HTTPHeaders=\[]`)) |
| 81 | + Expect(err).NotTo(HaveOccurred()) |
| 82 | + Eventually(sess).Should(Exit(0)) |
| 83 | + }) |
| 84 | + |
| 85 | + Specify("that user can set a tcpSocket liveness healthcheck", func() { |
| 86 | + sess, err := cmd.Start("deis healthchecks:set liveness tcpSocket -a %s 80", &user, app.Name) |
| 87 | + Eventually(sess).Should(Say("Applying livenessProbe healthcheck...")) |
| 88 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 89 | + Eventually(sess).Should(Say(`TCP Socket Probe\: Port=80`)) |
| 90 | + Expect(err).NotTo(HaveOccurred()) |
| 91 | + Eventually(sess).Should(Exit(0)) |
| 92 | + |
| 93 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 94 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 95 | + Eventually(sess).Should(Say(`TCP Socket Probe\: Port=80`)) |
| 96 | + Expect(err).NotTo(HaveOccurred()) |
| 97 | + Eventually(sess).Should(Exit(0)) |
| 98 | + }) |
| 99 | + |
| 100 | + Specify("that user can set an exec readiness healthcheck", func() { |
| 101 | + sess, err := cmd.Start("deis healthchecks:set readiness exec -a %s -- /bin/true", &user, app.Name) |
| 102 | + Eventually(sess).Should(Say("Applying readinessProbe healthcheck...")) |
| 103 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 104 | + Eventually(sess).Should(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 105 | + Expect(err).NotTo(HaveOccurred()) |
| 106 | + Eventually(sess).Should(Exit(0)) |
| 107 | + |
| 108 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 109 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 110 | + Eventually(sess).Should(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 111 | + Expect(err).NotTo(HaveOccurred()) |
| 112 | + Eventually(sess).Should(Exit(0)) |
| 113 | + }) |
| 114 | + |
| 115 | + Specify("that user can set a httpGet readiness healthcheck", func() { |
| 116 | + sess, err := cmd.Start("deis healthchecks:set readiness httpGet -a %s 80", &user, app.Name) |
| 117 | + Eventually(sess).Should(Say("Applying readinessProbe healthcheck...")) |
| 118 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 119 | + Eventually(sess).Should(Say(`HTTP GET Probe\: Path="/" Port=80 HTTPHeaders=\[]`)) |
| 120 | + Expect(err).NotTo(HaveOccurred()) |
| 121 | + Eventually(sess).Should(Exit(0)) |
| 122 | + |
| 123 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 124 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 125 | + Eventually(sess).Should(Say(`HTTP GET Probe\: Path="/" Port=80 HTTPHeaders=\[]`)) |
| 126 | + Expect(err).NotTo(HaveOccurred()) |
| 127 | + Eventually(sess).Should(Exit(0)) |
| 128 | + }) |
| 129 | + |
| 130 | + Specify("that user can set a tcpSocket readiness healthcheck", func() { |
| 131 | + sess, err := cmd.Start("deis healthchecks:set readiness tcpSocket -a %s 80", &user, app.Name) |
| 132 | + Eventually(sess).Should(Say("Applying readinessProbe healthcheck...")) |
| 133 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 134 | + Eventually(sess).Should(Say(`TCP Socket Probe\: Port=80`)) |
| 135 | + Expect(err).NotTo(HaveOccurred()) |
| 136 | + Eventually(sess).Should(Exit(0)) |
| 137 | + |
| 138 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 139 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 140 | + Eventually(sess).Should(Say(`TCP Socket Probe\: Port=80`)) |
| 141 | + Expect(err).NotTo(HaveOccurred()) |
| 142 | + Eventually(sess).Should(Exit(0)) |
| 143 | + }) |
| 144 | + |
| 145 | + Context("and already has a healthcheck set", func() { |
| 146 | + BeforeEach(func() { |
| 147 | + sess, err := cmd.Start(`deis healthchecks:set readiness exec -a %s -- /bin/true`, &user, app.Name) |
| 148 | + Eventually(sess).Should(Say("Applying readinessProbe healthcheck...")) |
| 149 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 150 | + Eventually(sess).Should(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 151 | + Expect(err).NotTo(HaveOccurred()) |
| 152 | + Eventually(sess).Should(Exit(0)) |
| 153 | + }) |
| 154 | + |
| 155 | + Specify("that user can unset that healthcheck", func() { |
| 156 | + sess, err := cmd.Start("deis healthchecks:unset -a %s readiness", &user, app.Name) |
| 157 | + Eventually(sess).Should(Say("Removing healthchecks...")) |
| 158 | + Eventually(sess, settings.MaxEventuallyTimeout).Should(Say("=== %s Healthchecks", app.Name)) |
| 159 | + Eventually(sess).ShouldNot(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 160 | + Expect(err).NotTo(HaveOccurred()) |
| 161 | + Eventually(sess).Should(Exit(0)) |
| 162 | + |
| 163 | + sess, err = cmd.Start("deis healthchecks:list -a %s", &user, app.Name) |
| 164 | + Eventually(sess).Should(Say("=== %s Healthchecks", app.Name)) |
| 165 | + Eventually(sess).ShouldNot(Say(`Exec Probe\: Command=\[/bin/true]`)) |
| 166 | + Expect(err).NotTo(HaveOccurred()) |
| 167 | + Eventually(sess).Should(Exit(0)) |
| 168 | + }) |
| 169 | + }) |
| 170 | + }) |
| 171 | + }) |
| 172 | + |
| 173 | + DescribeTable("any user can get command-line help for healthchecks", func(command string, expected string) { |
| 174 | + sess, err := cmd.Start(command, nil) |
| 175 | + Eventually(sess).Should(Say(expected)) |
| 176 | + Expect(err).NotTo(HaveOccurred()) |
| 177 | + Eventually(sess).Should(Exit(0)) |
| 178 | + // TODO: test that help output was more than five lines long |
| 179 | + }, |
| 180 | + Entry("helps on \"help healthchecks\"", |
| 181 | + "deis help healthchecks", "Valid commands for healthchecks:"), |
| 182 | + Entry("helps on \"healthchecks -h\"", |
| 183 | + "deis healthchecks -h", "Valid commands for healthchecks:"), |
| 184 | + Entry("helps on \"healthchecks --help\"", |
| 185 | + "deis healthchecks --help", "Valid commands for healthchecks:"), |
| 186 | + Entry("helps on \"help healthchecks:list\"", |
| 187 | + "deis help healthchecks:list", "Lists healthchecks for an application."), |
| 188 | + Entry("helps on \"healthchecks:list -h\"", |
| 189 | + "deis healthchecks:list -h", "Lists healthchecks for an application."), |
| 190 | + Entry("helps on \"healthchecks:list --help\"", |
| 191 | + "deis healthchecks:list --help", "Lists healthchecks for an application."), |
| 192 | + Entry("helps on \"help healthchecks:set\"", |
| 193 | + "deis help healthchecks:set", "Sets healthchecks for an application."), |
| 194 | + Entry("helps on \"healthchecks:set -h\"", |
| 195 | + "deis healthchecks:set -h", "Sets healthchecks for an application."), |
| 196 | + Entry("helps on \"healthchecks:set --help\"", |
| 197 | + "deis healthchecks:set --help", "Sets healthchecks for an application."), |
| 198 | + Entry("helps on \"help healthchecks:unset\"", |
| 199 | + "deis help healthchecks:unset", "Unsets healthchecks for an application."), |
| 200 | + Entry("helps on \"healthchecks:unset -h\"", |
| 201 | + "deis healthchecks:unset -h", "Unsets healthchecks for an application."), |
| 202 | + Entry("helps on \"healthchecks:unset --help\"", |
| 203 | + "deis healthchecks:unset --help", "Unsets healthchecks for an application."), |
| 204 | + ) |
| 205 | +}) |
0 commit comments