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