Skip to content

Commit

Permalink
[bitnami/cassandra] Improve Ginkgo test (#28603)
Browse files Browse the repository at this point in the history
Signed-off-by: David Gomez <dgomezleon@vmware.com>
  • Loading branch information
dgomezleon authored Jul 31, 2024
1 parent 77d52b1 commit bcf704a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
25 changes: 16 additions & 9 deletions .vib/cassandra/ginkgo/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
. "github.com/onsi/gomega"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
)
Expand All @@ -35,6 +36,7 @@ var _ = Describe("Cassandra", Ordered, func() {
By("checking all the replicas are available")
getAvailableReplicas := func(ss *appsv1.StatefulSet) int32 { return ss.Status.AvailableReplicas }
getSucceededJobs := func(j *batchv1.Job) int32 { return j.Status.Succeeded }
getRestartedAtAnnotation := func(pod *v1.Pod) string { return pod.Annotations["kubectl.kubernetes.io/restartedAt"] }
getOpts := metav1.GetOptions{}

ss, err := c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)
Expand Down Expand Up @@ -71,19 +73,20 @@ var _ = Describe("Cassandra", Ordered, func() {
return c.BatchV1().Jobs(namespace).Get(ctx, createDBJobName, getOpts)
}, timeout, PollingInterval).Should(WithTransform(getSucceededJobs, Equal(int32(1))))

By("scaling down to 0 replicas")

ss, err = utils.StsScale(ctx, c, ss, 0)
By("deleting the job once it has succeeded")
err = c.BatchV1().Jobs(namespace).Delete(ctx, createDBJobName, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())

Eventually(func() (*appsv1.StatefulSet, error) {
return c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)
}, timeout, PollingInterval).Should(WithTransform(getAvailableReplicas, BeZero()))

By("scaling up to the original replicas")
ss, err = utils.StsScale(ctx, c, ss, origReplicas)
By("rollout restart the statefulset")
_, err = utils.StsRolloutRestart(ctx, c, ss)
Expect(err).NotTo(HaveOccurred())

for i := 0; i < int(origReplicas); i++ {
Eventually(func() (*v1.Pod, error) {
return c.CoreV1().Pods(namespace).Get(ctx, fmt.Sprintf("%s-%d", stsName, i), getOpts)
}, timeout, PollingInterval).Should(WithTransform(getRestartedAtAnnotation, Not(BeEmpty())))
}

Eventually(func() (*appsv1.StatefulSet, error) {
return c.AppsV1().StatefulSets(namespace).Get(ctx, stsName, getOpts)
}, timeout, PollingInterval).Should(WithTransform(getAvailableReplicas, Equal(origReplicas)))
Expand All @@ -97,6 +100,10 @@ var _ = Describe("Cassandra", Ordered, func() {
Eventually(func() (*batchv1.Job, error) {
return c.BatchV1().Jobs(namespace).Get(ctx, deleteDBJobName, getOpts)
}, timeout, PollingInterval).Should(WithTransform(getSucceededJobs, Equal(int32(1))))

By("deleting the job once it has succeeded")
err = c.BatchV1().Jobs(namespace).Delete(ctx, deleteDBJobName, metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
})
})

Expand Down
8 changes: 6 additions & 2 deletions bitnami/cassandra/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 11.3.11 (2024-07-25)
## 11.3.12 (2024-07-31)

* [bitnami/cassandra] Release 11.3.11 ([#28408](https://github.com/bitnami/charts/pull/28408))
* [bitnami/cassandra] Improve Ginkgo test ([#28603](https://github.com/bitnami/charts/pull/28603))

## <small>11.3.11 (2024-07-25)</small>

* [bitnami/cassandra] Release 11.3.11 (#28408) ([8a65384](https://github.com/bitnami/charts/commit/8a6538440b1ca408369ec814831f6239fe47fa3b)), closes [#28408](https://github.com/bitnami/charts/issues/28408)

## <small>11.3.10 (2024-07-24)</small>

Expand Down
2 changes: 1 addition & 1 deletion bitnami/cassandra/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ maintainers:
name: cassandra
sources:
- https://github.com/bitnami/charts/tree/main/bitnami/cassandra
version: 11.3.11
version: 11.3.12

0 comments on commit bcf704a

Please sign in to comment.