Skip to content
Merged
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
16 changes: 16 additions & 0 deletions test/e2e/framework/federatedresourcequota.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"

policyv1alpha1 "github.com/karmada-io/karmada/pkg/apis/policy/v1alpha1"
karmada "github.com/karmada-io/karmada/pkg/generated/clientset/versioned"
Expand Down Expand Up @@ -89,3 +90,18 @@ func WaitFederatedResourceQuotaCollectStatus(client karmada.Interface, namespace
}, PollTimeout, PollInterval).Should(gomega.Equal(true))
})
}

// WaitFederatedResourceQuotaFitWith wait FederatedResourceQuota fit condition.
func WaitFederatedResourceQuotaFitWith(client karmada.Interface, namespace, name string, fit func(frq *policyv1alpha1.FederatedResourceQuota) bool) {
ginkgo.By(fmt.Sprintf("Waiting for FederatedResourceQuota %s/%s to fit condition", namespace, name), func() {
gomega.Eventually(func() bool {
frq, err := client.PolicyV1alpha1().FederatedResourceQuotas(namespace).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
klog.Errorf("Failed to get FederatedResourceQuota(%s/%s), err: %v", namespace, name, err)
return false
}

return fit(frq)
}, PollTimeout, PollInterval).Should(gomega.Equal(true))
})
}
5 changes: 5 additions & 0 deletions test/e2e/suites/base/federatedresourcequota_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ var _ = ginkgo.Describe("FederatedResourceQuota enforcement testing", func() {
}
federatedResourceQuota = helper.NewFederatedResourceQuotaWithOverall(frqNamespace, frqName, overall)
framework.CreateFederatedResourceQuota(karmadaClient, federatedResourceQuota)
framework.WaitFederatedResourceQuotaFitWith(karmadaClient, frqNamespace, frqName, func(frq *policyv1alpha1.FederatedResourceQuota) bool {
// To avoid race condition, ensure that OverallUsed is not nil first, and then deployment can be created.
// MoreInfo can refer to https://github.com/karmada-io/karmada/pull/6876#issuecomment-3455446833.
return frq.Status.Overall != nil
})
ginkgo.DeferCleanup(func() {
framework.RemoveFederatedResourceQuota(karmadaClient, frqNamespace, frqName)
})
Expand Down