@@ -75,6 +75,56 @@ export = {
75
75
test . done ( ) ;
76
76
} ,
77
77
78
+ "errors if daemon and maximumPercent not 100" ( test : Test ) {
79
+ // GIVEN
80
+ const stack = new cdk . Stack ( ) ;
81
+ const vpc = new ec2 . VpcNetwork ( stack , 'MyVpc' , { } ) ;
82
+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' , { vpc } ) ;
83
+ cluster . addCapacity ( 'DefaultAutoScalingGroup' , { instanceType : new ec2 . InstanceType ( 't2.micro' ) } ) ;
84
+ const taskDefinition = new ecs . Ec2TaskDefinition ( stack , 'Ec2TaskDef' ) ;
85
+ taskDefinition . addContainer ( 'BaseContainer' , {
86
+ image : ecs . ContainerImage . fromRegistry ( 'test' ) ,
87
+ memoryReservationMiB : 10 ,
88
+ } ) ;
89
+
90
+ // THEN
91
+ test . throws ( ( ) => {
92
+ new ecs . Ec2Service ( stack , "Ec2Service" , {
93
+ cluster,
94
+ taskDefinition,
95
+ daemon : true ,
96
+ maximumPercent : 300
97
+ } ) ;
98
+ } , / M a x i m u m p e r c e n t m u s t b e 1 0 0 f o r d a e m o n m o d e ./ ) ;
99
+
100
+ test . done ( ) ;
101
+ } ,
102
+
103
+ "errors if daemon and minimum not 0" ( test : Test ) {
104
+ // GIVEN
105
+ const stack = new cdk . Stack ( ) ;
106
+ const vpc = new ec2 . VpcNetwork ( stack , 'MyVpc' , { } ) ;
107
+ const cluster = new ecs . Cluster ( stack , 'EcsCluster' , { vpc } ) ;
108
+ cluster . addCapacity ( 'DefaultAutoScalingGroup' , { instanceType : new ec2 . InstanceType ( 't2.micro' ) } ) ;
109
+ const taskDefinition = new ecs . Ec2TaskDefinition ( stack , 'Ec2TaskDef' ) ;
110
+ taskDefinition . addContainer ( 'BaseContainer' , {
111
+ image : ecs . ContainerImage . fromRegistry ( 'test' ) ,
112
+ memoryReservationMiB : 10 ,
113
+ } ) ;
114
+
115
+ // THEN
116
+ test . throws ( ( ) => {
117
+ new ecs . Ec2Service ( stack , "Ec2Service" , {
118
+ cluster,
119
+ taskDefinition,
120
+ daemon : true ,
121
+ minimumHealthyPercent : 50
122
+ } ) ;
123
+ } , / M i n i m u m h e a l t h y p e r c e n t m u s t b e 0 f o r d a e m o n m o d e ./ ) ;
124
+
125
+ test . done ( ) ;
126
+ } ,
127
+
78
128
'Output does not contain DesiredCount if daemon mode is set' ( test : Test ) {
79
129
// GIVEN
80
130
const stack = new cdk . Stack ( ) ;
@@ -141,7 +191,11 @@ export = {
141
191
142
192
// THEN
143
193
expect ( stack ) . to ( haveResource ( "AWS::ECS::Service" , {
144
- SchedulingStrategy : "DAEMON"
194
+ SchedulingStrategy : "DAEMON" ,
195
+ DeploymentConfiguration : {
196
+ MaximumPercent : 100 ,
197
+ MinimumHealthyPercent : 0
198
+ } ,
145
199
} ) ) ;
146
200
147
201
test . done ( ) ;
0 commit comments