github.com/gophercloud/gophercloud@v1.11.0/internal/acceptance/openstack/compute/v2/volumeattach_test.go (about)

     1  //go:build acceptance || compute || volumeattach
     2  // +build acceptance compute volumeattach
     3  
     4  package v2
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/gophercloud/gophercloud/internal/acceptance/clients"
    10  	bs "github.com/gophercloud/gophercloud/internal/acceptance/openstack/blockstorage/v2"
    11  	"github.com/gophercloud/gophercloud/internal/acceptance/tools"
    12  	th "github.com/gophercloud/gophercloud/testhelper"
    13  )
    14  
    15  func TestVolumeAttachAttachment(t *testing.T) {
    16  	clients.RequireLong(t)
    17  
    18  	client, err := clients.NewComputeV2Client()
    19  	th.AssertNoErr(t, err)
    20  
    21  	blockClient, err := clients.NewBlockStorageV3Client()
    22  	th.AssertNoErr(t, err)
    23  
    24  	server, err := CreateServer(t, client)
    25  	th.AssertNoErr(t, err)
    26  	defer DeleteServer(t, client, server)
    27  
    28  	volume, err := bs.CreateVolume(t, blockClient)
    29  	th.AssertNoErr(t, err)
    30  	defer bs.DeleteVolume(t, blockClient, volume)
    31  
    32  	client.Microversion = "2.79"
    33  	volumeAttachment, err := CreateVolumeAttachment(t, client, blockClient, server, volume)
    34  	th.AssertNoErr(t, err)
    35  	defer DeleteVolumeAttachment(t, client, blockClient, server, volumeAttachment)
    36  
    37  	tools.PrintResource(t, volumeAttachment)
    38  
    39  	th.AssertEquals(t, volumeAttachment.ServerID, server.ID)
    40  }