vm_shepherd 1.7.2 → 1.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/vm_shepherd/aws_manager.rb +1 -1
- data/lib/vm_shepherd/version.rb +1 -1
- data/spec/vm_shepherd/aws_manager_spec.rb +113 -68
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab0c19467d9811ac4ac4b56875e8155e3299390f
|
4
|
+
data.tar.gz: e3441beaa08bde0a2556d68b252f87b5725c213d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5fd911a4e52484be279df6cffe69b027fd29e2f4db2e4713cd7f22bd3d9e91c963cdd4eed2e9166b1460f66bc96051b3b28d1e66230d9bafa46059438a47c5b
|
7
|
+
data.tar.gz: d38f7542b02454852050272cb487ba02a7a64f35edf4bb031d3b3ded01bb65a51ed4f4de9d64e7d4df6d5347a8cabb61ec14887a5d49aaef1de2f0cc9b29ba4b
|
data/lib/vm_shepherd/version.rb
CHANGED
@@ -143,72 +143,68 @@ module VmShepherd
|
|
143
143
|
]
|
144
144
|
end
|
145
145
|
let(:ec2_client) { double(AWS::EC2::Client) }
|
146
|
-
let(:
|
147
|
-
{:
|
146
|
+
let(:create_security_group_response_1) do
|
147
|
+
{group_id: 'elb-1-security-group'}
|
148
|
+
end
|
149
|
+
let(:create_security_group_response_2) do
|
150
|
+
{group_id: 'elb-2-security-group'}
|
148
151
|
end
|
149
152
|
let(:security_groups) do
|
150
153
|
{
|
151
|
-
'elb-security-group' =>
|
154
|
+
'elb-1-security-group' => elb_1_security_group,
|
155
|
+
'elb-2-security-group' => elb_2_security_group,
|
152
156
|
}
|
153
157
|
end
|
154
|
-
let(:
|
158
|
+
let(:elb_1_security_group) { instance_double(AWS::EC2::SecurityGroup, security_group_id: 'elb-1-security-group-id') }
|
159
|
+
let(:elb_2_security_group) { instance_double(AWS::EC2::SecurityGroup, security_group_id: 'elb-2-security-group-id') }
|
155
160
|
|
156
161
|
before do
|
157
162
|
allow(ec2).to receive(:client).and_return(ec2_client)
|
158
|
-
allow(ec2_client).to receive(:create_security_group).
|
163
|
+
allow(ec2_client).to receive(:create_security_group).with(hash_including(group_name: 'fake-stack-name_elb-1-name')).
|
164
|
+
and_return(create_security_group_response_1)
|
165
|
+
allow(ec2_client).to receive(:create_security_group).with(hash_including(group_name: 'fake-stack-name_elb-2-name')).
|
166
|
+
and_return(create_security_group_response_2)
|
159
167
|
allow(ec2).to receive(:security_groups).and_return(security_groups)
|
160
|
-
allow(
|
168
|
+
allow(elb_1_security_group).to receive(:authorize_ingress)
|
169
|
+
allow(elb_2_security_group).to receive(:authorize_ingress)
|
161
170
|
allow(elb_client).to receive(:create_load_balancer)
|
162
171
|
end
|
163
172
|
|
164
|
-
it 'creates and attaches a security group for the
|
165
|
-
|
173
|
+
it 'creates and attaches a security group for the ELBs' do
|
174
|
+
elb_1_security_group_args = {
|
166
175
|
group_name: 'fake-stack-name_elb-1-name',
|
167
176
|
description: 'ELB Security Group',
|
168
177
|
vpc_id: 'fake-vpc-id',
|
169
178
|
}
|
170
|
-
expect(ec2_client).to receive(:create_security_group).with(
|
171
|
-
expect(
|
172
|
-
|
173
|
-
ami_manager.prepare_environment(cloudformation_template_file.path)
|
174
|
-
end
|
179
|
+
expect(ec2_client).to receive(:create_security_group).with(elb_1_security_group_args).and_return(create_security_group_response_1)
|
180
|
+
expect(elb_1_security_group).to receive(:authorize_ingress).with(:tcp, 1111, '0.0.0.0/0')
|
175
181
|
|
176
|
-
|
177
|
-
elb_params = {
|
178
|
-
load_balancer_name: 'elb-1-name',
|
179
|
-
listeners: [
|
180
|
-
{protocol: 'TCP', load_balancer_port: 1111, instance_protocol: 'TCP', instance_port: 11},
|
181
|
-
],
|
182
|
-
subnets: ['fake-subnet-id'],
|
183
|
-
security_groups: ['elb-security-group-id']
|
184
|
-
}
|
185
|
-
expect(elb_client).to receive(:create_load_balancer).with(elb_params)
|
186
|
-
|
187
|
-
ami_manager.prepare_environment(cloudformation_template_file.path)
|
188
|
-
end
|
189
|
-
|
190
|
-
it 'creates and attaches a security group for the second ELB' do
|
191
|
-
security_group_args = {
|
182
|
+
elb_2_security_group_args = {
|
192
183
|
group_name: 'fake-stack-name_elb-2-name',
|
193
184
|
description: 'ELB Security Group',
|
194
185
|
vpc_id: 'fake-vpc-id',
|
195
186
|
}
|
196
|
-
expect(ec2_client).to receive(:create_security_group).with(
|
197
|
-
expect(
|
187
|
+
expect(ec2_client).to receive(:create_security_group).with(elb_2_security_group_args).and_return(create_security_group_response_2)
|
188
|
+
expect(elb_2_security_group).to receive(:authorize_ingress).with(:tcp, 2222, '0.0.0.0/0')
|
198
189
|
|
199
190
|
ami_manager.prepare_environment(cloudformation_template_file.path)
|
200
191
|
end
|
201
192
|
|
202
|
-
it 'attaches an elb with the name of the stack for the
|
203
|
-
|
204
|
-
load_balancer_name: 'elb-
|
205
|
-
listeners: [
|
206
|
-
{protocol: 'TCP', load_balancer_port: 2222, instance_protocol: 'TCP', instance_port: 22},
|
207
|
-
],
|
193
|
+
it 'attaches an elb with the name of the stack for the ELBs' do
|
194
|
+
elb_1_params = {
|
195
|
+
load_balancer_name: 'elb-1-name',
|
196
|
+
listeners: [{protocol: 'TCP', load_balancer_port: 1111, instance_protocol: 'TCP', instance_port: 11}],
|
208
197
|
subnets: ['fake-subnet-id'],
|
209
|
-
security_groups: ['elb-security-group-id']
|
198
|
+
security_groups: ['elb-1-security-group-id']
|
210
199
|
}
|
211
|
-
expect(elb_client).to receive(:create_load_balancer).with(
|
200
|
+
expect(elb_client).to receive(:create_load_balancer).with(elb_1_params)
|
201
|
+
elb_2_params = {
|
202
|
+
load_balancer_name: 'elb-2-name',
|
203
|
+
listeners: [{protocol: 'TCP', load_balancer_port: 2222, instance_protocol: 'TCP', instance_port: 22}],
|
204
|
+
subnets: ['fake-subnet-id'],
|
205
|
+
security_groups: ['elb-2-security-group-id']
|
206
|
+
}
|
207
|
+
expect(elb_client).to receive(:create_load_balancer).with(elb_2_params)
|
212
208
|
|
213
209
|
ami_manager.prepare_environment(cloudformation_template_file.path)
|
214
210
|
end
|
@@ -426,69 +422,118 @@ module VmShepherd
|
|
426
422
|
context 'when an elb is configured' do
|
427
423
|
let(:extra_configs) do
|
428
424
|
{
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
425
|
+
elbs: [
|
426
|
+
{
|
427
|
+
name: 'elb-1-name',
|
428
|
+
port_mappings: [[1111, 11]],
|
429
|
+
stack_output_keys: {
|
430
|
+
vpc_id: 'vpc_id',
|
431
|
+
subnet_id: 'private_subnet',
|
432
|
+
},
|
433
|
+
},
|
434
|
+
{
|
435
|
+
name: 'elb-2-name',
|
436
|
+
port_mappings: [[2222, 22]],
|
437
|
+
stack_output_keys: {
|
438
|
+
vpc_id: 'vpc_id',
|
439
|
+
subnet_id: 'private_subnet',
|
440
|
+
},
|
441
|
+
}
|
442
|
+
],
|
435
443
|
}
|
436
444
|
end
|
437
445
|
|
438
|
-
let(:elb) { instance_double(AWS::ELB, load_balancers: [
|
439
|
-
let(:
|
446
|
+
let(:elb) { instance_double(AWS::ELB, load_balancers: [load_balancer_1_to_delete, load_balancer_2_to_delete, other_load_balancer]) }
|
447
|
+
let(:load_balancer_1_to_delete) do
|
448
|
+
instance_double(AWS::ELB::LoadBalancer,
|
449
|
+
name: 'elb-1-name',
|
450
|
+
security_groups: [elb_1_security_group],
|
451
|
+
exists?: false,
|
452
|
+
)
|
453
|
+
end
|
454
|
+
let(:load_balancer_2_to_delete) do
|
440
455
|
instance_double(AWS::ELB::LoadBalancer,
|
441
|
-
name: 'elb-name',
|
442
|
-
security_groups: [
|
456
|
+
name: 'elb-2-name',
|
457
|
+
security_groups: [elb_2_security_group],
|
443
458
|
exists?: false,
|
444
459
|
)
|
445
460
|
end
|
446
461
|
let(:other_load_balancer) { instance_double(AWS::ELB::LoadBalancer, name: 'other-elb-name') }
|
447
|
-
let(:
|
448
|
-
let(:
|
462
|
+
let(:elb_1_security_group) { instance_double(AWS::EC2::SecurityGroup, name: 'elb-1-security-group', id: 'sg-elb-1-id') }
|
463
|
+
let(:elb_2_security_group) { instance_double(AWS::EC2::SecurityGroup, name: 'elb-2-security-group', id: 'sg-elb-2-id') }
|
464
|
+
let(:network_interface_1_elb_1) do
|
465
|
+
instance_double(AWS::EC2::NetworkInterface,
|
466
|
+
security_groups: [elb_1_security_group],
|
467
|
+
exists?: false,
|
468
|
+
)
|
469
|
+
end
|
470
|
+
let(:network_interface_2_elb_1) do
|
471
|
+
instance_double(AWS::EC2::NetworkInterface,
|
472
|
+
security_groups: [elb_1_security_group],
|
473
|
+
exists?: false,
|
474
|
+
)
|
475
|
+
end
|
476
|
+
let(:network_interface_1_elb_2) do
|
449
477
|
instance_double(AWS::EC2::NetworkInterface,
|
450
|
-
security_groups: [
|
478
|
+
security_groups: [elb_2_security_group],
|
451
479
|
exists?: false,
|
452
480
|
)
|
453
481
|
end
|
454
|
-
let(:
|
482
|
+
let(:network_interface_2_elb_2) do
|
455
483
|
instance_double(AWS::EC2::NetworkInterface,
|
456
|
-
security_groups: [
|
484
|
+
security_groups: [elb_2_security_group],
|
457
485
|
exists?: false,
|
458
486
|
)
|
459
487
|
end
|
460
488
|
|
461
489
|
before do
|
462
490
|
allow(AWS::ELB).to receive(:new).and_return(elb)
|
463
|
-
allow(ec2).to receive(:network_interfaces).and_return(
|
464
|
-
|
465
|
-
|
491
|
+
allow(ec2).to receive(:network_interfaces).and_return(
|
492
|
+
[
|
493
|
+
network_interface_1_elb_1,
|
494
|
+
network_interface_2_elb_1,
|
495
|
+
network_interface_1_elb_2,
|
496
|
+
network_interface_2_elb_2,
|
497
|
+
]
|
498
|
+
)
|
499
|
+
allow(load_balancer_1_to_delete).to receive(:delete)
|
500
|
+
allow(load_balancer_2_to_delete).to receive(:delete)
|
501
|
+
allow(elb_1_security_group).to receive(:delete)
|
502
|
+
allow(elb_2_security_group).to receive(:delete)
|
466
503
|
end
|
467
504
|
|
468
|
-
it 'waits for the
|
469
|
-
expect(
|
505
|
+
it 'waits for the ELBs to be deleted' do
|
506
|
+
expect(load_balancer_1_to_delete).to receive(:exists?).and_return(true).
|
470
507
|
exactly(10).times
|
508
|
+
expect(load_balancer_2_to_delete).not_to receive(:exists?)
|
471
509
|
|
472
|
-
expect(
|
510
|
+
expect(elb_1_security_group).not_to receive(:delete).ordered
|
511
|
+
expect(elb_2_security_group).not_to receive(:delete).ordered
|
473
512
|
expect { ami_manager.clean_environment }.to raise_error(AwsManager::RetryLimitExceeded)
|
474
513
|
end
|
475
514
|
|
476
515
|
it 'waits for the network interfaces to be deleted' do
|
477
|
-
allow(
|
516
|
+
allow(load_balancer_1_to_delete).to receive(:exists?).and_return(false)
|
517
|
+
allow(load_balancer_2_to_delete).to receive(:exists?).and_return(false)
|
478
518
|
|
479
|
-
expect(
|
519
|
+
expect(network_interface_1_elb_1).to receive(:exists?).and_return(false).
|
480
520
|
exactly(10).times
|
481
|
-
|
482
|
-
expect(network_interface_2).to receive(:exists?).and_return(true).
|
521
|
+
expect(network_interface_2_elb_1).to receive(:exists?).and_return(true).
|
483
522
|
exactly(10).times
|
523
|
+
expect(network_interface_1_elb_2).not_to receive(:exists?)
|
524
|
+
expect(network_interface_2_elb_2).not_to receive(:exists?)
|
484
525
|
|
485
|
-
expect(
|
526
|
+
expect(elb_1_security_group).not_to receive(:delete).ordered
|
527
|
+
expect(elb_2_security_group).not_to receive(:delete).ordered
|
486
528
|
expect { ami_manager.clean_environment }.to raise_error(AwsManager::RetryLimitExceeded)
|
487
529
|
end
|
488
530
|
|
489
|
-
it 'terminates the
|
490
|
-
expect(
|
491
|
-
expect(
|
531
|
+
it 'terminates the ELBs then removes the security group' do
|
532
|
+
expect(load_balancer_1_to_delete).to receive(:delete).ordered
|
533
|
+
expect(elb_1_security_group).to receive(:delete).ordered
|
534
|
+
|
535
|
+
expect(load_balancer_2_to_delete).to receive(:delete).ordered
|
536
|
+
expect(elb_2_security_group).to receive(:delete).ordered
|
492
537
|
|
493
538
|
ami_manager.clean_environment
|
494
539
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vm_shepherd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ops Manager Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-v1
|