Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #51 possibility to add checksum #80

Merged
merged 4 commits into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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']
}

Expand Down
2 changes: 2 additions & 0 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -70,6 +71,7 @@
wget::fetch{ $nexus_archive:
source => $download_url,
destination => $dl_file,
source_hash => $md5sum,
before => Exec['nexus-untar'],
}

Expand Down
1 change: 1 addition & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
$nexus_data_folder = undef
$download_folder = '/srv'
$manage_config = true
$md5sum = ''
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this default to empty string instead of undef?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right the undef value is better. I change it!

}
47 changes: 47 additions & 0 deletions spec/acceptance/checksum_spec.rb
Original file line number Diff line number Diff line change
@@ -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&trade; 2.8.0-05/ }
end
end

end
end
25 changes: 24 additions & 1 deletion spec/classes/package_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
'revision' => '01',
'version' => '2.11.2',
'download_folder' => '/srv',
'md5sum' => '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this supposed to be undef now?

Copy link
Contributor Author

@gbloquel gbloquel Oct 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are almost right.

md5sum can not be used with undef value, that will cause during test:

ruby -c spec/classes/package_spec.rb
spec/classes/package_spec.rb:27: syntax error, unexpected keyword_undef
          'md5sum'                        => undef,
                                                  ^
spec/classes/package_spec.rb:115: syntax error, unexpected keyword_end, expecting '}'
rake aborted!
Command failed with status (1): [ruby -c spec/classes/package_spec.rb...]

caused by undef can not be used in hash

The empty value is used to be compatible with strict mode during the test

}
}

Expand All @@ -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(
Expand Down Expand Up @@ -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'
}
)

Expand All @@ -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
Expand Down