@@ -25,7 +25,7 @@ func newClient(t *testing.T) (*gophercloud.ServiceClient, error) {
25
25
})
26
26
}
27
27
28
- func TestVolumeActions (t * testing.T ) {
28
+ func TestVolumeAttach (t * testing.T ) {
29
29
client , err := newClient (t )
30
30
th .AssertNoErr (t , err )
31
31
@@ -44,10 +44,15 @@ func TestVolumeActions(t *testing.T) {
44
44
err = volumes .WaitForStatus (client , cv .ID , "available" , 60 )
45
45
th .AssertNoErr (t , err )
46
46
47
+ instanceID := os .Getenv ("OS_INSTANCE_ID" )
48
+ if instanceID == "" {
49
+ t .Fatal ("Environment variable OS_INSTANCE_ID is required" )
50
+ }
51
+
47
52
_ , err = volumeactions .Attach (client , cv .ID , & volumeactions.AttachOpts {
48
53
MountPoint : "/mnt" ,
49
54
Mode : "rw" ,
50
- InstanceUUID : "50902f4f-a974-46a0-85e9-7efc5e22dfdd" ,
55
+ InstanceUUID : instanceID ,
51
56
}).Extract ()
52
57
th .AssertNoErr (t , err )
53
58
@@ -57,3 +62,35 @@ func TestVolumeActions(t *testing.T) {
57
62
_ , err = volumeactions .Detach (client , cv .ID ).Extract ()
58
63
th .AssertNoErr (t , err )
59
64
}
65
+
66
+ func TestVolumeReserve (t * testing.T ) {
67
+ client , err := newClient (t )
68
+ th .AssertNoErr (t , err )
69
+
70
+ cv , err := volumes .Create (client , & volumes.CreateOpts {
71
+ Size : 1 ,
72
+ Name : "blockv2-volume" ,
73
+ }).Extract ()
74
+ th .AssertNoErr (t , err )
75
+ defer func () {
76
+ err = volumes .WaitForStatus (client , cv .ID , "available" , 60 )
77
+ th .AssertNoErr (t , err )
78
+ err = volumes .Delete (client , cv .ID ).ExtractErr ()
79
+ th .AssertNoErr (t , err )
80
+ }()
81
+
82
+ err = volumes .WaitForStatus (client , cv .ID , "available" , 60 )
83
+ th .AssertNoErr (t , err )
84
+
85
+ _ , err = volumeactions .Reserve (client , cv .ID ).Extract ()
86
+ th .AssertNoErr (t , err )
87
+
88
+ err = volumes .WaitForStatus (client , cv .ID , "attaching" , 60 )
89
+ th .AssertNoErr (t , err )
90
+
91
+ _ , err = volumeactions .Unreserve (client , cv .ID ).Extract ()
92
+ th .AssertNoErr (t , err )
93
+
94
+ err = volumes .WaitForStatus (client , cv .ID , "available" , 60 )
95
+ th .AssertNoErr (t , err )
96
+ }
0 commit comments