Skip to content

Commit

Permalink
[bitnami/postgresql] test: ✅ Improve reliability of ginkgo tests (#29472
Browse files Browse the repository at this point in the history
)

* [bitnami/postgresql] test: ✅ Improve reliability of ginkgo tests

Signed-off-by: Javier J. Salmerón García <[email protected]>

* Update CHANGELOG.md

Signed-off-by: Bitnami Containers <[email protected]>

---------

Signed-off-by: Javier J. Salmerón García <[email protected]>
Signed-off-by: Bitnami Containers <[email protected]>
Co-authored-by: Bitnami Containers <[email protected]>
  • Loading branch information
javsalgar and bitnami-bot authored Sep 17, 2024
1 parent 4bccd45 commit c43177e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
18 changes: 9 additions & 9 deletions .vib/postgresql/ginkgo/postgresql_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 @@ -34,6 +35,7 @@ var _ = Describe("Postgresql", Ordered, func() {
It("should have access to the created database", func() {

getAvailableReplicas := func(ss *appsv1.StatefulSet) int32 { return ss.Status.AvailableReplicas }
getRestartedAtAnnotation := func(pod *v1.Pod) string { return pod.Annotations["kubectl.kubernetes.io/restartedAt"] }
getSucceededJobs := func(j *batchv1.Job) int32 { return j.Status.Succeeded }
getOpts := metav1.GetOptions{}

Expand Down Expand Up @@ -71,17 +73,15 @@ var _ = Describe("Postgresql", 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("rollout restart the statefulset")
_, err = utils.StsRolloutRestart(ctx, c, ss)
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)
Expect(err).NotTo(HaveOccurred())
for i := int(origReplicas) - 1; i >= 0; 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)
Expand Down
8 changes: 6 additions & 2 deletions bitnami/postgresql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 15.5.31 (2024-09-13)
## 15.5.32 (2024-09-17)

* [bitnami/postgresql] Release 15.5.31 ([#29404](https://github.com/bitnami/charts/pull/29404))
* [bitnami/postgresql] test: :white_check_mark: Improve reliability of ginkgo tests ([#29472](https://github.com/bitnami/charts/pull/29472))

## <small>15.5.31 (2024-09-13)</small>

* [bitnami/postgresql] Release 15.5.31 (#29404) ([baf9a0f](https://github.com/bitnami/charts/commit/baf9a0facb2d1a659bf53d13c4088929bbf86400)), closes [#29404](https://github.com/bitnami/charts/issues/29404)

## <small>15.5.30 (2024-09-13)</small>

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

0 comments on commit c43177e

Please sign in to comment.