From 38d3b8808e169b43927329cf801b5f51ba8cec5b Mon Sep 17 00:00:00 2001 From: Jan Klare Date: Thu, 19 Mar 2015 09:32:56 +0100 Subject: [PATCH] move from bundle to chefdk and add bootstrap.sh bootstrap script installs testing dependencies on trusty and relies on common bootstrap.sh in stackforge/cookbook-openstack-common - fixed mixup in dependency for knife task in Rakefile - deprecated Gemfile - updated TESTING.md blueprint: bootstrap-infra-test-nodes Change-Id: Ia6e457570fc585874dbf56751c2f8388eb637bbc --- Gemfile | 4 ++++ Rakefile | 25 +++++++++---------------- TESTING.md | 15 +++++++-------- bootstrap.sh | 9 +++++++++ 4 files changed, 29 insertions(+), 24 deletions(-) create mode 100755 bootstrap.sh diff --git a/Gemfile b/Gemfile index 1299374..31c90b5 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,7 @@ +## THIS GEMFILE IS DEPRECATED AND WILL BE REMOVED AFTER THE NEXT RELEASE +## THERE WON'T BE ANY UPDATES TO THIS FILE DURING THIS RELEASE CYCLE +## WE SWITCHED TO CHEFDK AS THE BUNDLE FOR THE NEEDED GEMS + source 'https://rubygems.org' gem 'chef', '~> 11.18.6' diff --git a/Rakefile b/Rakefile index 8f541f3..ce29baa 100644 --- a/Rakefile +++ b/Rakefile @@ -2,36 +2,29 @@ task default: ["test"] task :test => [:lint, :style, :knife, :unit] -task :bundler_prep do - mkdir_p '.bundle' - sh %{bundle install --path=.bundle --jobs 1 --retry 3 --verbose} +task :berks_prep do + sh %{chef exec berks vendor} end -task :berks_prep => :bundler_prep do - sh %{bundle exec berks vendor} +task :lint do + sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} end -task :lint => :bundler_prep do - sh %{bundle exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .} +task :knife => :berks_prep do + sh %{chef exec knife cookbook test openstack-integration-test -o berks-cookbooks} end -task :knife => :bundler_prep do - sh %{bundle exec knife cookbook test openstack-integration-test -o berks-cookbooks} -end - -task :style => :bundler_prep do - sh %{bundle exec rubocop} +task :style do + sh %{chef exec rubocop} end task :unit => :berks_prep do - sh %{bundle exec rspec --format documentation} + sh %{chef exec rspec --format documentation} end task :clean do rm_rf [ - '.bundle', 'berks-cookbooks', - 'Gemfile.lock', 'Berksfile.lock' ] end diff --git a/TESTING.md b/TESTING.md index 686f687..2067634 100644 --- a/TESTING.md +++ b/TESTING.md @@ -1,20 +1,19 @@ # Testing the Cookbook # -This 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). +This cookbook uses [chefdk](https://downloads.chef.io/chef-dk/) and [berkshelf](http://berkshelf.com/) to isolate dependencies. Make sure you have chefdk 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). For more detailed information on what needs to be installed, you can have a quick look into the bootstrap.sh file in this repository, which does install all the needed things to get going on ubuntu trusty. The tests defined in the Rakefile include lint, style and unit. For integration testing please refere to the [openstack-chef-repo](https://github.com/stackforge/openstack-chef-repo). We have four test suites which you can run either, individually (there are three rake tasks): - $ rake lint - $ rake style - $ rake knife - $ rake unit + $ chef exec rake lint + $ chef exec rake style + $ chef exec rake knife + $ chef exec rake unit or altogether: - $ rake test + $ chef exec rake -The `rake` tasks will take care of installing the needed gem dependencies and cookbooks with `berkshelf`. +The `rake` tasks will take care of installing the needed cookbooks with `berkshelf`. ## Rubocop ## diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..f38a960 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,9 @@ +#!/bin/bash -x +## This script is for installing all the needed packages on trusty to run the chef tests with 'chef exec rake'. +## It relies on the common bootstrap.sh from stackforge/cookbook-openstack-common for installing common dependencies. + +curl https://raw.githubusercontent.com/stackforge/cookbook-openstack-common/master/bootstrap.sh \ + --retry 3 \ + --silent \ + --show-error \ + | /bin/bash -x