@@ -1831,7 +1831,7 @@ var _ = SIGDescribe("CollaSet", func() {
18311831 }, 30 * time .Second , 3 * time .Second ).Should (BeTrue ())
18321832 })
18331833
1834- framework .ConformanceIt ("scaleIn new pod" , func () {
1834+ framework .ConformanceIt ("scaleIn origin and new pod" , func () {
18351835 cls := tester .NewCollaSet ("collaset-" + randStr , 1 , appsv1alpha1.UpdateStrategy {})
18361836 // use bad image to mock new replace pod unavailable
18371837 cls .Spec .Template .Spec .Containers [0 ].Image = "nginx:non-exist"
@@ -1848,7 +1848,64 @@ var _ = SIGDescribe("CollaSet", func() {
18481848 pod .Labels [appsv1alpha1 .PodReplaceIndicationLabelKey ] = "true"
18491849 })).NotTo (HaveOccurred ())
18501850
1851- By ("Wait for replace new pod created" )
1851+ By ("Wait for new pod created by OperationJob" )
1852+ Eventually (func () error { return tester .ExpectedStatusReplicas (cls , 2 , 0 , 0 , 2 , 2 ) }, 30 * time .Second , 3 * time .Second ).ShouldNot (HaveOccurred ())
1853+
1854+ By ("scaleIn the specified new pod" )
1855+ pods , err = tester .ListPodsForCollaSet (cls )
1856+ Expect (err ).NotTo (HaveOccurred ())
1857+ var newPod * v1.Pod
1858+ for _ , pod := range pods {
1859+ if pod .Name != podToReplace .Name {
1860+ newPod = pod
1861+ break
1862+ }
1863+ }
1864+ Expect (tester .UpdateCollaSet (cls , func (cls * appsv1alpha1.CollaSet ) {
1865+ cls .Spec .Replicas = int32Pointer (0 )
1866+ cls .Spec .ScaleStrategy = appsv1alpha1.ScaleStrategy {
1867+ PodToDelete : []string {newPod .Name , podToReplace .Name },
1868+ }
1869+ })).NotTo (HaveOccurred ())
1870+
1871+ By ("Wait for CollaSet reconciled" )
1872+ Eventually (func () bool {
1873+ if err := tester .GetCollaSet (cls ); err != nil {
1874+ return false
1875+ }
1876+ return cls .Generation == cls .Status .ObservedGeneration
1877+ }, 10 * time .Second , 3 * time .Second ).Should (Equal (true ))
1878+
1879+ By ("Wait for pods deleted" )
1880+ Eventually (func () error { return tester .ExpectedStatusReplicas (cls , 0 , 0 , 0 , 0 , 0 ) }, 30 * time .Second , 3 * time .Second ).ShouldNot (HaveOccurred ())
1881+
1882+ By ("Check resourceContext" )
1883+ var currResourceContexts []* appsv1alpha1.ResourceContext
1884+ Eventually (func () bool {
1885+ currResourceContexts , err = tester .ListResourceContextsForCollaSet (cls )
1886+ Expect (err ).Should (BeNil ())
1887+ return len (currResourceContexts ) == 0
1888+ }, 30 * time .Second , 3 * time .Second ).Should (BeTrue ())
1889+ })
1890+
1891+ framework .ConformanceIt ("scaleIn new pod only" , func () {
1892+ cls := tester .NewCollaSet ("collaset-" + randStr , 1 , appsv1alpha1.UpdateStrategy {})
1893+ // use bad image to mock new replace pod unavailable
1894+ cls .Spec .Template .Spec .Containers [0 ].Image = "nginx:non-exist"
1895+ Expect (tester .CreateCollaSet (cls )).NotTo (HaveOccurred ())
1896+
1897+ By ("Wait for status replicas satisfied" )
1898+ Eventually (func () error { return tester .ExpectedStatusReplicas (cls , 1 , 0 , 0 , 1 , 1 ) }, 30 * time .Second , 3 * time .Second ).ShouldNot (HaveOccurred ())
1899+
1900+ By ("Replace pod by label" )
1901+ pods , err := tester .ListPodsForCollaSet (cls )
1902+ Expect (err ).NotTo (HaveOccurred ())
1903+ podToReplace := pods [0 ]
1904+ Expect (tester .UpdatePod (podToReplace , func (pod * v1.Pod ) {
1905+ pod .Labels [appsv1alpha1 .PodReplaceIndicationLabelKey ] = "true"
1906+ })).NotTo (HaveOccurred ())
1907+
1908+ By ("Wait for new pod created by OperationJob" )
18521909 Eventually (func () error { return tester .ExpectedStatusReplicas (cls , 2 , 0 , 0 , 2 , 2 ) }, 30 * time .Second , 3 * time .Second ).ShouldNot (HaveOccurred ())
18531910
18541911 By ("Selective scaleIn new pod" )
0 commit comments