FindOrCreateTCPRouterGroup uses the routing API to find a router group with name INTEGRATION-TCP-NODE- , or create one if it does not exist. Returns the name of the router group.
(node int)
| 23 | // INTEGRATION-TCP-NODE-<node>, or create one if it does not exist. Returns the name of |
| 24 | // the router group. |
| 25 | func FindOrCreateTCPRouterGroup(node int) string { |
| 26 | routerGroupName := fmt.Sprintf("INTEGRATION-TCP-NODE-%d", node) |
| 27 | |
| 28 | session := CF("curl", fmt.Sprintf("/routing/v1/router_groups?name=%s", routerGroupName)) |
| 29 | Eventually(session).Should(Exit(0)) |
| 30 | doesNotExist := regexp.MustCompile("ResourceNotFoundError") |
| 31 | if doesNotExist.Match(session.Out.Contents()) { |
| 32 | jsonBody := fmt.Sprintf(`{"name": "%s", "type": "tcp", "reservable_ports": "%d-%d"}`, routerGroupName, MinTestPort, MaxTestPort) |
| 33 | session := CF("curl", "-d", jsonBody, "-X", "POST", "/routing/v1/router_groups") |
| 34 | Eventually(session).Should(Say(`"name":\s*"%s"`, routerGroupName)) |
| 35 | Eventually(session).Should(Say(`"type":\s*"tcp"`)) |
| 36 | Eventually(session).Should(Exit(0)) |
| 37 | } |
| 38 | |
| 39 | return routerGroupName |
| 40 | } |
| 41 | |
| 42 | // Route represents a route. |
| 43 | type Route struct { |
no test coverage detected