@@ -70,6 +70,24 @@ const SingleHealthmonitorBody = `
7070}
7171`
7272
73+ // CreatePingHealthmonitorBody is the canned body of a POST request to create a ping healthmonitor.
74+ const CreatePingHealthmonitorBody = `
75+ {
76+ "healthmonitor": {
77+ "admin_state_up":true,
78+ "project_id":"83657cfcdfe44cd5920adaf26c48ceea",
79+ "delay":10,
80+ "name":"web",
81+ "max_retries":1,
82+ "max_retries_down":7,
83+ "timeout":1,
84+ "type":"PING",
85+ "pools": [{"id": "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d"}],
86+ "id":"466c8345-28d8-4f84-a246-e04380b0461d"
87+ }
88+ }
89+ `
90+
7391// PostUpdateHealthmonitorBody is the canned response body of a Update request on an existing healthmonitor.
7492const PostUpdateHealthmonitorBody = `
7593{
@@ -93,6 +111,24 @@ const PostUpdateHealthmonitorBody = `
93111}
94112`
95113
114+ // PostUpdatePingHealthmonitorBody is the canned response body of a Update request on an existing healthmonitor.
115+ const PostUpdatePingHealthmonitorBody = `
116+ {
117+ "healthmonitor": {
118+ "admin_state_up":true,
119+ "project_id":"83657cfcdfe44cd5920adaf26c48ceea",
120+ "delay":10,
121+ "name":"web",
122+ "max_retries":1,
123+ "max_retries_down":7,
124+ "timeout":1,
125+ "type":"PING",
126+ "pools": [{"id": "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d"}],
127+ "id":"466c8345-28d8-4f84-a246-e04380b0461d"
128+ }
129+ }
130+ `
131+
96132var (
97133 HealthmonitorWeb = monitors.Monitor {
98134 AdminStateUp : true ,
@@ -140,6 +176,18 @@ var (
140176 ID : "5d4b5228-33b0-4e60-b225-9b727c1a20e7" ,
141177 Pools : []monitors.PoolID {{ID : "d459f7d8-c6ee-439d-8713-d3fc08aeed8d" }},
142178 }
179+ HealthmonitorWebUpdated = monitors.Monitor {
180+ AdminStateUp : true ,
181+ Name : "web" ,
182+ ProjectID : "83657cfcdfe44cd5920adaf26c48ceea" ,
183+ Delay : 10 ,
184+ MaxRetries : 1 ,
185+ MaxRetriesDown : 7 ,
186+ Timeout : 1 ,
187+ Type : "PING" ,
188+ ID : "466c8345-28d8-4f84-a246-e04380b0461d" ,
189+ Pools : []monitors.PoolID {{ID : "84f1b61f-58c4-45bf-a8a9-2dafb9e5214d" }},
190+ }
143191)
144192
145193// HandleHealthmonitorListSuccessfully sets up the test server to respond to a healthmonitor List request.
@@ -191,6 +239,31 @@ func HandleHealthmonitorCreationSuccessfully(t *testing.T, response string) {
191239 })
192240}
193241
242+ // HandlePingHealthmonitorCreationSuccessfully sets up the test server to respond to a ping healthmonitor creation request
243+ // with a given response.
244+ func HandlePingHealthmonitorCreationSuccessfully (t * testing.T , response string ) {
245+ th .Mux .HandleFunc ("/v2.0/lbaas/healthmonitors" , func (w http.ResponseWriter , r * http.Request ) {
246+ th .TestMethod (t , r , "POST" )
247+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
248+ th .TestJSONRequest (t , r , `{
249+ "healthmonitor": {
250+ "type":"PING",
251+ "pool_id":"84f1b61f-58c4-45bf-a8a9-2dafb9e5214d",
252+ "project_id":"83657cfcdfe44cd5920adaf26c48ceea",
253+ "delay":10,
254+ "name":"web",
255+ "timeout":1,
256+ "max_retries":1,
257+ "max_retries_down":7
258+ }
259+ }` )
260+
261+ w .WriteHeader (http .StatusAccepted )
262+ w .Header ().Add ("Content-Type" , "application/json" )
263+ fmt .Fprintf (w , response )
264+ })
265+ }
266+
194267// HandleHealthmonitorGetSuccessfully sets up the test server to respond to a healthmonitor Get request.
195268func HandleHealthmonitorGetSuccessfully (t * testing.T ) {
196269 th .Mux .HandleFunc ("/v2.0/lbaas/healthmonitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7" , func (w http.ResponseWriter , r * http.Request ) {
@@ -236,3 +309,24 @@ func HandleHealthmonitorUpdateSuccessfully(t *testing.T) {
236309 fmt .Fprintf (w , PostUpdateHealthmonitorBody )
237310 })
238311}
312+
313+ // HandlePingHealthmonitorUpdateSuccessfully sets up the test server to respond to a healthmonitor Update request.
314+ func HandlePingHealthmonitorUpdateSuccessfully (t * testing.T ) {
315+ th .Mux .HandleFunc ("/v2.0/lbaas/healthmonitors/5d4b5228-33b0-4e60-b225-9b727c1a20e7" , func (w http.ResponseWriter , r * http.Request ) {
316+ th .TestMethod (t , r , "PUT" )
317+ th .TestHeader (t , r , "X-Auth-Token" , client .TokenID )
318+ th .TestHeader (t , r , "Accept" , "application/json" )
319+ th .TestHeader (t , r , "Content-Type" , "application/json" )
320+ th .TestJSONRequest (t , r , `{
321+ "healthmonitor": {
322+ "delay":3,
323+ "name":"NewHealthmonitorName",
324+ "timeout":20,
325+ "max_retries":10,
326+ "max_retries_down":8
327+ }
328+ }` )
329+
330+ fmt .Fprintf (w , PostUpdatePingHealthmonitorBody )
331+ })
332+ }
0 commit comments