Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
Add Travis CI, Rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
sethvargo committed Sep 18, 2013
1 parent 6b38928 commit 210e9f7
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 65 deletions.
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
AllCops:
Excludes:
- vendor/**

AlignParameters:
Enabled: false
Encoding:
Enabled: false
HashSyntax:
Enabled: false
LineLength:
Enabled: false
MethodLength:
Max: 30
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rvm:
- 1.9.3
- 2.0.0
before_script:
- bundle exec berks install
script:
- bundle exec foodcritic -f any .
- bundle exec rubocop
5 changes: 2 additions & 3 deletions Berksfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
site :opscode

metadata

group :integration do
cookbook "apt"
cookbook "yum"
cookbook 'apt', '~> 2.0'
cookbook 'yum', '~> 2.0'
end
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
activemq Cookbook
=================
[![Build Status](https://secure.travis-ci.org/opscode-cookbooks/activemq.png?branch=master)](http://travis-ci.org/opscode-cookbooks/activemq)

Installs activemq and sets up a service using the init script that comes with it.


Expand Down Expand Up @@ -29,6 +31,39 @@ Usage
Simply add `recipe[activemq]` to a run list.


Development
-----------
This section details "quick development" steps. For a detailed explanation, see [[Contributing.md]].

1. Clone this repository from GitHub:

$ git clone [email protected]:opscode-cookbooks/activemq.git

2. Create a git branch

$ git checkout -b my_bug_fix

3. Install dependencies:

$ bundle install

4. Make your changes/patches/fixes, committing appropiately
5. **Write tests**
6. Run the tests:

- `bundle exec foodcritic -f any .`
- `bundle exec rspec`
- `bundle exec rubocop`
- `bundle exec kitchen test`

In detail:

- Foodcritic will catch any Chef-specific style errors
- RSpec will run the unit tests
- Rubocop will check for Ruby-specific style errors
- Test Kitchen will run and converge the recipes


License & Authors
-----------------
- Author:: Joshua Timberman (<[email protected]>)
Expand Down
59 changes: 44 additions & 15 deletions TESTING.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,54 @@
This cookbook includes support for running tests via Test Kitchen (1.0). This has some requirements.
This cookbook uses a variety of testing components:

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

Once the above requirements are met, install the additional requirements:

Install the berkshelf plugin for vagrant, and berkshelf to your local Ruby environment.
Prerequisites
-------------
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.

vagrant plugin install vagrant-berkshelf
gem install berkshelf
You must also have `bundler` installed:

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

gem install test-kitchen --pre
You must also have Vagrant and VirtualBox installed:

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

gem install kitchen-vagrant
Once installed, you must install the `vagrant-berkshelf` plugin:

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

kitchen list
kitchen test

Development
-----------
1. Clone the git repository from GitHub:

$ git clone [email protected]:opscode-cookbooks/COOKBOOK.git

2. Install the dependencies using bundler:

$ bundle install

3. Create a branch for your changes:

$ git checkout -b my_bug_fix

4. Make any changes
5. Write tests to support those changes. It is highly recommended you write both unit and integration tests.
6. Run the tests:

- `bundle exec rspec`
- `bundle exec foodcritic .`
- `bundle exec rubocop`
- `bundle exec kitchen test`

7. Assuming the tests pass, open a Pull Request on GitHub
8. Open a JIRA ticket for this compontent, linking the JIRA ticket to the Pull Request and visa versa.
9. Mark the JIRA ticket as "Fix Provided"

For more information, see [Opscode's Contribution Guidelines](https://wiki.opscode.com/display/chef/How+to+Contribute).
10 changes: 5 additions & 5 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
# limitations under the License.
#

default['activemq']['mirror'] = "http://apache.mirrors.tds.net"
default['activemq']['version'] = "5.8.0"
default['activemq']['home'] = "/opt"
default['activemq']['wrapper']['max_memory'] = "1024"
default['activemq']['wrapper']['useDedicatedTaskRunner'] = "true"
default['activemq']['mirror'] = 'http://apache.mirrors.tds.net'
default['activemq']['version'] = '5.8.0'
default['activemq']['home'] = '/opt'
default['activemq']['wrapper']['max_memory'] = '1024'
default['activemq']['wrapper']['useDedicatedTaskRunner'] = 'true'

default['activemq']['enable_stomp'] = true
default['activemq']['use_default_config'] = false
21 changes: 11 additions & 10 deletions libraries/chef_activemq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#
#
class Chef
# ActiveMQ helper module
module ActiveMQ
# Returns the name of the jar file that contains the ActiveMQ main classes. Since ActiveMQ 5.8.0 the name
# of such jar file is "activemq.jar", prior to that it was "run.jar".
Expand All @@ -26,17 +27,17 @@ module ActiveMQ
#
# @return [String] the name of the ActiveMQ jar file that should be included in the JVM Classpath.
def self.get_amq_jar_name(node)
version = node['activemq']['version']
vMj, vMn, vRev = version.split('.').map { |v| Integer(v) rescue nil }
version = node['activemq']['version']
major, minor, _ = version.split('.').map(&:to_i)

case
when vMj == 5 && vMn >= 8
'activemq.jar'
when vMj >= 6
'activemq.jar'
else
'run.jar'
end
case
when major == 5 && minor >= 8
'activemq.jar'
when major >= 6
'activemq.jar'
else
'run.jar'
end
end
end
end
18 changes: 8 additions & 10 deletions metadata.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name "activemq"
maintainer "Opscode, Inc."
maintainer_email "[email protected]"
license "Apache 2.0"
description "Installs activemq and sets it up as service"
name 'activemq'
maintainer 'Opscode, Inc.'
maintainer_email '[email protected]'
license 'Apache 2.0'
description 'Installs activemq and sets it up as service'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.2.1"
version '1.2.1'

%w{ubuntu debian redhat centos suse}.each do |os|
%w(ubuntu debian redhat centos suse).each do |os|
supports os
end

%w{java}.each do |cb|
depends cb
end
depends 'java', '~> 1.13'
43 changes: 21 additions & 22 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# limitations under the License.
#

include_recipe "java"
include_recipe 'java::default'

tmp = Chef::Config[:file_cache_path]
version = node['activemq']['version']
Expand All @@ -31,7 +31,7 @@
unless File.exists?("#{activemq_home}/bin/activemq")
remote_file "#{tmp}/apache-activemq-#{version}-bin.tar.gz" do
source "#{mirror}/activemq/apache-activemq/#{version}/apache-activemq-#{version}-bin.tar.gz"
mode "0644"
mode '0644'
end

execute "tar zxf #{tmp}/apache-activemq-#{version}-bin.tar.gz" do
Expand All @@ -40,31 +40,30 @@
end

file "#{activemq_home}/bin/activemq" do
owner "root"
group "root"
mode "0755"
owner 'root'
group 'root'
mode '0755'
end

# TODO: make this more robust
arch = (node['kernel']['machine'] == "x86_64") ? "x86-64" : "x86-32"
arch = node['kernel']['machine'] == 'x86_64' ? 'x86-64' : 'x86-32'

link "/etc/init.d/activemq" do
link '/etc/init.d/activemq' do
to "#{activemq_home}/bin/linux-#{arch}/activemq"
end

if node['activemq']['use_default_config']
template "#{activemq_home}/conf/activemq.xml" do
source "activemq.xml.erb"
mode "0755"
owner "root"
group "root"
notifies :restart, "service[activemq]"
end
template "#{activemq_home}/conf/activemq.xml" do
source 'activemq.xml.erb'
mode '0755'
owner 'root'
group 'root'
notifies :restart, 'service[activemq]'
only_if { node['activemq']['use_default_config'] }
end

service "activemq" do
supports :restart => true, :status => true
action [:enable, :start]
service 'activemq' do
supports :restart => true, :status => true
action [:enable, :start]
end

# symlink so the default wrapper.conf can find the native wrapper library
Expand All @@ -73,13 +72,13 @@
end

# symlink the wrapper's pidfile location into /var/run
link "/var/run/activemq.pid" do
link '/var/run/activemq.pid' do
to "#{activemq_home}/bin/linux/ActiveMQ.pid"
not_if "test -f /var/run/activemq.pid"
not_if 'test -f /var/run/activemq.pid'
end

template "#{activemq_home}/bin/linux/wrapper.conf" do
source "wrapper.conf.erb"
mode 0644
source 'wrapper.conf.erb'
mode '0644'
notifies :restart, 'service[activemq]'
end

0 comments on commit 210e9f7

Please sign in to comment.