File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -224,3 +224,12 @@ func TestToServiceUpdateRollback(t *testing.T) {
224
224
assert .Check (t , is .DeepEqual (service .UpdateConfig , expected .UpdateConfig ))
225
225
assert .Check (t , is .DeepEqual (service .RollbackConfig , expected .RollbackConfig ))
226
226
}
227
+
228
+ func TestToServiceMaxReplicasGlobalModeConflict (t * testing.T ) {
229
+ opt := serviceOptions {
230
+ mode : "global" ,
231
+ maxReplicas : 1 ,
232
+ }
233
+ _ , err := opt .ToServiceMode ()
234
+ assert .Error (t , err , "replicas-max-per-node can only be used with replicated mode" )
235
+ }
Original file line number Diff line number Diff line change @@ -808,3 +808,23 @@ func TestUpdateNetworks(t *testing.T) {
808
808
assert .NilError (t , err )
809
809
assert .Check (t , is .DeepEqual ([]swarm.NetworkAttachmentConfig {{Target : "id999" }}, svc .TaskTemplate .Networks ))
810
810
}
811
+
812
+ func TestUpdateMaxReplicas (t * testing.T ) {
813
+ ctx := context .Background ()
814
+
815
+ svc := swarm.ServiceSpec {
816
+ TaskTemplate : swarm.TaskSpec {
817
+ ContainerSpec : & swarm.ContainerSpec {},
818
+ Placement : & swarm.Placement {
819
+ MaxReplicas : 1 ,
820
+ },
821
+ },
822
+ }
823
+
824
+ flags := newUpdateCommand (nil ).Flags ()
825
+ flags .Set (flagMaxReplicas , "2" )
826
+ err := updateService (ctx , nil , flags , & svc )
827
+ assert .NilError (t , err )
828
+
829
+ assert .Check (t , is .DeepEqual (svc .TaskTemplate .Placement , & swarm.Placement {MaxReplicas : 0x02 }))
830
+ }
You can’t perform that action at this time.
0 commit comments