(FM-8223) converted to use litmus (#376)
(FM-8223) converted to use litmus
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
fixtures:
|
||||
repositories:
|
||||
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
||||
archive: "git://github.com/voxpupuli/puppet-archive.git"
|
||||
facts: 'git://github.com/puppetlabs/puppetlabs-facts.git'
|
||||
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"
|
||||
puppet_agent: 'git://github.com/puppetlabs/puppetlabs-puppet_agent.git'
|
||||
provision: 'git://github.com/puppetlabs/provision.git'
|
||||
symlinks:
|
||||
java: "#{source_dir}"
|
||||
|
||||
18
.sync.yml
18
.sync.yml
@@ -7,14 +7,7 @@
|
||||
unmanaged: true
|
||||
|
||||
.travis.yml:
|
||||
docker_sets:
|
||||
- set: docker/centos-7
|
||||
- set: docker/ubuntu-14.04
|
||||
docker_defaults:
|
||||
bundler_args: ""
|
||||
secure: ""
|
||||
branches:
|
||||
- release
|
||||
unmanaged: true
|
||||
|
||||
appveyor.yml:
|
||||
delete: true
|
||||
@@ -26,15 +19,6 @@ Gemfile:
|
||||
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}'
|
||||
platforms: ruby
|
||||
- gem: 'puppet-module-win-system-r#{minor_version}'
|
||||
platforms:
|
||||
- mswin
|
||||
- mingw
|
||||
- x64_mingw
|
||||
|
||||
spec/spec_helper.rb:
|
||||
mock_with: ':rspec'
|
||||
|
||||
55
.travis.yml
55
.travis.yml
@@ -24,22 +24,57 @@ 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: PLATFORMS=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
|
||||
-
|
||||
bundler_args:
|
||||
dist: trusty
|
||||
env: PLATFORMS=el_puppet5
|
||||
rvm: 2.5.1
|
||||
before_script:
|
||||
- bundle exec rake 'litmus:provision_list[travis_el]'
|
||||
- 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: PLATFORMS=el_puppet6
|
||||
rvm: 2.5.1
|
||||
before_script:
|
||||
- bundle exec rake 'litmus:provision_list[travis_el]'
|
||||
- bundle exec rake 'litmus:install_agent[puppet6]'
|
||||
- bundle exec rake litmus:install_module
|
||||
script:
|
||||
- bundle exec rake litmus:acceptance:parallel
|
||||
services: docker
|
||||
stage: acceptance
|
||||
sudo: required
|
||||
-
|
||||
env: CHECK="check:symlinks check:git_ignore check:dot_underscore check:test_file rubocop syntax lint metadata_lint"
|
||||
|
||||
25
distelli-manifest.yml
Normal file
25
distelli-manifest.yml
Normal file
@@ -0,0 +1,25 @@
|
||||
team-modules/puppetlabs-java:
|
||||
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: .
|
||||
@@ -78,7 +78,7 @@
|
||||
"version_requirement": ">= 5.5.10 < 7.0.0"
|
||||
}
|
||||
],
|
||||
"template-url": "https://github.com/puppetlabs/pdk-templates#master",
|
||||
"template-url": "https://github.com/puppetlabs/pdk-templates/#master",
|
||||
"template-ref": "heads/master-0-gb096033",
|
||||
"pdk-version": "1.11.1"
|
||||
}
|
||||
|
||||
13
provision.yaml
Normal file
13
provision.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
---
|
||||
default:
|
||||
provisioner: docker
|
||||
images: ['waffleimage/debian8']
|
||||
travis_deb:
|
||||
provisioner: docker
|
||||
images: ['debian:8', 'debian:9', 'ubuntu:14.04', 'ubuntu:16.04', 'ubuntu:18.04']
|
||||
travis_el:
|
||||
provisioner: docker_exp
|
||||
images: ['centos:6', 'centos:7', 'oraclelinux:6', 'oraclelinux:7', 'scientificlinux/sl:6', 'scientificlinux/sl:7']
|
||||
release_checks:
|
||||
provisioner: vmpooler
|
||||
images: ['redhat-6-x86_64', 'redhat-7-x86_64', 'redhat-8-x86_64', 'centos-6-x86_64', 'centos-7-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', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64', 'sles-11-x86_64', 'sles-12-x86_64', 'sles-15-x86_64']
|
||||
@@ -1,7 +1,5 @@
|
||||
require 'spec_helper_acceptance'
|
||||
|
||||
include Unix::File
|
||||
|
||||
java_class_jre = "class { 'java':\n"\
|
||||
" distribution => 'jre',\n"\
|
||||
'}'
|
||||
@@ -22,14 +20,6 @@ _sun_jdk = "class { 'java':\n"\
|
||||
" distribution => 'sun-jdk',\n"\
|
||||
'}'
|
||||
|
||||
oracle_jre = "class { 'java':\n"\
|
||||
" distribution => 'oracle-jre',\n"\
|
||||
'}'
|
||||
|
||||
oracle_jdk = "class { 'java':\n"\
|
||||
" distribution => 'oracle-jdk',\n"\
|
||||
'}'
|
||||
|
||||
blank_version = "class { 'java':\n"\
|
||||
" version => '',\n"\
|
||||
'}'
|
||||
@@ -51,88 +41,15 @@ bogus_alternative = "class { 'java':\n"\
|
||||
" java_alternative_path => '/whatever',\n"\
|
||||
'}'
|
||||
|
||||
# Oracle installs are disabled by default, because the links to valid oracle installations
|
||||
# change often. Look the parameters up from the Oracle download URLs at https://java.oracle.com and
|
||||
# enable the tests:
|
||||
|
||||
oracle_enabled = false
|
||||
oracle_version_major = '8'
|
||||
oracle_version_minor = '201'
|
||||
oracle_version_build = '09'
|
||||
oracle_hash = '42970487e3af4f5aa5bca3f542482c60'
|
||||
|
||||
install_oracle_jdk_jre = <<EOL
|
||||
java::oracle {
|
||||
'test_oracle_jre':
|
||||
version => '#{oracle_version_major}',
|
||||
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
|
||||
version_minor => 'b#{oracle_version_build}',
|
||||
url_hash => '#{oracle_hash}',
|
||||
java_se => 'jre',
|
||||
}
|
||||
java::oracle {
|
||||
'test_oracle_jdk':
|
||||
version => '#{oracle_version_major}',
|
||||
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
|
||||
version_minor => 'b#{oracle_version_build}',
|
||||
url_hash => '#{oracle_hash}',
|
||||
java_se => 'jdk',
|
||||
}
|
||||
EOL
|
||||
|
||||
install_oracle_jre_jce = <<EOL
|
||||
java::oracle {
|
||||
'test_oracle_jre':
|
||||
version => '#{oracle_version_major}',
|
||||
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
|
||||
version_minor => 'b#{oracle_version_build}',
|
||||
url_hash => '#{oracle_hash}',
|
||||
java_se => 'jre',
|
||||
jce => true,
|
||||
}
|
||||
|
||||
EOL
|
||||
|
||||
install_oracle_jdk_jce = <<EOL
|
||||
java::oracle {
|
||||
'test_oracle_jdk':
|
||||
version => '#{oracle_version_major}',
|
||||
version_major => '#{oracle_version_major}u#{oracle_version_minor}',
|
||||
version_minor => 'b#{oracle_version_build}',
|
||||
url_hash => '#{oracle_hash}',
|
||||
java_se => 'jdk',
|
||||
jce => true,
|
||||
}
|
||||
EOL
|
||||
|
||||
context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
||||
context 'installing java jre', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
|
||||
it 'installs jre' do
|
||||
idempotent_apply(default, java_class_jre)
|
||||
idempotent_apply(java_class_jre)
|
||||
end
|
||||
end
|
||||
|
||||
context 'installing java jdk', unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
||||
context 'installing java jdk', unless: UNSUPPORTED_PLATFORMS.include?(os[:family]) do
|
||||
it 'installs jdk' do
|
||||
idempotent_apply(default, java_class)
|
||||
end
|
||||
end
|
||||
|
||||
context 'oracle', if: (
|
||||
(fact('operatingsystem') == 'Ubuntu') && fact('operatingsystemrelease').match(%r{^14\.04})
|
||||
) do
|
||||
# not supported
|
||||
# The package is not available from any sources, but if a customer
|
||||
# custom-builds the package using java-package and adds it to a local
|
||||
# repository, that is the intention of this version ability
|
||||
describe 'jre' do
|
||||
it 'installs oracle-jre' do
|
||||
apply_manifest(oracle_jre, expect_failures: true)
|
||||
end
|
||||
end
|
||||
describe 'jdk' do
|
||||
it 'installs oracle-jdk' do
|
||||
apply_manifest(oracle_jdk, expect_failures: true)
|
||||
end
|
||||
idempotent_apply(java_class)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -154,40 +71,10 @@ context 'with failure cases' do
|
||||
end
|
||||
|
||||
it 'fails on debian or RHEL when passed fake java_alternative and path' do
|
||||
if fact('osfamily') == 'Debian' || fact('osfamily') == 'RedHat'
|
||||
if os[:family] == 'debian' || os[:family] == 'redhat'
|
||||
apply_manifest(bogus_alternative, expect_failures: true)
|
||||
else
|
||||
apply_manifest(bogus_alternative, catch_failures: true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'java::oracle', if: oracle_enabled, unless: UNSUPPORTED_PLATFORMS.include?(fact('osfamily')) do
|
||||
let(:install_path) do
|
||||
(fact('osfamily') == 'RedHat') ? '/usr/java' : '/usr/lib/jvm'
|
||||
end
|
||||
|
||||
let(:version_suffix) do
|
||||
(fact('osfamily') == 'RedHat') ? '-amd64' : ''
|
||||
end
|
||||
|
||||
it 'installs oracle jdk and jre' do
|
||||
idempotent_apply(default, install_oracle_jdk_jre)
|
||||
jdk_result = shell("test ! -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar")
|
||||
jre_result = shell("test ! -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar")
|
||||
expect(jdk_result.exit_code).to eq(0)
|
||||
expect(jre_result.exit_code).to eq(0)
|
||||
end
|
||||
|
||||
it 'installs oracle jdk with jce' do
|
||||
idempotent_apply(default, install_oracle_jdk_jce)
|
||||
result = shell("test -e #{install_path}/jdk1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/jre/lib/security/local_policy.jar")
|
||||
expect(result.exit_code).to eq(0)
|
||||
end
|
||||
|
||||
it 'installs oracle jre with jce' do
|
||||
idempotent_apply(default, install_oracle_jre_jce)
|
||||
result = shell("test -e #{install_path}/jre1.#{oracle_version_major}.0_#{oracle_version_minor}#{version_suffix}/lib/security/local_policy.jar")
|
||||
expect(result.exit_code).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
HOSTS:
|
||||
centos-7-x64:
|
||||
roles:
|
||||
- agent
|
||||
- default
|
||||
platform: el-7-x86_64
|
||||
hypervisor: vagrant
|
||||
box: puppetlabs/centos-7.2-64-nocm
|
||||
CONFIG:
|
||||
type: foss
|
||||
@@ -1,10 +0,0 @@
|
||||
HOSTS:
|
||||
debian-8-x64:
|
||||
roles:
|
||||
- agent
|
||||
- default
|
||||
platform: debian-8-amd64
|
||||
hypervisor: vagrant
|
||||
box: puppetlabs/debian-8.2-64-nocm
|
||||
CONFIG:
|
||||
type: foss
|
||||
@@ -1,10 +0,0 @@
|
||||
HOSTS:
|
||||
ubuntu-1404-x64:
|
||||
roles:
|
||||
- agent
|
||||
- default
|
||||
platform: ubuntu-14.04-amd64
|
||||
hypervisor: vagrant
|
||||
box: puppetlabs/ubuntu-14.04-64-nocm
|
||||
CONFIG:
|
||||
type: foss
|
||||
@@ -1,12 +0,0 @@
|
||||
HOSTS:
|
||||
centos-7-x64:
|
||||
platform: el-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:
|
||||
trace_limit: 200
|
||||
@@ -1,11 +0,0 @@
|
||||
HOSTS:
|
||||
debian-8-x64:
|
||||
platform: debian-8-amd64
|
||||
hypervisor: docker
|
||||
image: debian:8
|
||||
docker_preserve_image: true
|
||||
docker_cmd: '["/sbin/init"]'
|
||||
docker_image_commands:
|
||||
- 'apt-get update && apt-get install -y net-tools wget locales strace lsof && echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen'
|
||||
CONFIG:
|
||||
trace_limit: 200
|
||||
@@ -1,12 +0,0 @@
|
||||
HOSTS:
|
||||
ubuntu-1404-x64:
|
||||
platform: ubuntu-14.04-amd64
|
||||
hypervisor: docker
|
||||
image: ubuntu:14.04
|
||||
docker_preserve_image: true
|
||||
docker_cmd: '["/sbin/init"]'
|
||||
docker_image_commands:
|
||||
# ensure that upstart is booting correctly in the container
|
||||
- 'rm /usr/sbin/policy-rc.d && rm /sbin/initctl && dpkg-divert --rename --remove /sbin/initctl && apt-get update && apt-get install -y net-tools wget && locale-gen en_US.UTF-8'
|
||||
CONFIG:
|
||||
trace_limit: 200
|
||||
@@ -1,37 +1,59 @@
|
||||
require 'beaker-pe'
|
||||
require 'beaker-puppet'
|
||||
require 'beaker-rspec'
|
||||
require 'beaker/puppet_install_helper'
|
||||
require 'beaker/module_install_helper'
|
||||
# frozen_string_literal: true
|
||||
|
||||
run_puppet_install_helper
|
||||
configure_type_defaults_on(hosts)
|
||||
install_module_on(hosts)
|
||||
install_module_dependencies_on(hosts)
|
||||
require 'serverspec'
|
||||
require 'puppet_litmus'
|
||||
require 'spec_helper_acceptance_local' if File.file?(File.join(File.dirname(__FILE__), 'spec_helper_acceptance_local.rb'))
|
||||
include PuppetLitmus
|
||||
|
||||
UNSUPPORTED_PLATFORMS = ['Darwin', 'windows'].freeze
|
||||
if ENV['TARGET_HOST'].nil? || ENV['TARGET_HOST'] == 'localhost'
|
||||
puts 'Running tests against this machine !'
|
||||
if Gem.win_platform?
|
||||
set :backend, :cmd
|
||||
else
|
||||
set :backend, :exec
|
||||
end
|
||||
else
|
||||
# load inventory
|
||||
inventory_hash = inventory_hash_from_inventory_file
|
||||
node_config = config_from_node(inventory_hash, ENV['TARGET_HOST'])
|
||||
|
||||
unless ENV['RS_PROVISION'] == 'no' || ENV['BEAKER_provision'] == 'no'
|
||||
hosts.each do |host|
|
||||
install_puppet_module_via_pmt_on(host, module_name: 'puppetlabs-apt')
|
||||
end
|
||||
end
|
||||
|
||||
RSpec.configure do |c|
|
||||
# Readable test descriptions
|
||||
c.formatter = :documentation
|
||||
end
|
||||
|
||||
def idempotent_apply(hosts, manifest, opts = {}, &block)
|
||||
block_on hosts, opts do |host|
|
||||
file_path = host.tmpfile('apply_manifest.pp')
|
||||
create_remote_file(host, file_path, manifest + "\n")
|
||||
|
||||
puppet_apply_opts = { :verbose => nil, 'detailed-exitcodes' => nil }
|
||||
on_options = { acceptable_exit_codes: [0, 2] }
|
||||
on host, puppet('apply', file_path, puppet_apply_opts), on_options, &block
|
||||
puppet_apply_opts2 = { :verbose => nil, 'detailed-exitcodes' => nil }
|
||||
on_options2 = { acceptable_exit_codes: [0] }
|
||||
on host, puppet('apply', file_path, puppet_apply_opts2), on_options2, &block
|
||||
if target_in_group(inventory_hash, ENV['TARGET_HOST'], 'docker_nodes')
|
||||
host = ENV['TARGET_HOST']
|
||||
set :backend, :docker
|
||||
set :docker_container, host
|
||||
elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'ssh_nodes')
|
||||
set :backend, :ssh
|
||||
options = Net::SSH::Config.for(host)
|
||||
options[:user] = node_config.dig('ssh', 'user') unless node_config.dig('ssh', 'user').nil?
|
||||
options[:port] = node_config.dig('ssh', 'port') unless node_config.dig('ssh', 'port').nil?
|
||||
options[:keys] = node_config.dig('ssh', 'private-key') unless node_config.dig('ssh', 'private-key').nil?
|
||||
options[:password] = node_config.dig('ssh', 'password') unless node_config.dig('ssh', 'password').nil?
|
||||
options[:verify_host_key] = Net::SSH::Verifiers::Null.new unless node_config.dig('ssh', 'host-key-check').nil?
|
||||
host = if ENV['TARGET_HOST'].include?(':')
|
||||
ENV['TARGET_HOST'].split(':').first
|
||||
else
|
||||
ENV['TARGET_HOST']
|
||||
end
|
||||
set :host, options[:host_name] || host
|
||||
set :ssh_options, options
|
||||
set :request_pty, true
|
||||
elsif target_in_group(inventory_hash, ENV['TARGET_HOST'], 'winrm_nodes')
|
||||
require 'winrm'
|
||||
|
||||
set :backend, :winrm
|
||||
set :os, family: 'windows'
|
||||
user = node_config.dig('winrm', 'user') unless node_config.dig('winrm', 'user').nil?
|
||||
pass = node_config.dig('winrm', 'password') unless node_config.dig('winrm', 'password').nil?
|
||||
endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
|
||||
|
||||
opts = {
|
||||
user: user,
|
||||
password: pass,
|
||||
endpoint: endpoint,
|
||||
operation_timeout: 300,
|
||||
}
|
||||
|
||||
winrm = WinRM::Connection.new opts
|
||||
Specinfra.configuration.winrm = winrm
|
||||
end
|
||||
end
|
||||
|
||||
1
spec/spec_helper_acceptance_local.rb
Normal file
1
spec/spec_helper_acceptance_local.rb
Normal file
@@ -0,0 +1 @@
|
||||
UNSUPPORTED_PLATFORMS = ['darwin', 'windows'].freeze
|
||||
Reference in New Issue
Block a user