fix acceptance tests and prevent decoding empty responses
diff --git a/acceptance/openstack/blockstorage/v2/extensions/volumeactions_test.go b/acceptance/openstack/blockstorage/v2/extensions/volumeactions_test.go
index ccd9422..e01967b 100644
--- a/acceptance/openstack/blockstorage/v2/extensions/volumeactions_test.go
+++ b/acceptance/openstack/blockstorage/v2/extensions/volumeactions_test.go
@@ -29,14 +29,18 @@
client, err := newClient(t)
th.AssertNoErr(t, err)
+ t.Logf("Creating volume")
cv, err := volumes.Create(client, &volumes.CreateOpts{
Size: 1,
Name: "blockv2-volume",
}).Extract()
th.AssertNoErr(t, err)
+
defer func() {
err = volumes.WaitForStatus(client, cv.ID, "available", 60)
th.AssertNoErr(t, err)
+
+ t.Logf("Deleting volume")
err = volumes.Delete(client, cv.ID).ExtractErr()
th.AssertNoErr(t, err)
}()
@@ -49,17 +53,19 @@
t.Fatal("Environment variable OS_INSTANCE_ID is required")
}
- _, err = volumeactions.Attach(client, cv.ID, &volumeactions.AttachOpts{
+ t.Logf("Attaching volume")
+ err = volumeactions.Attach(client, cv.ID, &volumeactions.AttachOpts{
MountPoint: "/mnt",
Mode: "rw",
InstanceUUID: instanceID,
- }).Extract()
+ }).ExtractErr()
th.AssertNoErr(t, err)
err = volumes.WaitForStatus(client, cv.ID, "in-use", 60)
th.AssertNoErr(t, err)
- _, err = volumeactions.Detach(client, cv.ID).Extract()
+ t.Logf("Detaching volume")
+ err = volumeactions.Detach(client, cv.ID).ExtractErr()
th.AssertNoErr(t, err)
}
@@ -67,14 +73,18 @@
client, err := newClient(t)
th.AssertNoErr(t, err)
+ t.Logf("Creating volume")
cv, err := volumes.Create(client, &volumes.CreateOpts{
Size: 1,
Name: "blockv2-volume",
}).Extract()
th.AssertNoErr(t, err)
+
defer func() {
err = volumes.WaitForStatus(client, cv.ID, "available", 60)
th.AssertNoErr(t, err)
+
+ t.Logf("Deleting volume")
err = volumes.Delete(client, cv.ID).ExtractErr()
th.AssertNoErr(t, err)
}()
@@ -82,15 +92,58 @@
err = volumes.WaitForStatus(client, cv.ID, "available", 60)
th.AssertNoErr(t, err)
- _, err = volumeactions.Reserve(client, cv.ID).Extract()
+ t.Logf("Reserving volume")
+ err = volumeactions.Reserve(client, cv.ID).ExtractErr()
th.AssertNoErr(t, err)
err = volumes.WaitForStatus(client, cv.ID, "attaching", 60)
th.AssertNoErr(t, err)
- _, err = volumeactions.Unreserve(client, cv.ID).Extract()
+ t.Logf("Unreserving volume")
+ err = volumeactions.Unreserve(client, cv.ID).ExtractErr()
th.AssertNoErr(t, err)
err = volumes.WaitForStatus(client, cv.ID, "available", 60)
th.AssertNoErr(t, err)
}
+
+func TestVolumeConns(t *testing.T) {
+ client, err := newClient(t)
+ th.AssertNoErr(t, err)
+
+ t.Logf("Creating volume")
+ cv, err := volumes.Create(client, &volumes.CreateOpts{
+ Size: 1,
+ Name: "blockv2-volume",
+ }).Extract()
+ th.AssertNoErr(t, err)
+
+ defer func() {
+ err = volumes.WaitForStatus(client, cv.ID, "available", 60)
+ th.AssertNoErr(t, err)
+
+ t.Logf("Deleting volume")
+ err = volumes.Delete(client, cv.ID).ExtractErr()
+ th.AssertNoErr(t, err)
+ }()
+
+ err = volumes.WaitForStatus(client, cv.ID, "available", 60)
+ th.AssertNoErr(t, err)
+
+ connOpts := &volumeactions.ConnectorOpts{
+ IP: "127.0.0.1",
+ Host: "stack",
+ Initiator: "iqn.1994-05.com.redhat:17cf566367d2",
+ Multipath: false,
+ Platform: "x86_64",
+ OSType: "linux2",
+ }
+
+ t.Logf("Initializing connection")
+ _, err = volumeactions.InitializeConnection(client, cv.ID, connOpts).Extract()
+ th.AssertNoErr(t, err)
+
+ t.Logf("Terminating connection")
+ err = volumeactions.TerminateConnection(client, cv.ID, connOpts).ExtractErr()
+ th.AssertNoErr(t, err)
+}
diff --git a/openstack/blockstorage/v2/extensions/volumeactions/requests.go b/openstack/blockstorage/v2/extensions/volumeactions/requests.go
index 515fe68..842a659 100644
--- a/openstack/blockstorage/v2/extensions/volumeactions/requests.go
+++ b/openstack/blockstorage/v2/extensions/volumeactions/requests.go
@@ -62,7 +62,7 @@
return res
}
- _, res.Err = client.Post(attachURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, res.Err = client.Post(attachURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
OkCodes: []int{202},
})
@@ -76,7 +76,7 @@
v := make(map[string]interface{})
reqBody := map[string]interface{}{"os-detach": v}
- _, res.Err = client.Post(detachURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, res.Err = client.Post(detachURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
OkCodes: []int{202},
})
@@ -90,7 +90,7 @@
v := make(map[string]interface{})
reqBody := map[string]interface{}{"os-reserve": v}
- _, res.Err = client.Post(reserveURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, res.Err = client.Post(reserveURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
OkCodes: []int{200, 201, 202},
})
@@ -104,7 +104,7 @@
v := make(map[string]interface{})
reqBody := map[string]interface{}{"os-unreserve": v}
- _, res.Err = client.Post(unreserveURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
+ _, res.Err = client.Post(unreserveURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
OkCodes: []int{200, 201, 202},
})
@@ -193,8 +193,8 @@
reqBody := map[string]interface{}{"os-terminate_connection": connctorMap}
- _, res.Err = client.Post(teminateConnectionURL(client, id), reqBody, &res.Body, &gophercloud.RequestOpts{
- OkCodes: []int{200, 201, 202},
+ _, res.Err = client.Post(teminateConnectionURL(client, id), reqBody, nil, &gophercloud.RequestOpts{
+ OkCodes: []int{202},
})
return res
diff --git a/openstack/blockstorage/v2/extensions/volumeactions/results.go b/openstack/blockstorage/v2/extensions/volumeactions/results.go
index c767307..65778e5 100644
--- a/openstack/blockstorage/v2/extensions/volumeactions/results.go
+++ b/openstack/blockstorage/v2/extensions/volumeactions/results.go
@@ -11,22 +11,22 @@
// AttachResult contains the response body and error from a Get request.
type AttachResult struct {
- commonResult
+ gophercloud.ErrResult
}
// DetachResult contains the response body and error from a Get request.
type DetachResult struct {
- commonResult
+ gophercloud.ErrResult
}
// ReserveResult contains the response body and error from a Get request.
type ReserveResult struct {
- commonResult
+ gophercloud.ErrResult
}
// UnreserveResult contains the response body and error from a Get request.
type UnreserveResult struct {
- commonResult
+ gophercloud.ErrResult
}
// InitializeConnectionResult contains the response body and error from a Get request.
@@ -36,7 +36,7 @@
// TerminateConnectionResult contains the response body and error from a Get request.
type TerminateConnectionResult struct {
- commonResult
+ gophercloud.ErrResult
}
// Extract will get the Volume object out of the commonResult object.
@@ -46,7 +46,6 @@
}
var res map[string]interface{}
-
err := mapstructure.Decode(r.Body, &res)
return res, err