-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #517 from puppetlabs/FM-8188
(FM-8188) convert ntp to use litmus
- Loading branch information
Showing
11 changed files
with
192 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
fixtures: | ||
repositories: | ||
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
"augeas_core": "https://github.com/puppetlabs/puppetlabs-augeas_core.git" | ||
facts: 'git://github.com/puppetlabs/puppetlabs-facts.git' | ||
"stdlib": "https://github.com/puppetlabs/puppetlabs-stdlib.git" | ||
provision: "git://github.com/puppetlabs/provision.git" | ||
puppet_agent: 'git://github.com/puppetlabs/puppetlabs-puppet_agent.git' | ||
symlinks: | ||
"ntp": "#{source_dir}" | ||
"my_ntp": "#{source_dir}/spec/fixtures/my_ntp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
team-modules/puppetlabs-ntp: | ||
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: . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
--- | ||
default: | ||
provisioner: docker_exp | ||
images: ['waffleimage/centos7'] | ||
waffle_deb: | ||
provisioner: docker_exp | ||
images: ['waffleimage/debian8', 'waffleimage/debian9', 'waffleimage/ubuntu14.04', 'waffleimage/ubuntu16.04', 'waffleimage/ubuntu18.04'] | ||
waffle_el6: | ||
provisioner: docker_exp | ||
images: ['waffleimage/centos6', 'waffleimage/scientificlinux6'] | ||
waffle_el7: | ||
provisioner: docker_exp | ||
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', 'sles-12-x86_64', 'sles-15-x86_64', 'ubuntu-1404-x86_64', 'ubuntu-1604-x86_64', 'ubuntu-1804-x86_64'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,59 @@ | ||
require 'beaker-pe' | ||
require 'beaker-puppet' | ||
require 'beaker-rspec' | ||
require 'beaker/puppet_install_helper' | ||
require 'beaker/module_install_helper' | ||
|
||
UNSUPPORTED_PLATFORMS = ['windows', 'darwin'].freeze | ||
|
||
run_puppet_install_helper | ||
configure_type_defaults_on(hosts) | ||
install_ca_certs unless ENV['PUPPET_INSTALL_TYPE'] =~ %r{pe}i | ||
install_module_on(hosts) | ||
install_module_dependencies_on(hosts) | ||
|
||
unless ENV['RS_PROVISION'] == 'no' || ENV['BEAKER_provision'] == 'no' | ||
|
||
hosts.each do |host| | ||
# Need to disable update of ntp servers from DHCP, as subsequent restart of ntp causes test failures | ||
if fact_on(host, 'osfamily') == 'Debian' | ||
on host, 'dpkg-divert --divert /etc/dhcp-ntp.bak --local --rename --add /etc/dhcp/dhclient-exit-hooks.d/ntp' | ||
on host, 'dpkg-divert --divert /etc/dhcp3-ntp.bak --local --rename --add /etc/dhcp3/dhclient-exit-hooks.d/ntp' | ||
elsif fact_on(host, 'osfamily') == 'RedHat' | ||
on host, 'echo "PEERNTP=no" >> /etc/sysconfig/network' | ||
end | ||
end | ||
end | ||
|
||
RSpec.configure do |c| | ||
# Project root | ||
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
# Readable test descriptions | ||
c.formatter = :documentation | ||
|
||
# Configure all nodes in nodeset | ||
c.before :suite do | ||
hosts.each do |host| | ||
copy_module_to(host, source: proj_root, module_name: 'ntp') | ||
end | ||
# frozen_string_literal: true | ||
|
||
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 | ||
|
||
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 | ||
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 | ||
else | ||
# load inventory | ||
inventory_hash = inventory_hash_from_inventory_file | ||
node_config = config_from_node(inventory_hash, ENV['TARGET_HOST']) | ||
|
||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# frozen_string_literal: true | ||
|
||
UNSUPPORTED_PLATFORMS = ['windows', 'darwin'].freeze |