Skip to content

Commit

Permalink
Merge pull request #366 from test-kitchen/fix-306
Browse files Browse the repository at this point in the history
Fix 306
  • Loading branch information
Seth Thomas authored Jan 23, 2018
2 parents eff3ee9 + abc3aca commit af024b1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/kitchen/driver/ec2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def create(state) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength

info("EC2 instance <#{state[:server_id]}> ready (hostname: #{state[:hostname]}).")
instance.transport.connection(state).wait_until_ready
create_ec2_json(state)
create_ec2_json(state) if instance.provisioner.name =~ /chef/
debug("ec2:create '#{state[:hostname]}'")
rescue Exception
# Clean up any auto-created security groups or keys on the way out.
Expand Down
14 changes: 13 additions & 1 deletion spec/kitchen/driver/ec2_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
end
let(:platform) { Kitchen::Platform.new(:name => "fooos-99") }
let(:transport) { Kitchen::Transport::Dummy.new }
let(:provisioner) { Kitchen::Provisioner::Dummy.new }
let(:generator) { instance_double(Kitchen::Driver::Aws::InstanceGenerator) }
# There is too much name overlap I let creep in - my `client` is actually
# a wrapper around the actual ec2 client
Expand All @@ -51,6 +52,7 @@
Kitchen::Instance,
:logger => logger,
:transport => transport,
:provisioner => provisioner,
:platform => platform,
:to_str => "str"
)
Expand Down Expand Up @@ -460,12 +462,22 @@
expect(driver).to receive(:wait_until_ready).with(server, state)
allow(actual_client).to receive(:describe_images).with({ :image_ids => [server.image_id] }).and_return(ec2_stub)
expect(transport).to receive_message_chain("connection.wait_until_ready")
expect(driver).to receive(:create_ec2_json).with(state)
driver.create(state)
expect(state[:server_id]).to eq(id)
end
end

context "chef provisioner" do
let(:provisioner) { double("chef provisioner", :name => "chef_solo") }

before do
expect(driver).to receive(:create_ec2_json).with(state)
expect(driver).to receive(:submit_server).and_return(server)
end

include_examples "common create"
end

context "non-windows on-demand instance" do
before do
expect(driver).to receive(:submit_server).and_return(server)
Expand Down

0 comments on commit af024b1

Please sign in to comment.