Skip to content

Commit 38d60fc

Browse files
Merge pull request #139 from bheuvel/feature/Rake_functional_testing
Using Rake for functional testing
2 parents a97c558 + ba14638 commit 38d60fc

File tree

5 files changed

+77
-120
lines changed

5 files changed

+77
-120
lines changed

README.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -391,20 +391,15 @@ $ bundle exec rake
391391
```
392392

393393
If the unit-tests pass, verify the plugin is functionaly good by running the functional tests with bats.
394-
Before running the tests you need to export a set of variables that are used in the tests.
394+
Before running the tests you need to export a set of variables that are used in the tests. Look at the
395+
Rake file for the required variables, or run the following Rake command to check:
395396
```
396-
export CLOUDSTACK_HOST="..."
397-
export CLOUDSTACK_API_KEY="..."
398-
export CLOUDSTACK_SECRET_KEY="..."
399-
export PUBLIC_SOURCE_NAT_IP="..."
400-
export PUBLIC_SSH_PORT="..."
401-
export ZONE_NAME="..."
402-
export NETWORK_NAME="..."
403-
export SERVICE_OFFERING_NAME="..."
404-
export TEMPLATE_NAME="..."
405-
406-
cd functional-tests
407-
./run_tests.sh
397+
bundle exec rake functional_tests:check_environment
398+
```
399+
400+
Run all functional tests by executing:
401+
```
402+
bundle exec rake functional_tests:all
408403
```
409404

410405
If those pass, you're ready to start developing the plugin. You can test

Rakefile

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,72 @@ RSpec::Core::RakeTask.new
1919

2020
# Default task is to run the unit tests
2121
task :default => "spec"
22+
23+
24+
namespace :functional_tests do
25+
desc "Check for required enviroment variables for functional testing"
26+
task :check_environment do
27+
[
28+
'CLOUDSTACK_API_KEY',
29+
'CLOUDSTACK_SECRET_KEY',
30+
'CLOUDSTACK_HOST',
31+
'PUBLIC_SOURCE_NAT_IP',
32+
'NETWORK_NAME',
33+
'SERVICE_OFFERING_NAME',
34+
'ZONE_NAME',
35+
'PUBLIC_WINRM_PORT',
36+
'PRIVATE_WINRM_PORT',
37+
'PUBLIC_SSH_PORT',
38+
'PRIVATE_SSH_PORT',
39+
'SOURCE_CIDR',
40+
'LINUX_TEMPLATE_NAME',
41+
'WINDOWS_TEMPLATE_NAME'
42+
].each do |var|
43+
if ENV[var].nil?
44+
puts "#{var} not set. Quitting"
45+
exit 1
46+
end
47+
end
48+
end
49+
50+
desc "Run all functional tests"
51+
task :all => [ :check_environment ] do
52+
Rake::Task['functional_tests:vmlifecycle'].invoke
53+
Rake::Task['functional_tests:rsync'].invoke
54+
end
55+
56+
desc "Run functional test: VM Life cycle"
57+
task :vmlifecycle => [ :check_environment ] do
58+
Dir.chdir(File.expand_path("../", __FILE__))
59+
test_dir_name='vmlifecycle'
60+
Dir.chdir("functional-tests/#{test_dir_name}/")
61+
Dir.glob("Vagrantfile*", File::FNM_CASEFOLD).each do |vagrant_file|
62+
puts ""
63+
puts "Testing #{test_dir_name}"
64+
puts ""
65+
ENV['TEST_NAME'] = "vagrant_cloudstack_functional_test-#{test_dir_name}"
66+
ENV['VAGRANT_VAGRANTFILE'] = vagrant_file
67+
sh %{ vagrant up }
68+
sh %{ vagrant destroy -f }
69+
end
70+
Dir.chdir(File.expand_path("../", __FILE__))
71+
end
72+
73+
desc "Run functional test: RSync"
74+
task :rsync => [ :check_environment ] do
75+
Dir.chdir(File.expand_path("../", __FILE__))
76+
test_dir_name='rsync'
77+
Dir.chdir("functional-tests/#{test_dir_name}/")
78+
Dir.glob("Vagrantfile*", File::FNM_CASEFOLD).each do |vagrant_file|
79+
puts ""
80+
puts "Testing #{test_dir_name}"
81+
puts ""
82+
ENV['TEST_NAME'] = "vagrant_cloudstack_functional_test-#{test_dir_name}"
83+
ENV['VAGRANT_VAGRANTFILE'] = vagrant_file
84+
sh %{ vagrant up }
85+
sh %{ vagrant ssh -c "ls /vagrant; echo;" }
86+
sh %{ vagrant destroy -f }
87+
end
88+
Dir.chdir(File.expand_path("../", __FILE__))
89+
end
90+
end

functional-tests/rsync/test.bats

Lines changed: 0 additions & 31 deletions
This file was deleted.

functional-tests/run_tests.sh

Lines changed: 0 additions & 54 deletions
This file was deleted.

functional-tests/vmlifecycle/test.bats

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)