Skip to content

Commit

Permalink
Merge pull request #1083 from kubevirt/revert-1076-tests-wait-for-pvcs
Browse files Browse the repository at this point in the history
Revert "tests: On cleanup, wait until PVCs are bound."
  • Loading branch information
kubevirt-bot authored Sep 20, 2024
2 parents e2dd4b9 + 687e194 commit 8835831
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 38 deletions.
1 change: 1 addition & 0 deletions tests/dataSources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ var _ = Describe("DataSources", func() {
Entry("[test_id:4773]view role", &viewRole),
Entry("[test_id:4842]view role binding", &viewRoleBinding),
Entry("[test_id:4771]edit cluster role", &editClusterRole),
Entry("[test_id:4770]golden image NS", &goldenImageNS),
)
})

Expand Down
40 changes: 2 additions & 38 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/kubernetes"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
Expand All @@ -44,7 +43,6 @@ import (

sspv1beta1 "kubevirt.io/ssp-operator/api/v1beta1"
sspv1beta2 "kubevirt.io/ssp-operator/api/v1beta2"
"kubevirt.io/ssp-operator/internal"
"kubevirt.io/ssp-operator/internal/common"
"kubevirt.io/ssp-operator/tests/env"
)
Expand Down Expand Up @@ -281,18 +279,9 @@ func (s *existingSspStrategy) Init() {
}

func (s *existingSspStrategy) Cleanup() {
if s.ssp == nil {
return
if s.ssp != nil {
s.RevertToOriginalSspCr()
}

s.RevertToOriginalSspCr()

// Waiting for DataImportCrons to import images.
//
// The tests in dataSources_test.go remove and recreate DataImportCrons, and
// they can cause the PVCs to be removed. To keep the cluster in healthy state after tests,
// we wait until PVCs are reimported.
s.waitForDataImportCrons()
}

func (s *existingSspStrategy) GetName() string {
Expand Down Expand Up @@ -368,31 +357,6 @@ func (s *existingSspStrategy) SkipIfUpgradeLane() {
skipIfUpgradeLane()
}

func (s *existingSspStrategy) waitForDataImportCrons() {
Eventually(func(g Gomega) {
for _, dataImportCronTemplate := range s.ssp.Spec.CommonTemplates.DataImportCronTemplates {
importCron := &cdiv1beta1.DataImportCron{}
importCronNamespacedName := types.NamespacedName{
Namespace: dataImportCronTemplate.Namespace,
Name: dataImportCronTemplate.Name,
}
if importCronNamespacedName.Namespace == "" {
importCronNamespacedName.Namespace = internal.GoldenImagesNamespace
}

g.Expect(apiClient.Get(ctx, importCronNamespacedName, importCron)).To(Succeed(),
fmt.Sprintf("Could not get DataImportCron: %s", importCronNamespacedName.String()))

g.Expect(importCron.Status.Conditions).To(ContainElement(Satisfy(
func(condition cdiv1beta1.DataImportCronCondition) bool {
return condition.Type == cdiv1beta1.DataImportCronUpToDate &&
condition.Status == v1.ConditionTrue
},
)), fmt.Sprintf("DataImportCron %s is not up to date", importCronNamespacedName.String()))
}
}, env.Timeout(), time.Second).Should(Succeed())
}

var (
apiClient client.Client
coreClient *kubernetes.Clientset
Expand Down

0 comments on commit 8835831

Please sign in to comment.