From 1f7545b213c18a4a0bca22a7b7960fca98bbb79f Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:04:31 +0100 Subject: [PATCH 1/8] add testing dependencies --- Gemfile | 13 +++++++++++++ Gemfile.lock | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 Gemfile create mode 100644 Gemfile.lock diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..43256ba --- /dev/null +++ b/Gemfile @@ -0,0 +1,13 @@ +source "http://rubygems.org" + +if ENV.key?('PUPPET_VERSION') + puppetversion = "= #{ENV['PUPPET_VERSION']}" +else + puppetversion = ['~> 2.7'] +end + +gem "rake" +gem "puppet", puppetversion +gem "puppet-lint" +gem "rspec-puppet" +gem "puppetlabs_spec_helper" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e5efb1b --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,37 @@ +GEM + remote: http://rubygems.org/ + specs: + diff-lcs (1.2.2) + facter (1.6.18) + metaclass (0.0.1) + mocha (0.13.3) + metaclass (~> 0.0.1) + puppet (2.7.21) + facter (~> 1.5) + puppet-lint (0.3.2) + puppetlabs_spec_helper (0.4.1) + mocha (>= 0.10.5) + rake + rspec (>= 2.9.0) + rspec-puppet (>= 0.1.1) + rake (10.0.4) + rspec (2.13.0) + rspec-core (~> 2.13.0) + rspec-expectations (~> 2.13.0) + rspec-mocks (~> 2.13.0) + rspec-core (2.13.1) + rspec-expectations (2.13.0) + diff-lcs (>= 1.1.3, < 2.0) + rspec-mocks (2.13.0) + rspec-puppet (0.1.6) + rspec + +PLATFORMS + ruby + +DEPENDENCIES + puppet (~> 2.7) + puppet-lint + puppetlabs_spec_helper + rake + rspec-puppet From d15243493bdc35ab1080847609db73130f5afcaa Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:04:57 +0100 Subject: [PATCH 2/8] add puppet module dependencies for testing --- .fixtures.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .fixtures.yml diff --git a/.fixtures.yml b/.fixtures.yml new file mode 100644 index 0000000..d78d3c7 --- /dev/null +++ b/.fixtures.yml @@ -0,0 +1,5 @@ +fixtures: + repositories: + stdlib: git://github.com/puppetlabs/puppetlabs-stdlib.git + symlinks: + java: "#{source_dir}" From 6a4ca4f7c7795c2d2eb07db6866ed2ad45a76f5b Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:05:40 +0100 Subject: [PATCH 3/8] add rake file to run tests and build module --- Rakefile | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Rakefile diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..bb968be --- /dev/null +++ b/Rakefile @@ -0,0 +1,5 @@ +require 'puppetlabs_spec_helper/rake_tasks' +require 'puppet-lint/tasks/puppet-lint' + +PuppetLint.configuration.send("disable_80chars") +PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}" From 1d5c5992ab6bcbfe8091bd6b6f8bead44e48fa25 Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:06:16 +0100 Subject: [PATCH 4/8] ignore fixtures downloaded by test runner --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 79d3358..73879ef 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ pkg/ .DS_Store metadata.json +spec/fixtures From 4b54bab0cb02f2f643e6641329aa87714f24be23 Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:07:20 +0100 Subject: [PATCH 5/8] add tests for the current an expected centos behaviour --- spec/classes/java_spec.rb | 26 ++++++++++++++++++++++++++ spec/spec.opts | 6 ------ spec/spec_helper.rb | 19 +------------------ 3 files changed, 27 insertions(+), 24 deletions(-) create mode 100644 spec/classes/java_spec.rb delete mode 100644 spec/spec.opts diff --git a/spec/classes/java_spec.rb b/spec/classes/java_spec.rb new file mode 100644 index 0000000..c4e962e --- /dev/null +++ b/spec/classes/java_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +describe 'java', :type => :class do + + context 'select openjdk for Centos 5.8' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8'} } + it { should contain_package('java').with_name('java-1.7.0-openjdk') } + end + + context 'select openjdk for Centos 6.3' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.8'} } + it { should contain_package('java').with_name('java-1.7.0-openjdk') } + end + + context 'select default for Centos 5.3' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} } + it { should contain_package('java').with_name('jdk') } + end + + context 'select passed value for Centos 5.3' do + let(:facts) { {:osfamily => 'RedHat', :operatingsystem => 'Centos', :operatingsystemrelease => '5.3'} } + let(:params) { { 'distribution' => 'java-1.6.0-openjdk' } } + it { should contain_package('java').with_name('java-1.6.0-openjdk') } + end + +end diff --git a/spec/spec.opts b/spec/spec.opts deleted file mode 100644 index 91cd642..0000000 --- a/spec/spec.opts +++ /dev/null @@ -1,6 +0,0 @@ ---format -s ---colour ---loadby -mtime ---backtrace diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a4aeeae..2c6f566 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,18 +1 @@ -require 'pathname' -dir = Pathname.new(__FILE__).parent -$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib') - -require 'mocha' -require 'puppet' -gem 'rspec', '=1.2.9' -require 'spec/autorun' - -Spec::Runner.configure do |config| - config.mock_with :mocha -end - -# We need this because the RAL uses 'should' as a method. This -# allows us the same behaviour but with a different method name. -class Object - alias :must :should -end +require 'puppetlabs_spec_helper/module_spec_helper' From 5007be2226e7e4cfd8b541c9b8e9d67af74e7335 Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:08:14 +0100 Subject: [PATCH 6/8] get correct jdk version for centos 5.8 and 6.3 --- manifests/init.pp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/manifests/init.pp b/manifests/init.pp index 40363d5..363a7c0 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -10,7 +10,6 @@ # # Sample Usage: # -# [Remember: No empty lines between comments and class definition] class java( $distribution = 'jdk', $version = 'present' @@ -26,20 +25,23 @@ class java( 'RedHat': { - if ($operatingsystem == 'Fedora') { - class { 'java::package_redhat': - version => $version, - distribution => 'java', - require => Anchor['java::begin'], - before => Anchor['java::end'], + if ($::operatingsystem == 'Fedora') { + $distribution_redhat = 'java' + } elsif ($::operatingsystem == 'Centos') { + case $::operatingsystemrelease { + '5.8': { $distribution_redhat = 'java-1.7.0-openjdk' } + '6.3': { $distribution_redhat = 'java-1.7.0-openjdk' } + default: { $distribution_redhat = $distribution } } } else { - class { 'java::package_redhat': - version => $version, - distribution => $distribution, - require => Anchor['java::begin'], - before => Anchor['java::end'], - } + $distribution_redhat = $distribution + } + + class { 'java::package_redhat': + version => $version, + distribution => $distribution_redhat, + require => Anchor['java::begin'], + before => Anchor['java::end'], } } From b637c2e7e78f50274599bff29b04b0c921a2a6b1 Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:08:37 +0100 Subject: [PATCH 7/8] format modulefile --- Modulefile | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/Modulefile b/Modulefile index 672bd0c..02297a0 100644 --- a/Modulefile +++ b/Modulefile @@ -1,11 +1,10 @@ -name 'puppetlabs-java' -version '0.2.0' -source 'git://github.com/puppetlabs/puppetlabs-java' -author 'puppetlabs' -license 'Apache' -summary 'Manage the official Java runtime' -description 'Manage the official Java runtime' +name 'puppetlabs-java' +version '0.2.0' +source 'git://github.com/puppetlabs/puppetlabs-java' +author 'puppetlabs' +license 'Apache' +summary 'Manage the official Java runtime' +description 'Manage the official Java runtime' project_page 'https://github.com/puppetlabs/puppetlabs-java' -## Add dependencies, if any: -dependency 'puppetlabs/stdlib', '>= 0.1.6' +dependency 'puppetlabs/stdlib', '>= 0.1.6' From f5ee99f29753cd1aada29363bad64ab27ba04666 Mon Sep 17 00:00:00 2001 From: Gareth Rushgrove Date: Tue, 2 Apr 2013 16:15:57 +0100 Subject: [PATCH 8/8] update list of tested repositories in readme --- README.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.markdown b/README.markdown index 4494835..1825065 100644 --- a/README.markdown +++ b/README.markdown @@ -7,7 +7,10 @@ Currently this simply deploys the package on Enterprise Linux based systems and Tested on: * Centos 5.6 + * Centos 5.8 + * Centos 6.3 * Ubuntu 10.04 Lucid + * Ubuntu 12.04 Precise # RedHat Support #