diff --git a/Gemfile b/Gemfile index 549cbf1..c5853de 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,9 @@ source "https://rubygems.org" gem "vagrant", "~>1.0" gem "librarian-puppet" gem "github_api", "0.8.1" +gem 'rake' +group :unit_tests do + gem 'puppetlabs_spec_helper' + gem 'puppet', '3.1.0' + gem 'rspec-puppet' +end diff --git a/Rakefile b/Rakefile index 57ac1ce..e1035c8 100644 --- a/Rakefile +++ b/Rakefile @@ -157,6 +157,19 @@ end namespace :test do + desc 'run openstack puppet module unit tests' + task :unit do + status = command = "export MODULEPATH=#{base_dir}/modules;export GEM_HOME=#{base_dir}/.vendor;" + ['cinder', 'nova', 'glance', 'openstack', 'keystone', 'horizon', 'swift'].collect do |proj| + Dir.chdir("modules/#{proj}") do + local_command = command + "bundle exec rake spec_standalone" + puts local_command + system(local_command) + end + end.uniq + status == ['true'] ? exit(0) : exit(1) + end + desc 'reset test environment' task :reset do refresh_modules diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000..2c6f566 --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1 @@ +require 'puppetlabs_spec_helper/module_spec_helper' diff --git a/test_scripts/openstack_test.sh b/test_scripts/openstack_test.sh index 892add7..591ba3d 100644 --- a/test_scripts/openstack_test.sh +++ b/test_scripts/openstack_test.sh @@ -28,7 +28,13 @@ elif [ $module_install_method = 'pmt' ]; then git clone git://github.com/puppetlabs/puppetlabs-tempest modules/tempest git clone git://github.com/puppetlabs/puppetlabs-vcsrepo modules/vcsrepo fi -# install a controller and compute instance + +# install gem dependencies +mkdir .vendor +export GEM_HOME=`pwd`/.vendor +# install gem dependencies +bundle install + # only build out integration test environment if we are not running unit tests if [ ! $test_mode = 'unit' ]; then @@ -40,12 +46,7 @@ if [ ! $test_mode = 'unit' ]; then echo 'openstack_version: folsom' > hiera_data/jenkins.yaml fi - # install gem dependencies - mkdir .vendor - export GEM_HOME=`pwd`/.vendor - # install gem dependencies - bundle install - +# install a controller and compute instance # check that the VM is not currently running # if it is, stop that VM if VBoxManage list vms | grep openstack_controller.puppetlabs.lan; then @@ -75,7 +76,7 @@ elif [ $test_mode = 'tempest_smoke' ]; then elif [ $test_mode = 'tempest_full' ]; then bundle exec vagrant ssh -c 'cd /var/lib/tempest/;sudo ./jenkins_launch_script.sh;' openstack_controller elif [ $test_mode = 'unit' ]; then - echo 'we do not yet support running unit tests' + bundle exec rake test:unit else echo "Unsupported testnode ${test_mode}, this test matrix only support tempest_smoke and puppet_openstack tests" fi