Filling out initial rubocop support.
https://blueprints.launchpad.net/openstack-chef/+spec/lint-and-unit-testing-for-havana Removing tailor, cleaning up metadata and Gemfile and adding TESTING.md Change-Id: Ia84f3de61ff07b32d0cba15146a971fdf9e7d099
This commit is contained in:
parent
481007ad84
commit
f2e08cf983
7
.rubocop.yml
Normal file
7
.rubocop.yml
Normal file
@ -0,0 +1,7 @@
|
||||
# UTF-8 headers not generally in these files
|
||||
Encoding:
|
||||
Enabled: false
|
||||
|
||||
# ignore long lines
|
||||
LineLength:
|
||||
Enabled: false
|
25
.tailor
25
.tailor
@ -1,25 +0,0 @@
|
||||
Tailor.config do |config|
|
||||
config.formatters "text"
|
||||
config.file_set '**/*.rb' do |style|
|
||||
style.max_line_length 80, level: :off
|
||||
style.allow_camel_case_methods false, level: :error
|
||||
style.allow_hard_tabs false, level: :error
|
||||
style.allow_screaming_snake_case_classes false, level: :error
|
||||
style.allow_trailing_line_spaces false, level: :error
|
||||
style.allow_invalid_ruby false, level: :warn
|
||||
style.indentation_spaces 2, level: :error
|
||||
style.max_code_lines_in_class 300, level: :error
|
||||
style.max_code_lines_in_method 50, level: :error
|
||||
style.spaces_after_comma 1, level: :error
|
||||
style.spaces_after_lbrace 1, level: :error
|
||||
style.spaces_after_lbracket 0, level: :error
|
||||
style.spaces_after_lparen 0, level: :error
|
||||
style.spaces_before_comma 0, level: :error
|
||||
style.spaces_before_lbrace 1, level: :error
|
||||
style.spaces_before_rbrace 1, level: :error
|
||||
style.spaces_before_rbracket 0, level: :error
|
||||
style.spaces_before_rparen 0, level: :error
|
||||
style.spaces_in_empty_braces 0, level: :error
|
||||
style.trailing_newlines 1, level: :error
|
||||
end
|
||||
end
|
16
Gemfile
16
Gemfile
@ -1,9 +1,9 @@
|
||||
source "https://rubygems.org"
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem "chef", "~> 11.4.4"
|
||||
gem "json", "<= 1.7.7" # chef 11 dependency
|
||||
gem "berkshelf", "~> 2.0.10"
|
||||
gem "chefspec", "~> 3.0.2"
|
||||
gem "foodcritic", "~> 3.0.3"
|
||||
gem "strainer"
|
||||
gem "tailor"
|
||||
gem 'chef', '~> 11.4.4'
|
||||
gem 'json', '<= 1.7.7' # chef 11 dependency
|
||||
gem 'berkshelf', '~> 2.0.10'
|
||||
gem 'chefspec', '~> 3.0.2'
|
||||
gem 'foodcritic', '~> 3.0.3'
|
||||
gem 'strainer'
|
||||
gem 'rubocop', '>= 0.16.0'
|
||||
|
22
Gemfile.lock
22
Gemfile.lock
@ -8,6 +8,7 @@ GEM
|
||||
akami (1.2.0)
|
||||
gyoku (>= 0.4.0)
|
||||
nokogiri (>= 1.4.0)
|
||||
ast (1.1.0)
|
||||
berkshelf (2.0.10)
|
||||
activesupport (~> 3.2.0)
|
||||
addressable (~> 2.3.4)
|
||||
@ -88,7 +89,6 @@ GEM
|
||||
ipaddress (0.8.0)
|
||||
json (1.7.7)
|
||||
little-plugger (1.1.3)
|
||||
log_switch (0.4.0)
|
||||
logging (1.8.1)
|
||||
little-plugger (>= 1.1.3)
|
||||
multi_json (>= 1.3.6)
|
||||
@ -120,8 +120,13 @@ GEM
|
||||
mixlib-shellout
|
||||
systemu (~> 2.5.2)
|
||||
yajl-ruby
|
||||
parser (2.1.2)
|
||||
ast (~> 1.1)
|
||||
slop (~> 3.4, >= 3.4.5)
|
||||
polyglot (0.3.3)
|
||||
powerpack (0.0.9)
|
||||
rack (1.5.2)
|
||||
rainbow (1.99.1)
|
||||
rake (10.1.0)
|
||||
rbzip2 (0.2.0)
|
||||
rest-client (1.6.7)
|
||||
@ -155,6 +160,10 @@ GEM
|
||||
rspec-expectations (2.14.4)
|
||||
diff-lcs (>= 1.1.3, < 2.0)
|
||||
rspec-mocks (2.14.4)
|
||||
rubocop (0.16.0)
|
||||
parser (~> 2.1)
|
||||
powerpack (~> 0.0.6)
|
||||
rainbow (>= 1.1.4)
|
||||
rubyntlm (0.1.1)
|
||||
savon (0.9.5)
|
||||
akami (~> 1.0)
|
||||
@ -164,21 +173,14 @@ GEM
|
||||
nokogiri (>= 1.4.0)
|
||||
nori (~> 1.0)
|
||||
wasabi (~> 1.0)
|
||||
slop (3.4.7)
|
||||
solve (0.8.2)
|
||||
strainer (3.3.0)
|
||||
berkshelf (~> 2.0)
|
||||
buff-platform (~> 0.1)
|
||||
systemu (2.5.2)
|
||||
tailor (1.3.1)
|
||||
log_switch (>= 0.3.0)
|
||||
term-ansicolor (>= 1.0.5)
|
||||
text-table (>= 1.2.2)
|
||||
term-ansicolor (1.2.2)
|
||||
tins (~> 0.8)
|
||||
text-table (1.2.3)
|
||||
thor (0.18.1)
|
||||
timers (1.1.0)
|
||||
tins (0.13.1)
|
||||
treetop (1.4.15)
|
||||
polyglot
|
||||
polyglot (>= 0.3.1)
|
||||
@ -207,5 +209,5 @@ DEPENDENCIES
|
||||
chefspec (~> 3.0.2)
|
||||
foodcritic (~> 3.0.3)
|
||||
json (<= 1.7.7)
|
||||
rubocop (>= 0.16.0)
|
||||
strainer
|
||||
tailor
|
||||
|
10
README.md
10
README.md
@ -247,15 +247,7 @@ EC2 Configuration Attributes
|
||||
Testing
|
||||
=====
|
||||
|
||||
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
|
||||
|
||||
Tests are defined in Strainerfile.
|
||||
|
||||
To run tests:
|
||||
|
||||
$ bundle install # install gem dependencies
|
||||
$ bundle exec berks install # install cookbook dependencies
|
||||
$ bundle exec strainer test # run tests
|
||||
Please refer to the [TESTING.md](TESTING.md) for instructions for testing the cookbook.
|
||||
|
||||
License and Author
|
||||
==================
|
||||
|
@ -1,5 +1,6 @@
|
||||
# Strainerfile
|
||||
tailor: bundle exec tailor
|
||||
rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK/Gemfile $SANDBOX/$COOKBOOK/metadata.rb --config $SANDBOX/$COOKBOOK/.rubocop.yml
|
||||
# rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK
|
||||
knife test: bundle exec knife cookbook test $COOKBOOK
|
||||
foodcritic: bundle exec foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK
|
||||
chefspec: bundle exec rspec $SANDBOX/$COOKBOOK/spec
|
||||
|
42
TESTING.md
Normal file
42
TESTING.md
Normal file
@ -0,0 +1,42 @@
|
||||
# Testing the Cookbook #
|
||||
|
||||
This cookbook uses [bundler](http://gembundler.com/), [berkshelf](http://berkshelf.com/), and [strainer](https://github.com/customink/strainer) to isolate dependencies and run tests.
|
||||
|
||||
Tests are defined in [Strainerfile](Strainerfile), which in turn calls rubocop, knife, foodcritic and chefspec.
|
||||
|
||||
To run all of the tests with Strainer:
|
||||
|
||||
$ bundle exec strainer test -s Strainerfile
|
||||
|
||||
Or you may run the tests individually:
|
||||
|
||||
$ bundle install --path=.bundle # install gem dependencies
|
||||
$ bundle exec berks install --path=.cookbooks # install cookbook dependencies
|
||||
$ bundle exec strainer test -s Strainerfile # run tests
|
||||
|
||||
## Rubocop ##
|
||||
|
||||
[Rubocop](https://github.com/bbatsov/rubocop) is a static Ruby code analyzer, based on the community [Ruby style guide](https://github.com/bbatsov/ruby-style-guide). We are attempting to adhere to this where applicable, slowly cleaning up the cookbooks until we can turn on Rubocop for gating the commits.
|
||||
|
||||
### Attribute Rules ###
|
||||
|
||||
Since there are slight style differences between the coding of attributes, recipes and metadata files there are specific `.rubocop.yml` files for each of:
|
||||
|
||||
[Gemfile and metadata.rb](.rubocop.yml)
|
||||
[attributes/*.rb](attributes/.rubocop.yml)
|
||||
[recipes/.rubocop.yml](recipes/.rubocop.yml)
|
||||
[spec/.rubocop.yml](spec/.rubocop.yml)
|
||||
|
||||
## Knife ##
|
||||
|
||||
[knife cookbook test](http://docs.opscode.com/chef/knife.html#test) is used to check the cookbook's Ruby and ERB files for basic syntax errors.
|
||||
|
||||
## Foodcritic ##
|
||||
|
||||
[Foodcritic](http://acrmp.github.io/foodcritic/) is a lint tool for Chef cookbooks. We ignore the following rules:
|
||||
|
||||
[FC003](http://acrmp.github.io/foodcritic/#FC003) these cookbooks are not intended for Chef Solo.
|
||||
|
||||
## Chefspec
|
||||
|
||||
[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.
|
52
metadata.rb
52
metadata.rb
@ -1,33 +1,33 @@
|
||||
name "openstack-compute"
|
||||
maintainer "Opscode, Inc."
|
||||
maintainer_email "matt@opscode.com"
|
||||
license "Apache 2.0"
|
||||
description "The OpenStack Compute service Nova."
|
||||
name 'openstack-compute'
|
||||
maintainer 'Opscode, Inc.'
|
||||
maintainer_email 'matt@opscode.com'
|
||||
license 'Apache 2.0'
|
||||
description 'The OpenStack Compute service Nova.'
|
||||
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
|
||||
version "8.0.0"
|
||||
version '8.0.0'
|
||||
|
||||
recipe "openstack-compute::api-ec2", "Installs AWS EC2 compatible API"
|
||||
recipe "openstack-compute::api-metadata", "Installs the nova metadata package"
|
||||
recipe "openstack-compute::api-os-compute", "Installs OS API"
|
||||
recipe "openstack-compute::compute", "nova-compute service"
|
||||
recipe "openstack-compute::conductor", "Installs nova conductor service"
|
||||
recipe "openstack-compute::libvirt", "Installs libvirt, used by nova compute for management of the virtual machine environment"
|
||||
recipe "openstack-compute::identity_registration", "Registers the API and EC2 endpoints with Keystone"
|
||||
recipe "openstack-compute::network", "Installs nova network service"
|
||||
recipe "openstack-compute::nova-cert", "Installs nova-cert service"
|
||||
recipe "openstack-compute::nova-common", "Builds the basic nova.conf config file with details of the rabbitmq, mysql, glance and keystone servers"
|
||||
recipe "openstack-compute::nova-setup", "Sets up the nova database on the mysql server, including the initial schema and subsequent creation of the appropriate networks"
|
||||
recipe "openstack-compute::scheduler", "Installs nova scheduler service"
|
||||
recipe "openstack-compute::vncproxy", "Installs and configures the vncproxy service for console access to VMs"
|
||||
recipe 'openstack-compute::api-ec2', 'Installs AWS EC2 compatible API'
|
||||
recipe 'openstack-compute::api-metadata', 'Installs the nova metadata package'
|
||||
recipe 'openstack-compute::api-os-compute', 'Installs OS API'
|
||||
recipe 'openstack-compute::compute', 'nova-compute service'
|
||||
recipe 'openstack-compute::conductor', 'Installs nova conductor service'
|
||||
recipe 'openstack-compute::libvirt', 'Installs libvirt, used by nova compute for management of the virtual machine environment'
|
||||
recipe 'openstack-compute::identity_registration', 'Registers the API and EC2 endpoints with Keystone'
|
||||
recipe 'openstack-compute::network', 'Installs nova network service'
|
||||
recipe 'openstack-compute::nova-cert', 'Installs nova-cert service'
|
||||
recipe 'openstack-compute::nova-common', 'Builds the basic nova.conf config file with details of the rabbitmq, mysql, glance and keystone servers'
|
||||
recipe 'openstack-compute::nova-setup', 'Sets up the nova database on the mysql server, including the initial schema and subsequent creation of the appropriate networks'
|
||||
recipe 'openstack-compute::scheduler', 'Installs nova scheduler service'
|
||||
recipe 'openstack-compute::vncproxy', 'Installs and configures the vncproxy service for console access to VMs'
|
||||
|
||||
%w{ ubuntu fedora redhat centos suse }.each do |os|
|
||||
supports os
|
||||
end
|
||||
|
||||
depends "openstack-common", "~> 8.0"
|
||||
depends "openstack-identity", "~> 8.0"
|
||||
depends "openstack-image", "~> 8.0"
|
||||
depends "openstack-network", "~> 8.0"
|
||||
depends "selinux"
|
||||
depends "yum"
|
||||
depends "python"
|
||||
depends 'openstack-common', '~> 8.0'
|
||||
depends 'openstack-identity', '~> 8.0'
|
||||
depends 'openstack-image', '~> 8.0'
|
||||
depends 'openstack-network', '~> 8.0'
|
||||
depends 'selinux'
|
||||
depends 'yum'
|
||||
depends 'python'
|
||||
|
Loading…
Reference in New Issue
Block a user