Skip to content

Commit 9cb8803

Browse files
committed
[COOK-3572] Add Test Kitchen, Specs, Travis CI
Signed-off-by: Seth Vargo <sethvargo@gmail.com>
1 parent f25558a commit 9cb8803

File tree

37 files changed

+357
-416
lines changed

37 files changed

+357
-416
lines changed

.chef/knife.rb

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
1-
.vagrant
2-
Berksfile.lock
3-
Gemfile.lock
41
*~
52
*#
63
.#*
74
\#*#
85
.*.sw[a-z]
96
*.un~
10-
.bundle
11-
.cache
12-
.kitchen
13-
bin
7+
*.tmp
8+
*.bk
9+
*.bkup
1410
.kitchen.local.yml
11+
Berksfile.lock
12+
Gemfile.lock
13+
14+
.bundle/
15+
.cache/
16+
.kitchen/
17+
.vagrant/
18+
.vagrant.d/
19+
bin/
20+
tmp/
21+
vendor/

.kitchen.yml

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,21 @@
1-
---
21
driver_plugin: vagrant
32
driver_config:
43
require_chef_omnibus: true
54

65
platforms:
7-
- name: ubuntu-12.04
8-
driver_config:
9-
box: opscode-ubuntu-12.04
10-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
11-
run_list:
12-
- recipe[apt]
13-
14-
- name: ubuntu-10.04
15-
driver_config:
16-
box: opscode-ubuntu-10.04
17-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-10.04_provisionerless.box
18-
run_list:
19-
- recipe[apt]
20-
21-
- name: centos-6.4
22-
driver_config:
23-
box: opscode-centos-6.4
24-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box
25-
26-
- name: centos-5.9
27-
driver_config:
28-
box: opscode-centos-5.9
29-
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-5.9_provisionerless.box
6+
- name: ubuntu-12.04
7+
run_list:
8+
- recipe[apt]
9+
- name: ubuntu-10.04
10+
run_list:
11+
- recipe[apt]
12+
- name: centos-6.4
13+
- name: centos-5.9
3014

3115
suites:
32-
- name: default
33-
run_list:
34-
- recipe[sudo]
35-
attributes: {}
16+
- name: default
17+
run_list:
18+
- recipe[fake::default]
19+
- name: create
20+
run_list:
21+
- recipe[fake::create]

.rspec

Lines changed: 0 additions & 2 deletions
This file was deleted.

