Skip to content

Commit

Permalink
Syntax/lint checks / unit tests / integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
djoos committed Apr 4, 2014
1 parent 8cd7b4b commit c4d8464
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 90 deletions.
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
.vagrant
Vagrantfile

Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
/cookbooks

# Bundler
cookbooks
.coverage
spec

Berksfile.lock
Gemfile.lock
.vagrant
Vagrantfile
bin/*
.bundle/*

.kitchen
.kitchen.local.yml
123 changes: 67 additions & 56 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,56 +1,67 @@
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true

platforms:
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
# - name: ubuntu-13.04
# driver_config:
# box: opscode-ubuntu-13.04
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box
# - name: centos-6.3
# driver_config:
# box: opscode-centos-6.3
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.3_provisionerless.box
- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box

suites:
- name: default
run_list:
- recipe[newrelic::default]
attributes:
newrelic:
service_notify_action: nothing
service_actions:
- nothing
# - name: dotnet-agent
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::dotnet-agent]
# - name: java-agent
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::java-agent]
# - name: nodejs-agent
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::nodejs-agent]
# - name: php-agent
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::php-agent]
# - name: python-agent
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::python-agent]
# - name: meetme-plugin
# run_list:
# - recipe[newrelic::default]
# - recipe[newrelic::meetme-plugin]
---
driver_plugin: vagrant
driver_config:
require_chef_omnibus: true

platforms:
- name: ubuntu-12.04
driver_config:
box: opscode-ubuntu-12.04
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box
# - name: ubuntu-13.04
# driver_config:
# box: opscode-ubuntu-13.04
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_ubuntu-13.04_provisionerless.box
# - name: centos-6.3
# driver_config:
# box: opscode-centos-6.3
# box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.3_provisionerless.box
- name: centos-6.4
driver_config:
box: opscode-centos-6.4
box_url: https://opscode-vm-bento.s3.amazonaws.com/vagrant/opscode_centos-6.4_provisionerless.box

suites:
- name: default
run_list:
- recipe[newrelic::default]
attributes:
newrelic:
license: 78defba8b120b1f16f269f6f53bac7234fe83ee9
# server-monitor-agent:
# service_notify_action: nothing
# service_actions:
# - nothing
# - name: dotnet-agent
# run_list:
# - recipe[newrelic::dotnet-agent]
# - name: java-agent
# run_list:
# - recipe[newrelic::java-agent]
# - name: meetme-plugin
# run_list:
# - recipe[newrelic::meetme-plugin]
# - name: nodejs-agent
# run_list:
# - recipe[newrelic::nodejs-agent]
# - name: php-agent
# run_list:
# - recipe[newrelic::php-agent]
# - name: python-agent
# run_list:
# - recipe[newrelic::python-agent]
- name: repository
run_list:
- recipe[newrelic::repository]
# - name: ruby-agent
# run_list:
# - recipe[newrelic::ruby-agent]
- name: server-monitor-agent
run_list:
- recipe[newrelic::server-monitor-agent]
attributes:
newrelic:
server-monitor-agent:
service_notify_action: nothing
service_actions:
- nothing
23 changes: 23 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
AlignParameters:
Enabled: false

FileName:
Enabled: false

Encoding:
Enabled: false

LineLength:
Max: 200

HashSyntax:
EnforcedStyle: hash_rockets

RedundantBegin:
Enabled: false

UselessAssignment:
Enabled: false

MethodLength:
Enabled: false
6 changes: 5 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ before_script:
- bundle exec berks install

script:
- bundle exec foodcritic -f any .
- bundle exec rake travis

branches:
only:
- master

notifications:
email:
Expand Down
15 changes: 15 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Contributing
=========

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. [Add tests for your changes](https://github.com/escapestudios-cookbooks/newrelic/blob/master/TESTING.md)
4. Push your changes to your feature branch (`git push origin my-new-feature`)
5. Create a new Pull Request (PR)

## Testing
Contributions will only be accepted if they are fully tested as specified in [TESTING.md](https://github.com/escapestudios-cookbooks/newrelic/blob/master/TESTING.md).

## metadata.rb
Please do not modify the version number in the metadata.rb; not all changes to the cookbook may be merged and released in the same version. We will handle the version updates during the release process.
17 changes: 14 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
source 'https://rubygems.org'

gem 'foodcritic'
gem 'berkshelf'
gem 'test-kitchen'
gem 'kitchen-vagrant'

group :testing do
gem 'rake'
gem 'rubocop'
gem 'foodcritic'
gem 'chefspec'
gem 'thor'
end

group :integration do
gem 'test-kitchen'
gem 'kitchen-vagrant'
gem 'serverspec'
end
61 changes: 61 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
require 'foodcritic'
require 'kitchen'

#syntax/lint checks
namespace :lint do
desc 'Run Ruby syntax/lint checks'
Rubocop::RakeTask.new(:ruby)

desc 'Run Chef syntax/lint checks'
FoodCritic::Rake::LintTask.new(:chef) { |task|
task.options = { fail_tags: ['any'] }
}
end

desc 'Run all syntax/lint checks'
task lint: ['lint:ruby', 'lint:chef']

#unit testing: ChefSpec
desc 'Run RSpec and ChefSpec unit tests'
RSpec::Core::RakeTask.new(:unit)

#integration testing: Test Kitchen
namespace :integration do
desc 'Run Test Kitchen integration tests with Vagrant'
task :vagrant do
Kitchen.logger = Kitchen.default_file_logger
Kitchen::Config.new.instances.each do |instance|
instance.test(:always)
end
end

# desc 'Run Test Kitchen integration tests with cloud plugins'
# task :cloud do
# run_kitchen = true
# if ENV['TRAVIS'] == 'true' && ENV['TRAVIS_PULL_REQUEST'] != 'false'
# run_kitchen = false
# end
#
# if run_kitchen
# Kitchen.logger = Kitchen.default_file_logger
# @loader = Kitchen::Loader::YAML.new(project_config: './.kitchen.cloud.yml')
# config = Kitchen::Config.new( loader: @loader)
# config.instances.each do |instance|
# instance.test(:always)
# end
# end
# end
end

desc 'Run all integration tests'
#task integration: ['integration:vagrant', 'integration:cloud']
task integration: ['integration:vagrant']

#Travic CI
desc 'Run tests on Travis CI'
task travis: ['lint', 'unit']

#the default rake task should just run it all
task default: ['lint', 'unit', 'integration']
47 changes: 47 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
Testing the cookbook
====================

Contributions to this cookbook will only be accepted if all tests pass successfully:

* Ruby syntax/lint checks: [RuboCop](http://batsov.com/rubocop/)
* Chef syntax/lint checks: [Foodcritic](http://acrmp.github.io/foodcritic/)
* Unit tests: [ChefSpec](http://code.sethvargo.com/chefspec/)
* Integration tests: [Test Kitchen](http://kitchen.ci/)

Setting up the test environment
-------------------------------

Install the latest version of [Vagrant](http://www.vagrantup.com/downloads.html) and [VirtualBox](https://www.virtualbox.org/wiki/Downloads) (free) or [VMWare Fusion](http://www.vmware.com/products/fusion) (paid).

Clone the latest version of the cookbook from the repository.

git clone [email protected]:escapestudios-cookbooks/newrelic.git
cd newrelic

Install the gems used for testing:

bundle install

Install the berkshelf plugin for vagrant:

vagrant plugin install vagrant-berkshelf

Running syntax/lint checks
--------------------------

bundle exec rake lint

Running unit tests
------------------

bundle exec rake unit

Running integration tests
-------------------------

bundle exec rake integration

Running all checks/tests
------------------------

bundle exec rake
46 changes: 23 additions & 23 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
name "newrelic"
maintainer "Escape Studios"
maintainer_email "[email protected]"
license "MIT"
description "Installs/Configures New Relic"
name 'newrelic'
maintainer 'Escape Studios'
maintainer_email '[email protected]'
license 'MIT'
description 'Installs/Configures New Relic'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.0.1"
version '1.0.1'

%w{ debian ubuntu redhat centos fedora scientific amazon windows smartos }.each do |os|
supports os
%w({ debian ubuntu redhat centos fedora scientific amazon windows smartos }).each do |os|
supports os
end

depends "python"
depends 'python'

recommends "php"
recommends "ms_dotnet4"
recommends "curl"
recommends "nodejs"
recommends 'php'
recommends 'ms_dotnet4'
recommends 'curl'
recommends 'nodejs'

recipe "newrelic", "Adds the New Relic repository, installs & configures the New Relic server monitor agent."
recipe "newrelic::repository", "Adds the New Relic repository."
recipe "newrelic::server-monitor-agent", "Installs & configures the New Relic server monitor agent."
recipe "newrelic::dotnet-agent", "Installs New Relic .NET agent"
recipe "newrelic::java-agent", "Installs the New Relic Java agent."
recipe "newrelic::nodejs-agent", "Installs New Relic Node.js agent"
recipe "newrelic::php-agent", "Installs the New Relic PHP agent."
recipe "newrelic::python-agent", "Installs the New Relic Python agent."
recipe "newrelic::ruby-agent", "Installs the New Relic Ruby agent."
recipe "newrelic::meetme-plugin", "Installs the New Relic MeetMe plugin."
recipe 'newrelic', 'Adds the New Relic repository, installs & configures the New Relic server monitor agent.'
recipe 'newrelic::repository', 'Adds the New Relic repository.'
recipe 'newrelic::server-monitor-agent', 'Installs & configures the New Relic server monitor agent.'
recipe 'newrelic::dotnet-agent', 'Installs New Relic .NET agent.'
recipe 'newrelic::java-agent', 'Installs the New Relic Java agent.'
recipe 'newrelic::nodejs-agent', 'Installs New Relic Node.js agent.'
recipe 'newrelic::php-agent', 'Installs the New Relic PHP agent.'
recipe 'newrelic::python-agent', 'Installs the New Relic Python agent.'
recipe 'newrelic::ruby-agent', 'Installs the New Relic Ruby agent.'
recipe 'newrelic::meetme-plugin', 'Installs the New Relic MeetMe plugin.'

0 comments on commit c4d8464

Please sign in to comment.