Skip to content

Commit

Permalink
chore: test MinAvailable update for PodDisruptionBudgets
Browse files Browse the repository at this point in the history
Signed-off-by: 久米 拓馬 <takuma.kume@pepabo.com>
  • Loading branch information
takumakume committed Apr 5, 2023
1 parent ef93f50 commit 32031a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions test/e2e/framework/redis_cluster_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,14 +477,19 @@ func CreateRedisNodeServiceAccountFunc(kubeClient kclient.Client, redisCluster *

// IsPodDisruptionBudgetCreatedFunc returns the func that checks if the PodDisruptionBudget
// associated with the RedisCluster has been created properly.
func IsPodDisruptionBudgetCreatedFunc(kubeClient kclient.Client, redisCluster *rapi.RedisCluster) func() error {
func IsPodDisruptionBudgetCreatedFunc(kubeClient kclient.Client, redisCluster *rapi.RedisCluster, minAvailable int32) func() error {
return func() error {
pdb := &policyv1.PodDisruptionBudget{}
pdbName := types.NamespacedName{Namespace: redisCluster.Namespace, Name: redisCluster.Name}
err := kubeClient.Get(context.Background(), pdbName, &policyv1.PodDisruptionBudget{})
err := kubeClient.Get(context.Background(), pdbName, pdb)
if err != nil {
Logf("Cannot get PodDisruptionBudget associated to the redisCluster:%s/%s, err:%v", redisCluster.Namespace, redisCluster.Name, err)
return err
}

if minAvailable != pdb.Spec.MinAvailable.IntVal {
return LogAndReturnErrorf("PodDisruptionBudget minAvailable mismatch: %v, but got: %v", minAvailable, pdb.Spec.MinAvailable.IntVal)
}
return nil
}
}
4 changes: 3 additions & 1 deletion test/e2e/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ var _ = Describe("RedisCluster CRUD operations", func() {

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

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

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

Expand Down Expand Up @@ -87,6 +87,8 @@ lazyfree-lazy-expire yes`,

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

Eventually(framework.IsPodDisruptionBudgetCreatedFunc(kubeClient, cluster, int32(7)), "5s", "1s").ShouldNot(HaveOccurred())

Eventually(framework.ZonesBalancedFunc(kubeClient, cluster), "10s", "1s").ShouldNot(HaveOccurred())
})
Context("a RedisCluster is running", func() {
Expand Down

0 comments on commit 32031a7

Please sign in to comment.