@@ -68,6 +68,22 @@ func TestDeclarativeValidateForDeclarative(t *testing.T) {
68
68
field .Invalid (field .NewPath ("spec.replicas" ), nil , "" ).WithOrigin ("minimum" ),
69
69
},
70
70
},
71
+ // spec.minReadySeconds
72
+ "0 minReadySeconds" : {
73
+ input : mkValidReplicationController (setSpecMinReadySeconds (0 )),
74
+ },
75
+ "1 minReadySeconds" : {
76
+ input : mkValidReplicationController (setSpecMinReadySeconds (1 )),
77
+ },
78
+ "positive minReadySeconds" : {
79
+ input : mkValidReplicationController (setSpecMinReadySeconds (100 )),
80
+ },
81
+ "negative minReadySeconds" : {
82
+ input : mkValidReplicationController (setSpecMinReadySeconds (- 1 )),
83
+ expectedErrs : field.ErrorList {
84
+ field .Invalid (field .NewPath ("spec.minReadySeconds" ), nil , "" ).WithOrigin ("minimum" ),
85
+ },
86
+ },
71
87
}
72
88
for k , tc := range testCases {
73
89
t .Run (k , func (t * testing.T ) {
@@ -148,6 +164,26 @@ func TestValidateUpdateForDeclarative(t *testing.T) {
148
164
field .Invalid (field .NewPath ("spec.replicas" ), nil , "" ).WithOrigin ("minimum" ),
149
165
},
150
166
},
167
+ // spec.minReadySeconds
168
+ "0 minReadySeconds" : {
169
+ old : mkValidReplicationController (),
170
+ update : mkValidReplicationController (setSpecMinReadySeconds (0 )),
171
+ },
172
+ "1 minReadySeconds" : {
173
+ old : mkValidReplicationController (),
174
+ update : mkValidReplicationController (setSpecMinReadySeconds (1 )),
175
+ },
176
+ "positive minReadySeconds" : {
177
+ old : mkValidReplicationController (),
178
+ update : mkValidReplicationController (setSpecMinReadySeconds (3 )),
179
+ },
180
+ "negative minReadySeconds" : {
181
+ old : mkValidReplicationController (),
182
+ update : mkValidReplicationController (setSpecMinReadySeconds (- 1 )),
183
+ expectedErrs : field.ErrorList {
184
+ field .Invalid (field .NewPath ("spec.minReadySeconds" ), nil , "" ).WithOrigin ("minimum" ),
185
+ },
186
+ },
151
187
}
152
188
for k , tc := range testCases {
153
189
t .Run (k , func (t * testing.T ) {
@@ -227,3 +263,9 @@ func setSpecReplicas(val int32) func(rc *api.ReplicationController) {
227
263
rc .Spec .Replicas = ptr .To (val )
228
264
}
229
265
}
266
+
267
+ func setSpecMinReadySeconds (val int32 ) func (rc * api.ReplicationController ) {
268
+ return func (rc * api.ReplicationController ) {
269
+ rc .Spec .MinReadySeconds = val
270
+ }
271
+ }
0 commit comments