Skip to content

Instantly share code, notes, and snippets.

@daviddavis
Last active December 27, 2015 16:49
Show Gist options
  • Save daviddavis/7357809 to your computer and use it in GitHub Desktop.
Save daviddavis/7357809 to your computer and use it in GitHub Desktop.
Script for running individual Katello::Engine tests
#!/usr/bin/env bash
if [[ -n $1 ]]
then
RAKE_PATH=`bundle show rake`
ruby -I"lib:test:${KATELLO_PATH}/test:${KATELLO_PATH}/spec" -I"${RAKE_PATH}/lib" \
"${RAKE_PATH}/lib/rake/rake_test_loader.rb" $@ ${KATELLO_PATH}/test/katello_test_runner.rb
else
bundle exec rake test:katello
fi
@daviddavis
Copy link
Author

This should be faster than rake test:katello since you're bypassing rake and its dependencies. Moreover you can do stuff like run individual tests (see below).

Setting KATELLO_PATH

In order to run this script you need to make sure you have $KATELLO_PATH set to your katello directory. You can either export it:

export KATELLO_PATH=$HOME/workspace/katello

Or you could even add this to the top of the script:

KATELLO_PATH=$HOME/workspace/katello

Where ~/workspace/katello would be your katello directory.

Usage

Run all the tests

ktest                                                                                                                       

Run the puppet module tests

ktest ../katello/test/models/puppet_module_test.rb

Run the parse_metadata test in puppet module test file

ktest ../katello/test/models/puppet_module_test.rb -ntest_parse_metadata

Time Comparison

Running ruby directly tends to speed up the time by about 60-80 seconds.

rake test:katello TEST=../katello/test/models/puppet_module_test.rb

/home/dadavis/.rvm/gems/ruby-1.9.3-p448@foreman/bin/rake test:katello   149.24s user 10.72s system 80% cpu 3:17.64 total

ktest ../katello/test/models/puppet_module_test.rb

ktest ../katello/test/models/puppet_module_test.rb  107.16s user 6.97s system 98% cpu 1:55.39 total

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment