File: fixtures.go

package info (click to toggle)
golang-github-gophercloud-gophercloud 1.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,416 kB
  • sloc: sh: 99; makefile: 21
file content (287 lines) | stat: -rw-r--r-- 9,207 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
package testing

import (
	"fmt"
	"net/http"
	"testing"

	"github.com/gophercloud/gophercloud/openstack/sharedfilesystems/v2/schedulerstats"
	"github.com/gophercloud/gophercloud/testhelper"
	"github.com/gophercloud/gophercloud/testhelper/client"
)

const PoolsListBody = `
{
    "pools": [
        {
            "name": "opencloud@alpha#ALPHA_pool",
            "host": "opencloud",
            "backend": "alpha",
            "pool": "ALPHA_pool"
        },
        {
            "name": "opencloud@beta#BETA_pool",
            "host": "opencloud",
            "backend": "beta",
            "pool": "BETA_pool"
        },
        {
            "name": "opencloud@gamma#GAMMA_pool",
            "host": "opencloud",
            "backend": "gamma",
            "pool": "GAMMA_pool"
        },
        {
            "name": "opencloud@delta#DELTA_pool",
            "host": "opencloud",
            "backend": "delta",
            "pool": "DELTA_pool"
        }
    ]
}
`

const PoolsListBodyDetail = `
{
    "pools": [
        {
            "name": "opencloud@alpha#ALPHA_pool",
            "host": "opencloud",
            "backend": "alpha",
            "pool": "ALPHA_pool",
            "capabilities": {
                "pool_name": "ALPHA_pool",
                "total_capacity_gb": 1230.0,
                "free_capacity_gb": 1210.0,
                "reserved_percentage": 0,
                "share_backend_name": "ALPHA",
                "storage_protocol": "NFS_CIFS",
                "vendor_name": "Open Source",
                "driver_version": "1.0",
                "timestamp": "2019-05-07T00:28:02.935569",
                "driver_handles_share_servers": true,
                "snapshot_support": true,
                "create_share_from_snapshot_support": true,
                "revert_to_snapshot_support": true,
                "mount_snapshot_support": true,
                "dedupe": false,
                "compression": false,
                "replication_type": null,
                "replication_domain": null,
                "sg_consistent_snapshot_support": "pool",
                "ipv4_support": true,
                "ipv6_support": false
            }
        },
        {
            "name": "opencloud@beta#BETA_pool",
            "host": "opencloud",
            "backend": "beta",
            "pool": "BETA_pool",
            "capabilities": {
                "pool_name": "BETA_pool",
                "total_capacity_gb": 1230.0,
                "free_capacity_gb": 1210.0,
                "reserved_percentage": 0,
                "share_backend_name": "BETA",
                "storage_protocol": "NFS_CIFS",
                "vendor_name": "Open Source",
                "driver_version": "1.0",
                "timestamp": "2019-05-07T00:28:02.817309",
                "driver_handles_share_servers": true,
                "snapshot_support": true,
                "create_share_from_snapshot_support": true,
                "revert_to_snapshot_support": true,
                "mount_snapshot_support": true,
                "dedupe": false,
                "compression": false,
                "replication_type": null,
                "replication_domain": null,
                "sg_consistent_snapshot_support": "pool",
                "ipv4_support": true,
                "ipv6_support": false
            }
        },
        {
            "name": "opencloud@gamma#GAMMA_pool",
            "host": "opencloud",
            "backend": "gamma",
            "pool": "GAMMA_pool",
            "capabilities": {
                "pool_name": "GAMMA_pool",
                "total_capacity_gb": 1230.0,
                "free_capacity_gb": 1210.0,
                "reserved_percentage": 0,
                "replication_type": "readable",
                "share_backend_name": "GAMMA",
                "storage_protocol": "NFS_CIFS",
                "vendor_name": "Open Source",
                "driver_version": "1.0",
                "timestamp": "2019-05-07T00:28:02.899888",
                "driver_handles_share_servers": false,
                "snapshot_support": true,
                "create_share_from_snapshot_support": true,
                "revert_to_snapshot_support": true,
                "mount_snapshot_support": true,
                "dedupe": false,
                "compression": false,
                "sg_consistent_snapshot_support": "pool",
                "ipv4_support": true,
                "ipv6_support": false
            }
        },
        {
            "name": "opencloud@delta#DELTA_pool",
            "host": "opencloud",
            "backend": "delta",
            "pool": "DELTA_pool",
            "capabilities": {
                "pool_name": "DELTA_pool",
                "total_capacity_gb": 1230.0,
                "free_capacity_gb": 1210.0,
                "reserved_percentage": 0,
                "replication_type": "readable",
                "share_backend_name": "DELTA",
                "storage_protocol": "NFS_CIFS",
                "vendor_name": "Open Source",
                "driver_version": "1.0",
                "timestamp": "2019-05-07T00:28:02.963660",
                "driver_handles_share_servers": false,
                "snapshot_support": true,
                "create_share_from_snapshot_support": true,
                "revert_to_snapshot_support": true,
                "mount_snapshot_support": true,
                "dedupe": false,
                "compression": false,
                "sg_consistent_snapshot_support": "pool",
                "ipv4_support": true,
                "ipv6_support": false
            }
        }
    ]
}
`

