@@ -84,9 +84,9 @@ func TestCertifyScaling(t *testing.T) {
8484 g .Expect (err ).NotTo (HaveOccurred ())
8585}
8686
87- // Test the scenario where we create a Coherence cluster without a replicas field, which will default to three Pods.
87+ // Test the scenario where we create a Coherence cluster without a " replicas" field, which will default to three Pods.
8888// Then scale up the cluster to four.
89- // The apply an update using the same Coherence resource with no replicas field.
89+ // Then apply an update using the same Coherence resource with no replicas field.
9090// After the update is applied, the cluster should still be four and not revert to three.
9191func TestCertifyScalingWithUpdate (t * testing.T ) {
9292 // Ensure that everything is cleaned up after the test!
@@ -118,6 +118,40 @@ func TestCertifyScalingWithUpdate(t *testing.T) {
118118 g .Expect (err ).NotTo (HaveOccurred ())
119119}
120120
121+ // Test the scenario where we create a Coherence cluster with a "replicas" field.
122+ // Then scale up the cluster to four.
123+ // Then apply an update using the same Coherence resource with no replicas field.
124+ // After the update is applied, the cluster should still be four and not revert to three.
125+ func TestCertifyScalingClusterWithReplicasThenUpdate (t * testing.T ) {
126+ // Ensure that everything is cleaned up after the test!
127+ testContext .CleanupAfterTest (t )
128+ g := NewGomegaWithT (t )
129+
130+ ns := helper .GetTestClusterNamespace ()
131+
132+ // the name of the cluster from scale-with-update-one.yaml and scale-with-update-two.yaml
133+ name := "certify-scale-update"
134+
135+ // Start with the two replicas
136+ err := apply (t , ns , "scale-with-update-with-replicas.yaml" )
137+ g .Expect (err ).NotTo (HaveOccurred ())
138+ _ , err = helper .WaitForPodsWithLabel (testContext , ns , "one=testOne" , 2 , time .Second * 10 , time .Minute * 10 )
139+ g .Expect (err ).NotTo (HaveOccurred ())
140+
141+ // Scale Up to four
142+ err = scale (t , ns , name , 4 )
143+ g .Expect (err ).NotTo (HaveOccurred ())
144+ _ , err = helper .WaitForStatefulSet (testContext , ns , name , 4 , time .Second * 10 , time .Minute * 5 )
145+ g .Expect (err ).NotTo (HaveOccurred ())
146+
147+ // apply the update
148+ err = apply (t , ns , "scale-with-update-two.yaml" )
149+ g .Expect (err ).NotTo (HaveOccurred ())
150+ // There should eventually be four Pods with the additional label
151+ _ , err = helper .WaitForPodsWithLabel (testContext , ns , "two=testTwo" , 4 , time .Second * 10 , time .Minute * 10 )
152+ g .Expect (err ).NotTo (HaveOccurred ())
153+ }
154+
121155func scale (t * testing.T , namespace , name string , replicas int32 ) error {
122156 cmd := exec .Command ("kubectl" , "-n" , namespace , "scale" , fmt .Sprintf ("--replicas=%d" , replicas ), "coherence/" + name )
123157 cmd .Stdout = os .Stdout
0 commit comments