@@ -2,6 +2,11 @@ require 'rubygems'
22require 'bundler/setup'
33require 'rspec/core/rake_task'
44
5+ RSpec ::Core ::RakeTask . new ( :functionaltest ) do |t |
6+ t . pattern = "*_spec.rb"
7+ t . rspec_opts = "-fd"
8+ end
9+
510# Immediately sync all stdout so that tools like buildbot can
611# immediately load in the output.
712$stdout. sync = true
@@ -22,6 +27,13 @@ task :default => "spec"
2227
2328
2429namespace :functional_tests do
30+
31+ # Name must match folder beneath functional-tests/
32+ functional_test_names = [
33+ 'vmlifecycle' ,
34+ 'rsync'
35+ ]
36+
2537 desc "Check for required enviroment variables for functional testing"
2638 task :check_environment do
2739 [
@@ -49,42 +61,24 @@ namespace :functional_tests do
4961
5062 desc "Run all functional tests"
5163 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 }
64+ functional_test_names . each do |test_name |
65+ Rake ::Task [ "functional_tests:#{ test_name } " ] . invoke
6966 end
70- Dir . chdir ( File . expand_path ( "../" , __FILE__ ) )
7167 end
7268
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 }
69+
70+ functional_test_names . each do |test_dir_name |
71+ desc "Run functional test: #{ test_dir_name } "
72+ task test_dir_name => [ :check_environment ] do
73+ Dir . chdir ( "#{ File . expand_path ( '../' , __FILE__ ) } /functional-tests/#{ test_dir_name } /" )
74+ Dir . glob ( "Vagrantfile*" , File ::FNM_CASEFOLD ) . each do |vagrant_file |
75+
76+ ENV [ 'TEST_NAME' ] = "vagrant_cloudstack_functional_test-#{ test_dir_name } "
77+ ENV [ 'VAGRANT_VAGRANTFILE' ] = vagrant_file
78+ puts "Running RSpec tests in folder : #{ test_dir_name } "
79+ puts "Using Vagrant file : #{ ENV [ 'VAGRANT_VAGRANTFILE' ] } "
80+ Rake ::Task [ :functionaltest ] . execute
81+ end
8782 end
88- Dir . chdir ( File . expand_path ( "../" , __FILE__ ) )
8983 end
9084end
0 commit comments