Sha256: 74b9a094d87582713a41663b2c7a98523fb7e0a555d9b715c245e3fa8ffea3bc

Contents?: true

Size: 1.48 KB

Versions: 5

Compression:

Stored size: 1.48 KB

Contents

require 'egon/undercloud/installer'
require 'egon/undercloud/ssh-connection'
require 'egon/undercloud/commands'
require 'net/ssh'
require 'net/ssh/connection/session'

def run_and_assert_installer(installer, failure)
    expect(installer.started?).to be false
    expect(installer.completed?).to be false
    expect(installer.failure?).to be false
    sleep_count = 0
    installer.install("ls")
    # installer runs in the background if sleep_count > 0
    while !installer.completed?
      expect(installer.started?).to be true
      sleep 1
    end
    expect(installer.started?).to be true
    expect(installer.completed?).to be true
    expect(installer.failure?).to be failure
end

describe "undercloud installer" do

  before do
    @connection = Egon::Undercloud::SSHConnection.new("194.0.0.0", "mock", "mock")
    @installer = Egon::Undercloud::Installer.new(@connection)
  end

  it "installer should run in background and not fail" do
    allow(@connection).to receive(:execute) { @connection.call_complete }
    run_and_assert_installer(@installer, false)
  end

  it "exception raised by ssh should indicate failure" do
    allow(Net::SSH).to receive(:start) { raise "Error in ssh" }
    run_and_assert_installer(@installer, true)
  end

  it "connection should timeout and installer indicate failure" do
    run_and_assert_installer(@installer, true)
  end

  it "check ports should fail on mock connection" do
    @installer.check_ports
    expect(@installer.failure?).to be true
  end
  
end
  

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
egon-0.3.4 test/test_undercloud.rb
egon-0.3.3 test/test_undercloud.rb
egon-0.3.2 test/test_undercloud.rb
egon-0.3.1 test/test_undercloud.rb
egon-0.3.0 test/test_undercloud.rb