Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Acceptance tests: cucumber #182

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ group :development do
gem 'byebug'
gem 'mocha'
gem 'minitest'
gem 'cucumber', '~> 2.1'
gem 'aruba', '~> 0.13'
gem 'komenda', '~> 0.1.6'
end
36 changes: 36 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,39 @@ PATH
GEM
remote: https://rubygems.org/
specs:
aruba (0.14.1)
childprocess (~> 0.5.6)
contracts (~> 0.9)
cucumber (>= 1.3.19)
ffi (~> 1.9.10)
rspec-expectations (>= 2.99)
thor (~> 0.19)
ast (2.2.0)
builder (3.2.2)
byebug (8.2.1)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
contracts (0.13.0)
cucumber (2.3.3)
builder (>= 2.1.2)
cucumber-core (~> 1.4.0)
cucumber-wire (~> 0.0.1)
diff-lcs (>= 1.1.3)
gherkin (~> 3.2.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.4.0)
gherkin (~> 3.2.0)
cucumber-wire (0.0.1)
diff-lcs (1.2.5)
domain_name (0.5.25)
unf (>= 0.0.5, < 1.0.0)
erubis (2.7.0)
eventmachine (1.0.8)
events (0.9.8)
ffi (1.9.10)
ffi (1.9.10-x64-mingw32)
gherkin (3.2.0)
gssapi (1.2.0)
ffi (>= 1.0.1)
gyoku (1.3.1)
Expand All @@ -51,6 +73,8 @@ GEM
httpclient (2.7.1)
i18n (0.7.0)
json (1.8.3)
komenda (0.1.6)
events (~> 0.9.8)
listen (3.0.5)
rb-fsevent (>= 0.9.3)
rb-inotify (>= 0.9)
Expand All @@ -66,6 +90,7 @@ GEM
mocha (1.1.0)
metaclass (~> 0.0.1)
multi_json (1.11.2)
multi_test (0.1.2)
net-scp (1.1.2)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
Expand Down Expand Up @@ -96,6 +121,10 @@ GEM
http-cookie (>= 1.0.2, < 2.0)
mime-types (>= 1.16, < 3.0)
netrc (~> 0.7)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
rubocop (0.38.0)
parser (>= 2.3.0.6, < 3.0)
powerpack (~> 0.1)
Expand All @@ -107,6 +136,7 @@ GEM
eventmachine (~> 1.0.0)
rubyntlm (0.4.0)
rubyzip (1.1.7)
thor (0.19.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.7.1)
Expand Down Expand Up @@ -134,12 +164,18 @@ PLATFORMS
x64-mingw32

DEPENDENCIES
aruba (~> 0.13)
byebug
cucumber (~> 2.1)
json
komenda (~> 0.1.6)
landrush!
minitest
mocha
rake
rubocop (~> 0.38.0)
rubydns (= 0.8.5)
vagrant!

BUNDLED WITH
1.10.6
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ Clean generated files:

bundle exec rake clobber

Run cucumber/aruba acceptance tests:

bundle exec cucumber

Run the vagrant binary with the Landrush plugin loaded from your local
source code:

Expand Down
3 changes: 3 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ require 'rake'
require 'rake/testtask'
require 'rake/clean'
require 'rubocop/rake_task'
require 'cucumber/rake/task'

CLOBBER.include('pkg/*')

Expand Down Expand Up @@ -35,3 +36,5 @@ task :generate_diagrams do
end

RuboCop::RakeTask.new

Cucumber::Rake::Task.new(:features)
24 changes: 24 additions & 0 deletions features/dns_resolution.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Feature: dns_resolution
Landrush should make a virtual machine's IP address DNS-resolvable.

Scenario Outline: booting a box
Given a file named "Vagrantfile" with:
"""
Vagrant.configure('2') do |config|
config.vm.box = '<box>'
config.vm.hostname = 'my-host.my-tld'
config.vm.network :private_network, ip: '10.10.10.123'

config.landrush.enabled = true
config.landrush.tld = 'my-tld'
end
"""
When I successfully run `bundle exec vagrant up --provider <provider>`
Then the hostname "my-host.my-tld" should resolve to "10.10.10.123" on the internal DNS server
And the hostname "my-host.my-tld" should resolve to "10.10.10.123" on the host
And the hostname "my-host.my-tld" should resolve to "10.10.10.123" on the guest

Examples:
| box | provider |
| debian/jessie64 | virtualbox |
| ubuntu/wily64 | virtualbox |
19 changes: 19 additions & 0 deletions features/step_definitions/dns.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require 'landrush/server'

Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the internal DNS server$/) do |host, ip|
port = Landrush::Server.port
resolver = Resolv::DNS.new(:nameserver_port => [['localhost', port]], :search => ['local'], :ndots => 1)
ip_resolved = resolver.getaddress(host).to_s
expect(ip_resolved).to eq(ip)
end

Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the host$/) do |host, ip|
addrinfo = Addrinfo.getaddrinfo(host, nil, Socket::AF_INET)
ip_resolved = addrinfo.first.ip_address
expect(ip_resolved).to eq(ip)
end

Then(/^the hostname "([^"]+)" should resolve to "([^"]+)" on the guest/) do |host, ip|
run("vagrant ssh -c \"dig +short '#{host}' A\"")
expect(last_command_started).to have_output(/^#{ip}$/)
end
15 changes: 15 additions & 0 deletions features/support/env.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'aruba/cucumber'
require 'komenda'

Aruba.configure do |config|
config.exit_timeout = 300
config.activate_announcer_on_command_failure = [:stdout, :stderr]
end

After do |_scenario|
Komenda.run('bundle exec vagrant landrush stop', fail_on_fail: true)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is Komenda about in this case? What does it add to the mix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a simple way to run a shell command. I couldn't easily find something exposed by Aruba (which might be nicer?).


if File.exist?(File.join(aruba.config.working_directory, 'Vagrantfile'))
Komenda.run('bundle exec vagrant destroy -f', cwd: aruba.config.working_directory, fail_on_fail: true)
end
end