|
14 | 14 | @plan = plan(role: :root)
|
15 | 15 | end
|
16 | 16 |
|
17 |
| - context 'when capacity provider included' do |
| 17 | + context 'when include_asg_capacity_provider is true and include_cluster_instances is true' do |
18 | 18 | describe 'by default' do
|
19 | 19 | before(:context) do
|
20 | 20 | @plan = plan(role: :root) do |vars|
|
21 | 21 | vars.include_asg_capacity_provider = true
|
| 22 | + vars.include_cluster_instances = true |
22 | 23 | end
|
23 | 24 | end
|
24 | 25 |
|
|
53 | 54 | context 'with managed termination protection' do
|
54 | 55 | before(:context) do
|
55 | 56 | @plan = plan(role: :root) do |vars|
|
| 57 | + vars.include_cluster_instances = true |
56 | 58 | vars.include_asg_capacity_provider = true
|
57 | 59 | vars.asg_capacity_provider_manage_termination_protection = true
|
58 | 60 | end
|
|
75 | 77 | context 'without managed termination protection' do
|
76 | 78 | before(:context) do
|
77 | 79 | @plan = plan(role: :root) do |vars|
|
| 80 | + vars.include_cluster_instances = true |
78 | 81 | vars.include_asg_capacity_provider = true
|
79 | 82 | vars.asg_capacity_provider_manage_termination_protection = false
|
80 | 83 | end
|
|
97 | 100 | context 'with managed scaling' do
|
98 | 101 | before(:context) do
|
99 | 102 | @plan = plan(role: :root) do |vars|
|
| 103 | + vars.include_cluster_instances = true |
100 | 104 | vars.include_asg_capacity_provider = true
|
101 | 105 | vars.asg_capacity_provider_manage_scaling = true
|
102 | 106 | vars.asg_capacity_provider_minimum_scaling_step_size = 3
|
|
169 | 173 | context 'without managed scaling' do
|
170 | 174 | before(:context) do
|
171 | 175 | @plan = plan(role: :root) do |vars|
|
| 176 | + vars.include_cluster_instances = true |
172 | 177 | vars.include_asg_capacity_provider = true
|
173 | 178 | vars.asg_capacity_provider_manage_scaling = false
|
174 | 179 | end
|
|
191 | 196 | end
|
192 | 197 | end
|
193 | 198 |
|
194 |
| - context 'when capacity provider not included' do |
| 199 | + context 'when include_asg_capacity_provider is false and include_cluster_instances is true' do |
195 | 200 | before(:context) do
|
196 | 201 | @plan = plan(role: :root) do |vars|
|
| 202 | + vars.include_cluster_instances = true |
197 | 203 | vars.include_asg_capacity_provider = false
|
198 | 204 | end
|
199 | 205 | end
|
|
216 | 222 | ))
|
217 | 223 | end
|
218 | 224 | end
|
| 225 | + |
| 226 | + context 'when include_asg_capacity_provider is true and include_cluster_instances is false' do |
| 227 | + before(:context) do |
| 228 | + @plan = plan(role: :root) do |vars| |
| 229 | + vars.include_cluster_instances = false |
| 230 | + vars.include_asg_capacity_provider = true |
| 231 | + end |
| 232 | + end |
| 233 | + |
| 234 | + it 'does not create a capacity provider for the ECS cluster' do |
| 235 | + expect(@plan) |
| 236 | + .not_to(include_resource_creation(type: 'aws_ecs_capacity_provider')) |
| 237 | + end |
| 238 | + |
| 239 | + it 'does not include the AmazonECSManaged tag on the ASG' do |
| 240 | + expect(@plan) |
| 241 | + .not_to(include_resource_creation(type: 'aws_autoscaling_group') |
| 242 | + .with_attribute_value( |
| 243 | + :tag, |
| 244 | + including({ |
| 245 | + key: 'AmazonECSManaged', |
| 246 | + propagate_at_launch: true, |
| 247 | + value: '' |
| 248 | + }) |
| 249 | + )) |
| 250 | + end |
| 251 | + end |
| 252 | + |
| 253 | + context 'when include_asg_capacity_provider is false and include_cluster_instances is false' do |
| 254 | + before(:context) do |
| 255 | + @plan = plan(role: :root) do |vars| |
| 256 | + vars.include_cluster_instances = false |
| 257 | + vars.include_asg_capacity_provider = false |
| 258 | + end |
| 259 | + end |
| 260 | + |
| 261 | + it 'does not create a capacity provider for the ECS cluster' do |
| 262 | + expect(@plan) |
| 263 | + .not_to(include_resource_creation(type: 'aws_ecs_capacity_provider')) |
| 264 | + end |
| 265 | + |
| 266 | + it 'does not include the AmazonECSManaged tag on the ASG' do |
| 267 | + expect(@plan) |
| 268 | + .not_to(include_resource_creation(type: 'aws_autoscaling_group') |
| 269 | + .with_attribute_value( |
| 270 | + :tag, |
| 271 | + including({ |
| 272 | + key: 'AmazonECSManaged', |
| 273 | + propagate_at_launch: true, |
| 274 | + value: '' |
| 275 | + }) |
| 276 | + )) |
| 277 | + end |
| 278 | + end |
| 279 | + |
| 280 | + context 'when additional_capacity_providers are provided' do |
| 281 | + before(:context) do |
| 282 | + @plan = plan(role: :root) do |vars| |
| 283 | + vars.cluster_name = 'special-cluster' |
| 284 | + vars.include_cluster_instances = false |
| 285 | + vars.include_asg_capacity_provider = false |
| 286 | + vars.additional_capacity_providers = ["FARGATE"] |
| 287 | + end |
| 288 | + end |
| 289 | + |
| 290 | + it 'creates a cluster capacity providers resource' do |
| 291 | + expect(@plan) |
| 292 | + .to(include_resource_creation(type: 'aws_ecs_cluster_capacity_providers') |
| 293 | + .once) |
| 294 | + end |
| 295 | + |
| 296 | + it 'uses the correct cluster name on the cluster capacity providers resource' do |
| 297 | + expect(@plan) |
| 298 | + .to(include_resource_creation(type: 'aws_ecs_cluster_capacity_providers') |
| 299 | + .with_attribute_value( |
| 300 | + :cluster_name, |
| 301 | + "#{component}-#{dep_id}-special-cluster" |
| 302 | + )) |
| 303 | + end |
| 304 | + |
| 305 | + it 'adds the additional capacity providers to the cluster capacity providers' do |
| 306 | + expect(@plan) |
| 307 | + .to(include_resource_creation(type: 'aws_ecs_cluster_capacity_providers') |
| 308 | + .with_attribute_value( |
| 309 | + :capacity_providers, ["FARGATE"] |
| 310 | + )) |
| 311 | + end |
| 312 | + end |
219 | 313 | end
|
0 commit comments