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)
|
||||
end
|
||||
|
||||
def wait_for_boot(sleeptime=5)
|
||||
def wait_for_boot
|
||||
@env.logger.info "Waiting for VM to boot..."
|
||||
|
||||
@env.env.config.ssh.max_tries.to_i.times do |i|
|
||||
|
@ -41,7 +41,7 @@ module Vagrant
|
|||
# get shown
|
||||
return true if @env.interrupted?
|
||||
|
||||
sleep sleeptime
|
||||
sleep 5 if !@env["vagrant.test"]
|
||||
end
|
||||
|
||||
@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
|
||||
# cleans itself up
|
||||
sleep 1
|
||||
sleep 1 if !env["vagrant.test"]
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
|
|
|
@ -93,6 +93,7 @@ class Test::Unit::TestCase
|
|||
def mock_action_data
|
||||
app = lambda { |env| }
|
||||
env = Vagrant::Action::Environment.new(mock_environment)
|
||||
env["vagrant.test"] = true
|
||||
[app, env]
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ class SetEnvActionTest < Test::Unit::TestCase
|
|||
setup do
|
||||
@klass = Vagrant::Action::Env::Set
|
||||
@app, @env = mock_action_data
|
||||
@env.clear
|
||||
end
|
||||
|
||||
should "merge in the given options" do
|
||||
|
|
|
@ -66,18 +66,18 @@ class BootVMActionTest < Test::Unit::TestCase
|
|||
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?).once.returns(true).in_sequence(seq)
|
||||
assert @instance.wait_for_boot(0)
|
||||
assert @instance.wait_for_boot
|
||||
end
|
||||
|
||||
should "return right away if interrupted" do
|
||||
@env.error!(:interrupt)
|
||||
@vm.ssh.expects(:up?).times(1).returns(false)
|
||||
assert @instance.wait_for_boot(0)
|
||||
assert @instance.wait_for_boot
|
||||
end
|
||||
|
||||
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)
|
||||
assert !@instance.wait_for_boot(0)
|
||||
assert !@instance.wait_for_boot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue