Skip to content

Commit 857facf

Browse files
authored
test: experimental: various E2E improvements (#276)
1 parent 0ba0e7f commit 857facf

31 files changed

+418
-247
lines changed

apis/cluster/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/placement/v1beta1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/memberagent/main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ var (
9393
enablePprof = flag.Bool("enable-pprof", false, "enable pprof profiling")
9494
pprofPort = flag.Int("pprof-port", 6065, "port for pprof profiling")
9595
hubPprofPort = flag.Int("hub-pprof-port", 6066, "port for hub pprof profiling")
96+
hubQPS = flag.Float64("hub-api-qps", 50, "QPS to use while talking with fleet-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
97+
hubBurst = flag.Int("hub-api-burst", 500, "Burst to use while talking with fleet-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
98+
memberQPS = flag.Float64("member-api-qps", 250, "QPS to use while talking with fleet-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
99+
memberBurst = flag.Int("member-api-burst", 1000, "Burst to use while talking with fleet-apiserver. Doesn't cover events and node heartbeat apis which rate limiting is controlled by a different set of flags.")
100+
96101
// Work applier requeue rate limiter settings.
97102
workApplierRequeueRateLimiterAttemptsWithFixedDelay = flag.Int("work-applier-requeue-rate-limiter-attempts-with-fixed-delay", 1, "If set, the work applier will requeue work objects with a fixed delay for the specified number of attempts before switching to exponential backoff.")
98103
workApplierRequeueRateLimiterFixedDelaySeconds = flag.Float64("work-applier-requeue-rate-limiter-fixed-delay-seconds", 5.0, "If set, the work applier will requeue work objects with this fixed delay in seconds for the specified number of attempts before switching to exponential backoff.")
@@ -150,6 +155,8 @@ func main() {
150155
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
151156
}
152157
hubConfig, err := buildHubConfig(hubURL, *useCertificateAuth, *tlsClientInsecure)
158+
hubConfig.QPS = float32(*hubQPS)
159+
hubConfig.Burst = *hubBurst
153160
if err != nil {
154161
klog.ErrorS(err, "Failed to build Kubernetes client configuration for the hub cluster")
155162
klog.FlushAndExit(klog.ExitFlushTimeout, 1)
@@ -164,6 +171,8 @@ func main() {
164171
mcNamespace := fmt.Sprintf(utils.NamespaceNameFormat, mcName)
165172

166173
memberConfig := ctrl.GetConfigOrDie()
174+
memberConfig.QPS = float32(*memberQPS)
175+
memberConfig.Burst = *memberBurst
167176
// we place the leader election lease on the member cluster to avoid adding load to the hub
168177
hubOpts := ctrl.Options{
169178
Scheme: scheme,

test/apis/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/kindconfigs/cluster-1.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,3 @@ apiVersion: kind.x-k8s.io/v1alpha4
77
nodes:
88
- role: control-plane
99
- role: worker
10-
- role: worker
11-
- role: worker

test/e2e/kindconfigs/cluster-2.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,3 @@ nodes:
88
- role: control-plane
99
- role: worker
1010
- role: worker
11-
- role: worker

test/e2e/mixed_placement_test.go

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,15 +277,12 @@ var _ = Describe("mixed ClusterResourcePlacement and ResourcePlacement negative
277277
Eventually(rpStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update RP %s status as expected", rpName)
278278

279279
By("creating a CRP that uses PickAll strategy")
280+
// Note that this CRP will take over namespaces.
280281
createCRP(crpName)
281282
})
282283

283284
AfterAll(func() {
284285
ensureRPAndRelatedResourcesDeleted(types.NamespacedName{Name: rpName, Namespace: workNamespaceName}, allMemberClusters)
285-
By("CRP should take over the work resources")
286-
// ConfigMap on the hub was deleted in the previous step.
287-
crpStatusUpdatedActual := crpStatusUpdatedActual(workNamespaceIdentifiers(), allMemberClusterNames, nil, "1")
288-
Eventually(crpStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update CRP status as expected")
289286
ensureCRPAndRelatedResourcesDeleted(crpName, allMemberClusters)
290287
})
291288

@@ -345,5 +342,34 @@ var _ = Describe("mixed ClusterResourcePlacement and ResourcePlacement negative
345342
}
346343
Eventually(crpStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update RP %s status as expected", rpName)
347344
})
345+
346+
// The CRP must give up on the configMap first, otherwise it might attempt re-create the configMap
347+
// during the cleanup process.
348+
It("can update the CRP to give up on the configMap", func() {
349+
Eventually(func() error {
350+
crp := &placementv1beta1.ClusterResourcePlacement{}
351+
if err := hubClient.Get(ctx, types.NamespacedName{Name: crpName}, crp); err != nil {
352+
return fmt.Errorf("failed to get the CRP %s: %w", crpName, err)
353+
}
354+
355+
crp.Spec.ResourceSelectors = namespaceOnlySelector()
356+
if err := hubClient.Update(ctx, crp); err != nil {
357+
return fmt.Errorf("failed to update the CRP %s: %w", crpName, err)
358+
}
359+
return nil
360+
}, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update the CRP %s to give up on the configMap", crpName)
361+
})
362+
363+
It("should update CRP status as expected", func() {
364+
nsOnlyResIds := []placementv1beta1.ResourceIdentifier{
365+
{
366+
Kind: "Namespace",
367+
Name: workNamespaceName,
368+
Version: "v1",
369+
},
370+
}
371+
crpStatusUpdatedActual := crpStatusUpdatedActual(nsOnlyResIds, allMemberClusterNames, nil, "1")
372+
Eventually(crpStatusUpdatedActual, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to update CRP status as expected")
373+
})
348374
})
349375
})

test/e2e/placement_apply_strategy_test.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
. "github.com/onsi/ginkgo/v2"
2626
. "github.com/onsi/gomega"
2727
corev1 "k8s.io/api/core/v1"
28+
"k8s.io/apimachinery/pkg/api/errors"
2829
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2930
"k8s.io/apimachinery/pkg/types"
3031
"k8s.io/apimachinery/pkg/util/intstr"
@@ -601,9 +602,30 @@ var _ = Describe("validating CRP when resources exists", Ordered, func() {
601602
})
602603

603604
AfterAll(func() {
604-
ensureCRPAndRelatedResourcesDeleted(crpName, allMemberClusters)
605+
// Must delete the conflicting CRP first, otherwise it might re-create the resources when we check
606+
// if the original CRP has been fully deleted.
607+
//
608+
// And here the test suite will not use the shared common deletion logic as it will attempt to verify
609+
// resources that are not managed by the conflicting CRP.
610+
Eventually(func() error {
611+
conflictedCRP := &placementv1beta1.ClusterResourcePlacement{
612+
ObjectMeta: metav1.ObjectMeta{
613+
Name: conflictedCRPName,
614+
},
615+
}
616+
617+
if err := hubClient.Delete(ctx, conflictedCRP); err != nil && !errors.IsNotFound(err) {
618+
return fmt.Errorf("failed to delete CRP %s: %w", conflictedCRPName, err)
619+
}
605620

606-
ensureCRPAndRelatedResourcesDeleted(conflictedCRPName, allMemberClusters)
621+
// Wait until the CRP is fully deleted.
622+
if err := hubClient.Get(ctx, types.NamespacedName{Name: conflictedCRPName}, conflictedCRP); !errors.IsNotFound(err) {
623+
return fmt.Errorf("CRP %s is still present or an unexpected error has occurred: %w", conflictedCRPName, err)
624+
}
625+
return nil
626+
}, eventuallyDuration, eventuallyInterval).Should(Succeed(), "Failed to delete CRP %s", conflictedCRPName)
627+
628+
ensureCRPAndRelatedResourcesDeleted(crpName, allMemberClusters)
607629
})
608630
})
609631
})

0 commit comments

Comments
 (0)