Skip to content

Commit f6150c7

Browse files
author
Michael Smith
committed
Merge remote-tracking branch 'upstream/stable'
2 parents 4593003 + dd56bb6 commit f6150c7

File tree

11 files changed

+93
-11
lines changed

11 files changed

+93
-11
lines changed

acceptance/Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def location_for(place, fake_version = nil)
1212
end
1313
end
1414

15-
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 2.27')
15+
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 2.28')
1616
gem "rake", "~> 10.1"
1717
gem "httparty", :require => false
1818
gem 'uuidtools', :require => false

acceptance/config/aio/options.rb

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
'setup/common/pre-suite/000-delete-puppet-when-none.rb',
99
'setup/aio/pre-suite/010_Install.rb',
1010
'setup/aio/pre-suite/015_PackageHostsPresets.rb',
11+
'setup/aio/pre-suite/020_InstallCumulusModules.rb',
1112
'setup/common/pre-suite/025_StopFirewall.rb',
1213
'setup/common/pre-suite/040_ValidateSignCert.rb',
1314
'setup/aio/pre-suite/045_EnsureMasterStartedOnPassenger.rb',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
HOSTS:
3+
master:
4+
roles:
5+
- master
6+
platform: el-7-x86_64
7+
hypervisor: vcloud
8+
template: redhat-7-x86_64
9+
cumulus-22-x86_64:
10+
roles:
11+
- agent
12+
platform: cumulus-2.2-amd64
13+
hypervisor: none
14+
ip: 10.0.77.5
15+
vmhostname: dell-s6000.delivery.puppetlabs.net
16+
CONFIG:
17+
datastore: instance0
18+
resourcepool: delivery/Quality Assurance/FOSS/Dynamic
19+
folder: Delivery/Quality Assurance/FOSS/Dynamic
20+
pooling_api: http://vmpooler.delivery.puppetlabs.net/

