summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIonuț Arțăriși <iartarisi@suse.cz>2014-09-30 14:45:34 +0200
committerIonuț Arțăriși <iartarisi@suse.cz>2014-09-30 14:45:50 +0200
commit17eff9523c9e922ca9118956ec6441d07c6b2988 (patch)
treee940444c6645ab1510d2a648469929dad8280142
parent43553e0e176d2e6e7ce6180d8b726c3dacd86bf0 (diff)
add a Rakefile to structure test runs
Having a Rakefile will allow us to change the actual test commands on our side rather than relying on changes to the openstack-infra repository. This should make it a lot faster to change things, but also easier to test since the jenkins jobs are actually run in this repository, not the openstack-infra one. This commit defines the jobs we previously had defined in Jenkins and uses 'high-level' naming consistently (i.e. lint, style vs. foodcritic, rubocop). There is also a :clean task to help with deleting the files generated by the other jobs. Also changed foodcritic to run on the source cookbook rather than the one installed by berks, see e.g. https://github.com/berkshelf/berkshelf/issues/931#issuecomment-29668369 Change-Id: If366dff9394f416b0704bea89ae50c1c472606bf blueprint: rakefile
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Justin Shepherd <jshepher@rackspace.com> Workflow+1: Justin Shepherd <jshepher@rackspace.com> Code-Review+2: Mark Vanderwiel <vanderwl@us.ibm.com> Submitted-by: Jenkins Submitted-at: Tue, 07 Oct 2014 15:24:36 +0000 Reviewed-on: https://review.openstack.org/125028 Project: stackforge/cookbook-openstack-block-storage Branch: refs/heads/master
-rw-r--r--.gitignore2
-rw-r--r--.rubocop.yml1
-rw-r--r--Gemfile1
-rw-r--r--Rakefile33
-rw-r--r--TESTING.md20
5 files changed, 46 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 8fd93b5..92c9c9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
1.bundle/ 1.bundle/
2.cookbooks/ 2berks-cookbooks/
3.kitchen/ 3.kitchen/
4.vagrant/ 4.vagrant/
5.coverage/ 5.coverage/
diff --git a/.rubocop.yml b/.rubocop.yml
index 5500e6d..69447d8 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -13,6 +13,7 @@ Encoding:
13 Exclude: 13 Exclude:
14 - metadata.rb 14 - metadata.rb
15 - Gemfile 15 - Gemfile
16 - berks-cookbooks/**
16 17
17NumericLiterals: 18NumericLiterals:
18 Enabled: false 19 Enabled: false
diff --git a/Gemfile b/Gemfile
index 80d78db..7e598c3 100644
--- a/Gemfile
+++ b/Gemfile
@@ -10,3 +10,4 @@ gem 'rspec', '~> 3.0.0'
10gem 'foodcritic', '~> 3.0.3' 10gem 'foodcritic', '~> 3.0.3'
11gem 'rubocop', '~> 0.18.1' 11gem 'rubocop', '~> 0.18.1'
12gem 'fauxhai', '>= 2.1.0' 12gem 'fauxhai', '>= 2.1.0'
13gem 'rake', '~> 10.0'
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..e9952df
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,33 @@
1task default: ["test"]
2
3task :test => [:lint, :style, :unit]
4
5task :bundler_prep do
6 mkdir_p '.bundle'
7 sh %{bundle install --path=.bundle --jobs 1 --retry 3 --verbose}
8end
9
10task :berks_prep => :bundler_prep do
11 sh %{bundle exec berks vendor}
12end
13
14task :lint => :bundler_prep do
15 sh %{bundle exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .}
16end
17
18task :style => :bundler_prep do
19 sh %{bundle exec rubocop}
20end
21
22task :unit => :berks_prep do
23 sh %{bundle exec rspec --format documentation}
24end
25
26task :clean do
27 rm_rf [
28 '.bundle',
29 'berks-cookbooks',
30 'Gemfile.lock',
31 'Berksfile.lock'
32 ]
33end
diff --git a/TESTING.md b/TESTING.md
index 40bd063..b38785b 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -1,18 +1,18 @@
1# Testing the Cookbook # 1# Testing the Cookbook #
2 2
3This cookbook uses [bundler](http://gembundler.com/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. 3This cookbook uses [bundler](http://gembundler.com/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have `ruby 1.9.x`, `bundler`, `rake`, build essentials and the header files for `gecode` installed before continuing. Make sure that you're using gecode version 3. More info [here](https://github.com/opscode/dep-selector-libgecode/tree/0bad63fea305ede624c58506423ced697dd2545e#using-a-system-gecode-instead).
4 4
5To setup the dependencies: 5We have three test suites which you can run individually (there are three rake tasks):
6 6
7 $ bundle install --path=.bundle # install gem dependencies 7 $ rake lint
8 $ bundle exec berks vendor .cookbooks # install cookbook dependencies and create the folder .cookbooks 8 $ rake style
9 $ rake unit
9 10
10To run the tests: 11or altogether:
11 12
12 $ export COOKBOOK='openstack-block-storage' 13 $ rake test
13 $ bundle exec foodcritic -f any -t ~FC003 -t ~FC023 .cookbooks/$COOKBOOK 14
14 $ bundle exec rubocop .cookbooks/$COOKBOOK 15The `rake` tasks will take care of installing the needed gem dependencies and cookbooks with `berkshelf`.
15 $ bundle exec rspec --format documentation .cookbooks/$COOKBOOK/spec
16 16
17## Rubocop ## 17## Rubocop ##
18 18
@@ -27,4 +27,4 @@ To run the tests:
27 27
28## Chefspec 28## Chefspec
29 29
30[ChefSpec](http://github.com/sethvargo/chefspec/) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers. 30[ChefSpec](http://code.sethvargo.com/chefspec/) is a unit testing framework for testing Chef cookbooks. ChefSpec makes it easy to write examples and get fast feedback on cookbook changes without the need for virtual machines or cloud servers.