Add missing ChefSpec tests and other various fixes
We probably should move the dashboard recipe to the openstack-dashboad cookbook in another patch since we have fwaas and lbaas there as well. Other changes include: - Add missing cookbooks required for openstack-chef CI - Add missing openstack-network dependency needed for the neutron_int recipe - Add missing mdns, producer and worker services for RHEL platform - Ensure all servers start as well as be enabled - Add rndc_key attribute for setting the path of the rndc.key Depends-On: https://review.opendev.org/702772 Change-Id: Ibeb6f0d43313478eff1054552df48f96c7ec589d
This commit is contained in:
parent
cc4ec95267
commit
9a5b6fe6d7
13
Berksfile
13
Berksfile
|
@ -1,6 +1,17 @@
|
|||
source 'https://supermarket.chef.io'
|
||||
|
||||
%w(-common -identity client).each do |cookbook|
|
||||
solver :ruby, :required
|
||||
|
||||
%w(
|
||||
client
|
||||
-common
|
||||
-identity
|
||||
-image
|
||||
-integration-test
|
||||
-network
|
||||
-ops-database
|
||||
-ops-messaging
|
||||
).each do |cookbook|
|
||||
if Dir.exist?("../cookbook-openstack#{cookbook}")
|
||||
cookbook "openstack#{cookbook}", path: "../cookbook-openstack#{cookbook}"
|
||||
else
|
||||
|
|
15
README.rst
15
README.rst
|
@ -39,6 +39,7 @@ The following cookbooks are dependencies:
|
|||
- 'openstackclient'
|
||||
- 'openstack-common', '>= 18.0.0'
|
||||
- 'openstack-identity', '>= 18.0.0'
|
||||
- 'openstack-network', '>= 18.0.0'
|
||||
|
||||
Attributes
|
||||
==========
|
||||
|
@ -115,13 +116,13 @@ License and Author
|
|||
| **Author** | Lance Albertson (lance@osuosl.org) |
|
||||
+-----------------+-----------------------------------------+
|
||||
|
||||
+-----------------+---------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2017-2019, x-ion GmbH. |
|
||||
+-----------------+---------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2017, cloudbau GmbH. |
|
||||
+-----------------+---------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2019, Oregon State University |
|
||||
+-----------------+---------------------------------------------+
|
||||
+-----------------+--------------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2017-2019, x-ion GmbH. |
|
||||
+-----------------+--------------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2017, cloudbau GmbH. |
|
||||
+-----------------+--------------------------------------------------+
|
||||
| **Copyright** | Copyright (c) 2019-2020, Oregon State University |
|
||||
+-----------------+--------------------------------------------------+
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
not use this file except in compliance with the License. You may obtain
|
||||
|
|
|
@ -43,19 +43,22 @@ default['openstack']['dns']['pool']['ns_hostnames'] = ['ns1.example.org.']
|
|||
default['openstack']['dns']['pool']['ns_addresses'] = ['127.0.0.1']
|
||||
default['openstack']['dns']['pool']['masters'] = ['127.0.0.1']
|
||||
default['openstack']['dns']['pool']['bind_hosts'] = ['127.0.0.1']
|
||||
default['openstack']['dns']['pool']['rndc_key'] = '/etc/designate/rndc.key'
|
||||
|
||||
# platform-specific settings
|
||||
default['openstack']['dns']['user'] = 'designate'
|
||||
default['openstack']['dns']['group'] = 'designate'
|
||||
case node['platform_family']
|
||||
when 'rhel'
|
||||
# Note(jh): TBC
|
||||
default['openstack']['dns']['platform'] = {
|
||||
'designate_packages' => ['openstack-designate-api', 'openstack-designate-central',
|
||||
'openstack-designate-mdns', 'openstack-designate-producer',
|
||||
'openstack-designate-worker', 'openstack-designate-sink'],
|
||||
'designate_api_service' => 'designate-api',
|
||||
'designate_central_service' => 'designate-central',
|
||||
'designate_mdns_service' => 'designate-mdns',
|
||||
'designate_producer_service' => 'designate-producer',
|
||||
'designate_worker_service' => 'designate-worker',
|
||||
'designate_sink_service' => 'designate-sink',
|
||||
'package_overrides' => '',
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@ recipe 'worker', 'Starts and enables the designate-worker service'
|
|||
supports os
|
||||
end
|
||||
|
||||
depends 'openstackclient'
|
||||
depends 'openstack-common', '>= 18.0.0'
|
||||
depends 'openstack-identity', '>= 18.0.0'
|
||||
depends 'openstackclient'
|
||||
depends 'openstack-network', '>= 18.0.0'
|
||||
|
|
|
@ -26,6 +26,6 @@ service 'designate-api' do
|
|||
service_name platform_options['designate_api_service']
|
||||
supports status: true, restart: true
|
||||
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -25,6 +25,6 @@ platform_options = node['openstack']['dns']['platform']
|
|||
service 'designate_central' do
|
||||
service_name platform_options['designate_central_service']
|
||||
supports status: true, restart: true
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -22,6 +22,8 @@ class ::Chef::Recipe
|
|||
include ::Openstack
|
||||
end
|
||||
|
||||
include_recipe 'openstack-common'
|
||||
|
||||
if node['openstack']['dns']['syslog']['use']
|
||||
include_recipe 'openstack-common::logging'
|
||||
end
|
||||
|
@ -100,17 +102,19 @@ ruby_block "delete all attributes in node['openstack']['dns']['conf_secrets']" d
|
|||
end
|
||||
|
||||
rndc_secret = get_password 'token', 'designate_rndc'
|
||||
template '/etc/designate/rndc.key' do
|
||||
pool_config = node['openstack']['dns']['pool']
|
||||
|
||||
template pool_config['rndc_key'] do
|
||||
source 'rndc.key.erb'
|
||||
owner node['openstack']['dns']['user']
|
||||
group node['openstack']['dns']['group']
|
||||
sensitive true
|
||||
mode 00440
|
||||
variables(
|
||||
secret: rndc_secret
|
||||
)
|
||||
end
|
||||
|
||||
pool_config = node['openstack']['dns']['pool']
|
||||
template '/etc/designate/pools.yaml' do
|
||||
source 'pools.yaml.erb'
|
||||
owner node['openstack']['dns']['user']
|
||||
|
@ -121,7 +125,8 @@ template '/etc/designate/pools.yaml' do
|
|||
bind_hosts: pool_config['bind_hosts'],
|
||||
masters: pool_config['masters'],
|
||||
ns_addresses: pool_config['ns_addresses'],
|
||||
ns_hostnames: pool_config['ns_hostnames']
|
||||
ns_hostnames: pool_config['ns_hostnames'],
|
||||
rndc_key: pool_config['rndc_key']
|
||||
)
|
||||
end
|
||||
|
||||
|
|
|
@ -25,6 +25,6 @@ platform_options = node['openstack']['dns']['platform']
|
|||
service 'designate_mdns' do
|
||||
service_name platform_options['designate_mdns_service']
|
||||
supports status: true, restart: true
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -25,6 +25,6 @@ platform_options = node['openstack']['dns']['platform']
|
|||
service 'designate_producer' do
|
||||
service_name platform_options['designate_producer_service']
|
||||
supports status: true, restart: true
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -5,6 +5,6 @@ platform_options = node['openstack']['dns']['platform']
|
|||
service 'designate_sink' do
|
||||
service_name platform_options['designate_sink_service']
|
||||
supports status: true, restart: true
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -25,6 +25,6 @@ platform_options = node['openstack']['dns']['platform']
|
|||
service 'designate_worker' do
|
||||
service_name platform_options['designate_worker_service']
|
||||
supports status: true, restart: true
|
||||
action :enable
|
||||
action [:enable, :start]
|
||||
subscribes :restart, 'template[/etc/designate/designate.conf]'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::api' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate-api').with(
|
||||
service_name: 'designate-api',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate-api')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate-api')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::api' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate-api').with(
|
||||
service_name: 'designate-api',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate-api')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate-api')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::central' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_central').with(
|
||||
service_name: 'designate-central',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_central')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_central')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::central' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_central').with(
|
||||
service_name: 'designate-central',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_central')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_central')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,48 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::common' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to_not include_recipe('openstack-common::logging')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to upgrade_package('openstack-designate-api')
|
||||
expect(chef_run).to upgrade_package('openstack-designate-central')
|
||||
expect(chef_run).to upgrade_package('openstack-designate-mdns')
|
||||
expect(chef_run).to upgrade_package('openstack-designate-producer')
|
||||
expect(chef_run).to upgrade_package('openstack-designate-worker')
|
||||
expect(chef_run).to upgrade_package('openstack-designate-sink')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to upgrade_package('MySQL-python')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to create_template('/etc/designate/pools.yaml').with(
|
||||
source: 'pools.yaml.erb',
|
||||
owner: 'designate',
|
||||
group: 'designate',
|
||||
mode: 00644,
|
||||
variables: {
|
||||
banner: "\n# This file was autogenerated by Chef\n# Do not edit, changes will be overwritten\n",
|
||||
bind_hosts: %w(127.0.0.1),
|
||||
masters: %w(127.0.0.1),
|
||||
ns_addresses: %w(127.0.0.1),
|
||||
ns_hostnames: %w(ns1.example.org.),
|
||||
rndc_key: '/etc/designate/rndc.key',
|
||||
}
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,149 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::common' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to_not include_recipe('openstack-common::logging')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to upgrade_package('python3-designate')
|
||||
expect(chef_run).to upgrade_package('designate-api')
|
||||
expect(chef_run).to upgrade_package('designate-central')
|
||||
expect(chef_run).to upgrade_package('designate-mdns')
|
||||
expect(chef_run).to upgrade_package('designate-producer')
|
||||
expect(chef_run).to upgrade_package('designate-worker')
|
||||
expect(chef_run).to upgrade_package('bind9utils')
|
||||
expect(chef_run).to upgrade_package('designate-sink')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to upgrade_package('python3-mysqldb')
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to create_directory('/etc/designate').with(
|
||||
owner: 'designate',
|
||||
group: 'designate',
|
||||
mode: 00750
|
||||
)
|
||||
end
|
||||
describe 'designate.conf' do
|
||||
let(:file) { chef_run.template('/etc/designate/designate.conf') }
|
||||
it do
|
||||
expect(chef_run).to create_template(file.name).with(
|
||||
source: 'openstack-service.conf.erb',
|
||||
cookbook: 'openstack-common',
|
||||
owner: 'designate',
|
||||
group: 'designate',
|
||||
mode: 00640
|
||||
)
|
||||
end
|
||||
it 'section: DEFAULT' do
|
||||
[
|
||||
%r{^log_dir = /var/log/designate$},
|
||||
%r{^transport_url = rabbit://guest:mypass@127.0.0.1:5672$},
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('DEFAULT', line)
|
||||
end
|
||||
end
|
||||
it 'section: service:api' do
|
||||
[
|
||||
/^auth_strategy = keystone$/,
|
||||
/^enable_api_v1 = True$/,
|
||||
/^enabled_extensions_v1 = quotas, reports$/,
|
||||
/^enable_api_v2 = True$/,
|
||||
/^listen = 127.0.0.1:9001$/,
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('service:api', line)
|
||||
end
|
||||
end
|
||||
it 'section: service:worker' do
|
||||
[
|
||||
/^enabled = True$/,
|
||||
/^notify = True$/,
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('service:worker', line)
|
||||
end
|
||||
end
|
||||
it 'section: keystone_authtoken' do
|
||||
[
|
||||
/^auth_type = password$/,
|
||||
/^username = designate$/,
|
||||
/^project_name = service$/,
|
||||
/^project_domain_name = Default$/,
|
||||
/^user_domain_name = Default$/,
|
||||
/^service_token_roles_required = True$/,
|
||||
%r{^www_authenticate_uri = http://127.0.0.1:5000/v3$},
|
||||
/^password = designate-pass$/,
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('keystone_authtoken', line)
|
||||
end
|
||||
end
|
||||
it 'section: storage:sqlalchemy' do
|
||||
[
|
||||
%r{^connection = mysql\+pymysql://designate:db-pass@127.0.0.1:3306/designate\?charset=utf8$},
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file(file.name).with_section_content('storage:sqlalchemy', line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_template('/etc/designate/rndc.key').with(
|
||||
source: 'rndc.key.erb',
|
||||
owner: 'designate',
|
||||
group: 'designate',
|
||||
mode: 00440,
|
||||
sensitive: true,
|
||||
variables: {
|
||||
secret: 'rndc-key',
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_template('/etc/designate/pools.yaml').with(
|
||||
source: 'pools.yaml.erb',
|
||||
owner: 'designate',
|
||||
group: 'designate',
|
||||
mode: 00644,
|
||||
variables: {
|
||||
banner: "\n# This file was autogenerated by Chef\n# Do not edit, changes will be overwritten\n",
|
||||
bind_hosts: %w(127.0.0.1),
|
||||
masters: %w(127.0.0.1),
|
||||
ns_addresses: %w(127.0.0.1),
|
||||
ns_hostnames: %w(ns1.example.org.),
|
||||
rndc_key: '/etc/designate/rndc.key',
|
||||
}
|
||||
)
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to run_execute('designate-manage database sync').with(
|
||||
user: 'designate',
|
||||
group: 'designate',
|
||||
command: 'designate-manage database sync'
|
||||
)
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to nothing_execute('designate-manage pool update').with(
|
||||
user: 'designate',
|
||||
group: 'designate',
|
||||
command: 'designate-manage pool update'
|
||||
)
|
||||
end
|
||||
it do
|
||||
expect(chef_run.execute('designate-manage pool update')).to \
|
||||
subscribe_to('template[/etc/designate/pools.yaml]').on(:run)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::dashboard' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to upgrade_package('python3-designate-dashboard')
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,11 +0,0 @@
|
|||
describe 'default recipe on Ubuntu 16.04' do
|
||||
let(:chef_run) do
|
||||
ChefSpec::ServerRunner.new do |node|
|
||||
node.automatic[:lsb][:codename] = 'xenial'
|
||||
end.converge('openstack-dns::default')
|
||||
end
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
end
|
|
@ -0,0 +1,59 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::identity_registration' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
|
||||
connection_params = {
|
||||
openstack_api_key: 'admin',
|
||||
openstack_auth_url: 'http://127.0.0.1:5000/v3',
|
||||
openstack_domain_name: 'default',
|
||||
openstack_project_name: 'admin',
|
||||
openstack_username: 'admin',
|
||||
}
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_openstack_service('designate').with(
|
||||
type: 'dns',
|
||||
connection_params: connection_params
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_openstack_endpoint('dns').with(
|
||||
service_name: 'designate',
|
||||
interface: 'internal',
|
||||
url: 'http://127.0.0.1:9001',
|
||||
region: 'RegionOne',
|
||||
connection_params: connection_params
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_openstack_project('service').with(
|
||||
connection_params: connection_params
|
||||
)
|
||||
end
|
||||
|
||||
it do
|
||||
expect(chef_run).to create_openstack_user('designate').with(
|
||||
role_name: 'service',
|
||||
project_name: 'service',
|
||||
domain_name: 'Default',
|
||||
password: 'designate-pass',
|
||||
connection_params: connection_params
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::mdns' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_mdns').with(
|
||||
service_name: 'designate-mdns',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_mdns')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_mdns')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::mdns' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_mdns').with(
|
||||
service_name: 'designate-mdns',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_mdns')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_mdns')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,43 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::neutron_int' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe, 'openstack-network')
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
include_context 'neutron-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
|
||||
describe '/etc/neutron/neutron.conf' do
|
||||
it 'section: DEFAULT' do
|
||||
[
|
||||
/^external_dns_driver = designate$/,
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file('/etc/neutron/neutron.conf').with_section_content('DEFAULT', line)
|
||||
end
|
||||
end
|
||||
it 'section: designate' do
|
||||
[
|
||||
%r{^url = http://127.0.0.1:9001/v2$},
|
||||
/^auth_type = password$/,
|
||||
%r{^auth_url = http://127.0.0.1:5000/v3$},
|
||||
/^username = designate$/,
|
||||
/^project_name = service$/,
|
||||
/^project_domain_name = Default$/,
|
||||
/^user_domain_name = Default$/,
|
||||
/^password = designate-pass$/,
|
||||
].each do |line|
|
||||
expect(chef_run).to render_config_file('/etc/neutron/neutron.conf').with_section_content('designate', line)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::producer' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_producer').with(
|
||||
service_name: 'designate-producer',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_producer')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_producer')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::producer' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_producer').with(
|
||||
service_name: 'designate-producer',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_producer')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_producer')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::sink' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_sink').with(
|
||||
service_name: 'designate-sink',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_sink')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_sink')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::sink' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_sink').with(
|
||||
service_name: 'designate-sink',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_sink')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_sink')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,74 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require 'chefspec'
|
||||
require 'chefspec/berkshelf'
|
||||
require 'chef/application'
|
||||
require 'securerandom'
|
||||
|
||||
RSpec.configure do |config|
|
||||
config.color = true
|
||||
config.formatter = :documentation
|
||||
config.log_level = :warn
|
||||
config.file_cache_path = '/var/chef/cache'
|
||||
end
|
||||
|
||||
REDHAT_OPTS = {
|
||||
platform: 'redhat',
|
||||
version: '7',
|
||||
}.freeze
|
||||
UBUNTU_OPTS = {
|
||||
platform: 'ubuntu',
|
||||
version: '18.04',
|
||||
}.freeze
|
||||
|
||||
shared_context 'dns-stubs' do
|
||||
before do
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
|
||||
.with('dns')
|
||||
.and_return('rabbit://guest:mypass@127.0.0.1:5672')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_servers)
|
||||
.and_return '1.1.1.1:5672,2.2.2.2:5672'
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('db', 'designate')
|
||||
.and_return('db-pass')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('service', 'openstack-dns')
|
||||
.and_return('designate-pass')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('token', 'designate_rndc')
|
||||
.and_return('rndc-key')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('user', 'admin')
|
||||
.and_return('admin')
|
||||
end
|
||||
end
|
||||
|
||||
shared_context 'neutron-stubs' do
|
||||
before do
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('token', 'openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('token', 'neutron_metadata_secret')
|
||||
.and_return('metadata-secret')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('neutron')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('service', 'openstack-network')
|
||||
.and_return('neutron-pass')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
allow(Chef::Application).to receive(:fatal!)
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('service', 'openstack-compute')
|
||||
.and_return('nova-pass')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:get_password)
|
||||
.with('user', 'admin')
|
||||
.and_return('admin-pass')
|
||||
allow_any_instance_of(Chef::Recipe).to receive(:rabbit_transport_url)
|
||||
.with('network')
|
||||
.and_return('rabbit://guest:mypass@127.0.0.1:5672')
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::worker' do
|
||||
describe 'redhat' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_worker').with(
|
||||
service_name: 'designate-worker',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_worker')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_worker')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
# Encoding: utf-8
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-dns::worker' do
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
cached(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
|
||||
include_context 'dns-stubs'
|
||||
|
||||
it 'converges successfully' do
|
||||
expect { :chef_run }.to_not raise_error
|
||||
end
|
||||
it do
|
||||
expect(chef_run).to enable_service('designate_worker').with(
|
||||
service_name: 'designate-worker',
|
||||
supports: { restart: true, status: true }
|
||||
)
|
||||
expect(chef_run).to start_service('designate_worker')
|
||||
end
|
||||
it do
|
||||
expect(chef_run.service('designate_worker')).to \
|
||||
subscribe_to('template[/etc/designate/designate.conf]').on(:restart)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
include "<%= @bind_sysconfig %>/rndc.key";
|
||||
|
||||
controls {
|
||||
inet 127.0.0.1 port 953
|
||||
allow { 127.0.0.1; } keys { "designate"; };
|
||||
};
|
|
@ -43,5 +43,5 @@
|
|||
port: 53
|
||||
rndc_host: <%= bind_host %>
|
||||
rndc_port: 953
|
||||
rndc_key_file: /etc/designate/rndc.key
|
||||
rndc_key_file: <%= @rndc_key %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue