spec/beaker/hypervisor/aws_sdk_spec.rb in beaker-aws-0.6.0 vs spec/beaker/hypervisor/aws_sdk_spec.rb in beaker-aws-0.7.0

- old
+ new

@@ -42,19 +42,20 @@ :region => "us-west-2" }, }} before :each do - @hosts = make_hosts({:snapshot => :pe}, 6) + @hosts = make_hosts({:snapshot => :pe}, 7) @hosts[0][:platform] = "centos-5-x86-64-west" @hosts[1][:platform] = "centos-6-x86-64-west" @hosts[2][:platform] = "centos-7-x86-64-west" @hosts[3][:platform] = "ubuntu-12.04-amd64-west" @hosts[3][:user] = "ubuntu" @hosts[4][:platform] = 'f5-host' @hosts[4][:user] = 'notroot' @hosts[5][:platform] = 'netscaler-host' + @hosts[6][:platform] = 'windows-host' ENV['AWS_ACCESS_KEY'] = nil ENV['AWS_SECRET_ACCESS_KEY'] = nil end @@ -633,13 +634,13 @@ subject(:configure_hosts) { aws.configure_hosts } it { is_expected.to be_nil } context 'calls #set_etc_hosts' do - it 'for each host (except the f5 ones)' do - non_netdev_hosts = @hosts.select{ |h| !(h['platform'] =~ /f5|netscaler/) } - expect(aws).to receive(:set_etc_hosts).exactly(non_netdev_hosts.size).times + it 'for each host (except the f5 and windows ones)' do + non_netdev_windows_hosts = @hosts.select{ |h| !(h['platform'] =~ /f5|netscaler|windows/) } + expect(aws).to receive(:set_etc_hosts).exactly(non_netdev_windows_hosts.size).times expect(configure_hosts).to be_nil end it 'with predictable host entries' do @hosts = [@hosts[0], @hosts[1]] @@ -667,10 +668,29 @@ it 'enables root once on the f5 host through its code path' do allow(aws).to receive(:enable_root_netscaler) expect( aws ).to receive(:enable_root_f5).with( @hosts[4] ).once() aws.enable_root_on_hosts() end + context 'when :disable_root_ssh is true' do + it 'should not enable root' do + @hosts = [@hosts[0]] + + @hosts[0][:disable_root_ssh] = true + expect( aws ).to_not receive(:enable_root) + aws.enable_root_on_hosts(); + end + end + + context 'when :disable_root_ssh is defined and false' do + it 'should enable root' do + @hosts = [@hosts[0]] + + @hosts[0][:disable_root_ssh] = false + expect( aws ).to receive(:enable_root).with(@hosts[0]).once() + aws.enable_root_on_hosts(); + end + end end describe '#enable_root_f5' do let( :f5_host ) { @hosts[4] } subject(:enable_root_f5) { aws.enable_root_f5(f5_host) } @@ -713,18 +733,18 @@ end context 'for each host' do it 'calls exec' do @hosts.each do |host| - expect(host).to receive(:exec).once unless host['platform'] =~ /netscaler/ + expect(host).to receive(:exec).once unless host['platform'] =~ /netscaler|windows/ end expect(set_hostnames).to eq(@hosts) end it 'passes a Command instance to exec' do @hosts.each do |host| - expect(host).to receive(:exec).with( instance_of(Beaker::Command) ).once unless host['platform'] =~ /netscaler/ + expect(host).to receive(:exec).with( instance_of(Beaker::Command) ).once unless host['platform'] =~ /netscaler|windows/ end expect(set_hostnames).to eq(@hosts) end it 'sets the the vmhostname to the dns_name for each host' do @@ -735,20 +755,27 @@ end end it 'sets the the vmhostname to the beaker config name for each host' do options[:use_beaker_hostnames] = true - @hosts.each do |host| + @hosts.each do |host| host.instance_eval("@name = 'prettyponyprincess'") - end + end expect(set_hostnames).to eq(@hosts) @hosts.each do |host| expect(host[:vmhostname]).not_to eq(nil) expect(host[:vmhostname]).to eq(host.name) expect(host[:vmhostname]).to eq(host.hostname) end end + end + + context 'windows host platform' do + it 'should not change hostname when use_beaker_hostnames is enabled' do + options[:use_beaker_hostnames] = true + expect(@hosts[6]).to_not receive(:exec) + end end end describe '#backoff_sleep' do it "should call sleep 1024 times at attempt 10" do