Skip to content

Commit

Permalink
(FM-8118) Litmus conversion (puppetlabs#1175)
Browse files Browse the repository at this point in the history
(FM-8118) Litmus Conversion

This change updates the module for testing under Litmus.

Squashed Commit Messages:

* (WIP) - POC Litmus conversion

* Updating test to avoid failures when running against the same machine

* Readding idempotent testing

* Updating travis

* updating Gemfile and unmanaging travis.yml

* backup_spec fixing shell

* fixing version_is_greater_than as it compared strings and was incorrect

* changing provision to use http rather than ssh

* rework .sync.yml

* remove bolt

* Include litmus warning in README

* rubocop fixes

* Remove puppet 5 dependency clash

This is not a good idea, however it is one of the last options we have
to progress. There are gem dependencies when running litmus, pdk and
bolt on puppet 5. Doing this means litmus will not be installed on
puppet 5. We have pinned to a ruby version as puppet and ruby are
closely coupled and this is a solution that works and the ruby version
is available to us.

* puppet_litmus dont install if puppet5

* Update mariadb to mysql

* removing pin to special commits

* replace lsbdistcodename with operatingsystemmajrelease

* adding cron package for backups

* tidying manifest removing maridadb for debian

* remove white space, fix cron install

* fix tests

* fixing shell to run_shell

* Adding distelli-manifest.yml

* adding dependencies and more to travis

* remove rvm from distelli manifest

* test

* remove installation of cron in tests, it is done in the manifest

* pdk convert, enable provision_list

* fixing cron dependency failure on docker

* Adding locales testing

* Update distelli manifest

* Fixing cron failures

* including cronie and cron

* Redhat cronie else cron

* adding which install as part of a test

* fixing rubocop on locales

* updates to provision.yaml to use waffleimage

* update travis to include provision_list

* removing spec_helper_local conditional require on puppet_litmus

* pdk update, fix travis

* removing some el os for travis testing

* dont install cronie on redhat5

* putting provision back to travel_el images

* fixing structure in travis_db images

* fixing cron/cronie install on backup and dump

* decreasing travis_el os to diagnose timeout

* update manifest to fix syntax failure

* restructure travis

* pdk updating gems

* Take el7 out to run separately

* fixes for litmus 0.1.1

* minor test tweaks, remove redundant calls

* fixes needed for litmus block handling

* move setup to install section, travis

* stop using a mysql_helper.rb

* el 5 support for testing

* latest pdksync
  • Loading branch information
pmcmaw authored and RandomNoun7 committed May 30, 2019
1 parent eb3f191 commit ad5bb08
Show file tree
Hide file tree
Showing 23 changed files with 499 additions and 417 deletions.
3 changes: 3 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ fixtures:
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib"
"translate": "https://github.com/puppetlabs/puppetlabs-translate"
"cron_core": "https://github.com/puppetlabs/puppetlabs-cron_core.git"
"facts": "git://github.com/puppetlabs/puppetlabs-facts.git"
"puppet_agent": "git://github.com/puppetlabs/puppetlabs-puppet_agent.git"
"provision": "git://github.com/puppetlabs/provision.git"
symlinks:
"mysql": "#{source_dir}"
35 changes: 17 additions & 18 deletions .sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
- ---.project

.travis.yml:
docker_sets:
- set: docker/centos-7
- set: docker/ubuntu-14.04
docker_defaults:
bundler_args: ""
secure: ""
branches:
- release

unmanaged: true

Gemfile:
optional:
':development':
- gem: puppet-lint-i18n
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
required:
':system_tests':
- gem: 'puppet-module-posix-system-r#{minor_version}'
Expand All @@ -23,22 +23,21 @@ Gemfile:
- mswin
- mingw
- x64_mingw
- gem: beaker-testmode_switcher
':development':
- gem: puppet-lint-i18n
optional:
':development':
- gem: 'github_changelog_generator'
git: 'https://github.com/skywinder/github-changelog-generator'
ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
condition: "Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.2.2')"
- gem: 'puppet_litmus'
platforms:
- ruby
- mswin
- mingw
- x64_mingw
condition: "ENV['PUPPET_GEM_VERSION'].nil? or ENV['PUPPET_GEM_VERSION'] !~ %r{ 5}"

appveyor.yml:
unmanaged: true

Rakefile:
requires:
- puppet_pot_generator/rake_tasks
use_litmus_tasks: true
  changelog_user: 'puppetlabs'

spec/spec_helper.rb:
Expand Down
126 changes: 102 additions & 24 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,49 +11,127 @@ script:
- 'bundle exec rake $CHECK'
bundler_args: --without system_tests
rvm:
- 2.5.3
stages:
- static
- spec
- acceptance
-
if: tag =~ ^v\d
name: deploy
- 2.5.1
env:
global:
- PUPPET_GEM_VERSION="~> 6.0"
matrix:
fast_finish: true
include:
-
bundler_args:
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/centos-7 BEAKER_TESTMODE=apply
rvm: 2.5.3
script: bundle exec rake beaker
env: PLATFORMS=deb_puppet5
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision_list[travis_deb]'
- bundle exec bolt command run 'apt-get install wget -y' --inventoryfile inventory.yaml --nodes='localhost*'
- bundle exec rake 'litmus:install_agent[puppet5]'
- bundle exec rake litmus:install_module
script:
- bundle exec rake litmus:acceptance:parallel
services: docker
stage: acceptance
sudo: required
-
bundler_args:
bundler_args:
dist: trusty
env: PUPPET_INSTALL_TYPE=agent BEAKER_debug=true BEAKER_PUPPET_COLLECTION=puppet6 BEAKER_set=docker/ubuntu-14.04 BEAKER_TESTMODE=apply
rvm: 2.5.3
script: bundle exec rake beaker
env: PLATFORM=deb_puppet6
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision_list[travis_deb]'
- bundle exec bolt command run 'apt-get install wget -y' --inventoryfile inventory.yaml --nodes='localhost*'
- bundle exec rake 'litmus:install_agent[puppet6]'
- bundle exec rake litmus:install_module
script:
- bundle exec rake litmus:acceptance:parallel
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORMS=el7_puppet5
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision_list[travis_el7]'
- bundle exec rake 'litmus:install_agent[puppet5]'
- bundle exec rake litmus:install_module
script:
- bundle exec rake litmus:acceptance:parallel
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORM=el7_puppet6
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision_list[travis_el7]'
- bundle exec rake 'litmus:install_agent[puppet6]'
- bundle exec rake litmus:install_module
script:
- bundle exec rake litmus:acceptance:parallel
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORM=centos6_puppet5
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision[docker, waffleimage/centos6]'
- bundle exec rake 'litmus:install_agent[puppet5]'
- bundle exec rake litmus:install_module
script:
- TARGET_HOST=localhost:2222 bundle exec rspec ./spec/acceptance/
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORM=centos6_puppet6
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision[docker, waffleimage/centos6]'
- bundle exec rake 'litmus:install_agent[puppet6]'
- bundle exec rake litmus:install_module
script:
- TARGET_HOST=localhost:2222 bundle exec rspec ./spec/acceptance/
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORM=scientificlinux6_puppet5
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision[docker, waffleimage/scientificlinux6]'
- bundle exec rake 'litmus:install_agent[puppet5]'
- bundle exec rake litmus:install_module
script:
- TARGET_HOST=localhost:2222 bundle exec rspec ./spec/acceptance/
services: docker
sudo: required
-
bundler_args:
dist: trusty
env: PLATFORM=scientificlinux6_puppet6
rvm: 2.5.1
before_script:
- bundle exec rake 'litmus:provision[docker, waffleimage/scientificlinux6]'
- bundle exec rake 'litmus:install_agent[puppet6]'
- bundle exec rake litmus:install_module
script:
- TARGET_HOST=localhost:2222 bundle exec rspec ./spec/acceptance/
services: docker
stage: acceptance
sudo: required
-
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
stage: static
-
env: PUPPET_GEM_VERSION="~> 5.0" CHECK=parallel_spec
rvm: 2.4.5
stage: spec
-
env: PUPPET_GEM_VERSION="~> 6.0" CHECK=parallel_spec
rvm: 2.5.3
stage: spec
-
env: DEPLOY_TO_FORGE=yes
stage: deploy
branches:
only:
- master
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
group :system_tests do
gem "puppet-module-posix-system-r#{minor_version}", require: false, platforms: [:ruby]
gem "puppet-module-win-system-r#{minor_version}", require: false, platforms: [:mswin, :mingw, :x64_mingw]
gem "beaker-testmode_switcher", require: false
gem "puppet_litmus", require: false, platforms: [:ruby, :mswin, :mingw, :x64_mingw] if ENV['PUPPET_GEM_VERSION'].nil? or ENV['PUPPET_GEM_VERSION'] !~ %r{ 5}
end

puppet_version = ENV['PUPPET_GEM_VERSION']
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ For an extensive list of supported operating systems, see [metadata.json](https:

## Development

We are experimenting with a new tool for running acceptance tests. Its name is [puppet_litmus](https://github.com/puppetlabs/puppet_litmus) this replaces beaker as the test runner. To run the acceptance tests follow the instructions from this point [here](https://github.com/puppetlabs/puppet_litmus/wiki/Tutorial:-use-Litmus-to-execute-acceptance-tests-with-a-sample-module-(MoTD)#install-the-necessary-gems-for-the-module).

Puppet modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve.

We want to keep it as easy as possible to contribute changes so that our modules work in your environment. There are a few guidelines that we need contributors to follow so that we can have a chance of keeping on top of things.
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any?
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-syntax/tasks/puppet-syntax'
require 'puppet_blacksmith/rake_tasks' if Bundler.rubygems.find_name('puppet-blacksmith').any?
Expand Down
25 changes: 25 additions & 0 deletions distelli-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
team-modules/puppetlabs-mysql:
PreBuild:
- source /opt/rh/rh-ruby25/enable
- echo "--- LETS update BUNDLER ---"
- bundle install --path vendor/bundle --jobs 3
Build:
- echo "--- PROVISIONING ---"
- source /opt/rh/rh-ruby25/enable
- bundle exec rake litmus:provision_list[release_checks]
- cat inventory.yaml
- echo "--- AGENT INSTALLATION ---"
- bundle exec rake litmus:install_agent
- echo "--- MODULE INSTALLATION ---"
- bundle exec rake litmus:install_module
- echo "--- TESTS RUNNING ---"
- bundle exec rake litmus:acceptance:parallel
AfterBuildSuccess:
- source /opt/rh/rh-ruby25/enable
- bundle exec rake litmus:tear_down
AfterBuildFailure:
- source /opt/rh/rh-ruby25/enable
- bundle exec rake litmus:tear_down
CommitData:
- RepoType: Git
- RepoPath: .
10 changes: 10 additions & 0 deletions manifests/backup/mysqlbackup.pp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
require => Mysql_user["${backupuser}@localhost"],
}

if $::osfamily == 'RedHat' {
package {'cronie':
ensure => present,
}
} else {
package {'cron':
ensure => present,
}
}

cron { 'mysqlbackup-weekly':
ensure => $ensure,
command => 'mysqlbackup backup',
Expand Down
14 changes: 14 additions & 0 deletions manifests/backup/mysqldump.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,20 @@
require => Mysql_user["${backupuser}@localhost"],
}

if $::osfamily == 'RedHat' and $::operatingsystemmajrelease == '5' {
package {'crontabs':
ensure => present,
}
} elsif $::osfamily == 'RedHat' {
package {'cronie':
ensure => present,
}
} else {
package {'cron':
ensure => present,
}
}

cron { 'mysql-backup':
ensure => $ensure,
command => '/usr/local/sbin/mysqlbackup.sh',
Expand Down
13 changes: 6 additions & 7 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@
} else {
$provider = 'mysql'
}

if $provider == 'mariadb' {
$client_package_name = 'mariadb-client'
$server_package_name = 'mariadb-server'
Expand Down Expand Up @@ -222,13 +221,13 @@
} else {
$php_package_name = 'php5-mysql'
}

$python_package_name = 'python-mysqldb'
$ruby_package_name = $::lsbdistcodename ? {
'jessie' => 'ruby-mysql',
'stretch' => 'ruby-mysql2',
'trusty' => 'ruby-mysql',
'xenial' => 'ruby-mysql',
'bionic' => 'ruby-mysql2',
$ruby_package_name = $::operatingsystemrelease ? {
'8' => 'ruby-mysql',
'9' => 'ruby-mysql2',
'14' => 'ruby-mysql',
'16' => 'ruby-mysql',
default => 'libmysql-ruby',
}
}
Expand Down
4 changes: 2 additions & 2 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
}
],
"description": "MySQL module",
"template-url": "https://github.com/puppetlabs/pdk-templates#master",
"template-ref": "heads/master-0-gf778803",
"template-url": "https://github.com/puppetlabs/pdk-templates/#1.10.0",
"template-ref": "1.10.0-0-gbba9ac3",
"pdk-version": "1.10.0"
}
13 changes: 13 additions & 0 deletions provision.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
default:
provisioner: docker
images: ['waffleimage/centos7']
travis_deb:
provisioner: docker
images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04']
travis_el7:
provisioner: docker
images: ['waffleimage/centos7', 'waffleimage/oraclelinux7', 'waffleimage/scientificlinux7']
release_checks:
provisioner: vmpooler
images: ['redhat-5-x86_64', 'redhat-6-x86_64', 'redhat-7-x86_64', 'centos-5-x86_64', 'centos-6-x86_64', 'centos-7-x86_64', 'oracle-5-x86_64', 'oracle-6-x86_64', 'oracle-7-x86_64', 'scientific-6-x86_64', 'scientific-7-x86_64', 'debian-8-x86_64', 'debian-9-x86_64', 'sles-11-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64']
Loading

0 comments on commit ad5bb08

Please sign in to comment.