Filling out initial rubocop support for metadata.rb and the Gemfile.
https://blueprints.launchpad.net/openstack-chef/+spec/lint-and-unit-testing-for-havana Removing tailor, cleaning up metadata and Gemfile and adding TESTING.md Addresses: blueprint rubocop-for-object-storage Change-Id: Ib5eb85cb179638a3336b3b6add9a2556505ec48a
This commit is contained in:
		
							
								
								
									
										17
									
								
								Gemfile
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								Gemfile
									
									
									
									
									
								
							| @@ -1,10 +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 "webmock", "~> 1.11.0" | ||||
| gem "rubocop" | ||||
| gem 'chef', '~> 11.8' | ||||
| gem 'json', '<= 1.7.7' # chef 11 dependency | ||||
| gem 'berkshelf', '~> 2.0.10' | ||||
| gem 'chefspec', '~> 3.1.4' | ||||
| gem 'foodcritic', '~> 3.0.3' | ||||
| gem 'strainer' | ||||
| gem 'rubocop', '>= 0.16.0' | ||||
|   | ||||
							
								
								
									
										66
									
								
								Gemfile.lock
									
									
									
									
									
								
							
							
						
						
									
										66
									
								
								Gemfile.lock
									
									
									
									
									
								
							| @@ -37,30 +37,41 @@ GEM | ||||
|     celluloid-io (0.14.1) | ||||
|       celluloid (>= 0.14.1) | ||||
|       nio4r (>= 0.4.5) | ||||
|     chef (11.4.4) | ||||
|       erubis | ||||
|       highline (>= 1.6.9) | ||||
|     chef (11.8.2) | ||||
|       chef-zero (~> 1.6, >= 1.6.2) | ||||
|       diff-lcs (~> 1.2, >= 1.2.4) | ||||
|       erubis (~> 2.7) | ||||
|       highline (~> 1.6, >= 1.6.9) | ||||
|       json (>= 1.4.4, <= 1.7.7) | ||||
|       mixlib-authentication (>= 1.3.0) | ||||
|       mixlib-cli (~> 1.3.0) | ||||
|       mixlib-config (>= 1.1.2) | ||||
|       mixlib-log (>= 1.3.0) | ||||
|       mixlib-shellout | ||||
|       mime-types (~> 1.16) | ||||
|       mixlib-authentication (~> 1.3) | ||||
|       mixlib-cli (~> 1.3) | ||||
|       mixlib-config (~> 2.0) | ||||
|       mixlib-log (~> 1.3) | ||||
|       mixlib-shellout (~> 1.2) | ||||
|       net-ssh (~> 2.6) | ||||
|       net-ssh-multi (~> 1.1.0) | ||||
|       ohai (>= 0.6.0) | ||||
|       ohai (~> 6.0) | ||||
|       pry (~> 0.9) | ||||
|       puma (~> 1.6) | ||||
|       rest-client (>= 1.0.4, < 1.7.0) | ||||
|       yajl-ruby (~> 1.1) | ||||
|     chefspec (3.0.2) | ||||
|     chef-zero (1.7.2) | ||||
|       hashie (~> 2.0) | ||||
|       json | ||||
|       mixlib-log (~> 1.3) | ||||
|       moneta (< 0.7.0) | ||||
|       rack | ||||
|     chefspec (3.1.4) | ||||
|       chef (~> 11.0) | ||||
|       fauxhai (~> 2.0) | ||||
|       i18n (>= 0.6.9, < 1.0.0) | ||||
|       rspec (~> 2.14) | ||||
|     chozo (0.6.1) | ||||
|       activesupport (>= 3.2.0) | ||||
|       hashie (>= 2.0.2) | ||||
|       multi_json (>= 1.3.0) | ||||
|     crack (0.4.1) | ||||
|       safe_yaml (~> 0.9.0) | ||||
|     coderay (1.1.0) | ||||
|     diff-lcs (1.2.5) | ||||
|     erubis (2.7.0) | ||||
|     faraday (0.8.8) | ||||
| @@ -94,14 +105,16 @@ GEM | ||||
|     logging (1.8.1) | ||||
|       little-plugger (>= 1.1.3) | ||||
|       multi_json (>= 1.3.6) | ||||
|     mime-types (2.0) | ||||
|     method_source (0.8.2) | ||||
|     mime-types (1.25.1) | ||||
|     minitar (0.5.4) | ||||
|     mixlib-authentication (1.3.0) | ||||
|       mixlib-log | ||||
|     mixlib-cli (1.3.0) | ||||
|     mixlib-cli (1.4.0) | ||||
|     mixlib-config (2.1.0) | ||||
|     mixlib-log (1.6.0) | ||||
|     mixlib-shellout (1.3.0) | ||||
|     moneta (0.6.0) | ||||
|     multi_json (1.8.2) | ||||
|     multipart-post (1.2.0) | ||||
|     net-http-persistent (2.9) | ||||
| @@ -122,13 +135,19 @@ GEM | ||||
|       mixlib-shellout | ||||
|       systemu (~> 2.5.2) | ||||
|       yajl-ruby | ||||
|     parser (2.0.0) | ||||
|     parser (2.1.2) | ||||
|       ast (~> 1.1) | ||||
|       slop (~> 3.4, >= 3.4.5) | ||||
|     polyglot (0.3.3) | ||||
|     powerpack (0.0.9) | ||||
|     pry (0.9.12.4) | ||||
|       coderay (~> 1.0) | ||||
|       method_source (~> 0.8) | ||||
|       slop (~> 3.4) | ||||
|     puma (1.6.3) | ||||
|       rack (~> 1.2) | ||||
|     rack (1.5.2) | ||||
|     rainbow (1.1.4) | ||||
|     rainbow (1.99.1) | ||||
|     rake (10.1.0) | ||||
|     rbzip2 (0.2.0) | ||||
|     rest-client (1.6.7) | ||||
| @@ -162,12 +181,11 @@ GEM | ||||
|     rspec-expectations (2.14.4) | ||||
|       diff-lcs (>= 1.1.3, < 2.0) | ||||
|     rspec-mocks (2.14.4) | ||||
|     rubocop (0.15.0) | ||||
|       parser (~> 2.0) | ||||
|     rubocop (0.16.0) | ||||
|       parser (~> 2.1) | ||||
|       powerpack (~> 0.0.6) | ||||
|       rainbow (>= 1.1.4) | ||||
|     rubyntlm (0.1.1) | ||||
|     safe_yaml (0.9.7) | ||||
|     savon (0.9.5) | ||||
|       akami (~> 1.0) | ||||
|       builder (>= 2.1.2) | ||||
| @@ -193,9 +211,6 @@ GEM | ||||
|       hashie (>= 2.0.2) | ||||
|     wasabi (1.0.0) | ||||
|       nokogiri (>= 1.4.0) | ||||
|     webmock (1.11.0) | ||||
|       addressable (>= 2.2.7) | ||||
|       crack (>= 0.3.2) | ||||
|     winrm (1.1.3) | ||||
|       gssapi (~> 1.0.0) | ||||
|       httpclient (~> 2.2, >= 2.2.0.2) | ||||
| @@ -211,10 +226,9 @@ PLATFORMS | ||||
|  | ||||
| DEPENDENCIES | ||||
|   berkshelf (~> 2.0.10) | ||||
|   chef (~> 11.4.4) | ||||
|   chefspec (~> 3.0.2) | ||||
|   chef (~> 11.8) | ||||
|   chefspec (~> 3.1.4) | ||||
|   foodcritic (~> 3.0.3) | ||||
|   json (<= 1.7.7) | ||||
|   rubocop | ||||
|   rubocop (>= 0.16.0) | ||||
|   strainer | ||||
|   webmock (~> 1.11.0) | ||||
|   | ||||
							
								
								
									
										14
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								README.md
									
									
									
									
									
								
							| @@ -237,19 +237,7 @@ Standalone Proxy Server | ||||
