Sha256: 4aad01d3061e4d1f22c2d310cea5ffc336d9753cc3464ef365a35219b394788f

Contents?: true

Size: 1.58 KB

Versions: 11

Compression:

Stored size: 1.58 KB

Contents

require 'vagrant-conoha/spec_helper'

describe VagrantPlugins::ConoHa::Action::WaitForServerToBeActive do
  let(:nova) do
    double('nova')
  end

  let(:config) do
    double('config')
  end

  let(:env) do
    {}.tap do |env|
      env[:ui] = double('ui').tap do |ui|
        ui.stub(:info).with(anything)
        ui.stub(:error).with(anything)
      end
      env[:openstack_client] = double('openstack_client').tap do |os|
        os.stub(:nova) { nova }
      end
      env[:machine] = OpenStruct.new.tap do |m|
        m.provider_config = config
        m.id = 'server_id'
      end
    end
  end

  let(:app) do
    double('app').tap do |app|
      app.stub(:call).with(anything)
    end
  end

  describe 'call' do
    context 'when server is not yet active' do
      it 'become active after one retry' do
        nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'ACTIVE')
        expect(nova).to receive(:get_server_details).with(env, 'server_id').exactly(2).times
        expect(app).to receive(:call)
        config.stub(:server_active_timeout) { 5 }
        @action = WaitForServerToBeActive.new(app, nil, 1)
        @action.call(env)
      end
      it 'timeout after one retry' do
        nova.stub(:get_server_details).and_return({ 'status' => 'BUILD' }, 'status' => 'BUILD')
        expect(nova).to receive(:get_server_details).with(env, 'server_id').at_least(2).times
        config.stub(:server_active_timeout) { 2 }
        @action = WaitForServerToBeActive.new(app, nil, 1)
        expect { @action.call(env) }.to raise_error Errors::Timeout
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
vagrant-conoha-0.1.10 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.9 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.8 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.7 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.6 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.5 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.4 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.3 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.2 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.1 spec/vagrant-conoha/action/wait_active_spec.rb
vagrant-conoha-0.1.0 spec/vagrant-conoha/action/wait_active_spec.rb