Skip to content

Commit c0a6e24

Browse files
mpywelllbajolet-hashicorp
authored andcommitted
test all buses for overallocation, cleanup test bool conditions
1 parent 3f7a153 commit c0a6e24

File tree

2 files changed

+232
-4
lines changed

2 files changed

+232
-4
lines changed

builder/proxmox/common/config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ func TestISOs(t *testing.T) {
236236
var config Config
237237
_, _, err := config.Prepare(&config, cfg)
238238

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

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

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

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

builder/proxmox/common/step_start_vm_test.go

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,28 @@ func TestGenerateProxmoxDisks(t *testing.T) {
700700
},
701701
},
702702
},
703+
{
704+
"overallocate ide, should error",
705+
[]diskConfig{
706+
{
707+
Type: "ide",
708+
StoragePool: "local-lvm",
709+
Size: "11G",
710+
CacheMode: "none",
711+
DiskFormat: "qcow2",
712+
IOThread: true,
713+
},
714+
},
715+
[]ISOsConfig{},
716+
[]string{
717+
"ide0",
718+
"ide1",
719+
"ide2",
720+
"ide3",
721+
},
722+
true,
723+
&proxmox.QemuStorages{},
724+
},
703725
{
704726
"overallocate sata, should error",
705727
[]diskConfig{
@@ -756,6 +778,212 @@ func TestGenerateProxmoxDisks(t *testing.T) {
756778
true,
757779
&proxmox.QemuStorages{},
758780
},
781+
{
782+
"overallocate scsi, should error",
783+
[]diskConfig{
784+
{
785+
Type: "scsi",
786+
StoragePool: "local-lvm",
787+
Size: "11G",
788+
CacheMode: "none",
789+
DiskFormat: "qcow2",
790+
IOThread: true,
791+
},
792+
{
793+
Type: "scsi",
794+
StoragePool: "local-lvm",
795+
Size: "11G",
796+
CacheMode: "none",
797+
DiskFormat: "qcow2",
798+
IOThread: true,
799+
},
800+
{
801+
Type: "scsi",
802+
StoragePool: "local-lvm",
803+
Size: "11G",
804+
CacheMode: "none",
805+
DiskFormat: "qcow2",
806+
IOThread: true,
807+
},
808+
{
809+
Type: "scsi",
810+
StoragePool: "local-lvm",
811+
Size: "11G",
812+
CacheMode: "none",
813+
DiskFormat: "qcow2",
814+
IOThread: true,
815+
},
816+
{
817+
Type: "scsi",
818+
StoragePool: "local-lvm",
819+
Size: "11G",
820+
CacheMode: "none",
821+
DiskFormat: "qcow2",
822+
IOThread: true,
823+
},
824+
{
825+
Type: "scsi",
826+
StoragePool: "local-lvm",
827+
Size: "11G",
828+
CacheMode: "none",
829+
DiskFormat: "qcow2",
830+
IOThread: true,
831+
},
832+
{
833+
Type: "scsi",
834+
StoragePool: "local-lvm",
835+
Size: "11G",
836+
CacheMode: "none",
837+
DiskFormat: "qcow2",
838+
IOThread: true,
839+
},
840+
{
841+
Type: "scsi",
842+
StoragePool: "local-lvm",
843+
Size: "11G",
844+
CacheMode: "none",
845+
DiskFormat: "qcow2",
846+
IOThread: true,
847+
},
848+
{
849+
Type: "scsi",
850+
StoragePool: "local-lvm",
851+
Size: "11G",
852+
CacheMode: "none",
853+
DiskFormat: "qcow2",
854+
IOThread: true,
855+
},
856+
{
857+
Type: "scsi",
858+
StoragePool: "local-lvm",
859+
Size: "11G",
860+
CacheMode: "none",
861+
DiskFormat: "qcow2",
862+
IOThread: true,
863+
},
864+
{
865+
Type: "scsi",
866+
StoragePool: "local-lvm",
867+
Size: "11G",
868+
CacheMode: "none",
869+
DiskFormat: "qcow2",
870+
IOThread: true,
871+
},
872+
{
873+
Type: "scsi",
874+
StoragePool: "local-lvm",
875+
Size: "11G",
876+
CacheMode: "none",
877+
DiskFormat: "qcow2",
878+
IOThread: true,
879+
},
880+
},
881+
[]ISOsConfig{
882+
{
883+
Type: "scsi",
884+
ISOFile: "local:iso/test.iso",
885+
},
886+
{
887+
Type: "scsi",
888+
ISOFile: "local:iso/test.iso",
889+
},
890+
{
891+
Type: "scsi",
892+
ISOFile: "local:iso/test.iso",
893+
},
894+
{
895+
Type: "scsi",
896+
ISOFile: "local:iso/test.iso",
897+
},
898+
{
899+
Type: "scsi",
900+
ISOFile: "local:iso/test.iso",
901+
},
902+
{
903+
Type: "scsi",
904+
ISOFile: "local:iso/test.iso",
905+
},
906+
{
907+
Type: "scsi",
908+
ISOFile: "local:iso/test.iso",
909+
},
910+
{
911+
Type: "scsi",
912+
ISOFile: "local:iso/test.iso",
913+
},
914+
},
915+
[]string{
916+
"scsi0",
917+
"scsi1",
918+
"scsi2",
919+
"scsi3",
920+
"scsi4",
921+
"scsi5",
922+
"scsi6",
923+
"scsi7",
924+
"scsi8",
925+
"scsi9",
926+
"scsi10",
927+
"scsi11",
928+
},
929+
true,
930+
&proxmox.QemuStorages{},
931+
},
932+
{
933+
"overallocate virtio, should error",
934+
[]diskConfig{
935+
{
936+
Type: "virtio",
937+
StoragePool: "local-lvm",
938+
Size: "11G",
939+
CacheMode: "none",
940+
DiskFormat: "qcow2",
941+
IOThread: true,
942+
},
943+
{
944+
Type: "virtio",
945+
StoragePool: "local-lvm",
946+
Size: "11G",
947+
CacheMode: "none",
948+
DiskFormat: "qcow2",
949+
IOThread: true,
950+
},
951+
{
952+
Type: "virtio",
953+
StoragePool: "local-lvm",
954+
Size: "11G",
955+
CacheMode: "none",
956+
DiskFormat: "qcow2",
957+
IOThread: true,
958+
},
959+
{
960+
Type: "virtio",
961+
StoragePool: "local-lvm",
962+
Size: "11G",
963+
CacheMode: "none",
964+
DiskFormat: "qcow2",
965+
IOThread: true,
966+
},
967+
},
968+
[]ISOsConfig{},
969+
[]string{
970+
"virtio0",
971+
"virtio1",
972+
"virtio2",
973+
"virtio3",
974+
"virtio4",
975+
"virtio5",
976+
"virtio6",
977+
"virtio7",
978+
"virtio8",
979+
"virtio9",
980+
"virtio10",
981+
"virtio11",
982+
"virtio12",
983+
},
984+
true,
985+
&proxmox.QemuStorages{},
986+
},
759987
{
760988
"bunch of disks, should be defined in the discovery order",
761989
[]diskConfig{

0 commit comments

Comments
 (0)