1
1
<?php
2
2
3
- namespace OpenStack \integration \BlockStorage \v2 ;
3
+ namespace OpenStack \Integration \BlockStorage \v2 ;
4
4
5
5
use OpenStack \BlockStorage \v2 \Models \Snapshot ;
6
6
use OpenStack \BlockStorage \v2 \Models \Volume ;
@@ -34,22 +34,24 @@ public function runTests()
34
34
$ this ->volumeTypes ();
35
35
$ this ->logger ->info ('-> Snapshots ' );
36
36
$ this ->snapshots ();
37
+ $ this ->logger ->info ('-> Snapshot list ' );
38
+ $ this ->snapshotList ();
37
39
38
40
$ this ->outputTimeTaken ();
39
41
}
40
42
41
43
public function volumes ()
42
44
{
43
- $ this ->logStep ('-> Volumes tests ' );
45
+ $ this ->logStep ('Creating volume type ' );
44
46
$ volumeType = $ this ->getService ()->createVolumeType (['name ' => $ this ->randomStr ()]);
45
47
46
48
$ replacements = [
47
49
'{description} ' => $ this ->randomStr (),
48
- "'{size}' " => 1 ,
49
- '{name} ' => $ this ->randomStr (),
50
- '{volumeType} ' => $ volumeType ->id ,
51
- '{key1} ' => $ this ->randomStr (),
52
- '{val1} ' => $ this ->randomStr (),
50
+ "'{size}' " => 1 ,
51
+ '{name} ' => $ this ->randomStr (),
52
+ '{volumeType} ' => $ volumeType ->id ,
53
+ '{key1} ' => $ this ->randomStr (),
54
+ '{val1} ' => $ this ->randomStr (),
53
55
];
54
56
55
57
$ this ->logStep ('Creating volume ' );
@@ -70,7 +72,7 @@ public function volumes()
70
72
71
73
$ replacements += [
72
74
'{newName} ' => $ this ->randomStr (),
73
- '{newDescription} ' => $ this ->randomStr ()
75
+ '{newDescription} ' => $ this ->randomStr (),
74
76
];
75
77
76
78
$ this ->logStep ('Updating volume ' );
@@ -82,6 +84,7 @@ public function volumes()
82
84
/** @var \Generator $volumes */
83
85
require_once $ this ->sampleFile ($ replacements , 'volumes/list.php ' );
84
86
87
+ $ volume = $ this ->getService ()->getVolume ($ volumeId );
85
88
$ volume ->waitUntil ('available ' );
86
89
87
90
$ this ->logStep ('Deleting volume ' );
@@ -135,8 +138,8 @@ public function snapshots()
135
138
$ volume ->waitUntil ('available ' , 60 );
136
139
137
140
$ replacements = [
138
- '{volumeId} ' => $ volume ->id ,
139
- '{name} ' => $ this ->randomStr (),
141
+ '{volumeId} ' => $ volume ->id ,
142
+ '{name} ' => $ this ->randomStr (),
140
143
'{description} ' => $ this ->randomStr (),
141
144
];
142
145
@@ -183,11 +186,68 @@ public function snapshots()
183
186
184
187
$ snapshot ->waitUntil ('available ' , 60 );
185
188
189
+ $ this ->logStep ('Listing snapshots ' );
190
+ require_once $ this ->sampleFile ($ replacements , 'snapshots/list.php ' );
191
+
186
192
$ this ->logStep ('Deleting snapshot ' );
187
193
require_once $ this ->sampleFile ($ replacements , 'snapshots/delete.php ' );
188
194
$ snapshot ->waitUntilDeleted ();
189
195
190
196
$ this ->logStep ('Deleting volume ' );
191
197
$ volume ->delete ();
192
198
}
199
+
200
+ public function snapshotList ()
201
+ {
202
+ $ this ->logStep ('Creating volume ' );
203
+ $ volume = $ this ->getService ()->createVolume (['name ' => $ this ->randomStr (), 'size ' => 1 ]);
204
+ $ volume ->waitUntil ('available ' , 60 );
205
+
206
+ $ names = ['b ' . $ this ->randomStr (), 'a ' . $ this ->randomStr (), 'd ' . $ this ->randomStr (), 'c ' . $ this ->randomStr ()];
207
+ $ createdSnapshots = [];
208
+ foreach ($ names as $ name ) {
209
+ $ this ->logStep ('Creating snapshot ' . $ name );
210
+ $ snapshot = $ this ->getService ()->createSnapshot ([
211
+ 'volumeId ' => $ volume ->id ,
212
+ 'name ' => $ name ,
213
+ ]);
214
+
215
+ self ::assertInstanceOf (Snapshot::class, $ snapshot );
216
+
217
+ $ createdSnapshots [] = $ snapshot ;
218
+ $ snapshot ->waitUntil ('available ' , 60 );
219
+ }
220
+
221
+ try {
222
+ $ replacements = [
223
+ '{sortKey} ' => 'display_name ' ,
224
+ '{sortDir} ' => 'asc ' ,
225
+ ];
226
+
227
+ $ this ->logStep ('Listing snapshots ' );
228
+ require_once $ this ->sampleFile ($ replacements , 'snapshots/list.php ' );
229
+
230
+ $ this ->logStep ('Listing snapshots sorted asc ' );
231
+ /** @var Snapshot $snapshot */
232
+ require_once $ this ->sampleFile ($ replacements , 'snapshots/list_sorted.php ' );
233
+ self ::assertInstanceOf (Snapshot::class, $ snapshot );
234
+ self ::assertEquals ($ names [2 ], $ snapshot ->name );
235
+
236
+ $ this ->logStep ('Listing snapshots sorted desc ' );
237
+ $ replacements ['{sortDir} ' ] = 'desc ' ;
238
+ /** @var Snapshot $snapshot */
239
+ require_once $ this ->sampleFile ($ replacements , 'snapshots/list_sorted.php ' );
240
+ self ::assertInstanceOf (Snapshot::class, $ snapshot );
241
+ self ::assertEquals ($ names [1 ], $ snapshot ->name );
242
+ } finally {
243
+ foreach ($ createdSnapshots as $ snapshot ) {
244
+ $ this ->logStep ('Deleting snapshot ' . $ snapshot ->name );
245
+ $ snapshot ->delete ();
246
+ $ snapshot ->waitUntilDeleted ();
247
+ }
248
+
249
+ $ this ->logStep ('Deleting volume ' );
250
+ $ volume ->delete ();
251
+ }
252
+ }
193
253
}
0 commit comments