var (
	PoolFake1 = schedulerstats.Pool{
		Name:    "opencloud@alpha#ALPHA_pool",
		Host:    "opencloud",
		Backend: "alpha",
		Pool:    "ALPHA_pool",
	}

	PoolFake2 = schedulerstats.Pool{
		Name:    "opencloud@beta#BETA_pool",
		Host:    "opencloud",
		Backend: "beta",
		Pool:    "BETA_pool",
	}

	PoolFake3 = schedulerstats.Pool{
		Name:    "opencloud@gamma#GAMMA_pool",
		Host:    "opencloud",
		Backend: "gamma",
		Pool:    "GAMMA_pool",
	}

	PoolFake4 = schedulerstats.Pool{
		Name:    "opencloud@delta#DELTA_pool",
		Host:    "opencloud",
		Backend: "delta",
		Pool:    "DELTA_pool",
	}

	PoolDetailFake1 = schedulerstats.Pool{
		Name:    "opencloud@alpha#ALPHA_pool",
		Host:    "opencloud",
		Backend: "alpha",
		Pool:    "ALPHA_pool",
		Capabilities: schedulerstats.Capabilities{
			DriverVersion:             "1.0",
			FreeCapacityGB:            1210,
			StorageProtocol:           "NFS_CIFS",
			TotalCapacityGB:           1230,
			VendorName:                "Open Source",
			ShareBackendName:          "ALPHA",
			Timestamp:                 "2019-05-07T00:28:02.935569",
			DriverHandlesShareServers: true,
			SnapshotSupport:           true,
		},
	}

	PoolDetailFake2 = schedulerstats.Pool{
		Name:    "opencloud@beta#BETA_pool",
		Host:    "opencloud",
		Backend: "beta",
		Pool:    "BETA_pool",
		Capabilities: schedulerstats.Capabilities{
			DriverVersion:             "1.0",
			FreeCapacityGB:            1210,
			StorageProtocol:           "NFS_CIFS",
			TotalCapacityGB:           1230,
			VendorName:                "Open Source",
			ShareBackendName:          "BETA",
			Timestamp:                 "2019-05-07T00:28:02.817309",
			DriverHandlesShareServers: true,
			SnapshotSupport:           true,
		},
	}

	PoolDetailFake3 = schedulerstats.Pool{
		Name:    "opencloud@gamma#GAMMA_pool",
		Host:    "opencloud",
		Backend: "gamma",
		Pool:    "GAMMA_pool",
		Capabilities: schedulerstats.Capabilities{
			DriverVersion:             "1.0",
			FreeCapacityGB:            1210,
			StorageProtocol:           "NFS_CIFS",
			TotalCapacityGB:           1230,
			VendorName:                "Open Source",
			ShareBackendName:          "GAMMA",
			Timestamp:                 "2019-05-07T00:28:02.899888",
			DriverHandlesShareServers: false,
			SnapshotSupport:           true,
		},
	}

	PoolDetailFake4 = schedulerstats.Pool{
		Name:    "opencloud@delta#DELTA_pool",
		Host:    "opencloud",
		Backend: "delta",
		Pool:    "DELTA_pool",
		Capabilities: schedulerstats.Capabilities{
			DriverVersion:             "1.0",
			FreeCapacityGB:            1210,
			StorageProtocol:           "NFS_CIFS",
			TotalCapacityGB:           1230,
			VendorName:                "Open Source",
			ShareBackendName:          "DELTA",
			Timestamp:                 "2019-05-07T00:28:02.963660",
			DriverHandlesShareServers: false,
			SnapshotSupport:           true,
		},
	}
)

func HandlePoolsListSuccessfully(t *testing.T) {
	testhelper.Mux.HandleFunc("/scheduler-stats/pools", func(w http.ResponseWriter, r *http.Request) {
		testhelper.TestMethod(t, r, "GET")
		testhelper.TestHeader(t, r, "X-Auth-Token", client.TokenID)

		w.Header().Add("Content-Type", "application/json")

		r.ParseForm()
		fmt.Fprintf(w, PoolsListBody)

	})
	testhelper.Mux.HandleFunc("/scheduler-stats/pools/detail", func(w http.ResponseWriter, r *http.Request) {
		testhelper.TestMethod(t, r, "GET")
		testhelper.TestHeader(t, r, "X-Auth-Token", client.TokenID)

		w.Header().Add("Content-Type", "application/json")

		r.ParseForm()
		fmt.Fprintf(w, PoolsListBodyDetail)
	})
}