diff --git a/provider/server/exec_test.go b/provider/server/exec_test.go index d5f1163f..53099dc6 100644 --- a/provider/server/exec_test.go +++ b/provider/server/exec_test.go @@ -22,8 +22,7 @@ import ( "k8s.io/kubectl/pkg/util/term" ) -var _ = Describe("Exec", func() { - +var _ = Describe("Exec", Ordered, func() { It("should verify an exec-url with a token", func(ctx SpecContext) { By("creating the test machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ diff --git a/provider/server/machine_annotations_update_test.go b/provider/server/machine_annotations_update_test.go index f3e8681d..4b926d8d 100644 --- a/provider/server/machine_annotations_update_test.go +++ b/provider/server/machine_annotations_update_test.go @@ -12,9 +12,8 @@ import ( . "github.com/onsi/gomega" ) -var _ = Describe("UpdateMachineAnnotations", func() { +var _ = Describe("UpdateMachineAnnotations", Ordered, func() { It("should update machine annotations", func(ctx SpecContext) { - ignitionData := []byte("urjhikmnbdjfkknhhdddeee") By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ @@ -24,11 +23,10 @@ var _ = Describe("UpdateMachineAnnotations", func() { }, }, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, - Class: machineClassx3xlarge, - IgnitionData: ignitionData, - Volumes: nil, - NetworkInterfaces: nil, + Image: &iri.ImageSpec{ + Image: squashfsOSImage, + }, + Class: machineClassx3xlarge, }, }, }) diff --git a/provider/server/machine_create_test.go b/provider/server/machine_create_test.go index af9701ba..1d1c0443 100644 --- a/provider/server/machine_create_test.go +++ b/provider/server/machine_create_test.go @@ -14,22 +14,13 @@ import ( . "github.com/onsi/gomega" ) -const ( - osImage = "ghcr.io/ironcore-dev/ironcore-image/gardenlinux:rootfs-dev-20231206-v1" -) - -var _ = Describe("CreateMachine", func() { +var _ = Describe("CreateMachine", Ordered, func() { It("should create a machine without boot image, volume and network interface", func(ctx SpecContext) { By("creating a machine without boot image, volume and network interface") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "machinepoolletv1alpha1.MachineUIDLabel": "foobar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx3xlarge, }, }, @@ -37,10 +28,21 @@ var _ = Describe("CreateMachine", func() { Expect(err).NotTo(HaveOccurred()) Expect(createResp).NotTo(BeNil()) + DeferCleanup(func(ctx SpecContext) { + Eventually(func(g Gomega) bool { + _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) + g.Expect(err).To(SatisfyAny( + BeNil(), + MatchError(ContainSubstring("NotFound")), + )) + _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) + return libvirt.IsNotFound(err) + }).Should(BeTrue()) + }) + By("ensuring the correct creation response") Expect(createResp).Should(SatisfyAll( HaveField("Machine.Metadata.Id", Not(BeEmpty())), - HaveField("Machine.Spec.Power", iri.Power_POWER_ON), HaveField("Machine.Spec.Image", BeNil()), HaveField("Machine.Spec.Class", machineClassx3xlarge), HaveField("Machine.Spec.IgnitionData", BeNil()), @@ -53,18 +55,6 @@ var _ = Describe("CreateMachine", func() { HaveField("Machine.Status.NetworkInterfaces", BeNil()), )) - DeferCleanup(func(ctx SpecContext) { - Eventually(func(g Gomega) bool { - _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) - g.Expect(err).To(SatisfyAny( - BeNil(), - MatchError(ContainSubstring("NotFound")), - )) - _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) - return libvirt.IsNotFound(err) - }).Should(BeTrue()) - }) - By("ensuring domain and domain XML is created for machine") var domain libvirt.Domain Eventually(func() error { @@ -106,13 +96,8 @@ var _ = Describe("CreateMachine", func() { By("creating a machine without boot image") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "machinepoolletv1alpha1.MachineUIDLabel": "foobar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx3xlarge, Volumes: []*iri.Volume{ { @@ -134,13 +119,23 @@ var _ = Describe("CreateMachine", func() { Expect(err).NotTo(HaveOccurred()) Expect(createResp).NotTo(BeNil()) + DeferCleanup(func(ctx SpecContext) { + Eventually(func(g Gomega) bool { + _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) + g.Expect(err).To(SatisfyAny( + BeNil(), + MatchError(ContainSubstring("NotFound")), + )) + _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) + return libvirt.IsNotFound(err) + }).Should(BeTrue()) + }) + By("ensuring the correct creation response") Expect(createResp).Should(SatisfyAll( HaveField("Machine.Metadata.Id", Not(BeEmpty())), - HaveField("Machine.Spec.Power", iri.Power_POWER_ON), HaveField("Machine.Spec.Image", BeNil()), HaveField("Machine.Spec.Class", machineClassx3xlarge), - HaveField("Machine.Spec.IgnitionData", BeNil()), HaveField("Machine.Spec.Volumes", ContainElement(&iri.Volume{ Name: "disk-1", EmptyDisk: &iri.EmptyDisk{ @@ -158,18 +153,6 @@ var _ = Describe("CreateMachine", func() { HaveField("Machine.Status.NetworkInterfaces", BeNil()), )) - DeferCleanup(func(ctx SpecContext) { - Eventually(func(g Gomega) bool { - _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) - g.Expect(err).To(SatisfyAny( - BeNil(), - MatchError(ContainSubstring("NotFound")), - )) - _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) - return libvirt.IsNotFound(err) - }).Should(BeTrue()) - }) - By("ensuring domain and domain XML is created for machine") var domain libvirt.Domain Eventually(func() error { @@ -214,23 +197,16 @@ var _ = Describe("CreateMachine", func() { )) }) - ignitionData := []byte("urjhikmnbdjfkknhhdddeee") It("should create a machine with boot image and single empty disk", func(ctx SpecContext) { By("creating a machine with boot image and single empty disk") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "machinepoolletv1alpha1.MachineUIDLabel": "foobar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Image: &iri.ImageSpec{ - Image: osImage, + Image: squashfsOSImage, }, - Class: machineClassx3xlarge, - IgnitionData: ignitionData, + Class: machineClassx3xlarge, Volumes: []*iri.Volume{ { Name: "disk-1", @@ -251,13 +227,24 @@ var _ = Describe("CreateMachine", func() { Expect(err).NotTo(HaveOccurred()) Expect(createResp).NotTo(BeNil()) + DeferCleanup(func(ctx SpecContext) { + Eventually(func(g Gomega) bool { + _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) + g.Expect(err).To(SatisfyAny( + BeNil(), + MatchError(ContainSubstring("NotFound")), + )) + _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) + return libvirt.IsNotFound(err) + }).Should(BeTrue()) + }) + By("ensuring the correct creation response") Expect(createResp).Should(SatisfyAll( HaveField("Machine.Metadata.Id", Not(BeEmpty())), - HaveField("Machine.Spec.Power", iri.Power_POWER_ON), - HaveField("Machine.Spec.Image.Image", Equal(osImage)), + HaveField("Machine.Spec.Image.Image", Equal(squashfsOSImage)), HaveField("Machine.Spec.Class", machineClassx3xlarge), - HaveField("Machine.Spec.IgnitionData", Equal(ignitionData)), + HaveField("Machine.Spec.IgnitionData", BeNil()), HaveField("Machine.Spec.Volumes", ContainElement(&iri.Volume{ Name: "disk-1", Device: "oda", @@ -275,18 +262,6 @@ var _ = Describe("CreateMachine", func() { HaveField("Machine.Status.NetworkInterfaces", BeNil()), )) - DeferCleanup(func(ctx SpecContext) { - Eventually(func(g Gomega) bool { - _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) - g.Expect(err).To(SatisfyAny( - BeNil(), - MatchError(ContainSubstring("NotFound")), - )) - _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) - return libvirt.IsNotFound(err) - }).Should(BeTrue()) - }) - By("ensuring domain and domain XML is created for machine") var domain libvirt.Domain Eventually(func() error { @@ -335,18 +310,12 @@ var _ = Describe("CreateMachine", func() { By("creating a machine with boot image and multiple empty disks") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "machinepoolletv1alpha1.MachineUIDLabel": "foobar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Image: &iri.ImageSpec{ - Image: osImage, + Image: squashfsOSImage, }, - Class: machineClassx3xlarge, - IgnitionData: ignitionData, + Class: machineClassx3xlarge, Volumes: []*iri.Volume{ { Name: "disk-1", @@ -374,13 +343,23 @@ var _ = Describe("CreateMachine", func() { Expect(err).NotTo(HaveOccurred()) Expect(createResp).NotTo(BeNil()) + DeferCleanup(func(ctx SpecContext) { + Eventually(func(g Gomega) bool { + _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) + g.Expect(err).To(SatisfyAny( + BeNil(), + MatchError(ContainSubstring("NotFound")), + )) + _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) + return libvirt.IsNotFound(err) + }).Should(BeTrue()) + }) + By("ensuring the correct creation response") Expect(createResp).Should(SatisfyAll( HaveField("Machine.Metadata.Id", Not(BeEmpty())), - HaveField("Machine.Spec.Power", iri.Power_POWER_ON), - HaveField("Machine.Spec.Image.Image", Equal(osImage)), + HaveField("Machine.Spec.Image.Image", Equal(squashfsOSImage)), HaveField("Machine.Spec.Class", machineClassx3xlarge), - HaveField("Machine.Spec.IgnitionData", Equal(ignitionData)), HaveField("Machine.Spec.Volumes", ContainElements( &iri.Volume{ Name: "disk-1", @@ -406,18 +385,6 @@ var _ = Describe("CreateMachine", func() { HaveField("Machine.Status.NetworkInterfaces", BeNil()), )) - DeferCleanup(func(ctx SpecContext) { - Eventually(func(g Gomega) bool { - _, err := machineClient.DeleteMachine(ctx, &iri.DeleteMachineRequest{MachineId: createResp.Machine.Metadata.Id}) - g.Expect(err).To(SatisfyAny( - BeNil(), - MatchError(ContainSubstring("NotFound")), - )) - _, err = libvirtConn.DomainLookupByUUID(libvirtutils.UUIDStringToBytes(createResp.Machine.Metadata.Id)) - return libvirt.IsNotFound(err) - }).Should(BeTrue()) - }) - By("ensuring domain and domain XML is created for machine") var domain libvirt.Domain Eventually(func() error { diff --git a/provider/server/machine_delete_test.go b/provider/server/machine_delete_test.go index 398913f1..bf3e7764 100644 --- a/provider/server/machine_delete_test.go +++ b/provider/server/machine_delete_test.go @@ -15,32 +15,17 @@ import ( . "github.com/onsi/gomega" ) -var _ = Describe("DeleteMachine", func() { - +var _ = Describe("DeleteMachine", Ordered, func() { It("should delete a machine with graceful shutdown", func(ctx SpecContext) { By("creating a machine using squashfs os image") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Image: &iri.ImageSpec{ Image: squashfsOSImage, }, Class: machineClassx3xlarge, - Volumes: []*iri.Volume{ - { - Name: "disk-1", - EmptyDisk: &iri.EmptyDisk{ - SizeBytes: emptyDiskSize, - }, - Device: "oda", - }, - }, }, }, }) @@ -123,24 +108,9 @@ var _ = Describe("DeleteMachine", func() { By("creating a machine which may not boot properly") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx3xlarge, - Volumes: []*iri.Volume{ - { - Name: "disk-1", - EmptyDisk: &iri.EmptyDisk{ - SizeBytes: emptyDiskSize, - }, - Device: "oda", - }, - }, - NetworkInterfaces: nil, }, }, }) diff --git a/provider/server/machine_list_test.go b/provider/server/machine_list_test.go index e2375c8d..8e210b14 100644 --- a/provider/server/machine_list_test.go +++ b/provider/server/machine_list_test.go @@ -12,7 +12,7 @@ import ( . "github.com/onsi/gomega" ) -var _ = Describe("ListMachine", func() { +var _ = Describe("ListMachine", Ordered, func() { It("should list machines", func(ctx SpecContext) { By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ @@ -23,18 +23,10 @@ var _ = Describe("ListMachine", func() { }, }, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, - Class: machineClassx3xlarge, - Volumes: []*iri.Volume{ - { - Name: "disk-1", - EmptyDisk: &iri.EmptyDisk{ - SizeBytes: 5368709120, - }, - Device: "oda", - }, + Image: &iri.ImageSpec{ + Image: squashfsOSImage, }, - NetworkInterfaces: nil, + Class: machineClassx3xlarge, }, }, }) diff --git a/provider/server/machine_networkinterface_attach_test.go b/provider/server/machine_networkinterface_attach_test.go index 078fc61e..5008baa6 100644 --- a/provider/server/machine_networkinterface_attach_test.go +++ b/provider/server/machine_networkinterface_attach_test.go @@ -17,21 +17,16 @@ import ( "libvirt.org/go/libvirtxml" ) -var _ = Describe("AttachNetworkInterface", func() { +var _ = Describe("AttachNetworkInterface", Ordered, func() { It("should attach a network interface to the machine", func(ctx SpecContext) { By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx2medium, Image: &iri.ImageSpec{ - Image: osImage, + Image: squashfsOSImage, }, }, }, diff --git a/provider/server/machine_networkinterface_detach_test.go b/provider/server/machine_networkinterface_detach_test.go index 32515213..f8b04a65 100644 --- a/provider/server/machine_networkinterface_detach_test.go +++ b/provider/server/machine_networkinterface_detach_test.go @@ -17,38 +17,23 @@ import ( "libvirt.org/go/libvirtxml" ) -var _ = Describe("DetachNetworkInterface", func() { +var _ = Describe("DetachNetworkInterface", Ordered, func() { It("should detach a network interface from the machine", func(ctx SpecContext) { By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx2medium, Image: &iri.ImageSpec{ - Image: osImage, + Image: squashfsOSImage, }, NetworkInterfaces: []*iri.NetworkInterface{ { - Name: "nic-1", - NetworkId: "nid-1", - Ips: []string{"192.168.1.1"}, - Attributes: map[string]string{ - "key1": "value1", - }, + Name: "nic-1", }, { - Name: "nic-2", - NetworkId: "nid-2", - Ips: []string{"192.168.1.2"}, - Attributes: map[string]string{ - "key2": "value2", - }, + Name: "nic-2", }, }, }, diff --git a/provider/server/machine_powerstate_update_test.go b/provider/server/machine_powerstate_update_test.go index 5fa4f581..c0da7bb6 100644 --- a/provider/server/machine_powerstate_update_test.go +++ b/provider/server/machine_powerstate_update_test.go @@ -13,23 +13,18 @@ import ( ) // TODO: This test will require update after implementation of: https://github.com/ironcore-dev/libvirt-provider/issues/106 -var _ = Describe("UpdateMachinePower", func() { +var _ = Describe("UpdateMachinePower", Ordered, func() { It("should update machine power state", func(ctx SpecContext) { - ignitionData := []byte("urjhikmnbdjfkknhhdddeee") By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "machinepoolletv1alpha1.MachineUIDLabel": "foobar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, - Class: machineClassx3xlarge, - IgnitionData: ignitionData, - Volumes: nil, - NetworkInterfaces: nil, + Image: &iri.ImageSpec{ + Image: squashfsOSImage, + }, + Power: iri.Power_POWER_ON, + Class: machineClassx3xlarge, }, }, }) diff --git a/provider/server/machine_volume_attach_test.go b/provider/server/machine_volume_attach_test.go index 4c317a04..338c778c 100644 --- a/provider/server/machine_volume_attach_test.go +++ b/provider/server/machine_volume_attach_test.go @@ -15,18 +15,13 @@ import ( "libvirt.org/go/libvirtxml" ) -var _ = Describe("AttachVolume", func() { +var _ = Describe("AttachVolume", Ordered, func() { It("should correctly attach volume to machine", func(ctx SpecContext) { By("creating a machine") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Class: machineClassx3xlarge, }, }, diff --git a/provider/server/machine_volume_detach_test.go b/provider/server/machine_volume_detach_test.go index 23b1ec21..33cef42b 100644 --- a/provider/server/machine_volume_detach_test.go +++ b/provider/server/machine_volume_detach_test.go @@ -15,20 +15,15 @@ import ( "libvirt.org/go/libvirtxml" ) -var _ = Describe("DetachVolume", func() { +var _ = Describe("DetachVolume", Ordered, func() { It("should correctly detach volume from machine", func(ctx SpecContext) { By("creating a machine with two empty disks and single ceph volume") createResp, err := machineClient.CreateMachine(ctx, &iri.CreateMachineRequest{ Machine: &iri.Machine{ - Metadata: &irimeta.ObjectMetadata{ - Labels: map[string]string{ - "foo": "bar", - }, - }, + Metadata: &irimeta.ObjectMetadata{}, Spec: &iri.MachineSpec{ - Power: iri.Power_POWER_ON, Image: &iri.ImageSpec{ - Image: osImage, + Image: squashfsOSImage, }, Class: machineClassx3xlarge, Volumes: []*iri.Volume{ diff --git a/provider/server/server_suite_test.go b/provider/server/server_suite_test.go index 7de9db21..c4526ec6 100644 --- a/provider/server/server_suite_test.go +++ b/provider/server/server_suite_test.go @@ -31,7 +31,7 @@ import ( const ( eventuallyTimeout = 80 * time.Second pollingInterval = 50 * time.Millisecond - gracefulShutdownTimeout = 60 * time.Second + gracefulShutdownTimeout = 30 * time.Second resyncGarbageCollectorInterval = 5 * time.Second resyncVolumeSizeInterval = 1 * time.Minute consistentlyDuration = 1 * time.Second @@ -154,6 +154,11 @@ var _ = BeforeSuite(func() { DeferCleanup(libvirtConn.ConnectClose) }) +var _ = AfterSuite(func() { + err := os.RemoveAll(tempDir) + Expect(err).ToNot(HaveOccurred(), "Error cleanup test folder") +}) + func isSocketAvailable(socketPath string) error { fileInfo, err := os.Stat(socketPath) if err != nil { diff --git a/provider/server/status_test.go b/provider/server/status_test.go index 5298cdd3..d373b6b4 100644 --- a/provider/server/status_test.go +++ b/provider/server/status_test.go @@ -11,7 +11,7 @@ import ( . "github.com/onsi/gomega" ) -var _ = Describe("Status", func() { +var _ = Describe("Status", Ordered, func() { It("should get list of supported machine class with calculated quantity in status", func(ctx SpecContext) { By("getting machine class status") statusResp, err := machineClient.Status(ctx, &iriv1alpha1.StatusRequest{})