kitchen-ec2 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cane +2 -1
- data/.gitignore +2 -0
- data/.rspec +3 -0
- data/.rubocop.yml +9 -0
- data/.yardopts +3 -0
- data/CHANGELOG.md +60 -17
- data/Gemfile +3 -3
- data/README.md +241 -85
- data/Rakefile +30 -12
- data/data/amis.json +18 -0
- data/kitchen-ec2.gemspec +21 -10
- data/lib/kitchen/driver/aws/client.rb +110 -0
- data/lib/kitchen/driver/aws/instance_generator.rb +148 -0
- data/lib/kitchen/driver/ec2.rb +288 -88
- data/lib/kitchen/driver/ec2_version.rb +1 -1
- data/spec/kitchen/driver/ec2/client_spec.rb +119 -0
- data/spec/kitchen/driver/ec2/instance_generator_spec.rb +303 -0
- data/spec/kitchen/driver/ec2_spec.rb +82 -0
- data/spec/spec_helper.rb +104 -0
- metadata +131 -22
- data/.tailor +0 -106
- data/spec/create_spec.rb +0 -106
data/spec/create_spec.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'kitchen/driver/ec2'
|
2
|
-
require 'kitchen/provisioner/dummy'
|
3
|
-
|
4
|
-
describe Kitchen::Driver::Ec2 do
|
5
|
-
|
6
|
-
let(:config) do
|
7
|
-
{}
|
8
|
-
end
|
9
|
-
|
10
|
-
let(:state) do
|
11
|
-
{}
|
12
|
-
end
|
13
|
-
|
14
|
-
let(:server) do
|
15
|
-
double(:id => "123",
|
16
|
-
:wait_for => nil,
|
17
|
-
:dns_name => "server.example.com",
|
18
|
-
:private_ip_address => '172.13.16.11',
|
19
|
-
:public_ip_address => '213.225.123.134')
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:instance) do
|
23
|
-
Kitchen::Instance.new(:platform => double(:name => "centos-6.4"),
|
24
|
-
:suite => double(:name => "default"),
|
25
|
-
:driver => driver,
|
26
|
-
:provisioner => Kitchen::Provisioner::Dummy.new({}),
|
27
|
-
:busser => double("busser"),
|
28
|
-
:state_file => double("state_file"))
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:driver) do
|
32
|
-
Kitchen::Driver::Ec2.new(config)
|
33
|
-
end
|
34
|
-
|
35
|
-
before do
|
36
|
-
instance
|
37
|
-
allow(driver).to receive(:create_server).and_return(server)
|
38
|
-
allow(driver).to receive(:wait_for_sshd)
|
39
|
-
end
|
40
|
-
|
41
|
-
context 'Interface is set in config' do
|
42
|
-
|
43
|
-
it 'derives hostname from DNS when specified in the .kitchen.yml' do
|
44
|
-
config[:interface] = 'dns'
|
45
|
-
driver.create(state)
|
46
|
-
expect(state[:hostname]).to eql('server.example.com')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'derives hostname from public interface when specified in the .kitchen.yml' do
|
50
|
-
config[:interface] = 'public'
|
51
|
-
driver.create(state)
|
52
|
-
expect(state[:hostname]).to eql('213.225.123.134')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'derives hostname from private interface when specified in the .kitchen.yml' do
|
56
|
-
config[:interface] = 'private'
|
57
|
-
driver.create(state)
|
58
|
-
expect(state[:hostname]).to eql('172.13.16.11')
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'throws a nice exception if the config is bogus' do
|
62
|
-
config[:interface] = 'I am an idiot'
|
63
|
-
expect { driver.create(state) }.to raise_error(Kitchen::UserError, 'Invalid interface')
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
|
68
|
-
context 'Interface is derived automatically' do
|
69
|
-
|
70
|
-
let(:server) do
|
71
|
-
double(:id => "123",
|
72
|
-
:wait_for => nil,
|
73
|
-
:dns_name => nil,
|
74
|
-
:private_ip_address => nil,
|
75
|
-
:public_ip_address => nil)
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'sets hostname to DNS value if DNS value exists' do
|
79
|
-
allow(server).to receive(:dns_name).and_return('server.example.com')
|
80
|
-
driver.create(state)
|
81
|
-
expect(state[:hostname]).to eql('server.example.com')
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'sets hostname to public value if public value exists' do
|
85
|
-
allow(server).to receive(:public_ip_address).and_return('213.225.123.134')
|
86
|
-
driver.create(state)
|
87
|
-
|
88
|
-
expect(state[:hostname]).to eql('213.225.123.134')
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'sets hostname to private value if private value exists' do
|
92
|
-
allow(server).to receive(:private_ip_address).and_return('172.13.16.11')
|
93
|
-
driver.create(state)
|
94
|
-
expect(state[:hostname]).to eql('172.13.16.11')
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'sets hostname to DNS if one or more Public/Private values are set' do
|
98
|
-
allow(server).to receive(:dns_name).and_return('server.example.com')
|
99
|
-
allow(server).to receive(:public_ip_address).and_return('213.225.123.134')
|
100
|
-
allow(server).to receive(:private_ip_address).and_return('172.13.16.11')
|
101
|
-
driver.create(state)
|
102
|
-
expect(state[:hostname]).to eql('server.example.com')
|
103
|
-
end
|
104
|
-
|
105
|
-
end
|
106
|
-
end
|