Skip to content

Commit

Permalink
Merge pull request #418 from 0xFelix/fix-tests-garbage-collection
Browse files Browse the repository at this point in the history
Fix tests waiting for DVs to succeed
  • Loading branch information
kubevirt-bot committed Oct 5, 2022
2 parents 1771876 + 7f710e3 commit 05aa846
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
6 changes: 4 additions & 2 deletions tests/dataSources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ var _ = Describe("DataSources", func() {
pullMethod = cdiv1beta1.RegistryPullNode
commonAnnotations = map[string]string{
"cdi.kubevirt.io/storage.bind.immediate.requested": "true",
// Remove this annotation once CDI handles DataImportCron and garbage collection properly
"cdi.kubevirt.io/storage.deleteAfterCompletion": "false",
}

cronTemplate ssp.DataImportCronTemplate
Expand Down Expand Up @@ -857,7 +859,7 @@ var _ = Describe("DataSources", func() {
logObject(dataImportCron.GetKey(), &cdiv1beta1.DataImportCron{})
})

It("[test_id:8112] should restore DataSource if DataImportCron removed from SSP CR", func() {
PIt("[QUARANTINE][test_id:8112] should restore DataSource if DataImportCron removed from SSP CR", func() {
// Wait until DataImportCron imports PVC and changes data source
Eventually(func() bool {
cron := &cdiv1beta1.DataImportCron{}
Expand Down Expand Up @@ -1114,7 +1116,7 @@ var _ = Describe("DataSources", func() {
}, timeout, time.Second).Should(Equal(metav1.StatusReasonNotFound), "DataImportCron should not exist.")
})

It("[test_id:8298] should restore DataSource, when CDI label is removed", func() {
PIt("[QUARANTINE][test_id:8298] should restore DataSource, when CDI label is removed", func() {
// Wait until DataImportCron imports PVC and changes data source
Eventually(func() (bool, error) {
cron := &cdiv1beta1.DataImportCron{}
Expand Down
15 changes: 12 additions & 3 deletions tests/misc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/onsi/ginkgo/extensions/table"
apps "k8s.io/api/apps/v1"
core "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
Expand Down Expand Up @@ -241,6 +242,7 @@ var _ = Describe("RHEL VM creation", func() {
})

table.DescribeTable("should be able to start VM", func(imageUrl string) {
const annPodPhase = "cdi.kubevirt.io/storage.pod.phase"
const diskName = "disk0"
const sshPort = 22

Expand Down Expand Up @@ -331,12 +333,19 @@ var _ = Describe("RHEL VM creation", func() {

// Wait for DataVolume to finish importing
dvName := vm.Spec.DataVolumeTemplates[0].Name
Eventually(func(g Gomega) cdiv1beta1.DataVolumePhase {
Eventually(func(g Gomega) {
foundDv := &cdiv1beta1.DataVolume{}
err := apiClient.Get(ctx, client.ObjectKey{Name: dvName, Namespace: vm.Namespace}, foundDv)
if err != nil {
g.Expect(errors.IsNotFound(err)).To(BeTrue())
} else {
g.Expect(foundDv.Status.Phase).To(Equal(cdiv1beta1.Succeeded))
}
foundPvc := &core.PersistentVolumeClaim{}
err = apiClient.Get(ctx, client.ObjectKey{Name: dvName, Namespace: vm.Namespace}, foundPvc)
g.Expect(err).ToNot(HaveOccurred())
return foundDv.Status.Phase
}, 2*timeout, time.Second).Should(Equal(cdiv1beta1.Succeeded))
g.Expect(foundPvc.Annotations[annPodPhase]).To(Equal(string(core.PodSucceeded)))
}, 2*timeout, time.Second).Should(Succeed())

// Wait for VMI to be ready
Eventually(func(g Gomega) bool {
Expand Down

0 comments on commit 05aa846

Please sign in to comment.