Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve stability of test and reducing Duration of Integration Tests Run #245

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions provider/server/exec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
12 changes: 5 additions & 7 deletions provider/server/machine_annotations_update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
},
},
})
Expand Down
153 changes: 60 additions & 93 deletions provider/server/machine_create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,35 @@ 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,
},
},
})
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()),
Expand All @@ -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 {
Expand Down Expand Up @@ -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{
{
Expand All @@ -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{
Expand All @@ -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 {
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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 {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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 {
Expand Down
36 changes: 3 additions & 33 deletions provider/server/machine_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
},
})
Expand Down Expand Up @@ -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,
},
},
})
Expand Down
16 changes: 4 additions & 12 deletions provider/server/machine_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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,
},
},
})
Expand Down
Loading
Loading