Merge "Support [executor] type"
This commit is contained in:
@@ -4,16 +4,23 @@
|
||||
#
|
||||
# === Parameters
|
||||
# [*package_ensure*]
|
||||
# (Optional) Ensure state for package.
|
||||
# Defaults to present
|
||||
# (Optional) Ensure state for package.
|
||||
# Defaults to present
|
||||
#
|
||||
# [*enabled*]
|
||||
# (optional) Should the service be enabled.
|
||||
# Defaults to 'true'.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*manage_service*]
|
||||
# (optional) Whether the service should be managed by Puppet.
|
||||
# Defaults to 'true'.
|
||||
# Defaults to true.
|
||||
#
|
||||
# [*type*]
|
||||
# (Optional) Type of executor. Use local to run the executor within
|
||||
# the engine server. Use remote if the executor is launched as a separate
|
||||
# server to process events.
|
||||
# (string value)
|
||||
# Defaults to 'remote'.
|
||||
#
|
||||
# [*host*]
|
||||
# (Optional) Name of the executor node. This can be an opaque identifier.
|
||||
@@ -29,12 +36,13 @@
|
||||
# Defaults to $facts['os_service_default'].
|
||||
#
|
||||
class mistral::executor (
|
||||
$package_ensure = present,
|
||||
Boolean $manage_service = true,
|
||||
Boolean $enabled = true,
|
||||
$host = $facts['os_service_default'],
|
||||
$topic = $facts['os_service_default'],
|
||||
$version = $facts['os_service_default'],
|
||||
$package_ensure = present,
|
||||
Boolean $manage_service = true,
|
||||
Boolean $enabled = true,
|
||||
Enum['local', 'remote'] $type = 'remote',
|
||||
$host = $facts['os_service_default'],
|
||||
$topic = $facts['os_service_default'],
|
||||
$version = $facts['os_service_default'],
|
||||
) {
|
||||
|
||||
include mistral::deps
|
||||
@@ -47,7 +55,12 @@ class mistral::executor (
|
||||
}
|
||||
|
||||
if $manage_service {
|
||||
if $enabled {
|
||||
$enabled_real = $type ? {
|
||||
'remote' => $enabled,
|
||||
default => false,
|
||||
}
|
||||
|
||||
if $enabled_real {
|
||||
$service_ensure = 'running'
|
||||
} else {
|
||||
$service_ensure = 'stopped'
|
||||
@@ -56,7 +69,7 @@ class mistral::executor (
|
||||
service { 'mistral-executor':
|
||||
ensure => $service_ensure,
|
||||
name => $::mistral::params::executor_service_name,
|
||||
enable => $enabled,
|
||||
enable => $enabled_real,
|
||||
hasstatus => true,
|
||||
hasrestart => true,
|
||||
tag => 'mistral-service',
|
||||
@@ -64,6 +77,7 @@ class mistral::executor (
|
||||
}
|
||||
|
||||
mistral_config {
|
||||
'executor/type': value => $type;
|
||||
'executor/host': value => $host;
|
||||
'executor/topic': value => $topic;
|
||||
'executor/version': value => $version;
|
||||
|
||||
4
releasenotes/notes/executor-type-d6940e8c1380ca6c.yaml
Normal file
4
releasenotes/notes/executor-type-d6940e8c1380ca6c.yaml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
The new ``mistral::executor::type`` parameter has been added.
|
||||
@@ -1,51 +1,84 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'mistral::executor' do
|
||||
let :params do
|
||||
{
|
||||
:enabled => true,
|
||||
:manage_service => true,
|
||||
:host => true,
|
||||
:topic => true,
|
||||
:version => true
|
||||
}
|
||||
end
|
||||
|
||||
shared_examples 'mistral::executor' do
|
||||
context 'config params' do
|
||||
it { is_expected.to contain_class('mistral::params') }
|
||||
shared_examples_for 'mistral::executor' do
|
||||
context 'with defaults' do
|
||||
it 'configure executor default params' do
|
||||
is_expected.to contain_mistral_config('executor/type').with_value('remote')
|
||||
is_expected.to contain_mistral_config('executor/host').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_mistral_config('executor/topic').with_value('<SERVICE DEFAULT>')
|
||||
is_expected.to contain_mistral_config('executor/version').with_value('<SERVICE DEFAULT>')
|
||||
end
|
||||
|
||||
it { is_expected.to contain_mistral_config('executor/host').with_value( params[:host] ) }
|
||||
it { is_expected.to contain_mistral_config('executor/topic').with_value( params[:topic] ) }
|
||||
it { is_expected.to contain_mistral_config('executor/version').with_value( params[:version] ) }
|
||||
end
|
||||
it 'installs mistral-executor package' do
|
||||
is_expected.to contain_package('mistral-executor').with(
|
||||
:ensure => 'present',
|
||||
:name => platform_params[:executor_package_name],
|
||||
:tag => ['openstack', 'mistral-package']
|
||||
)
|
||||
end
|
||||
|
||||
[{:enabled => true}, {:enabled => false}].each do |param_hash|
|
||||
context "when service should be #{param_hash[:enabled] ? 'enabled' : 'disabled'}" do
|
||||
before do
|
||||
params.merge!(param_hash)
|
||||
end
|
||||
|
||||
it 'configures mistral-executor service' do
|
||||
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => params[:enabled] ? 'running' : 'stopped',
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => params[:enabled],
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
is_expected.to contain_service('mistral-executor').that_subscribes_to(nil)
|
||||
end
|
||||
it 'configures mistral-executor service' do
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => 'running',
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => true,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with disabled service managing' do
|
||||
before do
|
||||
params.merge!({
|
||||
:manage_service => false
|
||||
})
|
||||
context 'with specific parameters' do
|
||||
let :params do
|
||||
{ :type => 'local',
|
||||
:host => 'localhost',
|
||||
:topic => 'mistral_executor',
|
||||
:version => '1.0'
|
||||
}
|
||||
end
|
||||
|
||||
it 'configure executor params' do
|
||||
is_expected.to contain_mistral_config('executor/type').with_value('local')
|
||||
is_expected.to contain_mistral_config('executor/host').with_value('localhost')
|
||||
is_expected.to contain_mistral_config('executor/topic').with_value('mistral_executor')
|
||||
is_expected.to contain_mistral_config('executor/version').with_value('1.0')
|
||||
end
|
||||
|
||||
it 'disables mistral-executor service' do
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => 'stopped',
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with service disabled' do
|
||||
let :params do
|
||||
{ :enabled => false }
|
||||
end
|
||||
|
||||
it 'configures mistral-executor service' do
|
||||
is_expected.to contain_service('mistral-executor').with(
|
||||
:ensure => 'stopped',
|
||||
:name => platform_params[:executor_service_name],
|
||||
:enable => false,
|
||||
:hasstatus => true,
|
||||
:hasrestart => true,
|
||||
:tag => 'mistral-service',
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
context 'with service unmanaged' do
|
||||
let :params do
|
||||
{ :manage_service => false }
|
||||
end
|
||||
|
||||
it 'does not configure mistral-executor service' do
|
||||
@@ -55,7 +88,7 @@ describe 'mistral::executor' do
|
||||
end
|
||||
|
||||
on_supported_os({
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
:supported_os => OSDefaults.get_supported_os
|
||||
}).each do |os,facts|
|
||||
context "on #{os}" do
|
||||
let (:facts) do
|
||||
@@ -65,13 +98,20 @@ describe 'mistral::executor' do
|
||||
let (:platform_params) do
|
||||
case facts[:os]['family']
|
||||
when 'Debian'
|
||||
{ :executor_service_name => 'mistral-executor' }
|
||||
{
|
||||
:executor_package_name => 'mistral-executor',
|
||||
:executor_service_name => 'mistral-executor'
|
||||
}
|
||||
when 'RedHat'
|
||||
{ :executor_service_name => 'openstack-mistral-executor' }
|
||||
{
|
||||
:executor_package_name => 'openstack-mistral-executor',
|
||||
:executor_service_name => 'openstack-mistral-executor'
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
it_behaves_like 'mistral::executor'
|
||||
it_configures 'mistral::executor'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user