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

Update acceptance tests, add EPEL test case for RedHat acceptance tests #308

Merged
merged 2 commits into from
Sep 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions .sync.yml
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
Copy link
Member

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?

Copy link
Contributor Author

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:

Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>

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.

Copy link
Contributor Author

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).

Copy link
Member

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

Copy link
Contributor Author

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

- set: docker/centos-7
- set: docker/debian-8
20 changes: 19 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,25 @@ script:
matrix:
fast_finish: true
include:
- rvm: 2.1.9
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/ubuntu-14.04 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/centos-7 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.1
bundler_args: --without development
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_set=docker/debian-8 CHECK=beaker
services: docker
sudo: required
- rvm: 2.4.1
bundler_args: --without system_tests development
env: PUPPET_VERSION="~> 4.0" CHECK=test
- rvm: 2.2.7
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ group :system_tests do
end
gem 'serverspec', :require => false
gem 'beaker-puppet_install_helper', :require => false
gem 'beaker-module_install_helper', :require => false
end


Expand Down
53 changes: 42 additions & 11 deletions spec/acceptance/class_spec.rb
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
Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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).
I did see someone else create a self.foo in a test, and then use that where they wanted to reuse an item in the same test (vs. across different files).

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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
42 changes: 10 additions & 32 deletions spec/spec_helper_acceptance.rb
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