Update agent init file for better shutdown
Updated to match the changes here: https://review.openstack.org/#/c/408813/ Also adds basic tests for monasca::agent class Change-Id: Iec74ba0003a432f2175a745ff88cba2584972604
This commit is contained in:
parent
0c64cfad13
commit
bed6e5af2e
|
@ -1,3 +1,7 @@
|
||||||
mod 'wget',
|
mod 'wget',
|
||||||
:git => "https://github.com/maestrodev/puppet-wget.git",
|
:git => "https://github.com/maestrodev/puppet-wget.git",
|
||||||
:tag => 'v1.7.3'
|
:tag => 'v1.7.3'
|
||||||
|
|
||||||
|
mod 'epel',
|
||||||
|
:git => "https://github.com/stahnma/puppet-module-epel",
|
||||||
|
:tag => '1.2.2'
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe 'monasca::agent' do
|
||||||
|
|
||||||
|
let :params do
|
||||||
|
{ :url => 'http://localhost:8070/v2.0',
|
||||||
|
:username => 'monasca-agent',
|
||||||
|
:password => 'password',
|
||||||
|
:keystone_url => 'http://localhost:5000/v3/',
|
||||||
|
:install_python_deps => false }
|
||||||
|
end
|
||||||
|
|
||||||
|
shared_examples 'monasca-agent' do
|
||||||
|
|
||||||
|
context 'with default parameters' do
|
||||||
|
|
||||||
|
it 'sets up monasca-agent files' do
|
||||||
|
is_expected.to contain_file('/etc/init.d/monasca-agent').with(
|
||||||
|
:owner => 'root',
|
||||||
|
:group => 'root',
|
||||||
|
:mode => '0755',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'installs monasca-agent service' do
|
||||||
|
is_expected.to contain_service('monasca-agent').with(
|
||||||
|
:ensure => 'running',
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures various stuff' do
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*url: http:\/\/localhost:8070\/v2.0$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*username: monasca-agent$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*password: password$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*keystone_url: http:\/\/localhost:5000\/v3\/$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_name: null$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_domain_id: null$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_domain_name: null$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_id: null$/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with overridden parameters' do
|
||||||
|
before do
|
||||||
|
params.merge!({
|
||||||
|
:project_name => 'test_project',
|
||||||
|
:project_domain_id => 'domain_id',
|
||||||
|
:project_domain_name => 'test_domain',
|
||||||
|
:project_id => 'project_id',
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'configures various stuff' do
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_name: test_project$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_domain_id: domain_id$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_domain_name: test_domain$/)
|
||||||
|
is_expected.to contain_file('/etc/monasca/agent/agent.yaml').with_content(/^\s*project_id: project_id$/)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
on_supported_os({
|
||||||
|
:supported_os => OSDefaults.get_supported_os
|
||||||
|
}).each do |os,facts|
|
||||||
|
context "on #{os}" do
|
||||||
|
let (:facts) do
|
||||||
|
facts.merge!(OSDefaults.get_facts)
|
||||||
|
end
|
||||||
|
it_behaves_like 'monasca-agent'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -113,11 +113,20 @@ case "$1" in
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
|
|
||||||
echo "Stopping $DESC (stopping supervisord)" "$NAME"
|
|
||||||
if [ -e $SUPERVISOR_PIDFILE ]; then
|
if [ -e $SUPERVISOR_PIDFILE ]; then
|
||||||
kill `cat $SUPERVISOR_PIDFILE`
|
kill `cat $SUPERVISOR_PIDFILE`
|
||||||
|
retries=10
|
||||||
|
until ! check_status > /dev/null; do
|
||||||
|
if [ $retries -le 1 ]; then
|
||||||
|
echo "Timeout hit while waiting for agent to stop"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
retries=$(($retries - 1))
|
||||||
|
sleep 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
else
|
else
|
||||||
echo "Pid file $SUPERVISOR_PIDFILE not found, nothing to stop"
|
echo "Pid file $SUPERVISOR_PIDFILE not found, nothing to stop"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit $?
|
exit $?
|
||||||
|
@ -143,7 +152,6 @@ case "$1" in
|
||||||
|
|
||||||
restart|force-reload)
|
restart|force-reload)
|
||||||
$0 stop
|
$0 stop
|
||||||
sleep 1
|
|
||||||
$0 start
|
$0 start
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue