Sha256: dbba64aecbd4d05ce0664a6dc3c62acdbf834fff453d7d97eb0c6d70e9fac491

Contents?: true

Size: 1012 Bytes

Versions: 59

Compression:

Stored size: 1012 Bytes

Contents

require "vagrant/util/retryable"

module Acceptance
  module NetworkTests
    include Vagrant::Util::Retryable

    # Tests that the host can access the VM through the network.
    #
    # @param [String] url URL to request from the host.
    # @param [Integer] guest_port Port to run a web server on the guest.
    def assert_host_to_vm_network(url, guest_port)
      # Start up a web server in another thread by SSHing into the VM.
      thr = Thread.new do
        assert_execute("vagrant", "ssh", "-c", "python -m SimpleHTTPServer #{guest_port}")
      end

      # Verify that port forwarding works by making a simple HTTP request
      # to the port. We should get a 200 response. We retry this a few times
      # as we wait for the HTTP server to come online.
      retryable(:tries => 5, :sleep => 2) do
        result = Net::HTTP.get_response(URI.parse(url))
        result.code.should == "200"
      end
    ensure
      # The server needs to die. This is how.
      thr.kill if thr
    end
  end
end

Version data entries

59 entries across 59 versions & 11 rubygems

Version Path
tamtam-vagrant-reload-1.1.3 vendor/cache/vagrant-0ac2a8738841/test/acceptance/support/network_tests.rb
tamtam-vagrant-reload-1.1.2 vendor/cache/vagrant-0ac2a8738841/test/acceptance/support/network_tests.rb
tamtam-vagrant-reload-1.1.1 vendor/cache/vagrant-0ac2a8738841/test/acceptance/support/network_tests.rb
tamtam-vagrant-reload-1.1 vendor/cache/vagrant-0ac2a8738841/test/acceptance/support/network_tests.rb
bmhatfield-vagrant-1.0.10 test/acceptance/support/network_tests.rb
bmhatfield-vagrant-1.0.9 test/acceptance/support/network_tests.rb
tnargav-1.3.6 test/acceptance/support/network_tests.rb
tnargav-1.3.3 test/acceptance/support/network_tests.rb
bmhatfield-vagrant-1.0.8 test/acceptance/support/network_tests.rb
vagrant-shell-0.2.9 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/acceptance/support/network_tests.rb
tnargav-1.2.3 test/acceptance/support/network_tests.rb
vagrant-shell-0.2.8 demo/templates/vendor/bundle/ruby/1.9.1/gems/tnargav-1.2.2/test/acceptance/support/network_tests.rb
bmhatfield-vagrant-1.0.7 test/acceptance/support/network_tests.rb
vagrant-shell-0.2.6 vendor/bundle/gems/tnargav-1.2.2/test/acceptance/support/network_tests.rb
vagrant-shell-0.2.5 vendor/bundle/gems/tnargav-1.2.2/test/acceptance/support/network_tests.rb
tnargav-1.2.2 test/acceptance/support/network_tests.rb
vagrantup-1.1.3 test/acceptance/support/network_tests.rb
vagrantup-1.1.2 test/acceptance/support/network_tests.rb
vagrantup-1.1.1 test/acceptance/support/network_tests.rb
vagrantup-1.1.0 test/acceptance/support/network_tests.rb