MCPcopy
hub / github.com/cloudfoundry/cli / FindOrCreateTCPRouterGroup

Function FindOrCreateTCPRouterGroup

integration/helpers/route.go:25–40  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

23// INTEGRATION-TCP-NODE-<node>, or create one if it does not exist. Returns the name of
24// the router group.
25func 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.
43type Route struct {

Calls 2

CFFunction · 0.85
MatchMethod · 0.45

Tested by

no test coverage detected