Skip to content

Commit 09f2c74

Browse files
committed
Implement tests
1 parent bda4351 commit 09f2c74

2 files changed

Lines changed: 52 additions & 2 deletions

File tree

integration/v7/isolated/map_route_command_test.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ var _ = Describe("map-route command", func() {
3737
Eventually(session).Should(Say(`EXAMPLES:`))
3838
Eventually(session).Should(Say(`cf map-route my-app example.com # example.com`))
3939
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost # myhost.example.com`))
40-
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost -o loadbalancing=least-connection # myhost.example.com with a per-route option`))
4140
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --path foo # myhost.example.com/foo`))
4241
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --app-protocol http2 # myhost.example.com`))
4342
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost --app-port 8090 # myhost.example.com`))
43+
Eventually(session).Should(Say(`cf map-route my-app example.com --hostname myhost -o loadbalancing=least-connection # myhost.example.com with a per-route option`))
44+
Eventually(session).Should(Say(`cf map-route my-app example.com -o loadbalancing=hash -o hash_header=My-Hash-Header # use hash-based routing for example.com`))
4445
Eventually(session).Should(Say(`cf map-route my-app example.com --port 5000 # example.com:5000`))
4546
Eventually(session).Should(Say(`\n`))
4647

@@ -241,6 +242,21 @@ var _ = Describe("map-route command", func() {
241242
Eventually(session).Should(Exit(0))
242243
})
243244
})
245+
Context("when per-route options are provided", func() {
246+
It("creates the route and maps it to an app", func() {
247+
optionLBAlgo := "loadbalancing=hash"
248+
optionHashHeader := "hash_header=X-Header"
249+
optionHashBalance := "hash_balance=1.3"
250+
251+
session := helpers.CF("map-route", appName, domainName, "--hostname", hostName, "--path", path, "--option", optionLBAlgo, "--option", optionHashHeader, "--option", optionHashBalance)
252+
Eventually(session).Should(Say(`Creating route %s.%s%s for org %s / space %s as %s\.\.\.`, hostName, domainName, path, orgName, spaceName, userName))
253+
Eventually(session).Should(Say(`OK`))
254+
Eventually(session).Should(Say(`Mapping route %s.%s%s to app %s in org %s / space %s as %s\.\.\.`, hostName, domainName, path, appName, orgName, spaceName, userName))
255+
Eventually(session).Should(Say(`OK`))
256+
Eventually(session).Should(Exit(0))
257+
})
258+
})
259+
244260
})
245261

246262
When("it is an TCP domain", func() {

integration/v7/isolated/update_route_command_test.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ var _ = Describe("update-route command", func() {
3131
Eventually(session).Should(Say(`EXAMPLES:`))
3232
Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=round-robin`))
3333
Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=least-connection`))
34+
Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=hash -o hash_header=My-Hash-Header`))
35+
Eventually(session).Should(Say(`cf update-route example.com -o loadbalancing=hash -o hash_header=My-Hash-Header -o hash_balance=1.3`))
3436
Eventually(session).Should(Say(`cf update-route example.com -r loadbalancing`))
3537
Eventually(session).Should(Say(`cf update-route example.com --hostname myhost --path foo -o loadbalancing=round-robin`))
3638
Eventually(session).Should(Say(`\n`))
@@ -102,7 +104,7 @@ var _ = Describe("update-route command", func() {
102104
AfterEach(func() {
103105
domain.Delete()
104106
})
105-
When("a route option is specified", func() {
107+
When("a loadbalancing route option is specified", func() {
106108
It("updates the route and runs to completion without failing", func() {
107109
option = "loadbalancing=round-robin"
108110
session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", option)
@@ -113,6 +115,38 @@ var _ = Describe("update-route command", func() {
113115
})
114116
})
115117

118+
When("a hash-based routing options are specified", func() {
119+
It("updates the route and runs to completion without failing", func() {
120+
optionLBAlgo := "loadbalancing=hash"
121+
optionHashHeader := "hash_header=X-Header"
122+
optionHashBalance := "hash_balance=1.3"
123+
session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", optionLBAlgo, "--option", optionHashHeader, "--option", optionHashBalance)
124+
Eventually(session).Should(Say(`Updating route %s\.%s%s for org %s / space %s as %s\.\.\.`, hostname, domainName, path, orgName, spaceName, userName))
125+
Eventually(session).Should(Say(`Route %s\.%s%s has been updated`, hostname, domainName, path))
126+
Eventually(session).Should(Say(`OK`))
127+
Eventually(session).Should(Exit(0))
128+
})
129+
Context("missing required options for hash-based routing", func() {
130+
It("update fails", func() {
131+
optionLBAlgo := "loadbalancing=hash"
132+
session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", optionLBAlgo)
133+
Eventually(session.Err).Should(Say(`Hash header must be present when loadbalancing is set to hash`))
134+
Eventually(session).Should(Exit(1))
135+
})
136+
})
137+
Context("with wrong loadbalancing option", func() {
138+
It("update fails", func() {
139+
optionLBAlgo := "loadbalancing=round-robin"
140+
optionHashHeader := "hash_header=X-Header"
141+
optionHashBalance := "hash_balance=1.3"
142+
session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path, "--option", optionLBAlgo, "--option", optionHashHeader, "--option", optionHashBalance)
143+
Eventually(session.Err).Should(Say(`Options Hash header can only be set when loadbalancing is hash`))
144+
Eventually(session.Err).Should(Say(`Options Hash balance can only be set when loadbalancing is hash`))
145+
Eventually(session).Should(Exit(1))
146+
})
147+
})
148+
})
149+
116150
When("route options are not specified", func() {
117151
It("gives an error message and fails", func() {
118152
session := helpers.CF("update-route", domainName, "--hostname", hostname, "--path", path)

0 commit comments

Comments
 (0)