From 850cad7460fb2203e3bbfaaac444e43915fe8baf Mon Sep 17 00:00:00 2001 From: Michael Konietzny Date: Thu, 26 Jan 2017 23:51:18 +0100 Subject: [PATCH 1/3] * fix rubocop --- .travis.yml | 4 +- spec/classes/php_spec.rb | 112 +++++++++++++++------------ spec/defines/extension_rhscl_spec.rb | 76 +++++++++--------- 3 files changed, 102 insertions(+), 90 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6214a554..d090dd11 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ matrix: fast_finish: true include: - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test BEAKER_RSPEC_VERSION="<= 5.6.0" - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test BEAKER_RSPEC_VERSION="<= 5.6.0" - rvm: 2.1.9 env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test - rvm: 2.1.9 diff --git a/spec/classes/php_spec.rb b/spec/classes/php_spec.rb index ab7b0537..08806fed 100644 --- a/spec/classes/php_spec.rb +++ b/spec/classes/php_spec.rb @@ -9,26 +9,29 @@ describe 'when called with no parameters' do case facts[:osfamily] - when 'Debian' - it { is_expected.not_to contain_class('php::global') } - it { is_expected.to contain_class('php::fpm') } - it { is_expected.to contain_package('php5-cli').with_ensure('present') } - it { is_expected.to contain_package('php5-fpm').with_ensure('present') } - it { is_expected.to contain_package('php5-dev').with_ensure('present') } - it { is_expected.to contain_package('php-pear').with_ensure('present') } - it { is_expected.to contain_class('php::composer') } - when 'Suse' - it { is_expected.to contain_class('php::global') } - it { is_expected.to contain_package('php5').with_ensure('present') } - it { is_expected.to contain_package('php5-devel').with_ensure('present') } - it { is_expected.to contain_package('php5-pear').with_ensure('present') } - it { is_expected.not_to contain_package('php5-cli') } - it { is_expected.not_to contain_package('php5-dev') } - it { is_expected.not_to contain_package('php-pear') } - when 'RedHat', 'CentOS' - it { is_expected.to contain_class('php::global') } - it { is_expected.to contain_package('php-cli').with_ensure('present') } - it { is_expected.to contain_package('php-common').with_ensure('present') } + when 'Suse', 'RedHat', 'CentOS' + it { is_expected.to contain_class('php::global') } + end + + case facts[:osfamily] + when 'Debian' + it { is_expected.not_to contain_class('php::global') } + it { is_expected.to contain_class('php::fpm') } + it { is_expected.to contain_package('php5-cli').with_ensure('present') } + it { is_expected.to contain_package('php5-fpm').with_ensure('present') } + it { is_expected.to contain_package('php5-dev').with_ensure('present') } + it { is_expected.to contain_package('php-pear').with_ensure('present') } + it { is_expected.to contain_class('php::composer') } + when 'Suse' + it { is_expected.to contain_package('php5').with_ensure('present') } + it { is_expected.to contain_package('php5-devel').with_ensure('present') } + it { is_expected.to contain_package('php5-pear').with_ensure('present') } + it { is_expected.not_to contain_package('php5-cli') } + it { is_expected.not_to contain_package('php5-dev') } + it { is_expected.not_to contain_package('php-pear') } + when 'RedHat', 'CentOS' + it { is_expected.to contain_package('php-cli').with_ensure('present') } + it { is_expected.to contain_package('php-common').with_ensure('present') } end end @@ -37,22 +40,32 @@ let(:params) { { package_prefix: package_prefix } } case facts[:osfamily] - when 'Debian' - it { is_expected.not_to contain_class('php::global') } - it { is_expected.to contain_class('php::fpm') } - it { is_expected.to contain_class('php::composer') } - it { is_expected.to contain_package('php-pear').with_ensure('present') } - it { is_expected.to contain_package("#{package_prefix}cli").with_ensure('present') } - it { is_expected.to contain_package("#{package_prefix}dev").with_ensure('present') } - it { is_expected.to contain_package("#{package_prefix}fpm").with_ensure('present') } - when 'Suse' - it { is_expected.to contain_class('php::global') } - it { is_expected.to contain_package('php5').with_ensure('present') } - it { is_expected.to contain_package("#{package_prefix}devel").with_ensure('present') } - it { is_expected.to contain_package("#{package_prefix}pear").with_ensure('present') } - it { is_expected.not_to contain_package("#{package_prefix}cli") } - it { is_expected.not_to contain_package("#{package_prefix}dev") } - it { is_expected.not_to contain_package("php-pear") } + when 'Suse', 'RedHat', 'CentOS' + it { is_expected.to contain_class('php::global') } + end + + case facts[:osfamily] + when 'Debian', 'RedHat', 'CentOS' + it { is_expected.to contain_package("#{package_prefix}cli").with_ensure('present') } + end + + case facts[:osfamily] + when 'Debian' + it { is_expected.not_to contain_class('php::global') } + it { is_expected.to contain_class('php::fpm') } + it { is_expected.to contain_class('php::composer') } + it { is_expected.to contain_package('php-pear').with_ensure('present') } + it { is_expected.to contain_package("#{package_prefix}dev").with_ensure('present') } + it { is_expected.to contain_package("#{package_prefix}fpm").with_ensure('present') } + when 'Suse' + it { is_expected.to contain_package('php5').with_ensure('present') } + it { is_expected.to contain_package("#{package_prefix}devel").with_ensure('present') } + it { is_expected.to contain_package("#{package_prefix}pear").with_ensure('present') } + it { is_expected.not_to contain_package("#{package_prefix}cli").with_ensure('present') } + it { is_expected.not_to contain_package("#{package_prefix}dev") } + it { is_expected.not_to contain_package('php-pear') } + when 'RedHat', 'CentOS' + it { is_expected.to contain_package("#{package_prefix}common").with_ensure('present') } end end @@ -71,13 +84,14 @@ describe 'when called with mode "remi"' do scl_php_version = 'php56' rhscl_mode = 'remi' - let(:pre_condition) { "class {'::php::globals': - php_version => '#{scl_php_version}', - rhscl_mode => '#{rhscl_mode}' - }" - } + let(:pre_condition) do + "class {'::php::globals': + php_version => '#{scl_php_version}', + rhscl_mode => '#{rhscl_mode}' + }" + end let(:params) do - { settings: {'Date/date.timezone' => 'Europe/Berlin'}} + { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } @@ -93,13 +107,14 @@ describe 'when called with mode "rhscl"' do scl_php_version = 'rh-php56' rhscl_mode = 'rhscl' - let(:pre_condition) { "class {'::php::globals': - php_version => '#{scl_php_version}', - rhscl_mode => '#{rhscl_mode}' - }" - } + let(:pre_condition) do + "class {'::php::globals': + php_version => '#{scl_php_version}', + rhscl_mode => '#{rhscl_mode}' + }" + end let(:params) do - { settings: {'Date/date.timezone' => 'Europe/Berlin'}} + { settings: { 'Date/date.timezone' => 'Europe/Berlin' } } end it { is_expected.to contain_class('php::global') } @@ -109,7 +124,6 @@ it { is_expected.to contain_php__config('cli').with(file: "/etc/opt/rh/#{scl_php_version}/php-cli.ini") } it { is_expected.to contain_php__config__setting("/etc/opt/rh/#{scl_php_version}/php.ini: Date/date.timezone").with_value('Europe/Berlin') } end - end end end diff --git a/spec/defines/extension_rhscl_spec.rb b/spec/defines/extension_rhscl_spec.rb index bd0061dd..4ff40dd6 100644 --- a/spec/defines/extension_rhscl_spec.rb +++ b/spec/defines/extension_rhscl_spec.rb @@ -2,50 +2,48 @@ describe 'php::extension' do on_supported_os.each do |os, facts| - if facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS' + next unless facts[:osfamily] == 'RedHat' || facts[:osfamily] == 'CentOS' - context "on #{os}" do - let :facts do - facts - end - - describe 'with rhscl_mode "remi" enabled: install one extension' do - scl_php_version = 'php56' - rhscl_mode = 'remi' - configs_root = "/opt/#{rhscl_mode}/#{scl_php_version}/root/etc" - - let(:pre_condition) { "class {'::php::globals': - php_version => '#{scl_php_version}', - rhscl_mode => '#{rhscl_mode}' - }-> - class {'::php': - ensure => installed, - manage_repos => false, - fpm => false, - dev => true, # must be true since we are using the provider => pecl (option installs header files) - composer => false, - pear => true, - phpunit => false, - } " - } + context "on #{os}" do + let :facts do + facts + end - let(:title) { 'bz2' } - let(:params) do - { - package_name: 'common', - config_file_prefix: '20-', - settings: {'Date/date.timezone' => 'Europe/Berlin'} - } - end + describe 'with rhscl_mode "remi" enabled: install one extension' do + scl_php_version = 'php56' + rhscl_mode = 'remi' + configs_root = "/opt/#{rhscl_mode}/#{scl_php_version}/root/etc" - it { is_expected.to contain_class('php::global') } - it { is_expected.to contain_class('php') } - it { is_expected.to contain_class('php::global') } - it { is_expected.to contain_php__config('bz2').with(file: "#{configs_root}/php.d/20-bz2.ini") } - it { is_expected.to contain_php__config__setting("#{configs_root}/php.d/20-bz2.ini: Date/date.timezone").with_value('Europe/Berlin') } + let(:pre_condition) do + "class {'::php::globals': + php_version => '#{scl_php_version}', + rhscl_mode => '#{rhscl_mode}' + }-> + class {'::php': + ensure => installed, + manage_repos => false, + fpm => false, + dev => true, # must be true since we are using the provider => pecl (option installs header files) + composer => false, + pear => true, + phpunit => false, + }" + end + let(:title) { 'bz2' } + let(:params) do + { + package_name: 'common', + config_file_prefix: '20-', + settings: { 'Date/date.timezone' => 'Europe/Berlin' } + } end + + it { is_expected.to contain_class('php::global') } + it { is_expected.to contain_class('php') } + it { is_expected.to contain_php__config('bz2').with(file: "#{configs_root}/php.d/20-bz2.ini") } + it { is_expected.to contain_php__config__setting("#{configs_root}/php.d/20-bz2.ini: Date/date.timezone").with_value('Europe/Berlin') } end end end -end \ No newline at end of file +end From ebb6ac70819419fd35caa5e79926536f97c94c49 Mon Sep 17 00:00:00 2001 From: Michael Konietzny Date: Fri, 27 Jan 2017 00:11:07 +0100 Subject: [PATCH 2/3] * fix tests for ruby 1.9 (it seams that bundle v1.7.6 ignores the --without option) --- .travis.yml | 6 ++++-- Gemfile | 20 +++++++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index d090dd11..c19b06b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,15 +10,17 @@ before_install: - gem update bundler - gem --version - bundle -v +after_install: + - bundle exec gem list script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test BEAKER_RSPEC_VERSION="<= 5.6.0" + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test BEAKER_RSPEC_VERSION="<= 5.6.0" + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test - rvm: 2.1.9 env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test - rvm: 2.1.9 diff --git a/Gemfile b/Gemfile index e8db724e..46a0f90c 100644 --- a/Gemfile +++ b/Gemfile @@ -42,16 +42,18 @@ group :development do end group :system_tests do - if beaker_version = ENV['BEAKER_VERSION'] - gem 'beaker', *location_for(beaker_version) + if RUBY_VERSION >= '2.0.0' + if beaker_version = ENV['BEAKER_VERSION'] + gem 'beaker', *location_for(beaker_version) + end + if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] + gem 'beaker-rspec', *location_for(beaker_rspec_version) + else + gem 'beaker-rspec', :require => false + end + gem 'serverspec', :require => false + gem 'beaker-puppet_install_helper', :require => false end - if beaker_rspec_version = ENV['BEAKER_RSPEC_VERSION'] - gem 'beaker-rspec', *location_for(beaker_rspec_version) - else - gem 'beaker-rspec', :require => false - end - gem 'serverspec', :require => false - gem 'beaker-puppet_install_helper', :require => false end From 9f0613dbd30323e4a4305e4d7f4d4517150a31ed Mon Sep 17 00:00:00 2001 From: Michael Konietzny Date: Fri, 27 Jan 2017 10:00:51 +0100 Subject: [PATCH 3/3] * fix tests for ruby 1.9 (it seams that bundle v1.7.6 ignores the --without option) --- .travis.yml | 20 +++++++++----------- Gemfile | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index c19b06b8..78ebaf7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,31 +10,29 @@ before_install: - gem update bundler - gem --version - bundle -v -after_install: - - bundle exec gem list script: - 'bundle exec rake $CHECK' matrix: fast_finish: true include: - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test SYSTEM_TESTS="no" - rvm: 1.9.3 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" FUTURE_PARSER="yes" CHECK=test SYSTEM_TESTS="no" - rvm: 2.1.9 - env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test + env: PUPPET_VERSION="~> 3.0" STRICT_VARIABLES="yes" CHECK=test SYSTEM_TESTS="no" - rvm: 2.1.9 - env: PUPPET_VERSION="~> 4.0" CHECK=test + env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no" - rvm: 2.2.6 - env: PUPPET_VERSION="~> 4.0" CHECK=test + env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no" - rvm: 2.3.3 - env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes + env: PUPPET_VERSION="~> 4.0" CHECK=build DEPLOY_TO_FORGE=yes SYSTEM_TESTS="no" - rvm: 2.3.3 - env: PUPPET_VERSION="~> 4.0" CHECK=rubocop + env: PUPPET_VERSION="~> 4.0" CHECK=rubocop SYSTEM_TESTS="no" - rvm: 2.3.3 - env: PUPPET_VERSION="~> 4.0" CHECK=test + env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no" - rvm: 2.4.0 - env: PUPPET_VERSION="~> 4.0" CHECK=test + env: PUPPET_VERSION="~> 4.0" CHECK=test SYSTEM_TESTS="no" allow_failures: - rvm: 2.4.0 branches: diff --git a/Gemfile b/Gemfile index 46a0f90c..a397366b 100644 --- a/Gemfile +++ b/Gemfile @@ -42,7 +42,7 @@ group :development do end group :system_tests do - if RUBY_VERSION >= '2.0.0' + if ENV['SYSTEM_TESTS'] == 'yes' if beaker_version = ENV['BEAKER_VERSION'] gem 'beaker', *location_for(beaker_version) end