From 5f6f1263736a6dd762f48b3bd417f3a46ba8d8ba Mon Sep 17 00:00:00 2001 From: gbloquel Date: Sun, 9 Oct 2016 22:01:00 +0200 Subject: [PATCH 1/4] FIX #51 possibility to add checksum --- manifests/init.pp | 2 ++ manifests/package.pp | 2 ++ manifests/params.pp | 1 + spec/acceptance/checksum_spec.rb | 47 ++++++++++++++++++++++++++++++++ spec/classes/package_spec.rb | 25 ++++++++++++++++- 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 spec/acceptance/checksum_spec.rb diff --git a/manifests/init.pp b/manifests/init.pp index ab8fd58..324402f 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -49,6 +49,7 @@ $nexus_data_folder = $nexus::params::nexus_data_folder, $download_folder = $nexus::params::download_folder, $manage_config = $nexus::params::manage_config, + $md5sum = $nexus::params::md5sum, ) inherits nexus::params { include stdlib @@ -108,6 +109,7 @@ nexus_work_dir => $real_nexus_work_dir, nexus_work_dir_manage => $nexus_work_dir_manage, nexus_work_recurse => $nexus_work_recurse, + md5sum => $md5sum, notify => Class['nexus::service'] } diff --git a/manifests/package.pp b/manifests/package.pp index d6a42d2..ff3ae08 100644 --- a/manifests/package.pp +++ b/manifests/package.pp @@ -42,6 +42,7 @@ $nexus_work_recurse = $::nexus::nexus_work_recurse, $nexus_selinux_ignore_defaults = $::nexus::nexus_selinux_ignore_defaults, $download_folder = $::nexus::download_folder, + $md5sum = $::nexus::md5sum, ) { $nexus_home = "${nexus_root}/${nexus_home_dir}" @@ -70,6 +71,7 @@ wget::fetch{ $nexus_archive: source => $download_url, destination => $dl_file, + source_hash => $md5sum, before => Exec['nexus-untar'], } diff --git a/manifests/params.pp b/manifests/params.pp index d5d6ca7..7e6d501 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -41,4 +41,5 @@ $nexus_data_folder = undef $download_folder = '/srv' $manage_config = true + $md5sum = '' } diff --git a/spec/acceptance/checksum_spec.rb b/spec/acceptance/checksum_spec.rb new file mode 100644 index 0000000..cde91cd --- /dev/null +++ b/spec/acceptance/checksum_spec.rb @@ -0,0 +1,47 @@ +require 'spec_helper_acceptance' + +describe 'apt class' do + + context 'default parameters' do + # Using puppet_apply as a helper + it 'should work with no errors' do + pp = <<-EOS + class{ '::java': } + + class{ '::nexus': + version => '2.8.0', + revision => '05', + md5sum => 'e1cece1ae5eb3a12f857e2368a3e9dbc', + nexus_root => '/srv', + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_failures => true) + end + + describe user('nexus') do + it { should belong_to_group 'nexus' } + end + + describe service('nexus') do + it { is_expected.to be_enabled } + it { is_expected.to be_running } + end + + context 'Nexus should be running on the default port' do + describe port(8081) do + it { + sleep(180) # Waiting start up + should be_listening + } + end + + describe command('curl 0.0.0.0:8081/nexus/') do + its(:stdout) { should match /Sonatype Nexus™ 2.8.0-05/ } + end + end + + end +end diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index b8b10ee..e2f1a23 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -24,6 +24,7 @@ 'revision' => '01', 'version' => '2.11.2', 'download_folder' => '/srv', + 'md5sum' => '', } } @@ -34,6 +35,7 @@ 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', + 'source_hash' => '', ) } it { should contain_exec('nexus-untar').with( @@ -68,7 +70,7 @@ params.merge!( { 'deploy_pro' => true, - 'download_site' => 'http://download.sonatype.com/nexus/professional-bundle', + 'download_site' => 'http://download.sonatype.com/nexus/professional-bundle' } ) @@ -88,7 +90,28 @@ 'target' => '/srv/nexus-professional-2.11.2-01', ) end + + it 'should working with md5sum' do + params.merge!( + { + 'md5sum' => '1234567890' + } + ) + should contain_wget__fetch('nexus-2.11.2-01-bundle.tar.gz').with( + 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', + 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', + 'before' => 'Exec[nexus-untar]', + 'source_hash' => '1234567890', + ) + should contain_exec('nexus-untar').with( + 'command' => 'tar zxf /srv/nexus-2.11.2-01-bundle.tar.gz --directory /srv', + 'creates' => '/srv/nexus-2.11.2-01', + 'path' => [ '/bin', '/usr/bin' ], + ) + end + end + end end end From 8f4cf3b3db967c7f57aa1d97af7df8dfc24d896d Mon Sep 17 00:00:00 2001 From: gbloquel Date: Sat, 22 Oct 2016 09:18:12 +0200 Subject: [PATCH 2/4] FIX replace default value of md5sum by undef --- manifests/params.pp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifests/params.pp b/manifests/params.pp index 7e6d501..e27739f 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -41,5 +41,5 @@ $nexus_data_folder = undef $download_folder = '/srv' $manage_config = true - $md5sum = '' + $md5sum = undef } From 5757d0e82450ccf7700ff90b059736155aa5bfe0 Mon Sep 17 00:00:00 2001 From: gbloquel Date: Thu, 27 Oct 2016 21:43:08 +0200 Subject: [PATCH 3/4] FIX replace default value of md5sum by undef --- spec/classes/package_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index e2f1a23..15037e1 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -24,7 +24,6 @@ 'revision' => '01', 'version' => '2.11.2', 'download_folder' => '/srv', - 'md5sum' => '', } } @@ -35,7 +34,7 @@ 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', - 'source_hash' => '', + 'source_hash' => nil, ) } it { should contain_exec('nexus-untar').with( From 6fc6363bc129cb1966206f7ec31ba3346fb13891 Mon Sep 17 00:00:00 2001 From: gbloquel Date: Thu, 27 Oct 2016 22:07:10 +0200 Subject: [PATCH 4/4] Revert "FIX replace default value of md5sum by undef" This reverts commit 5757d0e82450ccf7700ff90b059736155aa5bfe0. --- spec/classes/package_spec.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spec/classes/package_spec.rb b/spec/classes/package_spec.rb index 15037e1..e2f1a23 100644 --- a/spec/classes/package_spec.rb +++ b/spec/classes/package_spec.rb @@ -24,6 +24,7 @@ 'revision' => '01', 'version' => '2.11.2', 'download_folder' => '/srv', + 'md5sum' => '', } } @@ -34,7 +35,7 @@ 'source' => 'http://download.sonatype.com/nexus/oss/nexus-2.11.2-01-bundle.tar.gz', 'destination' => '/srv/nexus-2.11.2-01-bundle.tar.gz', 'before' => 'Exec[nexus-untar]', - 'source_hash' => nil, + 'source_hash' => '', ) } it { should contain_exec('nexus-untar').with(