MCPcopy Create free account
hub / github.com/docker/cli / TestToServiceUpdateRollback

Function TestToServiceUpdateRollback

cli/command/service/opts_test.go:277–337  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

275}
276
277func TestToServiceUpdateRollback(t *testing.T) {
278 expected := swarm.ServiceSpec{
279 UpdateConfig: &swarm.UpdateConfig{
280 Parallelism: 23,
281 Delay: 34 * time.Second,
282 Monitor: 54321 * time.Nanosecond,
283 FailureAction: swarm.UpdateFailureActionPause,
284 MaxFailureRatio: 0.6,
285 Order: swarm.UpdateOrderStopFirst,
286 },
287 RollbackConfig: &swarm.UpdateConfig{
288 Parallelism: 12,
289 Delay: 23 * time.Second,
290 Monitor: 12345 * time.Nanosecond,
291 FailureAction: swarm.UpdateFailureActionContinue,
292 MaxFailureRatio: 0.5,
293 Order: swarm.UpdateOrderStartFirst,
294 },
295 }
296
297 // Note: in test-situation, the flags are only used to detect if an option
298 // was set; the actual value itself is read from the serviceOptions below.
299 flags := newCreateCommand(nil).Flags()
300 flags.Set("update-parallelism", "23")
301 flags.Set("update-delay", "34s")
302 flags.Set("update-monitor", "54321ns")
303 flags.Set("update-failure-action", string(swarm.UpdateFailureActionPause))
304 flags.Set("update-max-failure-ratio", "0.6")
305 flags.Set("update-order", string(swarm.UpdateOrderStopFirst))
306
307 flags.Set("rollback-parallelism", "12")
308 flags.Set("rollback-delay", "23s")
309 flags.Set("rollback-monitor", "12345ns")
310 flags.Set("rollback-failure-action", string(swarm.UpdateFailureActionContinue))
311 flags.Set("rollback-max-failure-ratio", "0.5")
312 flags.Set("rollback-order", string(swarm.UpdateOrderStartFirst))
313
314 o := newServiceOptions()
315 o.mode = "replicated"
316 o.update = updateOptions{
317 parallelism: 23,
318 delay: 34 * time.Second,
319 monitor: 54321 * time.Nanosecond,
320 onFailure: string(swarm.UpdateFailureActionPause),
321 maxFailureRatio: 0.6,
322 order: string(swarm.UpdateOrderStopFirst),
323 }
324 o.rollback = updateOptions{
325 parallelism: 12,
326 delay: 23 * time.Second,
327 monitor: 12345 * time.Nanosecond,
328 onFailure: string(swarm.UpdateFailureActionContinue),
329 maxFailureRatio: 0.5,
330 order: string(swarm.UpdateOrderStartFirst),
331 }
332
333 service, err := o.ToService(context.Background(), &fakeClient{}, flags)
334 assert.NilError(t, err)

Callers

nothing calls this directly

Calls 4

newServiceOptionsFunction · 0.85
ToServiceMethod · 0.80
newCreateCommandFunction · 0.70
SetMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…