@@ -133,18 +133,43 @@ var _ = Describe("restart Command", func() {
133
133
fakeActor .GetUnstagedNewestPackageGUIDReturns ("package-guid" , v7action.Warnings {}, nil )
134
134
})
135
135
136
- It ("stages the new package and starts the app with the new droplet" , func () {
137
- Expect (executeErr ).ToNot (HaveOccurred ())
138
- Expect (fakeAppStager .StageAndStartCallCount ()).To (Equal (1 ))
136
+ When ("no strategy is provided" , func () {
137
+ It ("stages the new package and starts the app with the new droplet" , func () {
138
+ Expect (executeErr ).ToNot (HaveOccurred ())
139
+ Expect (fakeAppStager .StageAndStartCallCount ()).To (Equal (1 ))
140
+
141
+ inputApp , inputSpace , inputOrg , inputPkgGUID , opts := fakeAppStager .StageAndStartArgsForCall (0 )
142
+ Expect (inputApp ).To (Equal (app ))
143
+ Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
144
+ Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
145
+ Expect (inputPkgGUID ).To (Equal ("package-guid" ))
146
+ Expect (opts .Strategy ).To (Equal (strategy ))
147
+ Expect (opts .NoWait ).To (Equal (noWait ))
148
+ Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
149
+ Expect (opts .CanarySteps ).To (HaveLen (0 ))
150
+ })
151
+ })
139
152
140
- inputApp , inputSpace , inputOrg , inputPkgGUID , opts := fakeAppStager .StageAndStartArgsForCall (0 )
141
- Expect (inputApp ).To (Equal (app ))
142
- Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
143
- Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
144
- Expect (inputPkgGUID ).To (Equal ("package-guid" ))
145
- Expect (opts .Strategy ).To (Equal (strategy ))
146
- Expect (opts .NoWait ).To (Equal (noWait ))
147
- Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
153
+ When ("canary strategy is provided" , func () {
154
+ BeforeEach (func () {
155
+ cmd .Strategy = flag.DeploymentStrategy {Name : constant .DeploymentStrategyCanary }
156
+ cmd .InstanceSteps = "1,2,4"
157
+ })
158
+
159
+ It ("starts the app with the current droplet" , func () {
160
+ Expect (executeErr ).ToNot (HaveOccurred ())
161
+ Expect (fakeAppStager .StageAndStartCallCount ()).To (Equal (1 ))
162
+
163
+ inputApp , inputSpace , inputOrg , inputPkgGUID , opts := fakeAppStager .StageAndStartArgsForCall (0 )
164
+ Expect (inputApp ).To (Equal (app ))
165
+ Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
166
+ Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
167
+ Expect (inputPkgGUID ).To (Equal ("package-guid" ))
168
+ Expect (opts .Strategy ).To (Equal (constant .DeploymentStrategyCanary ))
169
+ Expect (opts .NoWait ).To (Equal (noWait ))
170
+ Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
171
+ Expect (opts .CanarySteps ).To (Equal ([]resources.CanaryStep {{InstanceWeight : 1 }, {InstanceWeight : 2 }, {InstanceWeight : 4 }}))
172
+ })
148
173
})
149
174
150
175
Context ("staging and starting the app returns an error" , func () {
@@ -163,18 +188,43 @@ var _ = Describe("restart Command", func() {
163
188
fakeActor .GetUnstagedNewestPackageGUIDReturns ("" , v7action.Warnings {}, nil )
164
189
})
165
190
166
- It ("starts the app with the current droplet" , func () {
167
- Expect (executeErr ).ToNot (HaveOccurred ())
168
- Expect (fakeAppStager .StartAppCallCount ()).To (Equal (1 ))
191
+ When ("no strategy is provided" , func () {
192
+ It ("starts the app with the current droplet" , func () {
193
+ Expect (executeErr ).ToNot (HaveOccurred ())
194
+ Expect (fakeAppStager .StartAppCallCount ()).To (Equal (1 ))
195
+
196
+ inputApp , inputSpace , inputOrg , inputDropletGuid , opts := fakeAppStager .StartAppArgsForCall (0 )
197
+ Expect (inputApp ).To (Equal (app ))
198
+ Expect (inputDropletGuid ).To (Equal ("" ))
199
+ Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
200
+ Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
201
+ Expect (opts .Strategy ).To (Equal (strategy ))
202
+ Expect (opts .NoWait ).To (Equal (noWait ))
203
+ Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
204
+ Expect (opts .CanarySteps ).To (HaveLen (0 ))
205
+ })
206
+ })
207
+
208
+ When ("canary strategy is provided" , func () {
209
+ BeforeEach (func () {
210
+ cmd .Strategy = flag.DeploymentStrategy {Name : constant .DeploymentStrategyCanary }
211
+ cmd .InstanceSteps = "1,2,4"
212
+ })
169
213
170
- inputApp , inputSpace , inputOrg , inputDropletGuid , opts := fakeAppStager .StartAppArgsForCall (0 )
171
- Expect (inputApp ).To (Equal (app ))
172
- Expect (inputDropletGuid ).To (Equal ("" ))
173
- Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
174
- Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
175
- Expect (opts .Strategy ).To (Equal (strategy ))
176
- Expect (opts .NoWait ).To (Equal (noWait ))
177
- Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
214
+ It ("starts the app with the current droplet" , func () {
215
+ Expect (executeErr ).ToNot (HaveOccurred ())
216
+ Expect (fakeAppStager .StartAppCallCount ()).To (Equal (1 ))
217
+
218
+ inputApp , inputSpace , inputOrg , inputDropletGuid , opts := fakeAppStager .StartAppArgsForCall (0 )
219
+ Expect (inputApp ).To (Equal (app ))
220
+ Expect (inputDropletGuid ).To (Equal ("" ))
221
+ Expect (inputSpace ).To (Equal (cmd .Config .TargetedSpace ()))
222
+ Expect (inputOrg ).To (Equal (cmd .Config .TargetedOrganization ()))
223
+ Expect (opts .Strategy ).To (Equal (constant .DeploymentStrategyCanary ))
224
+ Expect (opts .NoWait ).To (Equal (noWait ))
225
+ Expect (opts .AppAction ).To (Equal (constant .ApplicationRestarting ))
226
+ Expect (opts .CanarySteps ).To (Equal ([]resources.CanaryStep {{InstanceWeight : 1 }, {InstanceWeight : 2 }, {InstanceWeight : 4 }}))
227
+ })
178
228
})
179
229
180
230
When ("starting the app returns an error" , func () {
@@ -218,5 +268,34 @@ var _ = Describe("restart Command", func() {
218
268
translatableerror.IncorrectUsageError {
219
269
Message : "--max-in-flight must be greater than or equal to 1" ,
220
270
}),
271
+
272
+ Entry ("instance-steps provided with rolling deployment" ,
273
+ func () {
274
+ cmd .Strategy = flag.DeploymentStrategy {Name : constant .DeploymentStrategyRolling }
275
+ cmd .InstanceSteps = "1,2,3"
276
+ },
277
+ translatableerror.RequiredFlagsError {
278
+ Arg1 : "--instance-steps" ,
279
+ Arg2 : "--strategy=canary" ,
280
+ }),
281
+
282
+ Entry ("instance-steps no strategy provided" ,
283
+ func () {
284
+ cmd .InstanceSteps = "1,2,3"
285
+ },
286
+ translatableerror.RequiredFlagsError {
287
+ Arg1 : "--instance-steps" ,
288
+ Arg2 : "--strategy=canary" ,
289
+ }),
290
+
291
+ Entry ("instance-steps a valid list of ints" ,
292
+ func () {
293
+ cmd .Strategy = flag.DeploymentStrategy {Name : constant .DeploymentStrategyCanary }
294
+ cmd .InstanceSteps = "some,thing,not,right"
295
+ },
296
+ translatableerror.ParseArgumentError {
297
+ ArgumentName : "--instance-steps" ,
298
+ ExpectedType : "list of weights" ,
299
+ }),
221
300
)
222
301
})
0 commit comments