-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
106 lines (89 loc) · 3.06 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
require 'rubygems'
require 'bundler/setup'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:functionaltest) do |t|
t.pattern = "*_spec.rb"
t.rspec_opts = "-fd"
t.verbose = false
end
# Immediately sync all stdout so that tools like buildbot can
# immediately load in the output.
$stdout.sync = true
$stderr.sync = true
# Change to the directory of this file.
Dir.chdir(File.expand_path("../", __FILE__))
# This installs the tasks that help with gem creation and
# publishing.
Bundler::GemHelper.install_tasks
# Install the `spec` task so that we can run tests.
RSpec::Core::RakeTask.new
# Default task is to run the unit tests
task :default => "spec"
namespace :functional_tests do
# Name must match folder beneath functional-tests/
functional_test_names = %w(vmlifecycle networking rsync)
separate_test_names = %w(basic)
desc "Check for required enviroment variables for functional testing"
task :check_environment do
missing_env=false
[
'COSMIC_API_KEY',
'COSMIC_SECRET_KEY',
'COSMIC_HOST',
'PUBLIC_SOURCE_NAT_IP',
'NETWORK_NAME',
'SERVICE_OFFERING_NAME',
'ZONE_NAME',
'PUBLIC_WINRM_PORT',
'PRIVATE_WINRM_PORT',
'PUBLIC_SSH_PORT',
'PRIVATE_SSH_PORT',
'SOURCE_CIDR',
'LINUX_TEMPLATE_NAME',
'WINDOWS_TEMPLATE_NAME',
'VPC_PUBLIC_IP',
'VPC_TIER_NAME',
'VR_PUBLIC_IP',
'VR_NETWORK_NAME',
'DISK_OFFERING_NAME'
].each do |var|
if ENV[var].nil?
puts "Please set environment variable #{var}."
missing_env=true
end
end
exit 1 if missing_env
end
desc "Run all functional tests"
task :all => [ :check_environment ] do
functional_test_names.each do |test_name|
Rake::Task["functional_tests:#{test_name}"].invoke
end
end
functional_test_names.each do |test_dir_name|
desc "Run functional test: #{test_dir_name}"
task test_dir_name => [ :check_environment ] do
Dir.chdir("#{File.expand_path('../', __FILE__)}/functional-tests/#{test_dir_name}/")
Dir.glob("Vagrantfile*", File::FNM_CASEFOLD).each do |vagrant_file|
ENV['TEST_NAME'] = "vagrant_cosmic_functional_test-#{test_dir_name}"
ENV['VAGRANT_VAGRANTFILE'] = vagrant_file
puts "Running RSpec tests in folder : #{test_dir_name}"
puts "Using Vagrant file : #{ENV['VAGRANT_VAGRANTFILE']}"
Rake::Task[:functionaltest].execute
end
end
end
separate_test_names.each do |test_dir_name|
desc "Run functional test: #{test_dir_name}"
task test_dir_name => [ :check_environment ] do
Dir.chdir("#{File.expand_path('../', __FILE__)}/functional-tests/#{test_dir_name}/")
Dir.glob("Vagrantfile*", File::FNM_CASEFOLD).each do |vagrant_file|
ENV['TEST_NAME'] = "vagrant_cosmic_functional_test-#{test_dir_name}"
ENV['VAGRANT_VAGRANTFILE'] = vagrant_file
puts "Running RSpec tests in folder : #{test_dir_name}"
puts "Using Vagrant file : #{ENV['VAGRANT_VAGRANTFILE']}"
Rake::Task[:functionaltest].execute
end
end
end
end