func registerCinderSnapshots(s *CollectorSuite) { snapshots := "/v2/v2ffff/snapshots/detail" th.Mux.HandleFunc(snapshots, func(w http.ResponseWriter, r *http.Request) { th.TestMethod(s.T(), r, "GET") th.TestHeader(s.T(), r, "X-Auth-Token", s.Token) th.TestFormValues(s.T(), r, map[string]string{"all_tenants": "true"}) w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) fmt.Fprintf(w, ` { "snapshots": [ { "created_at": "2016-02-21T19:59:15.000000", "description": "description", "id": "snap1cccc", "metadata": {}, "name": "snapshot_1", "os-extended-snapshot-attributes:progress": "100", "os-extended-snapshot-attributes:project_id": "%s", "size": %d, "status": "available", "volume_id": "495a1698-ca2f-4e84-8d34-fa544c65ae3d" } ] } `, s.Tenant2ID, s.SnapShotSize) }) }
func registerCinderVolumes(s *CollectorSuite) { url := "/v2/v2ffff/volumes/detail" //?all_tenants=true th.Mux.HandleFunc(url, func(w http.ResponseWriter, r *http.Request) { th.TestFormValues(s.T(), r, map[string]string{"all_tenants": "true"}) th.TestMethod(s.T(), r, "GET") th.TestHeader(s.T(), r, "X-Auth-Token", s.Token) w.Header().Add("Content-Type", "application/json") w.WriteHeader(http.StatusOK) fmt.Fprintf(w, ` { "volumes": [ { "attachments": [], "availability_zone": "nova", "bootable": "true", "consistencygroup_id": null, "created_at": "2016-02-12T10:04:27.000000", "description": "Volume for test tenant", "encrypted": false, "id": "%s", "links": [ { "href": "http://192.168.20.2:8776/v2/d98e06adf5db49ad9f372625cad7840b/volumes/1877e478-56bd-4993-80f0-8da9a7e06290", "rel": "self" }, { "href": "http://192.168.20.2:8776/d98e06adf5db49ad9f372625cad7840b/volumes/1877e478-56bd-4993-80f0-8da9a7e06290", "rel": "bookmark" } ], "metadata": {}, "multiattach": false, "name": "test_tenant_volume", "os-vol-host-attr:host": "rbd:volumes#DEFAULT", "os-vol-mig-status-attr:migstat": null, "os-vol-mig-status-attr:name_id": null, "os-vol-tenant-attr:tenant_id": "%s", "os-volume-replication:driver_data": null, "os-volume-replication:extended_status": null, "replication_status": "disabled", "size": %d, "snapshot_id": null, "source_volid": null, "status": "available", "user_id": "a3edd7a918fc4373981051c975295dc8", "volume_image_metadata": { "checksum": "ee1eca47dc88f4879d8a229cc70a07c6", "container_format": "bare", "disk_format": "qcow2", "image_id": "e256d524-bbd7-40af-9bfa-463d86917459", "image_name": "TestVM", "min_disk": "0", "min_ram": "64", "size": "13287936" }, "volume_type": null }, { "attachments": [], "availability_zone": "nova", "bootable": "true", "consistencygroup_id": null, "created_at": "2016-02-09T15:24:27.000000", "description": null, "encrypted": false, "id": "%s", "links": [ { "href": "http://192.168.20.2:8776/v2/d98e06adf5db49ad9f372625cad7840b/volumes/ff3e438c-250d-4b03-82ce-3bec50a6c858", "rel": "self" }, { "href": "http://192.168.20.2:8776/d98e06adf5db49ad9f372625cad7840b/volumes/ff3e438c-250d-4b03-82ce-3bec50a6c858", "rel": "bookmark" } ], "metadata": {}, "multiattach": false, "name": "test-volume", "os-vol-host-attr:host": "rbd:volumes#DEFAULT", "os-vol-mig-status-attr:migstat": null, "os-vol-mig-status-attr:name_id": null, "os-vol-tenant-attr:tenant_id": "%s", "os-volume-replication:driver_data": null, "os-volume-replication:extended_status": null, "replication_status": "disabled", "size": %d, "snapshot_id": null, "source_volid": null, "status": "available", "user_id": "a3edd7a918fc4373981051c975295dc8", "volume_image_metadata": { "checksum": "ee1eca47dc88f4879d8a229cc70a07c6", "container_format": "bare", "disk_format": "qcow2", "image_id": "e256d524-bbd7-40af-9bfa-463d86917459", "image_name": "TestVM", "min_disk": "0", "min_ram": "64", "size": "13287936" }, "volume_type": null } ] } `, s.Vol1, s.Tenant1ID, s.Vol1Size, s.Vol2, s.Tenant2ID, s.Vol2Size) }) }
func setupV3Responses(t *testing.T) { // Mock the service query. th.Mux.HandleFunc("/services", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "GET") th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) w.Header().Add("Content-Type", "application/json") fmt.Fprintf(w, ` { "links": { "next": null, "previous": null }, "services": [ { "description": "Correct", "id": "1234", "name": "same", "type": "same" }, { "description": "Bad Name", "id": "9876", "name": "different", "type": "same" } ] } `) }) // Mock the endpoint query. th.Mux.HandleFunc("/endpoints", func(w http.ResponseWriter, r *http.Request) { th.TestMethod(t, r, "GET") th.TestHeader(t, r, "X-Auth-Token", fake.TokenID) th.TestFormValues(t, r, map[string]string{ "service_id": "1234", "interface": "public", }) w.Header().Add("Content-Type", "application/json") fmt.Fprintf(w, ` { "endpoints": [ { "id": "12", "interface": "public", "name": "the-right-one", "region": "same", "service_id": "1234", "url": "https://correct:9000/" }, { "id": "14", "interface": "public", "name": "bad-region", "region": "different", "service_id": "1234", "url": "https://bad-region:9001/" } ], "links": { "next": null, "previous": null } } `) }) }