Skip to content

Commit

Permalink
Merge pull request #2713 from gophercloud/bp-v1-cf6531e
Browse files Browse the repository at this point in the history
[v1] tests: run MultiAttach with a capable Cinder Type
  • Loading branch information
mandre committed Aug 2, 2023
2 parents 283c721 + b1d38dd commit d2f09a0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
32 changes: 31 additions & 1 deletion acceptance/openstack/blockstorage/v3/blockstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,36 @@ func CreateVolumeTypeNoExtraSpecs(t *testing.T, client *gophercloud.ServiceClien
return vt, nil
}

// CreateVolumeTypeMultiAttach will create a volume type with a random name and
// extra specs for multi-attach. An error will be returned if the volume type was
// unable to be created.
func CreateVolumeTypeMultiAttach(t *testing.T, client *gophercloud.ServiceClient) (*volumetypes.VolumeType, error) {
name := tools.RandomString("ACPTTEST", 16)
description := "create_from_gophercloud"
t.Logf("Attempting to create volume type: %s", name)

createOpts := volumetypes.CreateOpts{
Name: name,
ExtraSpecs: map[string]string{"multiattach": "<is> True"},
Description: description,
}

vt, err := volumetypes.Create(client, createOpts).Extract()
if err != nil {
return nil, err
}

tools.PrintResource(t, vt)
th.AssertEquals(t, vt.IsPublic, true)
th.AssertEquals(t, vt.Name, name)
th.AssertEquals(t, vt.Description, description)
th.AssertEquals(t, vt.ExtraSpecs["multiattach"], "<is> True")

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

return vt, nil
}

// CreatePrivateVolumeType will create a private volume type with a random
// name and no extra specs. An error will be returned if the volume type was
// unable to be created.
Expand Down Expand Up @@ -268,7 +298,7 @@ func DeleteVolumeType(t *testing.T, client *gophercloud.ServiceClient, vt *volum

err := volumetypes.Delete(client, vt.ID).ExtractErr()
if err != nil {
t.Fatalf("Unable to delete volume %s: %v", vt.ID, err)
t.Fatalf("Unable to delete volume type %s: %v", vt.ID, err)
}

t.Logf("Successfully deleted volume type: %s", vt.ID)
Expand Down
11 changes: 7 additions & 4 deletions acceptance/openstack/blockstorage/v3/volumes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,33 @@ func TestVolumes(t *testing.T) {
}

func TestVolumesMultiAttach(t *testing.T) {
clients.RequireAdmin(t)
clients.RequireLong(t)

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

vt, err := CreateVolumeTypeMultiAttach(t, client)
th.AssertNoErr(t, err)
defer DeleteVolumeType(t, client, vt)

volumeName := tools.RandomString("ACPTTEST", 16)

volOpts := volumes.CreateOpts{
Size: 1,
Name: volumeName,
Description: "Testing creation of multiattach enabled volume",
Multiattach: true,
VolumeType: vt.ID,
}

vol, err := volumes.Create(client, volOpts).Extract()
th.AssertNoErr(t, err)
defer DeleteVolume(t, client, vol)

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

th.AssertEquals(t, vol.Multiattach, true)

err = volumes.Delete(client, vol.ID, volumes.DeleteOpts{}).ExtractErr()
th.AssertNoErr(t, err)
}

func TestVolumesCascadeDelete(t *testing.T) {
Expand Down

0 comments on commit d2f09a0

Please sign in to comment.