@@ -19,3 +19,72 @@ RSpec::Core::RakeTask.new
1919
2020# Default task is to run the unit tests
2121task :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
0 commit comments