Skip to content

Commit b1d38dd

Browse files
authored
tests: run MultiAttach with a capable Cinder Type
Starting from the Queens release, it is possible to attach a volume to multiple hosts/servers, using a volume type with multiattach capability. Cinder previously had a `multiattach` parameter that could be passed during the volume creation. This parameter was recently removed [1], and caused our jobs to fail. This commit change the tests to no longer use the removed parameter. Fixes #2657. Co-Authored-By: Martin André <m.andre@redhat.com> [1] openstack/cinder@d4535c7
1 parent 283c721 commit b1d38dd

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

acceptance/openstack/blockstorage/v3/blockstorage.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,36 @@ func CreateVolumeTypeNoExtraSpecs(t *testing.T, client *gophercloud.ServiceClien
177177
return vt, nil
178178
}
179179

180+
// CreateVolumeTypeMultiAttach will create a volume type with a random name and
181+
// extra specs for multi-attach. An error will be returned if the volume type was
182+
// unable to be created.
183+
func CreateVolumeTypeMultiAttach(t *testing.T, client *gophercloud.ServiceClient) (*volumetypes.VolumeType, error) {
184+
name := tools.RandomString("ACPTTEST", 16)
185+
description := "create_from_gophercloud"
186+
t.Logf("Attempting to create volume type: %s", name)
187+
188+
createOpts := volumetypes.CreateOpts{
189+
Name: name,
190+
ExtraSpecs: map[string]string{"multiattach": "<is> True"},
191+
Description: description,
192+
}
193+
194+
vt, err := volumetypes.Create(client, createOpts).Extract()
195+
if err != nil {
196+
return nil, err
197+
}
198+
199+
tools.PrintResource(t, vt)
200+
th.AssertEquals(t, vt.IsPublic, true)
201+
th.AssertEquals(t, vt.Name, name)
202+
th.AssertEquals(t, vt.Description, description)
203+
th.AssertEquals(t, vt.ExtraSpecs["multiattach"], "<is> True")
204+
205+
t.Logf("Successfully created volume type: %s", vt.ID)
206+
207+
return vt, nil
208+
}
209+
180210
// CreatePrivateVolumeType will create a private volume type with a random
181211
// name and no extra specs. An error will be returned if the volume type was
182212
// unable to be created.
@@ -268,7 +298,7 @@ func DeleteVolumeType(t *testing.T, client *gophercloud.ServiceClient, vt *volum
268298

269299
err := volumetypes.Delete(client, vt.ID).ExtractErr()
270300
if err != nil {
271-
t.Fatalf("Unable to delete volume %s: %v", vt.ID, err)
301+
t.Fatalf("Unable to delete volume type %s: %v", vt.ID, err)
272302
}
273303

274304
t.Logf("Successfully deleted volume type: %s", vt.ID)

acceptance/openstack/blockstorage/v3/volumes_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,30 +67,33 @@ func TestVolumes(t *testing.T) {
6767
}
6868

6969
func TestVolumesMultiAttach(t *testing.T) {
70+
clients.RequireAdmin(t)
7071
clients.RequireLong(t)
7172

7273
client, err := clients.NewBlockStorageV3Client()
7374
th.AssertNoErr(t, err)
7475

76+
vt, err := CreateVolumeTypeMultiAttach(t, client)
77+
th.AssertNoErr(t, err)
78+
defer DeleteVolumeType(t, client, vt)
79+
7580
volumeName := tools.RandomString("ACPTTEST", 16)
7681

7782
volOpts := volumes.CreateOpts{
7883
Size: 1,
7984
Name: volumeName,
8085
Description: "Testing creation of multiattach enabled volume",
81-
Multiattach: true,
86+
VolumeType: vt.ID,
8287
}
8388

8489
vol, err := volumes.Create(client, volOpts).Extract()
8590
th.AssertNoErr(t, err)
91+
defer DeleteVolume(t, client, vol)
8692

8793
err = volumes.WaitForStatus(client, vol.ID, "available", 60)
8894
th.AssertNoErr(t, err)
8995

9096
th.AssertEquals(t, vol.Multiattach, true)
91-
92-
err = volumes.Delete(client, vol.ID, volumes.DeleteOpts{}).ExtractErr()
93-
th.AssertNoErr(t, err)
9497
}
9598

9699
func TestVolumesCascadeDelete(t *testing.T) {

0 commit comments

Comments
 (0)