Skip to content

Commit

Permalink
Add acceptance tests for tag field to compute block_device_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilienM committed Sep 20, 2023
1 parent 93e5d0f commit 9e26879
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions acceptance/openstack/compute/v2/bootfromvolume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,3 +303,45 @@ func TestBootFromNewCustomizedVolume(t *testing.T) {

tools.PrintResource(t, server)
}

func TestBootFromNewVolumeWithTag(t *testing.T) {
clients.RequireLong(t)

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

choices, err := clients.AcceptanceTestChoicesFromEnv()
th.AssertNoErr(t, err)

// minimum required microversion for getting volume tags is 2.70
// https://docs.openstack.org/nova/latest/reference/api-microversion-history.html#id64
client.Microversion = "2.70"

tagName := "tag1"
blockDevices := []bootfromvolume.BlockDevice{
{
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationVolume,
SourceType: bootfromvolume.SourceImage,
UUID: choices.ImageID,
VolumeSize: 2,
Tag: tagName,
},
}

server, err := CreateBootableVolumeServer(t, client, blockDevices)
th.AssertNoErr(t, err)
defer DeleteServer(t, client, server)

attachPages, err := volumeattach.List(client, server.ID).AllPages()
th.AssertNoErr(t, err)

attachments, err := volumeattach.ExtractVolumeAttachments(attachPages)
th.AssertNoErr(t, err)

tools.PrintResource(t, server)
tools.PrintResource(t, attachments)

th.AssertEquals(t, len(attachments), 1)
th.AssertEquals(t, attachments[0].Tag, tagName)
}

0 comments on commit 9e26879

Please sign in to comment.