diff --git a/.gitignore b/.gitignore index 01d0a08..82ed069 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,5 @@ pkg/ +.bundle/ +Gemfile.lock +log/ +vendor/ diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..baa17ab --- /dev/null +++ b/.travis.yml @@ -0,0 +1,21 @@ +--- +language: ruby +bundler_args: --without development +before_install: rm Gemfile.lock || true +services: + - docker +matrix: + fast_finish: true + include: + - rvm: 2.1 + env: PUPPET_INSTALL_TYPE=agent BEAKER_set=docker/centos-6-x64 + script: bundle exec rake beaker + services: docker + sudo: required + - rvm: 2.1 + env: PUPPET_INSTALL_TYPE=agent BEAKER_set=docker/centos-7-x64 + script: bundle exec rake beaker + services: docker + sudo: required +notifications: + email: false diff --git a/Gemfile b/Gemfile index 7bd34cd..c1f9d8d 100644 --- a/Gemfile +++ b/Gemfile @@ -5,3 +5,10 @@ gem 'puppet', puppetversion gem 'puppetlabs_spec_helper', '>= 0.1.0' gem 'puppet-lint', '>= 0.3.2' gem 'facter', '>= 1.7.0' + +group :system_tests do + gem "beaker" + gem "beaker-rspec" + gem "beaker-puppet_install_helper" + gem "serverspec-extended-types" +end diff --git a/README.md b/README.md index dde4922..bbd825b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build Status](https://travis-ci.org/sumpfgottheit/puppet-pythonel.svg?branch=master)](https://travis-ci.org/sumpfgottheit/puppet-pythonel) + # Supported Platforms - **Enterprise Linux 6**: RHEL6, CentOS6 and clones (not tested) diff --git a/spec/acceptance/class_spec.rb b/spec/acceptance/class_spec.rb new file mode 100644 index 0000000..9247811 --- /dev/null +++ b/spec/acceptance/class_spec.rb @@ -0,0 +1,82 @@ +require 'spec_helper_acceptance' + +describe 'pythonel' do + describe 'python35_ius' do + # Using puppet_apply as a helper + it 'should work idempotently with no errors' do + pp = <<-EOS + package {['centos-release-scl', 'epel-release']: + ensure => 'present' + } + package {'ius-release': + ensure => 'present', + provider => 'rpm', + source => "https://centos${::operatingsystemmajrelease}.iuscommunity.org/ius-release.rpm", + } + include pythonel::interpreter::python35_ius + pythonel::virtualenv { '/tmp/myapp_python35_ius': + interpreter => 'python35_ius', + systempkgs => true, + } -> + pythonel::pip { 'myapp-colorama': + package => 'colorama', + virtualenv => '/tmp/myapp_python35_ius', + interpreter => 'python35_ius' + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + describe package('python35u') do + it { is_expected.to be_installed } + end + describe virtualenv('/tmp/myapp_python35_ius') do + it { should be_virtualenv } + its(:pip_freeze) { should include('colorama') } + its(:python_version) { should match /^3\.5/ } + end + end + + describe 'rh_python34_scl' do + # Using puppet_apply as a helper + it 'should work idempotently with no errors' do + pp = <<-EOS + package {'centos-release-scl': + ensure => 'present' + } + include pythonel::interpreter::rh_python34_scl + pythonel::virtualenv { '/tmp/myapp_rh_python34_scl': + interpreter => 'rh_python34_scl', + systempkgs => true, + } -> + pythonel::pip { 'myapp-colorama': + package => 'colorama', + virtualenv => '/tmp/myapp_rh_python34_scl', + interpreter => 'rh_python34_scl' + } + EOS + + # Run it twice and test for idempotency + apply_manifest(pp, :catch_failures => true) + apply_manifest(pp, :catch_changes => true) + end + + # we can't use virtualenv serverspec here because you need to run 'scl + # enable rh-python34' before running any of the commands. the best we can do + # is check the directory for things that should be there + describe file('/tmp/myapp_rh_python34_scl') do + it { should be_directory } + end + + describe file('/tmp/myapp_rh_python34_scl/bin/python3') do + it { should exist } + it { should be_executable } + end + + describe file('/tmp/myapp_rh_python34_scl/lib/python3.4/site-packages/colorama') do + it { should be_directory } + end + end +end diff --git a/spec/acceptance/nodesets/docker/centos-6-x64.yml b/spec/acceptance/nodesets/docker/centos-6-x64.yml new file mode 100644 index 0000000..89e0808 --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-6-x64.yml @@ -0,0 +1,12 @@ +HOSTS: + centos-6-x64: + platform: centos-6-x86_64 + hypervisor: docker + image: centos:6 + docker_cmd: '["/sbin/init"]' + docker_image_commands: + - 'rm -rf /var/run/network/*' + - 'yum install -y crontabs tar wget which' +CONFIG: + type: foss + masterless: true diff --git a/spec/acceptance/nodesets/docker/centos-7-x64.yml b/spec/acceptance/nodesets/docker/centos-7-x64.yml new file mode 100644 index 0000000..36e928e --- /dev/null +++ b/spec/acceptance/nodesets/docker/centos-7-x64.yml @@ -0,0 +1,13 @@ +HOSTS: + centos-7-x64: + platform: centos-7-x86_64 + hypervisor: docker + image: centos:7 + docker_preserve_image: true + docker_cmd: '["/usr/sbin/init"]' + # install various tools required to get the image up to usable levels + docker_image_commands: + - 'yum install -y crontabs tar wget openssl sysvinit-tools iproute which initscripts' +CONFIG: + type: foss + masterless: true diff --git a/spec/spec_helper_acceptance.rb b/spec/spec_helper_acceptance.rb new file mode 100644 index 0000000..2f28ca7 --- /dev/null +++ b/spec/spec_helper_acceptance.rb @@ -0,0 +1,20 @@ +require 'beaker-rspec' +require 'beaker/puppet_install_helper' +require 'serverspec_extended_types' + +run_puppet_install_helper + +RSpec.configure do |c| + module_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) + + c.formatter = :documentation + + # Configure all nodes in nodeset + c.before :suite do + # Install module + puppet_module_install(:source => module_root, :module_name => 'pythonel') + hosts.each do |host| + on host, puppet('module', 'install', 'puppetlabs-stdlib'), { :acceptable_exit_codes => [0,1] } + end + end +end