Speed up tests by adding "vagrant.test" middleware env to avoid sleeps.
This commit is contained in:
parent
d09ebe1021
commit
c1d454dbee
|
@ -26,7 +26,7 @@ module Vagrant
|
||||||
@env["vm"].vm.start(@env.env.config.vm.boot_mode)
|
@env["vm"].vm.start(@env.env.config.vm.boot_mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
def wait_for_boot(sleeptime=5)
|
def wait_for_boot
|
||||||
@env.logger.info "Waiting for VM to boot..."
|
@env.logger.info "Waiting for VM to boot..."
|
||||||
|
|
||||||
@env.env.config.ssh.max_tries.to_i.times do |i|
|
@env.env.config.ssh.max_tries.to_i.times do |i|
|
||||||
|
@ -41,7 +41,7 @@ module Vagrant
|
||||||
# get shown
|
# get shown
|
||||||
return true if @env.interrupted?
|
return true if @env.interrupted?
|
||||||
|
|
||||||
sleep sleeptime
|
sleep 5 if !@env["vagrant.test"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@env.logger.info "Failed to connect to VM! Failed to boot?"
|
@env.logger.info "Failed to connect to VM! Failed to boot?"
|
||||||
|
|
|
@ -23,7 +23,7 @@ module Vagrant
|
||||||
|
|
||||||
# Sleep for a second to verify that the VM properly
|
# Sleep for a second to verify that the VM properly
|
||||||
# cleans itself up
|
# cleans itself up
|
||||||
sleep 1
|
sleep 1 if !env["vagrant.test"]
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -93,6 +93,7 @@ class Test::Unit::TestCase
|
||||||
def mock_action_data
|
def mock_action_data
|
||||||
app = lambda { |env| }
|
app = lambda { |env| }
|
||||||
env = Vagrant::Action::Environment.new(mock_environment)
|
env = Vagrant::Action::Environment.new(mock_environment)
|
||||||
|
env["vagrant.test"] = true
|
||||||
[app, env]
|
[app, env]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ class SetEnvActionTest < Test::Unit::TestCase
|
||||||
setup do
|
setup do
|
||||||
@klass = Vagrant::Action::Env::Set
|
@klass = Vagrant::Action::Env::Set
|
||||||
@app, @env = mock_action_data
|
@app, @env = mock_action_data
|
||||||
|
@env.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
should "merge in the given options" do
|
should "merge in the given options" do
|
||||||
|
|
|
@ -66,18 +66,18 @@ class BootVMActionTest < Test::Unit::TestCase
|
||||||
seq = sequence('pings')
|
seq = sequence('pings')
|
||||||
@vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i - 1).returns(false).in_sequence(seq)
|
@vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i - 1).returns(false).in_sequence(seq)
|
||||||
@vm.ssh.expects(:up?).once.returns(true).in_sequence(seq)
|
@vm.ssh.expects(:up?).once.returns(true).in_sequence(seq)
|
||||||
assert @instance.wait_for_boot(0)
|
assert @instance.wait_for_boot
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return right away if interrupted" do
|
should "return right away if interrupted" do
|
||||||
@env.error!(:interrupt)
|
@env.error!(:interrupt)
|
||||||
@vm.ssh.expects(:up?).times(1).returns(false)
|
@vm.ssh.expects(:up?).times(1).returns(false)
|
||||||
assert @instance.wait_for_boot(0)
|
assert @instance.wait_for_boot
|
||||||
end
|
end
|
||||||
|
|
||||||
should "ping the max number of times then just return" do
|
should "ping the max number of times then just return" do
|
||||||
@vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i).returns(false)
|
@vm.ssh.expects(:up?).times(@env.env.config.ssh.max_tries.to_i).returns(false)
|
||||||
assert !@instance.wait_for_boot(0)
|
assert !@instance.wait_for_boot
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue