(FM-8223) converted to use litmus
This commit is contained in:
@@ -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