-
Notifications
You must be signed in to change notification settings - Fork 951
Expand file tree
/
Copy pathvolume.bats
More file actions
executable file
·179 lines (129 loc) · 3.39 KB
/
volume.bats
File metadata and controls
executable file
·179 lines (129 loc) · 3.39 KB
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
#!/usr/bin/env bats
load test_helper
@test "volume.ls" {
vcsim_env
run govc volume.ls
assert_success ""
for i in $(seq 1 6); do
if [ $(( i % 2)) -eq 0 ] ; then
seq=even
else
seq=odd
fi
run env GOVC_SHOW_UNRELEASED=true govc volume.create \
-cluster-id super-$seq -label "pid=$$" -label "seq=$seq" my-volume-"$i"
assert_success
done
run govc volume.ls
assert_success
assert_output_lines 6
run govc volume.ls -L -n my-volume-2
assert_success
assert_output_lines 1
run govc volume.ls $output
assert_success
assert_output_lines 1
run govc volume.ls -label "pid=$$"
assert_success
assert_output_lines 6
run govc volume.ls -L -label seq=even
assert_success
assert_output_lines 3
run govc volume.ls $output
assert_success
assert_output_lines 3
run govc volume.ls -H green
assert_success
assert_output_lines 6
run govc volume.ls -H red
assert_success ""
run govc volume.ls -profile "vSAN Default Storage Policy"
assert_success ""
run env GOVC_SHOW_UNRELEASED=true govc volume.create \
-cluster-id my-cluster -profile "vSAN Default Storage Policy" another-volume
assert_success
id=$output
run govc volume.ls -profile "vSAN Default Storage Policy"
assert_success
assert_output_lines 1
run govc volume.ls -c invalid-cluster
assert_success ""
run govc volume.ls -c super-odd
assert_success
assert_output_lines 3
run govc volume.ls -c super-even -c my-cluster
assert_success
assert_output_lines 4
run govc volume.ls -json
assert_success
run govc disk.metadata.ls -K cns.containerCluster.clusterId "$id"
assert_success
assert_matches "my-cluster"
run govc volume.ls -b "$id" # -b invokes CnsQueryVolumeInfo
assert_success
run govc volume.ls -json -b -n another-volume
assert_success
run jq -r .info[].volumeInfo.vStorageObject.config.backing.filePath <<<"$output"
assert_success
path="$output"
run govc datastore.disk.info "$path"
assert_success
}
@test "volume.create -disk-id" {
vcsim_env
run env GOVC_SHOW_UNRELEASED=true govc volume.create \
-cluster-id my-cluster -disk-id invalid my-volume
assert_failure
run govc disk.create -size 10M my-disk
assert_success
id="$output"
run govc disk.ls "$id"
assert_success
run env GOVC_SHOW_UNRELEASED=true govc volume.create \
-cluster-id my-cluster -disk-id "$id" my-volume
assert_success
vol="$output"
run govc volume.ls "$vol"
assert_success
run govc volume.extend -size 20M "$id"
assert_success
run govc volume.rm "$vol"
assert_success
run govc disk.ls "$id"
assert_failure
run govc volume.extend -size 30M "$id"
assert_failure
}
@test "volume.rm" {
vcsim_env
export GOVC_SHOW_UNRELEASED=true
run govc volume.create -cluster-id my-cluster my-volume
assert_success
id="$output"
run govc disk.ls "$id"
assert_success
run govc volume.rm invalid
assert_failure
run govc volume.rm "$id"
assert_success
run govc volume.rm "$id"
assert_failure
run govc disk.ls "$id"
assert_failure
run govc volume.create -cluster-id my-cluster my-volume
assert_success
id="$output"
run govc volume.rm -keep "$id"
assert_success
run govc disk.ls "$id"
assert_success
}
@test "volume.snapshot" {
vcsim_env
run govc volume.snapshot.ls
assert_failure
run govc volume.snapshot.rm
assert_failure
run govc volume.snapshot.create
assert_failure
}