@@ -466,15 +466,14 @@ func TestAccDomainResource_destroyShutdownRunningWithImage(t *testing.T) {
466466 if _ , err := os .Stat (imagePath ); err != nil {
467467 t .Skipf ("LIBVIRT_TEST_ACPI_IMAGE does not exist: %v" , err )
468468 }
469- testAccRequireDefaultPool (t )
470469
471470 resource .Test (t , resource.TestCase {
472471 PreCheck : func () { testAccPreCheck (t ) },
473472 ProtoV6ProviderFactories : testAccProtoV6ProviderFactories ,
474473 CheckDestroy : testAccCheckDomainDestroy ,
475474 Steps : []resource.TestStep {
476475 {
477- Config : testAccDomainResourceConfigDestroyShutdownRunningWithImage ("test-domain-shutdown-image" , "test-volume-shutdown-image" , imagePath , 120 ),
476+ Config : testAccDomainResourceConfigDestroyShutdownRunningWithImage ("test-domain-shutdown-image" , "test-volume-shutdown-image" , "test-pool-shutdown-image" , "/var/lib/libvirt/images/test-pool-shutdown-image" , imagePath , 120 ),
478477 Check : resource .ComposeAggregateTestCheckFunc (
479478 resource .TestCheckResourceAttr ("libvirt_domain.test" , "name" , "test-domain-shutdown-image" ),
480479 resource .TestCheckResourceAttr ("libvirt_domain.test" , "running" , "true" ),
@@ -484,31 +483,13 @@ func TestAccDomainResource_destroyShutdownRunningWithImage(t *testing.T) {
484483 {
485484 // Give the guest time to finish early boot before testing shutdown behavior.
486485 PreConfig : func () { time .Sleep (45 * time .Second ) },
487- Config : testAccDomainResourceConfigDestroyShutdownRunningWithImage ("test-domain-shutdown-image" , "test-volume-shutdown-image" , imagePath , 120 ),
486+ Config : testAccDomainResourceConfigDestroyShutdownRunningWithImage ("test-domain-shutdown-image" , "test-volume-shutdown-image" , "test-pool-shutdown-image" , "/var/lib/libvirt/images/test-pool-shutdown-image" , imagePath , 120 ),
488487 Destroy : true ,
489488 },
490489 },
491490 })
492491}
493492
494- func testAccRequireDefaultPool (t * testing.T ) {
495- t .Helper ()
496-
497- ctx := context .Background ()
498- client , err := libvirtclient .NewClient (ctx , testAccLibvirtURI ())
499- if err != nil {
500- t .Skipf ("failed to create libvirt client: %v" , err )
501- }
502- defer func () { _ = client .Close () }()
503-
504- pool , err := client .Libvirt ().StoragePoolLookupByName ("default" )
505- if err != nil {
506- t .Skipf ("default storage pool not available: %v" , err )
507- }
508-
509- // Ignore error if pool is already active; we only need a usable pool.
510- _ = client .Libvirt ().StoragePoolCreate (pool , 0 )
511- }
512493
513494func TestAccDomainResource_updateWithRunning (t * testing.T ) {
514495 resource .Test (t , resource.TestCase {
@@ -752,19 +733,33 @@ resource "libvirt_domain" "test" {
752733` , name )
753734}
754735
755- func testAccDomainResourceConfigDestroyShutdownRunningWithImage (domainName , volumeName , imagePath string , timeout int64 ) string {
736+ func testAccDomainResourceConfigDestroyShutdownRunningWithImage (domainName , volumeName , poolName , poolPath , imagePath string , timeout int64 ) string {
756737 return fmt .Sprintf (`
738+ resource "libvirt_pool" "test" {
739+ name = %[3]q
740+ type = "dir"
741+ target = {
742+ path = %[4]q
743+ permissions = {
744+ mode = "777"
745+ }
746+ }
747+ }
748+
757749resource "libvirt_volume" "test" {
758750 name = "%[2]s.qcow2"
759- pool = "default"
751+ pool = libvirt_pool.test.name
760752 target = {
753+ permissions = {
754+ mode = "666"
755+ }
761756 format = {
762757 type = "qcow2"
763758 }
764759 }
765760 create = {
766761 content = {
767- url = %[3 ]q
762+ url = %[5 ]q
768763 }
769764 }
770765}
@@ -779,7 +774,7 @@ resource "libvirt_domain" "test" {
779774
780775 destroy = {
781776 shutdown = {
782- timeout = %[4 ]d
777+ timeout = %[6 ]d
783778 }
784779 }
785780
@@ -798,7 +793,7 @@ resource "libvirt_domain" "test" {
798793 {
799794 source = {
800795 volume = {
801- pool = "default"
796+ pool = libvirt_pool.test.name
802797 volume = libvirt_volume.test.name
803798 }
804799 }
@@ -822,7 +817,7 @@ resource "libvirt_domain" "test" {
822817 ]
823818 }
824819}
825- ` , domainName , volumeName , imagePath , timeout )
820+ ` , domainName , volumeName , poolName , poolPath , imagePath , timeout )
826821}
827822
828823func testAccCheckDomainIsRunning (name string ) resource.TestCheckFunc {
0 commit comments