Skip to content

Commit 81ed98b

Browse files
committed
chore: test MinAvailable update for PodDisruptionBudgets
Signed-off-by: 久米 拓馬 <[email protected]>
1 parent a01fa08 commit 81ed98b

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

test/e2e/framework/redis_cluster_handlers.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,19 @@ func CreateRedisNodeServiceAccountFunc(kubeClient kclient.Client, redisCluster *
477477

478478
// IsPodDisruptionBudgetCreatedFunc returns the func that checks if the PodDisruptionBudget
479479
// associated with the RedisCluster has been created properly.
480-
func IsPodDisruptionBudgetCreatedFunc(kubeClient kclient.Client, redisCluster *rapi.RedisCluster) func() error {
480+
func IsPodDisruptionBudgetCreatedFunc(kubeClient kclient.Client, redisCluster *rapi.RedisCluster, minAvailable int32) func() error {
481481
return func() error {
482+
pdb := &policyv1.PodDisruptionBudget{}
482483
pdbName := types.NamespacedName{Namespace: redisCluster.Namespace, Name: redisCluster.Name}
483-
err := kubeClient.Get(context.Background(), pdbName, &policyv1.PodDisruptionBudget{})
484+
err := kubeClient.Get(context.Background(), pdbName, pdb)
484485
if err != nil {
485486
Logf("Cannot get PodDisruptionBudget associated to the redisCluster:%s/%s, err:%v", redisCluster.Namespace, redisCluster.Name, err)
486487
return err
487488
}
489+
490+
if minAvailable != pdb.Spec.MinAvailable.IntVal {
491+
return LogAndReturnErrorf("PodDisruptionBudget minAvailable mismatch: %v, but got: %v", minAvailable, pdb.Spec.MinAvailable.IntVal)
492+
}
488493
return nil
489494
}
490495
}

test/e2e/operator.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var _ = Describe("RedisCluster CRUD operations", func() {
4545

4646
Eventually(framework.CreateRedisClusterConfigMapFunc(kubeClient, cluster), "5s", "1s").ShouldNot(HaveOccurred())
4747

48-
Eventually(framework.IsPodDisruptionBudgetCreatedFunc(kubeClient, cluster), "5s", "1s").ShouldNot(HaveOccurred())
48+
Eventually(framework.IsPodDisruptionBudgetCreatedFunc(kubeClient, cluster, int32(5)), "5s", "1s").ShouldNot(HaveOccurred())
4949

5050
Eventually(framework.IsRedisClusterStartedFunc(kubeClient, cluster), "8m", "5s").ShouldNot(HaveOccurred())
5151

@@ -87,6 +87,8 @@ lazyfree-lazy-expire yes`,
8787

8888
Eventually(framework.IsRedisClusterStartedFunc(kubeClient, cluster), "5m", "5s").ShouldNot(HaveOccurred())
8989

90+
Eventually(framework.IsPodDisruptionBudgetCreatedFunc(kubeClient, cluster, int32(7)), "5s", "1s").ShouldNot(HaveOccurred())
91+
9092
Eventually(framework.ZonesBalancedFunc(kubeClient, cluster), "10s", "1s").ShouldNot(HaveOccurred())
9193
})
9294
Context("a RedisCluster is running", func() {

0 commit comments

Comments
 (0)