From 702f82c3c91ae7571097ccb7ed648bb983de04ac Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Fri, 5 Apr 2013 10:41:59 -0700 Subject: [PATCH] This code refactors the openstack test script This script was updated so that I could test swift as well as cherry-pick commits from openstack's gerrit git repo. it adds conditionally logic for when the repo is swift (to build out the swift test env which includes a puppetmaster) it also adds a test_mode=puppet_swift which runs the basic swift smoke tests. it also adds code so that I can run the gerrit cherry-pick command to test patches from gerrit that are being reviewed. Change-Id: If944160dfcc6b68b56f4f688d9d6dea314bf0c5a --- test_scripts/openstack_test.sh | 74 +++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 15 deletions(-) diff --git a/test_scripts/openstack_test.sh b/test_scripts/openstack_test.sh index b2d1129..c93bdfe 100644 --- a/test_scripts/openstack_test.sh +++ b/test_scripts/openstack_test.sh @@ -8,6 +8,10 @@ # $test_mode type of test to run (accepts: tempest_full, tempest_smoke, puppet_openstack, unit) # $module_install_method - how to install modules (accepts librarian or pmt) # +# it also allows the following optional build parameters +# $checkout_patch_command - command that is run after alls gems and modules have been installed. This is +# intended to be a place holder for logic that checks out branches +# # # I am running it as follows: # mkdir $BUILD_ID # cd $BUILD_ID @@ -35,6 +39,15 @@ elif [ $module_install_method = 'pmt' ]; then git clone git://github.com/puppetlabs/puppetlabs-vcsrepo modules/vcsrepo fi +if [ -n "${module_repo:-}" ]; then + pushd $module_repo + if [ -n "${checkout_branch_command:-}" ]; then + eval $checkout_branch_command + fi + popd +fi + + # only build out integration test environment if we are not running unit tests if [ ! $test_mode = 'unit' ]; then # set operatingsystem to use for integration tests tests @@ -45,25 +58,53 @@ if [ ! $test_mode = 'unit' ]; then echo 'openstack_version: folsom' > hiera_data/jenkins.yaml fi -# 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 - VBoxManage controlvm openstack_controller.puppetlabs.lan poweroff || true - VBoxManage unregistervm openstack_controller.puppetlabs.lan --delete - fi - bundle exec vagrant up openstack_controller + if [ "${module_repo:-}" = 'modules/swift' ] ; then + # build out a swift test environment (requires a puppetmaster) - # check if the compute VM is running, if so stop the VM before launching ours - if VBoxManage list vms | grep compute2.puppetlabs.lan; then - VBoxManage controlvm compute2.puppetlabs.lan poweroff || true - VBoxManage unregistervm compute2.puppetlabs.lan --delete + # setup environemnt for a swift test + + # install a controller and compute instance + for i in puppetmaster swift_storage_1 swift_storage_2 swift_storage_3 swift_proxy swift_keystone; do + + # cleanup running swift instances + if VBoxManage list vms | grep ${i}.puppetlabs.lan; then + VBoxManage controlvm ${i}.puppetlabs.lan poweroff || true + VBoxManage unregistervm ${i}.puppetlabs.lan --delete + fi + + done + + # build out a puppetmaster + bundle exec vagrant up puppetmaster + + # deploy swift + bundle exec rake openstack:deploy_swift + + else + # build out an openstack environment + + # 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 + VBoxManage controlvm openstack_controller.puppetlabs.lan poweroff || true + VBoxManage unregistervm openstack_controller.puppetlabs.lan --delete + fi + bundle exec vagrant up openstack_controller + + # check if the compute VM is running, if so stop the VM before launching ours + if VBoxManage list vms | grep compute2.puppetlabs.lan; then + VBoxManage controlvm compute2.puppetlabs.lan poweroff || true + VBoxManage unregistervm compute2.puppetlabs.lan --delete + fi + bundle exec vagrant up compute2 + # install tempest on the controller + bundle exec vagrant status fi - bundle exec vagrant up compute2 - # install tempest on the controller - bundle exec vagrant status + fi +# decide what kind of tests to run if [ $test_mode = 'puppet_openstack' ]; then # run my simple puppet integration tests bundle exec vagrant ssh -c 'sudo bash /tmp/test_nova.sh;exit $?' openstack_controller @@ -76,6 +117,9 @@ elif [ $test_mode = 'tempest_full' ]; then bundle exec vagrant ssh -c 'cd /var/lib/tempest/;sudo ./jenkins_launch_script.sh;exit $?;' openstack_controller elif [ $test_mode = 'unit' ]; then bundle exec rake test:unit +elif [ $test_mode = 'puppet_swift' ] ; then + # assume that if the repo was swift that we are running our special little swift tests + bundle exec vagrant ssh -c 'sudo ruby /tmp/swift_test_file.rb;exit $?' swift_proxy else echo "Unsupported testnode ${test_mode}, this test matrix only support tempest_smoke and puppet_openstack tests" fi