| Testing | ||||
| ======= | ||||
|  | ||||
| This cookbook is using [ChefSpec](https://github.com/acrmp/chefspec) for testing. Run the following before commiting. It will run your tests, and check for lint errors. | ||||
|  | ||||
|     $ ./run_tests.bash | ||||
|  | ||||
| There is also a Vagrant test environment that you can launch in order to integration | ||||
| test this cookbook. See the <a href="tests/README.md" target="_blank">tests/README.md</a> file for more information on launching the environment. | ||||
|  | ||||
| Testing | ||||
| ======= | ||||
|  | ||||
|     $ bundle install | ||||
|     $ bundle exec berks install | ||||
|     $ bundle exec strainer test | ||||
| Please refer to the [TESTING.md](TESTING.md) for instructions for testing the cookbook. | ||||
|  | ||||
| License and Author | ||||
| ================== | ||||
|   | ||||
| @@ -1,5 +1,6 @@ | ||||
| # Strainerfile | ||||
| rubocop: bundle exec rubocop $SANDBOX/$COOKBOOK | ||||
| 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 | ||||
| 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. | ||||
							
								
								
									
										28
									
								
								metadata.rb
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								metadata.rb
									
									
									
									
									
								
							| @@ -1,20 +1,20 @@ | ||||
| name              "openstack-object-storage" | ||||
| maintainer        "ATT, Inc." | ||||
| license           "Apache 2.0" | ||||
| description       "Installs and configures Openstack Swift" | ||||
| name              'openstack-object-storage' | ||||
| maintainer        'ATT, Inc.' | ||||
| license           'Apache 2.0' | ||||
| description       'Installs and configures Openstack Swift' | ||||
| long_description  IO.read(File.join(File.dirname(__FILE__), 'README.md')) | ||||
| version           "8.0.0" | ||||
| recipe            "openstack-object-storage::setup", "Does initial setup of a swift cluster" | ||||
| recipe            "openstack-object-storage::account-server", "Installs the swift account server" | ||||
| recipe            "openstack-object-storage::object-server", "Installs the swift object server" | ||||
| recipe            "openstack-object-storage::proxy-server", "Installs the swift proxy server" | ||||
| recipe            "openstack-object-storage::container-server", "Installs the swift container server" | ||||
| version           '8.0.0' | ||||
| recipe            'openstack-object-storage::setup', 'Does initial setup of a swift cluster' | ||||
| recipe            'openstack-object-storage::account-server', 'Installs the swift account server' | ||||
| recipe            'openstack-object-storage::object-server', 'Installs the swift object server' | ||||
| recipe            'openstack-object-storage::proxy-server', 'Installs the swift proxy server' | ||||
| recipe            'openstack-object-storage::container-server', 'Installs the swift container server' | ||||
|  | ||||
| %w{ centos ubuntu }.each do |os| | ||||
|   supports os | ||||
| end | ||||
|  | ||||
| depends "memcached" | ||||
| depends "sysctl" | ||||
| depends "statsd" | ||||
| depends "apt" | ||||
| depends 'memcached' | ||||
| depends 'sysctl' | ||||
| depends 'statsd' | ||||
| depends 'apt' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Matt Ray
					Matt Ray