Skip to content

Commit

Permalink
test all buses for overallocation, cleanup test bool conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
mpywell authored and lbajolet-hashicorp committed Sep 26, 2024
1 parent 3f7a153 commit c0a6e24
Show file tree
Hide file tree
Showing 2 changed files with 232 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builder/proxmox/common/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,11 @@ func TestISOs(t *testing.T) {
var config Config
_, _, err := config.Prepare(&config, cfg)

if c.expectedToFail == true && err == nil {
if c.expectedToFail && err == nil {
t.Error("expected config preparation to fail, but no error occured")
}

if c.expectedToFail == false && err != nil {
if !c.expectedToFail && err != nil {
t.Errorf("expected config preparation to succeed, but %s", err.Error())
}
})
Expand Down Expand Up @@ -318,11 +318,11 @@ func TestDeprecatedISOOptionsAreConverted(t *testing.T) {
t.Errorf("Expected device to be converted to index %s", index)
}

if c.expectedToFail == true && err == nil {
if c.expectedToFail && err == nil {
t.Error("expected config preparation to fail, but no error occured")
}

if c.expectedToFail == false && err != nil {
if !c.expectedToFail && err != nil {
t.Errorf("expected config preparation to succeed, but %s", err.Error())
}

Expand Down
228 changes: 228 additions & 0 deletions builder/proxmox/common/step_start_vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,28 @@ func TestGenerateProxmoxDisks(t *testing.T) {
},
},
},
{
"overallocate ide, should error",
[]diskConfig{
{
Type: "ide",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
},
[]ISOsConfig{},
[]string{
"ide0",
"ide1",
"ide2",
"ide3",
},
true,
&proxmox.QemuStorages{},
},
{
"overallocate sata, should error",
[]diskConfig{
Expand Down Expand Up @@ -756,6 +778,212 @@ func TestGenerateProxmoxDisks(t *testing.T) {
true,
&proxmox.QemuStorages{},
},
{
"overallocate scsi, should error",
[]diskConfig{
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "scsi",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
},
[]ISOsConfig{
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
{
Type: "scsi",
ISOFile: "local:iso/test.iso",
},
},
[]string{
"scsi0",
"scsi1",
"scsi2",
"scsi3",
"scsi4",
"scsi5",
"scsi6",
"scsi7",
"scsi8",
"scsi9",
"scsi10",
"scsi11",
},
true,
&proxmox.QemuStorages{},
},
{
"overallocate virtio, should error",
[]diskConfig{
{
Type: "virtio",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "virtio",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "virtio",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
{
Type: "virtio",
StoragePool: "local-lvm",
Size: "11G",
CacheMode: "none",
DiskFormat: "qcow2",
IOThread: true,
},
},
[]ISOsConfig{},
[]string{
"virtio0",
"virtio1",
"virtio2",
"virtio3",
"virtio4",
"virtio5",
"virtio6",
"virtio7",
"virtio8",
"virtio9",
"virtio10",
"virtio11",
"virtio12",
},
true,
&proxmox.QemuStorages{},
},
{
"bunch of disks, should be defined in the discovery order",
[]diskConfig{
Expand Down

0 comments on commit c0a6e24

Please sign in to comment.