Skip to content

Commit 552eaba

Browse files
committed
test: cover cpu host-model readback preservation
Refs: #1269
1 parent 8c8a679 commit 552eaba

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

internal/provider/domain_resource_test.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,27 @@ func TestAccDomainResource_cpu(t *testing.T) {
328328
})
329329
}
330330

331+
func TestAccDomainResource_cpuHostModelPreservesPlanValue(t *testing.T) {
332+
resource.Test(t, resource.TestCase{
333+
PreCheck: func() { testAccPreCheck(t) },
334+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
335+
CheckDestroy: testAccCheckDomainDestroy,
336+
Steps: []resource.TestStep{
337+
{
338+
Config: testAccDomainResourceConfigCPUHostModel("test-domain-cpu-host-model"),
339+
Check: resource.ComposeAggregateTestCheckFunc(
340+
resource.TestCheckResourceAttr("libvirt_domain.test", "name", "test-domain-cpu-host-model"),
341+
resource.TestCheckResourceAttr("libvirt_domain.test", "cpu.mode", "host-model"),
342+
),
343+
},
344+
{
345+
Config: testAccDomainResourceConfigCPUHostModel("test-domain-cpu-host-model"),
346+
PlanOnly: true,
347+
},
348+
},
349+
})
350+
}
351+
331352
func testAccDomainResourceConfigCPU(name string) string {
332353
return fmt.Sprintf(`
333354
@@ -351,6 +372,29 @@ resource "libvirt_domain" "test" {
351372
`, name)
352373
}
353374

375+
func testAccDomainResourceConfigCPUHostModel(name string) string {
376+
return fmt.Sprintf(`
377+
378+
resource "libvirt_domain" "test" {
379+
name = %[1]q
380+
memory = 512
381+
memory_unit = "MiB"
382+
vcpu = 2
383+
type = "kvm"
384+
385+
os = {
386+
type = "hvm"
387+
type_arch = "x86_64"
388+
type_machine = "q35"
389+
}
390+
391+
cpu = {
392+
mode = "host-model"
393+
}
394+
}
395+
`, name)
396+
}
397+
354398
func TestAccDomainResource_clock(t *testing.T) {
355399
resource.Test(t, resource.TestCase{
356400
PreCheck: func() { testAccPreCheck(t) },

0 commit comments

Comments
 (0)