acceptance/lib/puppet/acceptance/install_utils.rb

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Acceptance
88
module InstallUtils
99
PLATFORM_PATTERNS = {
1010
:redhat => /fedora|el-|centos/,
11-
:debian => /debian|ubuntu/,
11+
:debian => /debian|ubuntu|cumulus/,
1212
:debian_ruby18 => /debian|ubuntu-lucid|ubuntu-precise/,
1313
:solaris_10 => /solaris-10/,
1414
:solaris_11 => /solaris-11/,
@@ -141,11 +141,15 @@ def install_repos_on(host, project, sha, repo_configs_dir)
141141
repo_url = "http://%s/%s/%s/repo_configs/rpm/%s" % [tld, project, sha, repo_filename]
142142

143143
on host, "curl -o /etc/yum.repos.d/#{repo_filename} #{repo_url}"
144-
when /^(debian|ubuntu)-([^-]+)-(.+)$/
144+
when /^(debian|ubuntu|cumulus)-([^-]+)-(.+)$/
145145
variant = $1
146146
version = $2
147147
arch = $3
148148

149+
if variant =~ /cumulus/ then
150+
version = variant
151+
end
152+
149153
list_filename = "pl-%s%s-%s.list" % [
150154
project,
151155
sha ? '-' + sha : '',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
platforms = hosts.map{|val| val[:platform]}
2+
skip_test "No cumulus hosts present" unless platforms.any? { |val| /cumulus/ =~ val }
3+
confine :to, {}, hosts.select { |host| host[:roles].include?('master') }
4+
5+
step 'install Cumulus Modules on masters' do
6+
hosts.each do |node|
7+
on(node, puppet('module','install','cumuluslinux-cumulus_license'))
8+
on(node, puppet('module','install','cumuluslinux-cumulus_interfaces'))
9+
on(node, puppet('module','install','cumuluslinux-cumulus_interface_policy'))
10+
on(node, puppet('module','install','cumuluslinux-cumulus_ports'))
11+
end
12+
end

acceptance/tests/aix/aix_package_provider.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def assert_package_version(package, expected_version)
2020

2121
teardown do
2222
on hosts, "rm -rf #{dir}"
23-
on hosts, puppet('resource', 'package', "'#{package}' ensure=absent")
23+
on hosts, "installp -u #{package}"
2424
end
2525

2626
step "download packages to use for test"

lib/puppet/application/agent.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ def run_command
322322
# waiting for certificates so that we don't block
323323
daemon = daemonize_process_when(Puppet[:daemonize])
324324

325+
# Setup signal traps immediately after daemonization so we clean up the daemon
326+
daemon.set_signal_traps
327+
325328
wait_for_certificates
326329

327330
if Puppet[:onetime]
@@ -346,7 +349,6 @@ def fingerprint
346349
end
347350

348351
def onetime(daemon)
349-
daemon.set_signal_traps
350352
begin
351353
exitstatus = daemon.agent.run
352354
rescue => detail

lib/puppet/application/master.rb

+3
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ def start_webrick_master
295295
daemon.server = Puppet::Network::Server.new(Puppet[:bindaddress], Puppet[:masterport])
296296
daemon.daemonize if Puppet[:daemonize]
297297

298+
# Setup signal traps immediately after daemonization so we clean up the daemon
299+
daemon.set_signal_traps
300+
298301
announce_start_of_master
299302

300303
daemon.start

lib/puppet/daemon.rb

-2
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,6 @@ def stop(args = {:exit => true})
138138
end
139139

140140
def start
141-
set_signal_traps
142-
143141
create_pidfile
144142

145143
raise Puppet::DevError, "Daemons must have an agent, server, or both" unless agent or server

lib/puppet/provider/service/src.rb

+27
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'timeout'
2+
13
# AIX System Resource controller (SRC)
24
Puppet::Type.type(:service).provide :src, :parent => :base do
35

@@ -63,6 +65,31 @@ def disable
6365
rmitab(@resource[:name])
6466
end
6567

68+
# Wait for the service to transition into the specified state before returning.
69+
# This is necessary due to the asynchronous nature of AIX services.
70+
# desired_state should either be :running or :stopped.
71+
def wait(desired_state)
72+
Timeout.timeout(60) do
73+
loop do
74+
status = self.status
75+
break if status == desired_state.to_sym
76+
sleep(1)
77+
end
78+
end
79+
rescue Timeout::Error
80+
raise Puppet::Error.new("Timed out waiting for #{@resource[:name]} to transition states")
81+
end
82+
83+
def start
84+
super
85+
self.wait(:running)
86+
end
87+
88+
def stop
89+
super
90+
self.wait(:stopped)
91+
end
92+
6693
def restart
6794
execute([command(:lssrc), "-Ss", @resource[:name]]).each_line do |line|
6895
args = line.split(":")

spec/unit/provider/service/src_spec.rb

+19-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
end
3838

3939
describe ".instances" do
40-
it "should has a .instances method" do
40+
it "should have a .instances method" do
4141
expect(provider_class).to respond_to :instances
4242
end
4343

@@ -63,15 +63,29 @@
6363
describe "when starting a service" do
6464
it "should execute the startsrc command" do
6565
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
66+
@provider.expects(:status).returns :running
6667
@provider.start
6768
end
69+
70+
it "should error if timeout occurs while stopping the service" do
71+
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
72+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
73+
expect { @provider.start }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
74+
end
6875
end
6976

7077
describe "when stopping a service" do
7178
it "should execute the stopsrc command" do
7279
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
80+
@provider.expects(:status).returns :stopped
7381
@provider.stop
7482
end
83+
84+
it "should error if timeout occurs while stopping the service" do
85+
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
86+
Timeout.expects(:timeout).with(60).raises(Timeout::Error)
87+
expect { @provider.stop }.to raise_error Puppet::Error, ('Timed out waiting for myservice to transition states')
88+
end
7589
end
7690

7791
describe "should have a set of methods" do
@@ -160,14 +174,15 @@
160174
@provider.restart
161175
end
162176

163-
it "should execute restart which runs stopsrc then startsrc" do
177+
it "should execute restart which runs stop then start" do
164178
sample_output = <<_EOF_
165179
#subsysname:synonym:cmdargs:path:uid:auditid:standin:standout:standerr:action:multi:contact:svrkey:svrmtype:priority:signorm:sigforce:display:waittime:grpname:
166180
myservice::--no-daemonize:/usr/sbin/puppetd:0:0:/dev/null:/var/log/puppet.log:/var/log/puppet.log:-O:-Q:-S:0:0:20:15:9:-d:20::"
167181
_EOF_
182+
168183
@provider.expects(:execute).with(['/usr/bin/lssrc', '-Ss', "myservice"]).returns sample_output
169-
@provider.expects(:execute).with(['/usr/bin/stopsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
170-
@provider.expects(:execute).with(['/usr/bin/startsrc', '-s', "myservice"], {:override_locale => false, :squelch => false, :combine => true, :failonfail => true})
184+
@provider.expects(:stop)
185+
@provider.expects(:start)
171186
@provider.restart
172187
end
173188
end

0 commit comments

Comments
 (0)