-
-
Notifications
You must be signed in to change notification settings - Fork 246
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
Update acceptance tests, add EPEL test case for RedHat acceptance tests #308
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
--- | ||
.travis.yml: | ||
secure: "SCQpiBB9qpZAjBRk+b9D3cSCQfYpDgHPOdOc7djfGeB5yn1UbGg7uW1zshrshb4QMLfUgvsL4LsT0CYj7ilBerghgeySF5JWuZdk05W/7Iudls4btbxdVjqtALR7p02mnk40qHTR1Tdb/j0gXW9uigU6nQU9iCP+Poa1KF6PXpk=" | ||
docker_sets: | ||
- set: docker/ubuntu-14.04 | ||
- set: docker/centos-7 | ||
- set: docker/debian-8 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,47 @@ | ||
require 'spec_helper_acceptance' | ||
|
||
describe 'nodejs class:', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do | ||
it 'runs successfully' do | ||
pp = <<-EOS | ||
class { 'nodejs': } | ||
if $::osfamily == 'RedHat' and $::operatingsystemrelease =~ /^5\.(\d+)/ { | ||
class { 'epel': } | ||
Class['epel'] -> Class['nodejs'] | ||
} | ||
EOS | ||
describe 'nodejs class:', unless: UNSUPPORTED_PLATFORMS.include?(fact('os.family')) do | ||
case fact('os.family') | ||
when 'RedHat' | ||
pkg_cmd = 'yum info nodejs | grep "^From repo"' | ||
when 'Debian' | ||
pkg_cmd = 'dpkg -s nodejs | grep ^Maintainer' | ||
end | ||
|
||
context 'default parameters' do | ||
let(:pp) { "class { 'nodejs': }" } | ||
|
||
it 'runs successfully' do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add the shared example for this but I can submit a PR for that later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool, I didn't spend too long trying to get it to work (it wouldn't work inside an 'it' block). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trick is that it already contains it blocks so you don't need that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
|
||
if %w[RedHat Debian].include? fact('os.family') | ||
describe package('nodejs') do | ||
it { is_expected.to be_installed } | ||
it 'comes from the expected source' do | ||
pkg_output = shell(pkg_cmd) | ||
expect(pkg_output.stdout).to match 'nodesource' | ||
end | ||
end | ||
end | ||
end | ||
|
||
context 'repo_class => epel', if: fact('os.family') == 'RedHat' do | ||
let(:pp) { "class { 'nodejs': repo_class => '::epel' }" } | ||
|
||
it 'runs successfully' do | ||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
end | ||
|
||
apply_manifest(pp, catch_failures: true) | ||
apply_manifest(pp, catch_changes: true) | ||
describe package('nodejs') do | ||
it { is_expected.to be_installed } | ||
it 'comes from the expected source' do | ||
pending("This won't work until we have CentOS 7.4 because of dependency") | ||
pkg_output = shell(pkg_cmd) | ||
expect(pkg_output.stdout).to match 'epel' | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,20 @@ | ||
require 'beaker-rspec' | ||
require 'beaker/puppet_install_helper' | ||
require 'beaker/module_install_helper' | ||
|
||
# Install Puppet | ||
unless ENV['RS_PROVISION'] == 'no' | ||
# This will install the latest available package on el and deb based | ||
# systems fail on windows and osx, and install via gem on other *nixes | ||
foss_opts = { default_action: 'gem_install' } | ||
run_puppet_install_helper | ||
install_module_on(hosts) | ||
install_module_dependencies_on(hosts) | ||
|
||
if default.is_pe? | ||
install_pe | ||
else | ||
install_puppet(foss_opts) | ||
end | ||
|
||
hosts.each do |host| | ||
on host, "mkdir -p #{host['distmoduledir']}" | ||
end | ||
end | ||
# Additional modules for soft deps | ||
install_module_from_forge('puppetlabs-apt', '>= 4.1.0 < 5.0.0') | ||
install_module_from_forge('stahnma-epel', '>= 1.2.0 < 2.0.0') | ||
install_module_from_forge('chocolatey-chocolatey', '>= 1.2.6 < 2.0.0') | ||
install_module_from_forge('gentoo-portage', '>= 2.0.1 < 3.0.0') | ||
|
||
UNSUPPORTED_PLATFORMS = %w[AIX Solaris].freeze | ||
|
||
RSpec.configure do |c| | ||
# Project root | ||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
# Readable test descriptions | ||
c.formatter = :documentation | ||
|
||
# Configure all nodes in nodeset | ||
c.before :suite do | ||
# Install module and dependencies | ||
hosts.each do |host| | ||
copy_module_to(host, source: proj_root, module_name: 'nodejs') | ||
shell("/bin/touch #{default['puppetpath']}/hiera.yaml") | ||
on host, puppet('module install puppetlabs-apt --version 2.0.1'), acceptable_exit_codes: [0, 1] | ||
on host, puppet('module install gentoo-portage --version 2.0.1'), acceptable_exit_codes: [0, 1] | ||
on host, puppet('module install chocolatey-chocolatey --version 0.5.2'), acceptable_exit_codes: [0, 1] | ||
on host, puppet('module install stahnma-epel --version 1.0.0'), acceptable_exit_codes: [0, 1] | ||
on host, puppet('module install treydock-gpg_key --version 0.0.3'), acceptable_exit_codes: [0, 1] | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does 16.04 also work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
16.04 fails if we want the source to be nodesource, as it seems like it's supposed to be:
https://github.com/voxpupuli/puppet-nodejs/blob/master/manifests/params.pp#L86
16.04 gives me:
I'm not sure if that's a bug (probably because Ubuntu 16 version is > nodesource one), or if it's intentional. If it's intentional, we could do some logic to look for different expected package sources depending on vendor.
Debian 82 did work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ps - before the updates to spec_helper_acceptance, the tests were failing completely on multiple platforms, so this at least is an improvement, I think. Once we know what the expected behavior is, we can figure out how the tests should be (and if any fixes are needed in the actual module code).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you add debian 8? Does 9 work as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an additional one, or instead of Ubuntu?
FWIW, I don't think modulesync provides Debian 9 yet, and I don't see it in the rake tasks
https://github.com/voxpupuli/modulesync_config/tree/master/moduleroot/spec/acceptance/nodesets