.rubocop.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
AllCops:
2+
Excludes:
3+
- vendor/**
4+
5+
AlignParameters:
6+
Enabled: false
7+
Encoding:
8+
Enabled: false
9+
HashSyntax:
10+
Enabled: false
11+
LineLength:
12+
Enabled: false
13+
MethodLength:
14+
Max: 30
15+

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rvm:
2+
- 1.9.3
3+
- 2.0.0
4+
before_script:
5+
- bundle exec berks install
6+
script:
7+
- bundle exec foodcritic -f any .
8+
- bundle exec rspec --color --format progress
9+
- bundle exec rubocop

Berksfile

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
site :opscode
2-
32
metadata
43

54
group :integration do
6-
cookbook "apt"
7-
cookbook "yum"
5+
cookbook 'apt', '~> 2.0'
6+
cookbook 'fake', path: 'test/fixtures/cookbooks/fake'
87
end

Gemfile

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
source :rubygems
1+
source 'http://rubygems.org'
22

3-
gem 'chef'
4-
gem 'rake'
3+
gem 'berkshelf', '~> 2.0'
4+
gem 'chefspec', '~> 2.0'
5+
gem 'foodcritic', '~> 2.2'
6+
gem 'rubocop', '~> 0.12'
57

6-
group :test do
7-
gem 'chefspec'
8-
gem 'fauxhai'
9-
gem 'foodcritic'
10-
gem 'fuubar'
11-
gem 'test-kitchen', '< 1.0'
8+
group :integration do
9+
gem 'test-kitchen', '~> 1.0.0.beta'
10+
gem 'kitchen-vagrant', '~> 0.11'
1211
end

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
sudo cookbook
22
=============
3+
[![Build Status](https://secure.travis-ci.org/opscode-cookbooks/sudo.png?branch=master)](http://travis-ci.org/opscode-cookbooks/sudo)
4+
35
The Chef `sudo` cookbook installs the `sudo` package and configures the `/etc/sudoers` file.
46

57
It also exposes an LWRP for adding and managing sudoers.
@@ -216,6 +218,41 @@ case it is not already</td>
216218
**If you use the template attribute, all other attributes will be ignored except for the variables attribute.**
217219

218220

221+
Development
222+
-----------
223+
This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].
224+
225+
1. Clone this repository from GitHub:
226+
227+
$ git clone git@github.com:opscode-cookbooks/sudo.git
228+
229+
2. Create a git branch
230+
231+
$ git checkout -b my_bug_fix
232+
233+
3. Install dependencies:
234+
235+
$ bundle install
236+
237+
4. Make your changes/patches/fixes, committing appropiately
238+
5. **Write tests**
239+
6. Run the tests:
240+
241+
- `bundle exec foodcritic -f any .`
242+
- `bundle exec rspec`
243+
- `bundle exec rubocop`
244+
- `bundle exec kitchen test`
245+
246+
In detail:
247+
248+
- Foodcritic will catch any Chef-specific style errors
249+
- RSpec will run the unit tests
250+
- Rubocop will check for Ruby-specific style errors
251+
- Test Kitchen will run and converge the recipes
252+
253+
254+
255+
219256
License and Authors
220257
-------------------
221258
- Author:: Bryan W. Berry <bryan.berry@gmail.com>

TESTING.md

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,54 @@
1-
This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
1+
This cookbook uses a variety of testing components:
22

3-
1. You must be using the Git repository, rather than the downloaded cookbook from the Chef Community Site.
4-
2. You must have Vagrant 1.1 installed.
5-
3. You must have a "sane" Ruby 1.9.3 environment.
3+
- Unit tests: [ChefSpec](https://github.com/acrmp/chefspec)
4+
- Integration tests: [Test Kitchen](https://github.com/opscode/test-kitchen)
5+
- Chef Style lints: [Foodcritic](https://github.com/acrmp/foodcritic)
6+
- Ruby Style lints: [Rubocop](https://github.com/bbatsov/rubocop)
67

7-
Once the above requirements are met, install the additional requirements:
88

9-
Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
9+
Prerequisites
10+
-------------
11+
To develop on this cookbook, you must have a sane Ruby 1.9+ environment. Given the nature of this installation process (and it's variance across multiple operating systems), we will leave this installation process to the user.
1012

11-
vagrant plugin install vagrant-berkshelf
12-
gem install berkshelf
13+
You must also have `bundler` installed:
1314

14-
Install Test Kitchen 1.0 (unreleased yet, use the alpha / prerelease version).
15+
$ gem install bundler
1516

16-
gem install test-kitchen --pre
17+
You must also have Vagrant and VirtualBox installed:
1718

18-
Install the Vagrant driver for Test Kitchen.
19+
- [Vagrant](https://vagrantup.com)
20+
- [VirtualBox](https://virtualbox.org)
1921

20-
gem install kitchen-vagrant
22+
Once installed, you must install the `vagrant-berkshelf` plugin:
2123

22-
Once the above are installed, you should be able to run Test Kitchen:
24+
$ vagrant plugin install vagrant-berkshelf
2325

24-
kitchen list
25-
kitchen test
26+
27+
Development
28+
-----------
29+
1. Clone the git repository from GitHub:
30+
31+
$ git clone git@github.com:opscode-cookbooks/COOKBOOK.git
32+
33+
2. Install the dependencies using bundler:
34+
35+
$ bundle install
36+
37+
3. Create a branch for your changes:
38+
39+
$ git checkout -b my_bug_fix
40+
41+
4. Make any changes
42+
5. Write tests to support those changes. It is highly recommended you write both unit and integration tests.
43+
6. Run the tests:
44+
45+
- `bundle exec rspec`
46+
- `bundle exec foodcritic .`
47+
- `bundle exec rubocop`
48+
- `bundle exec kitchen test`
49+
50+
7. Assuming the tests pass, open a Pull Request on GitHub
51+
8. Open a JIRA ticket for this component, linking the JIRA ticket to the Pull Request and visa versa.
52+
9. Mark the JIRA ticket as "Fix Provided"
53+
54+
For more information, see [Opscode's Contribution Guidelines](https://wiki.opscode.com/display/chef/How+to+Contribute).

0 commit comments

Comments
 (0)