@@ -18,6 +18,7 @@ import (
18
18
"k8s.io/apimachinery/pkg/util/intstr"
19
19
20
20
. "github.com/onsi/ginkgo"
21
+ . "github.com/onsi/ginkgo/extensions/table"
21
22
. "github.com/onsi/gomega"
22
23
rabbitmqv1beta1 "github.com/rabbitmq/cluster-operator/api/v1beta1"
23
24
"github.com/rabbitmq/cluster-operator/internal/resource"
@@ -1639,86 +1640,75 @@ var _ = Describe("RabbitmqClusterController", func() {
1639
1640
1640
1641
})
1641
1642
1642
- Context ("Server configurations updates" , func () {
1643
- AfterEach (func () {
1644
- Expect (client .Delete (ctx , cluster )).To (Succeed ())
1645
- waitForClusterDeletion (ctx , cluster , client )
1646
- })
1643
+ DescribeTable ("Server configurations updates" ,
1644
+ func (testCase string ) {
1645
+ // create rabbitmqcluster
1646
+ cluster = & rabbitmqv1beta1.RabbitmqCluster {
1647
+ ObjectMeta : metav1.ObjectMeta {
1648
+ Name : "rabbitmq-" + testCase ,
1649
+ Namespace : defaultNamespace ,
1650
+ },
1651
+ Spec : rabbitmqv1beta1.RabbitmqClusterSpec {
1652
+ Replicas : & one ,
1653
+ },
1654
+ }
1655
+ Expect (client .Create (ctx , cluster )).To (Succeed ())
1656
+ waitForClusterCreation (ctx , cluster , client )
1647
1657
1648
- assertRabbitmqServerUpdates := func (testCase string ) {
1649
- It ("updates the rabbitmq server" , func () {
1650
- // create rabbitmqcluster
1651
- cluster = & rabbitmqv1beta1.RabbitmqCluster {
1652
- ObjectMeta : metav1.ObjectMeta {
1653
- Name : "rabbitmq-" + testCase ,
1654
- Namespace : defaultNamespace ,
1655
- },
1656
- Spec : rabbitmqv1beta1.RabbitmqClusterSpec {
1657
- Replicas : & one ,
1658
- },
1658
+ // ensure that configMap and statefulSet does not have annotations set when configurations haven't changed
1659
+ configMap , err := clientSet .CoreV1 ().ConfigMaps (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server-conf" ), metav1.GetOptions {})
1660
+ Expect (err ).To (Not (HaveOccurred ()))
1661
+ Expect (configMap .Annotations ).ShouldNot (HaveKey ("rabbitmq.com/serverConfUpdatedAt" ))
1662
+
1663
+ sts , err := clientSet .AppsV1 ().StatefulSets (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server" ), metav1.GetOptions {})
1664
+ Expect (err ).To (Not (HaveOccurred ()))
1665
+ Expect (sts .Annotations ).ShouldNot (HaveKey ("rabbitmq.com/lastRestartAt" ))
1666
+
1667
+ // update rabbitmq server configurations
1668
+ Expect (updateWithRetry (cluster , func (r * rabbitmqv1beta1.RabbitmqCluster ) {
1669
+ if testCase == "additional-config" {
1670
+ r .Spec .Rabbitmq .AdditionalConfig = "test_config=0"
1659
1671
}
1660
- Expect (client .Create (ctx , cluster )).To (Succeed ())
1661
- waitForClusterCreation (ctx , cluster , client )
1672
+ if testCase == "advanced-config" {
1673
+ r .Spec .Rabbitmq .AdvancedConfig = "sample-advanced-config."
1674
+ }
1675
+ if testCase == "env-config" {
1676
+ r .Spec .Rabbitmq .EnvConfig = "some-env-variable"
1677
+ }
1678
+ })).To (Succeed ())
1662
1679
1663
- // ensure that configMap and statefulSet does not have annotations set when configurations haven't changed
1680
+ By ("annotating the server-conf ConfigMap" )
1681
+ // ensure annotations from the server-conf ConfigMap
1682
+ var annotations map [string ]string
1683
+ Eventually (func () map [string ]string {
1664
1684
configMap , err := clientSet .CoreV1 ().ConfigMaps (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server-conf" ), metav1.GetOptions {})
1665
1685
Expect (err ).To (Not (HaveOccurred ()))
1666
- Expect (configMap .Annotations ).ShouldNot (HaveKey ("rabbitmq.com/serverConfUpdatedAt" ))
1667
-
1686
+ annotations = configMap .Annotations
1687
+ return annotations
1688
+ }, 5 ).Should (HaveKey ("rabbitmq.com/serverConfUpdatedAt" ))
1689
+ _ , err = time .Parse (time .RFC3339 , annotations ["rabbitmq.com/serverConfUpdatedAt" ])
1690
+ Expect (err ).NotTo (HaveOccurred (), "Annotation rabbitmq.com/serverConfUpdatedAt was not a valid RFC3339 timestamp" )
1691
+
1692
+ By ("annotating the sts podTemplate" )
1693
+ // ensure statefulSet annotations
1694
+ Eventually (func () map [string ]string {
1668
1695
sts , err := clientSet .AppsV1 ().StatefulSets (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server" ), metav1.GetOptions {})
1669
1696
Expect (err ).To (Not (HaveOccurred ()))
1670
- Expect (sts .Annotations ).ShouldNot (HaveKey ("rabbitmq.com/lastRestartAt" ))
1697
+ annotations = sts .Spec .Template .Annotations
1698
+ return annotations
1699
+ }, 5 ).Should (HaveKey ("rabbitmq.com/lastRestartAt" ))
1700
+ _ , err = time .Parse (time .RFC3339 , annotations ["rabbitmq.com/lastRestartAt" ])
1701
+ Expect (err ).NotTo (HaveOccurred (), "Annotation rabbitmq.com/lastRestartAt was not a valid RFC3339 timestamp" )
1671
1702
1672
- // update rabbitmq server configurations
1673
- Expect (updateWithRetry (cluster , func (r * rabbitmqv1beta1.RabbitmqCluster ) {
1674
- if testCase == "additional-config" {
1675
- r .Spec .Rabbitmq .AdditionalConfig = "test_config=0"
1676
- }
1677
- if testCase == "advanced-config" {
1678
- r .Spec .Rabbitmq .AdvancedConfig = "sample-advanced-config."
1679
- }
1680
- if testCase == "env-config" {
1681
- r .Spec .Rabbitmq .EnvConfig = "some-env-variable"
1682
- }
1683
- })).To (Succeed ())
1684
-
1685
- By ("annotating the server-conf ConfigMap" )
1686
- // ensure annotations from the server-conf ConfigMap
1687
- var annotations map [string ]string
1688
- Eventually (func () map [string ]string {
1689
- configMap , err := clientSet .CoreV1 ().ConfigMaps (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server-conf" ), metav1.GetOptions {})
1690
- Expect (err ).To (Not (HaveOccurred ()))
1691
- annotations = configMap .Annotations
1692
- return annotations
1693
- }, 5 ).Should (HaveKey ("rabbitmq.com/serverConfUpdatedAt" ))
1694
- _ , err = time .Parse (time .RFC3339 , annotations ["rabbitmq.com/serverConfUpdatedAt" ])
1695
- Expect (err ).NotTo (HaveOccurred (), "Annotation rabbitmq.com/serverConfUpdatedAt was not a valid RFC3339 timestamp" )
1696
-
1697
- By ("annotating the sts podTemplate" )
1698
- // ensure statefulSet annotations
1699
- Eventually (func () map [string ]string {
1700
- sts , err := clientSet .AppsV1 ().StatefulSets (cluster .Namespace ).Get (ctx , cluster .ChildResourceName ("server" ), metav1.GetOptions {})
1701
- Expect (err ).To (Not (HaveOccurred ()))
1702
- annotations = sts .Spec .Template .Annotations
1703
- return annotations
1704
- }, 5 ).Should (HaveKey ("rabbitmq.com/lastRestartAt" ))
1705
- _ , err = time .Parse (time .RFC3339 , annotations ["rabbitmq.com/lastRestartAt" ])
1706
- Expect (err ).NotTo (HaveOccurred (), "Annotation rabbitmq.com/lastRestartAt was not a valid RFC3339 timestamp" )
1707
- })
1708
- }
1709
-
1710
- When ("spec.rabbitmq.additionalConfig is updated" , func () {
1711
- assertRabbitmqServerUpdates ("additional-config" )
1712
- })
1713
-
1714
- When ("spec.rabbitmq.advancedConfig is updated" , func () {
1715
- assertRabbitmqServerUpdates ("advanced-config" )
1716
- })
1703
+ // delete rmq cluster
1704
+ Expect (client .Delete (ctx , cluster )).To (Succeed ())
1705
+ waitForClusterDeletion (ctx , cluster , client )
1706
+ },
1717
1707
1718
- When ("spec.rabbitmq.envConfig is updated" , func () {
1719
- assertRabbitmqServerUpdates ( "env -config" )
1720
- })
1721
- } )
1708
+ Entry ("spec.rabbitmq.additionalConfig is updated" , "additional-config" ),
1709
+ Entry ( "spec.rabbitmq.advancedConfig is updated" , "advanced -config" ),
1710
+ Entry ( "spec.rabbitmq.envConfig is updated" , "env-config" ),
1711
+ )
1722
1712
})
1723
1713
1724
1714
func extractContainer (containers []corev1.Container , containerName string ) corev1.Container {
0 commit comments