github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/schedulerstats/testing/fixtures_test.go (about) 1 package testing 2 3 import ( 4 "fmt" 5 "net/http" 6 "testing" 7 8 "github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/schedulerstats" 9 "github.com/gophercloud/gophercloud/testhelper" 10 "github.com/gophercloud/gophercloud/testhelper/client" 11 ) 12 13 const PoolsListBody = ` 14 { 15 "pools": [ 16 { 17 "name": "opencloud@alpha#ALPHA_pool", 18 "host": "opencloud", 19 "backend": "alpha", 20 "pool": "ALPHA_pool" 21 }, 22 { 23 "name": "opencloud@beta#BETA_pool", 24 "host": "opencloud", 25 "backend": "beta", 26 "pool": "BETA_pool" 27 }, 28 { 29 "name": "opencloud@gamma#GAMMA_pool", 30 "host": "opencloud", 31 "backend": "gamma", 32 "pool": "GAMMA_pool" 33 }, 34 { 35 "name": "opencloud@delta#DELTA_pool", 36 "host": "opencloud", 37 "backend": "delta", 38 "pool": "DELTA_pool" 39 } 40 ] 41 } 42 ` 43 44 const PoolsListBodyDetail = ` 45 { 46 "pools": [ 47 { 48 "name": "opencloud@alpha#ALPHA_pool", 49 "host": "opencloud", 50 "backend": "alpha", 51 "pool": "ALPHA_pool", 52 "capabilities": { 53 "pool_name": "ALPHA_pool", 54 "total_capacity_gb": 1230.0, 55 "free_capacity_gb": 1210.0, 56 "reserved_percentage": 0, 57 "share_backend_name": "ALPHA", 58 "storage_protocol": "NFS_CIFS", 59 "vendor_name": "Open Source", 60 "driver_version": "1.0", 61 "timestamp": "2019-05-07T00:28:02.935569", 62 "driver_handles_share_servers": true, 63 "snapshot_support": true, 64 "create_share_from_snapshot_support": true, 65 "revert_to_snapshot_support": true, 66 "mount_snapshot_support": true, 67 "dedupe": false, 68 "compression": false, 69 "replication_type": null, 70 "replication_domain": null, 71 "sg_consistent_snapshot_support": "pool", 72 "ipv4_support": true, 73 "ipv6_support": false 74 } 75 }, 76 { 77 "name": "opencloud@beta#BETA_pool", 78 "host": "opencloud", 79 "backend": "beta", 80 "pool": "BETA_pool", 81 "capabilities": { 82 "pool_name": "BETA_pool", 83 "total_capacity_gb": 1230.0, 84 "free_capacity_gb": 1210.0, 85 "reserved_percentage": 0, 86 "share_backend_name": "BETA", 87 "storage_protocol": "NFS_CIFS", 88 "vendor_name": "Open Source", 89 "driver_version": "1.0", 90 "timestamp": "2019-05-07T00:28:02.817309", 91 "driver_handles_share_servers": true, 92 "snapshot_support": true, 93 "create_share_from_snapshot_support": true, 94 "revert_to_snapshot_support": true, 95 "mount_snapshot_support": true, 96 "dedupe": false, 97 "compression": false, 98 "replication_type": null, 99 "replication_domain": null, 100 "sg_consistent_snapshot_support": "pool", 101 "ipv4_support": true, 102 "ipv6_support": false 103 } 104 }, 105 { 106 "name": "opencloud@gamma#GAMMA_pool", 107 "host": "opencloud", 108 "backend": "gamma", 109 "pool": "GAMMA_pool", 110 "capabilities": { 111 "pool_name": "GAMMA_pool", 112 "total_capacity_gb": 1230.0, 113 "free_capacity_gb": 1210.0, 114 "reserved_percentage": 0, 115 "replication_type": "readable", 116 "share_backend_name": "GAMMA", 117 "storage_protocol": "NFS_CIFS", 118 "vendor_name": "Open Source", 119 "driver_version": "1.0", 120 "timestamp": "2019-05-07T00:28:02.899888", 121 "driver_handles_share_servers": false, 122 "snapshot_support": true, 123 "create_share_from_snapshot_support": true, 124 "revert_to_snapshot_support": true, 125 "mount_snapshot_support": true, 126 "dedupe": false, 127 "compression": false, 128 "sg_consistent_snapshot_support": "pool", 129 "ipv4_support": true, 130 "ipv6_support": false 131 } 132 }, 133 { 134 "name": "opencloud@delta#DELTA_pool", 135 "host": "opencloud", 136 "backend": "delta", 137 "pool": "DELTA_pool", 138 "capabilities": { 139 "pool_name": "DELTA_pool", 140 "total_capacity_gb": 1230.0, 141 "free_capacity_gb": 1210.0, 142 "reserved_percentage": 0, 143 "replication_type": "readable", 144 "share_backend_name": "DELTA", 145 "storage_protocol": "NFS_CIFS", 146 "vendor_name": "Open Source", 147 "driver_version": "1.0", 148 "timestamp": "2019-05-07T00:28:02.963660", 149 "driver_handles_share_servers": false, 150 "snapshot_support": true, 151 "create_share_from_snapshot_support": true, 152 "revert_to_snapshot_support": true, 153 "mount_snapshot_support": true, 154 "dedupe": false, 155 "compression": false, 156 "sg_consistent_snapshot_support": "pool", 157 "ipv4_support": true, 158 "ipv6_support": false 159 } 160 } 161 ] 162 } 163 ` 164 165 var ( 166 PoolFake1 = schedulerstats.Pool{ 167 Name: "opencloud@alpha#ALPHA_pool", 168 Host: "opencloud", 169 Backend: "alpha", 170 Pool: "ALPHA_pool", 171 } 172 173 PoolFake2 = schedulerstats.Pool{ 174 Name: "opencloud@beta#BETA_pool", 175 Host: "opencloud", 176 Backend: "beta", 177 Pool: "BETA_pool", 178 } 179 180 PoolFake3 = schedulerstats.Pool{ 181 Name: "opencloud@gamma#GAMMA_pool", 182 Host: "opencloud", 183 Backend: "gamma", 184 Pool: "GAMMA_pool", 185 } 186 187 PoolFake4 = schedulerstats.Pool{ 188 Name: "opencloud@delta#DELTA_pool", 189 Host: "opencloud", 190 Backend: "delta", 191 Pool: "DELTA_pool", 192 } 193 194 PoolDetailFake1 = schedulerstats.Pool{ 195 Name: "opencloud@alpha#ALPHA_pool", 196 Host: "opencloud", 197 Backend: "alpha", 198 Pool: "ALPHA_pool", 199 Capabilities: schedulerstats.Capabilities{ 200 DriverVersion: "1.0", 201 FreeCapacityGB: 1210, 202 StorageProtocol: "NFS_CIFS", 203 TotalCapacityGB: 1230, 204 VendorName: "Open Source", 205 ShareBackendName: "ALPHA", 206 Timestamp: "2019-05-07T00:28:02.935569", 207 DriverHandlesShareServers: true, 208 SnapshotSupport: true, 209 }, 210 } 211 212 PoolDetailFake2 = schedulerstats.Pool{ 213 Name: "opencloud@beta#BETA_pool", 214 Host: "opencloud", 215 Backend: "beta", 216 Pool: "BETA_pool", 217 Capabilities: schedulerstats.Capabilities{ 218 DriverVersion: "1.0", 219 FreeCapacityGB: 1210, 220 StorageProtocol: "NFS_CIFS", 221 TotalCapacityGB: 1230, 222 VendorName: "Open Source", 223 ShareBackendName: "BETA", 224 Timestamp: "2019-05-07T00:28:02.817309", 225 DriverHandlesShareServers: true, 226 SnapshotSupport: true, 227 }, 228 } 229 230 PoolDetailFake3 = schedulerstats.Pool{ 231 Name: "opencloud@gamma#GAMMA_pool", 232 Host: "opencloud", 233 Backend: "gamma", 234 Pool: "GAMMA_pool", 235 Capabilities: schedulerstats.Capabilities{ 236 DriverVersion: "1.0", 237 FreeCapacityGB: 1210, 238 StorageProtocol: "NFS_CIFS", 239 TotalCapacityGB: 1230, 240 VendorName: "Open Source", 241 ShareBackendName: "GAMMA", 242 Timestamp: "2019-05-07T00:28:02.899888", 243 DriverHandlesShareServers: false, 244 SnapshotSupport: true, 245 }, 246 } 247 248 PoolDetailFake4 = schedulerstats.Pool{ 249 Name: "opencloud@delta#DELTA_pool", 250 Host: "opencloud", 251 Backend: "delta", 252 Pool: "DELTA_pool", 253 Capabilities: schedulerstats.Capabilities{ 254 DriverVersion: "1.0", 255 FreeCapacityGB: 1210, 256 StorageProtocol: "NFS_CIFS", 257 TotalCapacityGB: 1230, 258 VendorName: "Open Source", 259 ShareBackendName: "DELTA", 260 Timestamp: "2019-05-07T00:28:02.963660", 261 DriverHandlesShareServers: false, 262 SnapshotSupport: true, 263 }, 264 } 265 ) 266 267 func HandlePoolsListSuccessfully(t *testing.T) { 268 testhelper.Mux.HandleFunc("/scheduler-stats/pools", func(w http.ResponseWriter, r *http.Request) { 269 testhelper.TestMethod(t, r, "GET") 270 testhelper.TestHeader(t, r, "X-Auth-Token", client.TokenID) 271 272 w.Header().Add("Content-Type", "application/json") 273 274 r.ParseForm() 275 fmt.Fprintf(w, PoolsListBody) 276 277 }) 278 testhelper.Mux.HandleFunc("/scheduler-stats/pools/detail", func(w http.ResponseWriter, r *http.Request) { 279 testhelper.TestMethod(t, r, "GET") 280 testhelper.TestHeader(t, r, "X-Auth-Token", client.TokenID) 281 282 w.Header().Add("Content-Type", "application/json") 283 284 r.ParseForm() 285 fmt.Fprintf(w, PoolsListBodyDetail) 286 }) 287 }