Skip to content

Commit 1d8cb54

Browse files
fmuleroBitnami Containers
and
Bitnami Containers
authoredAug 9, 2024··
[bitnami/redis] fix: Use rollout restart in ginkgo tests (#28813)
* [bitnami/redis] fix: Use rollout restart in ginkgo tests --------- Signed-off-by: Fran Mulero <fmulero@vmware.com> Signed-off-by: Bitnami Containers <bitnami-bot@vmware.com> Co-authored-by: Bitnami Containers <bitnami-bot@vmware.com>
1 parent 8eea194 commit 1d8cb54

File tree

4 files changed

+22
-12
lines changed

4 files changed

+22
-12
lines changed
 

‎.vib/redis/ginkgo/redis_suite_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ func TestRedis(t *testing.T) {
3838
}
3939

4040
func createJob(ctx context.Context, c kubernetes.Interface, name, port, image, stmt string) error {
41+
// Default job TTL in seconds
42+
ttl := int32(10)
4143
securityContext := &v1.SecurityContext{
4244
Privileged: &[]bool{false}[0],
4345
AllowPrivilegeEscalation: &[]bool{false}[0],
@@ -57,6 +59,7 @@ func createJob(ctx context.Context, c kubernetes.Interface, name, port, image, s
5759
Kind: "Job",
5860
},
5961
Spec: batchv1.JobSpec{
62+
TTLSecondsAfterFinished: &ttl,
6063
Template: v1.PodTemplateSpec{
6164
Spec: v1.PodSpec{
6265
RestartPolicy: "Never",

‎.vib/redis/ginkgo/redis_test.go

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
. "github.com/onsi/gomega"
1111
appsv1 "k8s.io/api/apps/v1"
1212
batchv1 "k8s.io/api/batch/v1"
13+
v1 "k8s.io/api/core/v1"
1314
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"k8s.io/client-go/kubernetes"
1516
)
@@ -36,6 +37,9 @@ var _ = Describe("Redis", Ordered, func() {
3637
getAvailableReplicas := func(ss *appsv1.StatefulSet) int32 { return ss.Status.AvailableReplicas }
3738
getSucceededJobs := func(j *batchv1.Job) int32 { return j.Status.Succeeded }
3839
getOpts := metav1.GetOptions{}
40+
restartKey := "kubectl.kubernetes.io/restartedAt"
41+
restartAnnotation := map[string]string{restartKey: time.Now().Format(time.RFC3339)}
42+
getRestartedAtAnnotation := func(pod *v1.Pod) string { return pod.Annotations[restartKey] }
3943

4044
By("checking all the replicas are available")
4145
ss, err := c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)
@@ -71,17 +75,16 @@ var _ = Describe("Redis", Ordered, func() {
7175
return c.BatchV1().Jobs(namespace).Get(ctx, createKEYJobName, getOpts)
7276
}, timeout, PollingInterval).Should(WithTransform(getSucceededJobs, Equal(int32(1))))
7377

74-
By("scaling down to 0 replicas")
75-
ss, err = utils.StsScale(ctx, c, ss, 0)
76-
Expect(err).NotTo(HaveOccurred())
78+
By("running rollout restart")
79+
// Annotate pods to force a rollout restart
80+
ss, err = utils.StsAnnotateTemplate(ctx, c, ss, restartAnnotation)
7781

78-
Eventually(func() (*appsv1.StatefulSet, error) {
79-
return c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)
80-
}, timeout, PollingInterval).Should(WithTransform(getAvailableReplicas, BeZero()))
81-
82-
By("scaling up to the original replicas")
83-
ss, err = utils.StsScale(ctx, c, ss, origReplicas)
84-
Expect(err).NotTo(HaveOccurred())
82+
// Wait for the new annotation in the existing pods
83+
for i := int(origReplicas) - 1; i >= 0; i-- {
84+
Eventually(func() (*v1.Pod, error) {
85+
return c.CoreV1().Pods(namespace).Get(ctx, fmt.Sprintf("%s-%d", stsName, i), getOpts)
86+
}, timeout, PollingInterval).Should(WithTransform(getRestartedAtAnnotation, Equal(restartAnnotation[restartKey])))
87+
}
8588

8689
Eventually(func() (*appsv1.StatefulSet, error) {
8790
return c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)

‎bitnami/redis/CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
# Changelog
22

3+
## 20.0.1 (2024-08-09)
4+
5+
* [bitnami/redis] fix: Use rollout restart in ginkgo tests ([#28813](https://github.com/bitnami/charts/pull/28813))
6+
37
## 20.0.0 (2024-08-09)
48

5-
* [bitnami/redis] Release 20.0.0 ([#28810](https://github.com/bitnami/charts/pull/28810))
9+
* [bitnami/redis] Release 20.0.0 (#28810) ([9e08d34](https://github.com/bitnami/charts/commit/9e08d34b938aebbe3ed955f4224b8e525313821d)), closes [#28810](https://github.com/bitnami/charts/issues/28810)
610

711
## <small>19.6.4 (2024-07-25)</small>
812

‎bitnami/redis/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ maintainers:
3636
name: redis
3737
sources:
3838
- https://github.com/bitnami/charts/tree/main/bitnami/redis
39-
version: 20.0.0
39+
version: 20.0.1

0 commit comments

Comments
 (0)
Please sign in to comment.