Initial common Pike updates

- Bumped chefdk to 1.6.1
- Switched release to pike
- Added is_release attribute for testing, defaults to false
- Added RDO deps repo for testing pre-release packages
- Added ubuntu-cloud proposed repo for testing pre-release packages
- Switched the default linter to cookstyle
- Normalized the banner message
- Dropped pip installation method for python-openstackclient since the
  packages are fresh enough

Change-Id: I7a67ba2520b8e44efec6edd8506f96b0e0dc913b
This commit is contained in:
Samuel Cassiba 2017-08-20 11:16:38 -04:00
parent ea0f371412
commit ffbf83d17f
25 changed files with 246 additions and 178 deletions

View File

@ -1,20 +1,20 @@
task default: ["test"]
task :test => [:lint, :style, :unit]
task :test => [:syntax, :lint, :unit]
desc "Vendor the cookbooks in the Berksfile"
task :berks_prep do
sh %{chef exec berks vendor}
end
desc "Run FoodCritic (lint) tests"
task :lint do
sh %{chef exec foodcritic --epic-fail any --tags ~FC003 --tags ~FC023 .}
desc "Run FoodCritic (syntax) tests"
task :syntax do
sh %{chef exec foodcritic --exclude spec -f any .}
end
desc "Run RuboCop (style) tests"
task :style do
sh %{chef exec rubocop}
desc "Run RuboCop (lint) tests"
task :lint do
sh %{chef exec cookstyle}
end
desc "Run RSpec (unit) tests"

View File

@ -101,7 +101,7 @@ default['openstack']['db']['charset'] = {
pgsql: nil,
sqlite: nil,
nosql: nil,
galera: 'utf8'
galera: 'utf8',
}
# Database connection options. Should include starting '?'
@ -112,13 +112,13 @@ default['openstack']['db']['options'] = {
postgresql: '',
sqlite: '',
nosql: '',
galera: "?charset=#{node['openstack']['db']['charset']['galera']}"
galera: "?charset=#{node['openstack']['db']['charset']['galera']}",
}
# platform and DBMS-specific python client packages
default['openstack']['db']['python_packages'] = {
postgresql: ['python-psycopg2'],
sqlite: []
sqlite: [],
}
case node['platform_family']
when 'rhel'

View File

@ -19,16 +19,17 @@
# limitations under the License.
#
# Release mode toggle for testing frameworks. Defaults to false.
# Override this to true at the environment level when you're ready.
default['openstack']['is_release'] = false
# Set to some text value if you want templated config files
# to contain a custom banner at the top of the written file
default['openstack']['common']['custom_template_banner'] = '
# This file autogenerated by Chef
# Do not edit, changes will be overwritten
# This file is automatically generated by Chef
# Any changes will be overwritten
'
# version for python-openstackclient
default['openstack']['common']['client_version'] = '3.11.0'
# OpenStack services and their project names
default['openstack']['common']['services'] = {
'bare-metal' => 'ironic',
@ -45,7 +46,7 @@ default['openstack']['common']['services'] = {
'orchestration' => 'heat',
'telemetry' => 'ceilometer',
'telemetry-metric' => 'gnocchi',
'application-catalog' => 'murano'
'application-catalog' => 'murano',
}
# Setting this to True means that database passwords and service user
@ -119,7 +120,7 @@ default['openstack']['secret']['user_passwords_data_bag'] = 'user_passwords'
# needs.
# The coordinated release of OpenStack codename
default['openstack']['release'] = 'ocata'
default['openstack']['release'] = 'pike'
# The Ubuntu Cloud Archive has packages for multiple Ubuntu releases. For
# more information, see: https://wiki.ubuntu.com/ServerTeam/CloudArchive.
@ -153,52 +154,52 @@ default['openstack']['api']['auth']['version'] = 'v3.0'
default['openstack']['logging']['loggers'] = {
'root' => {
'level' => 'NOTSET',
'handlers' => 'devel'
'handlers' => 'devel',
},
'ceilometer' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'ceilometer'
'qualname' => 'ceilometer',
},
'cinder' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'cinder'
'qualname' => 'cinder',
},
'glance' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'glance'
'qualname' => 'glance',
},
'horizon' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'horizon'
'qualname' => 'horizon',
},
'keystone' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'keystone'
'qualname' => 'keystone',
},
'nova' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'nova'
'qualname' => 'nova',
},
'neutron' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'neutron'
'qualname' => 'neutron',
},
'trove' => {
'level' => 'DEBUG',
'handlers' => 'prod,debug',
'qualname' => 'trove'
'qualname' => 'trove',
},
'amqplib' => {
'level' => 'WARNING',
'handlers' => 'stderr',
'qualname' => 'amqplib'
'qualname' => 'amqplib',
},
'sqlalchemy' => {
'level' => 'WARNING',
@ -206,52 +207,52 @@ default['openstack']['logging']['loggers'] = {
# "level' => 'DEBUG" logs SQL queries and results.
# "level' => 'WARNING" logs neither. (Recommended for production systems.)
'handlers' => 'stderr',
'qualname' => 'sqlalchemy'
'qualname' => 'sqlalchemy',
},
'boto' => {
'level' => 'WARNING',
'handlers' => 'stderr',
'qualname' => 'boto'
'qualname' => 'boto',
},
'suds' => {
'level' => 'INFO',
'handlers' => 'stderr',
'qualname' => 'suds'
'qualname' => 'suds',
},
'eventletwsgi' => {
'level' => 'WARNING',
'handlers' => 'stderr',
'qualname' => 'eventlet.wsgi.server'
'qualname' => 'eventlet.wsgi.server',
},
'nova_api_openstack_wsgi' => {
'level' => 'WARNING',
'handlers' => 'prod,debug',
'qualname' => 'nova.api.openstack.wsgi'
'qualname' => 'nova.api.openstack.wsgi',
},
'nova_osapi_compute_wsgi_server' => {
'level' => 'WARNING',
'handlers' => 'prod,debug',
'qualname' => 'nova.osapi_compute.wsgi.server'
}
'qualname' => 'nova.osapi_compute.wsgi.server',
},
}
# Allow configured formatters in logging.conf
default['openstack']['logging']['formatters'] = {
'normal' => {
'format' => '%(asctime)s %(levelname)s %(message)s'
'format' => '%(asctime)s %(levelname)s %(message)s',
},
'normal_with_name' => {
'format' => '[%(name)s]: %(asctime)s %(levelname)s %(message)s'
'format' => '[%(name)s]: %(asctime)s %(levelname)s %(message)s',
},
'debug' => {
'format' => '[%(name)s]: %(asctime)s %(levelname)s %(module)s.%(funcName)s %(message)s'
'format' => '[%(name)s]: %(asctime)s %(levelname)s %(module)s.%(funcName)s %(message)s',
},
'syslog_with_name' => {
'format' => '%(name)s: %(levelname)s %(message)s'
'format' => '%(name)s: %(levelname)s %(message)s',
},
'syslog_debug' => {
'format' => '%(name)s: %(levelname)s %(module)s.%(funcName)s %(message)s'
}
'format' => '%(name)s: %(levelname)s %(module)s.%(funcName)s %(message)s',
},
}
# Allow configured logging handlers in logging.conf
@ -259,26 +260,26 @@ default['openstack']['logging']['handlers'] = {
'stderr' => {
'args' => '(sys.stderr,)',
'class' => 'StreamHandler',
'formatter' => 'debug'
'formatter' => 'debug',
},
'devel' => {
'args' => '(sys.stdout,)',
'class' => 'StreamHandler',
'formatter' => 'debug',
'level' => 'NOTSET'
'level' => 'NOTSET',
},
'prod' => {
'args' => '((\'/dev/log\'), handlers.SysLogHandler.LOG_LOCAL0)',
'class' => 'handlers.SysLogHandler',
'formatter' => 'syslog_with_name',
'level' => 'INFO'
'level' => 'INFO',
},
'debug' => {
'args' => '((\'/dev/log\'), handlers.SysLogHandler.LOG_LOCAL1)',
'class' => 'handlers.SysLogHandler',
'formatter' => 'syslog_debug',
'level' => 'DEBUG'
}
'level' => 'DEBUG',
},
}
default['openstack']['memcached_servers'] = nil
@ -290,11 +291,11 @@ default['openstack']['sysctl']['net.ipv4.conf.default.rp_filter'] = 0
case node['platform_family']
when 'rhel'
default['openstack']['common']['platform'] = {
'package_overrides' => ''
'package_overrides' => '',
}
when 'debian'
default['openstack']['common']['platform'] = {
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'"
'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'",
}
end

View File

@ -92,7 +92,7 @@ rabbit_defaults = {
kombu_ssl_certfile: node['openstack']['mq']['rabbitmq']['kombu_ssl_certfile'],
kombu_ssl_ca_certs: node['openstack']['mq']['rabbitmq']['kombu_ssl_ca_certs'],
kombu_reconnect_delay: node['openstack']['mq']['rabbitmq']['kombu_reconnect_delay'],
kombu_reconnect_timeout: node['openstack']['mq']['rabbitmq']['kombu_reconnect_timeout']
kombu_reconnect_timeout: node['openstack']['mq']['rabbitmq']['kombu_reconnect_timeout'],
}
###################################################################

View File

@ -11,7 +11,7 @@ if [ -f /usr/bin/yum ] ; then
sudo pip uninstall requests -y || true
# install chefdk
chefdk=chefdk-1.5.0-1.el7.x86_64.rpm
chefdk=chefdk-1.6.1-1.el7.x86_64.rpm
wget -nv -t 3 https://packages.chef.io/stable/el/7/$chefdk
sudo yum -y install $chefdk
rm $chefdk
@ -26,7 +26,7 @@ elif [ -f /usr/bin/apt-get ]; then
sudo apt-get -y install build-essential liblzma-dev zlib1g-dev
# install chefdk
chefdk=chefdk_1.5.0-1_amd64.deb
chefdk=chefdk_1.6.1-1_amd64.deb
wget -nv -t 3 https://packages.chef.io/stable/ubuntu/16.04/$chefdk
sudo dpkg -i $chefdk
rm $chefdk

View File

@ -41,7 +41,7 @@ module ::Openstack
'OS_USER_DOMAIN_NAME' => user_domain,
'OS_PROJECT_DOMAIN_NAME' => project_domain,
'OS_IDENTITY_API_VERSION' => '3',
'OS_AUTH_URL' => auth_uri
'OS_AUTH_URL' => auth_uri,
}
end

View File

@ -51,7 +51,7 @@ module ::Openstack
end
# Shortcut to get the SQLAlchemy DB URI for a named service
def db_uri(service, user, pass, is_slave = false) # rubocop:disable MethodLength, CyclomaticComplexity
def db_uri(service, user, pass, is_slave = false)
info = db(service)
return unless info

View File

@ -46,7 +46,6 @@ if defined?(ChefSpec)
self
end
# rubocop:disable MethodLength, CyclomaticComplexity
def matches_content?
def section?(line, section = '.*')
return true if line =~ /^[ \t]*\[#{section}\]/

View File

@ -27,7 +27,7 @@ module ::Openstack
# into a single element array.
# table - the raw PrettyTable output of the CLI command
# output - array of hashes representing the data.
def prettytable_to_array(table) # rubocop:disable MethodLength
def prettytable_to_array(table)
ret = []
return ret if table.nil?
indicies = []

View File

@ -57,7 +57,7 @@ def connection_info
port: @port.to_i,
username: @super_user,
password: @super_password,
socket: @socket
socket: @socket,
}
end

View File

@ -19,17 +19,4 @@
# limitations under the License.
#
python_runtime '2'
python_virtualenv '/opt/osc' do
system_site_packages true
end
python_package 'python-openstackclient' do
version node['openstack']['common']['client_version']
virtualenv '/opt/osc'
end
link '/usr/local/bin/openstack' do
to '/opt/osc/bin/openstack'
end
package 'python-openstackclient'

View File

@ -37,6 +37,20 @@ when 'debian'
distribution "#{node['lsb']['codename']}-updates/#{node['openstack']['release']}"
components apt_components
end
# add in the proposed repo, but only if we're in development
proposed_action = if node['openstack']['is_release']
:remove
else
:add
end
apt_repository 'openstack-ppa-proposed' do
uri node['openstack']['apt']['uri']
distribution "#{node['lsb']['codename']}-proposed/#{node['openstack']['release']}"
components apt_components
action proposed_action
end
end
when 'rhel'
include_recipe 'yum' if node['openstack']['yum']['update_yum_cache']
@ -58,6 +72,25 @@ when 'rhel'
enabled true
action repo_action
end
# add in the RDO deps, but only if we're in development
deps_action = if node['openstack']['is_release']
:remove
else
:add
end
yum_repository "RDO-#{node['openstack']['release']}-deps" do
description "OpenStack RDO deps repo for #{node['openstack']['release']}"
baseurl "https://buildlogs.centos.org/centos/7/cloud/x86_64/openstack-#{node['openstack']['release']}"
gpgcheck false
enabled true
action deps_action
end
package 'centos-release-qemu-ev' do
action :upgrade
end
end
if node['openstack']['databag_type'] == 'vault'

32
recipes/python.rb Normal file
View File

@ -0,0 +1,32 @@
# encoding: UTF-8
#
# Cookbook Name:: openstack-common
# recipe:: python
#
# Copyright 2017 Workday Inc.
#
# 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 a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# install system packages for Ubuntu/Debian
case node['platform_family']
when 'debian', 'ubuntu'
python_runtime '3.5' do
provider :system
end
# use Software Collections for CentOS/RHEL
when 'rhel'
python_runtime '3.5' do
provider :scl
end
end

View File

@ -19,7 +19,7 @@ describe 'openstack-common::default' do
host: '127.0.0.1',
scheme: 'http',
path: '/v3',
port: '35357'
port: '35357',
}
end
it 'returns cli enviroment' do
@ -51,7 +51,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
allow(subject).to receive(:shell_out).with(
%w(openstack user list),
@ -71,7 +71,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
allow(subject).to receive(:shell_out).with(
%w(openstack --key1 value1 --key2 value2 --key3 user list),
@ -91,7 +91,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
allow(subject).to receive(:shell_out).with(
%w(openstack user list),
@ -110,7 +110,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
allow(subject).to receive(:openstack_command).with('openstack', 'user list', env, {})
allow(subject).to receive(:prettytable_to_array)
@ -130,7 +130,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
end
@ -161,7 +161,7 @@ describe 'openstack-common::default' do
'OS_USER_DOMAIN_NAME' => 'default',
'OS_PROJECT_DOMAIN_NAME' => 'default',
'OS_AUTH_URL' => 'http://127.0.0.1:35357/v3',
'OS_IDENTITY_API_VERSION' => 3
'OS_IDENTITY_API_VERSION' => 3,
}
allow(subject).to receive(:openstack_command).with('openstack', 'network list', env, {})
allow(subject).to receive(:prettytable_to_array)

View File

@ -10,22 +10,7 @@ describe 'openstack-common::client' do
end
it do
expect(chef_run).to install_python_runtime('2')
end
it do
expect(chef_run).to create_python_virtualenv('/opt/osc')
.with(system_site_packages: true)
end
it do
expect(chef_run).to install_python_package('python-openstackclient')
.with(version: '3.11.0')
end
it do
expect(chef_run).to create_link('/usr/local/bin/openstack')
.with(to: '/opt/osc/bin/openstack')
expect(chef_run).to install_package('python-openstackclient')
end
end
end

View File

@ -19,15 +19,15 @@ describe 'openstack-common::default' do
'another_section' => { 'foo' => 'bar', 'baz' => 'yay' },
'deep_section' => {
'foo' => { key: 'bar', value: 'baz' },
'baz' => 'yay'
}
'baz' => 'yay',
},
}
node.set['openstack']['anyservice']['conf_secrets'] =
{
'Default' => { 'secret_log' => 'secret_file_to_log' },
'secret_section' => { 'password' => '1234' },
'another_section' => { 'secret_foo' => 'secret_bar' },
'another_secret_section' => { 'secret_baz' => 'secret_yay' }
'another_secret_section' => { 'secret_baz' => 'secret_yay' },
}
end
@ -47,7 +47,7 @@ describe 'openstack-common::default' do
'another_secret_section' => { 'secret_baz' => 'secret_yay' },
'deep_section' => {
'foo' => { 'key' => 'bar', 'value' => 'baz' },
'baz' => 'yay'
'baz' => 'yay',
}
)
end

View File

@ -11,6 +11,10 @@ describe 'openstack-common::default' do
runner.converge(described_recipe)
end
it do
expect(chef_run).to upgrade_package('centos-release-qemu-ev')
end
context 'enabling RDO with gpgcheck enabled' do
before do
node.set['openstack']['yum']['rdo_enabled'] = true
@ -50,6 +54,16 @@ describe 'openstack-common::default' do
end
end
context 'disabling RDO deps repo with is_release true' do
before do
node.set['openstack']['is_release'] = true
end
it 'does not add the RDO deps yum repository' do
expect(chef_run).to_not add_yum_repository('RDO-testrelease-deps')
end
end
context 'disabling RDO' do
before do
node.set['openstack']['yum']['rdo_enabled'] = false

View File

@ -29,7 +29,7 @@ describe 'openstack-common::default' do
node.set['openstack']['apt']['live_updates_enabled'] = true
expect(chef_run).to add_apt_repository('openstack-ppa').with(
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
distribution: 'xenial-updates/ocata',
distribution: 'xenial-updates/pike',
components: ['main']
)
end
@ -38,7 +38,24 @@ describe 'openstack-common::default' do
node.set['openstack']['apt']['live_updates_enabled'] = false
expect(chef_run).to_not add_apt_repository('openstack-ppa').with(
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
distribution: 'xenial-updates/ocata',
distribution: 'xenial-updates/pike',
components: ['main']
)
end
it 'configures openstack proposed repository' do
expect(chef_run).to add_apt_repository('openstack-ppa-proposed').with(
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
distribution: 'xenial-proposed/pike',
components: ['main']
)
end
it 'disables openstack proposed repository' do
node.override['openstack']['is_release'] = true
expect(chef_run).to_not add_apt_repository('openstack-ppa-proposed').with(
uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu',
distribution: 'xenial-proposed/pike',
components: ['main']
)
end
@ -67,7 +84,7 @@ describe 'openstack-common::default' do
'kombu_ssl_certfile' => 'cert_file',
'kombu_ssl_ca_certs' => 'ca_certs_file',
'kombu_reconnect_delay' => 123.456,
'kombu_reconnect_timeout' => 123
'kombu_reconnect_timeout' => 123,
}
rabbit_opts.each do |key, value|
it "configures rabbit mq #{key}" do

View File

@ -32,11 +32,11 @@ describe 'openstack-common::default' do
'endpoints' => {
ep_type => {
'compute-api' => {
'uri' => 'http://localhost:8080/v2/%(tenant_id)s'
}
}
}
}
'uri' => 'http://localhost:8080/v2/%(tenant_id)s',
},
},
},
},
}
allow(subject).to receive(:node).and_return(uri_hash)
expect(
@ -50,11 +50,11 @@ describe 'openstack-common::default' do
'endpoints' => {
ep_type => {
'compute-api' => {
'uri' => 'http://localhost:1234/path'
}
}
}
}
'uri' => 'http://localhost:1234/path',
},
},
},
},
}
allow(subject).to receive(:node).and_return(uri_hash)
expect(
@ -69,11 +69,11 @@ describe 'openstack-common::default' do
ep_type => {
'compute-api' => {
'uri' => 'http://localhost',
'host' => 'ignored'
}
}
}
}
'host' => 'ignored',
},
},
},
},
}
allow(subject).to receive(:node).and_return(uri_hash)
expect(subject.send("#{ep_type}_endpoint", 'compute-api').to_s).to eq('http://localhost')
@ -87,11 +87,11 @@ describe 'openstack-common::default' do
ep_type => {
'compute-api' => {
'host' => 'localhost',
'port' => '1234'
}
}
}
}
'port' => '1234',
},
},
},
},
}
allow(subject).to receive(:node).and_return(uri_hash)
subject.send("#{ep_type}_endpoint", 'compute-api')

View File

@ -37,103 +37,103 @@ describe 'openstack-common::logging' do
[
'keys=root,ceilometer,cinder,glance,horizon,keystone,nova,'\
'neutron,trove,amqplib,sqlalchemy,boto,suds,eventletwsgi,'\
'nova_api_openstack_wsgi,nova_osapi_compute_wsgi_server'
'nova_api_openstack_wsgi,nova_osapi_compute_wsgi_server',
],
'logger_root' =>
[
'level=NOTSET',
'handlers=devel'
'handlers=devel',
],
'logger_ceilometer' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=ceilometer'
'qualname=ceilometer',
],
'logger_cinder' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=cinder'
'qualname=cinder',
],
'logger_glance' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=glance'
'qualname=glance',
],
'logger_horizon' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=horizon'
'qualname=horizon',
],
'logger_keystone' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=keystone'
'qualname=keystone',
],
'logger_nova' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=nova'
'qualname=nova',
],
'logger_neutron' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=neutron'
'qualname=neutron',
],
'logger_trove' =>
[
'level=DEBUG',
'handlers=prod,debug',
'qualname=trove'
'qualname=trove',
],
'logger_amqplib' =>
[
'level=WARNING',
'handlers=stderr',
'qualname=amqplib'
'qualname=amqplib',
],
'logger_sqlalchemy' =>
[
'level=WARNING',
'handlers=stderr',
'qualname=sqlalchemy'
'qualname=sqlalchemy',
],
'logger_boto' =>
[
'level=WARNING',
'handlers=stderr',
'qualname=boto'
'qualname=boto',
],
'logger_suds' =>
[
'level=INFO',
'handlers=stderr',
'qualname=suds'
'qualname=suds',
],
'logger_eventletwsgi' =>
[
'level=WARNING',
'handlers=stderr',
'qualname=eventlet.wsgi.server'
'qualname=eventlet.wsgi.server',
],
'logger_nova_api_openstack_wsgi' =>
[
'level=WARNING',
'handlers=prod,debug',
'qualname=nova.api.openstack.wsgi'
'qualname=nova.api.openstack.wsgi',
],
'logger_nova_osapi_compute_wsgi_server' =>
[
'level=WARNING',
'handlers=prod,debug',
'qualname=nova.osapi_compute.wsgi.server'
]
'qualname=nova.osapi_compute.wsgi.server',
],
}.each do |section, content|
content.each do |line|
expect(chef_run).to render_config_file(file.name).with_section_content(section, line)
@ -156,7 +156,7 @@ describe 'openstack-common::logging' do
'formatter_syslog_with_name' =>
'format=%(name)s: %(levelname)s %(message)s',
'formatter_syslog_debug' =>
'format=%(name)s: %(levelname)s %(module)s.%(funcName)s %(message)s'
'format=%(name)s: %(levelname)s %(module)s.%(funcName)s %(message)s',
}.each do |section, content|
expect(chef_run).to render_config_file(file.name).with_section_content(section, content)
end
@ -172,29 +172,29 @@ describe 'openstack-common::logging' do
[
'args=(sys.stderr,)',
'class=StreamHandler',
'formatter=debug'
'formatter=debug',
],
'handler_devel' =>
[
'args=(sys.stdout,)',
'class=StreamHandler',
'formatter=debug',
'level=NOTSET'
'level=NOTSET',
],
'handler_prod' =>
[
"args=(('/dev/log'), handlers.SysLogHandler.LOG_LOCAL0)",
'class=handlers.SysLogHandler',
'formatter=syslog_with_name',
'level=INFO'
'level=INFO',
],
'handler_debug' =>
[
"args=(('/dev/log'), handlers.SysLogHandler.LOG_LOCAL1)",
'class=handlers.SysLogHandler',
'formatter=syslog_debug',
'level=DEBUG'
]
'level=DEBUG',
],
}.each do |section, content|
content.each do |line|
expect(chef_run).to render_config_file(file.name).with_section_content(section, line)

View File

@ -12,7 +12,7 @@ describe 'openstack-common::default' do
'::1' => { 'family' => 'inet6', 'prefixlen' => '128', 'scope' => 'Node' },
'2001:db8::1' => { 'family' => 'inet6', 'prefixlen' => '64', 'scope' => 'Node' } } },
'eth0' => { 'addresses' => { '10.0.0.2' => { 'family' => 'inet', 'prefixlen' => '32', 'netmask' => '255.255.255.255', 'scope' => 'Node' },
'10.0.0.3' => { 'family' => 'inet', 'prefixlen' => '24', 'netmask' => '255.255.255.0', 'scope' => 'Node' } } }
'10.0.0.3' => { 'family' => 'inet', 'prefixlen' => '24', 'netmask' => '255.255.255.0', 'scope' => 'Node' } } },
}
runner.converge(described_recipe)
@ -115,9 +115,9 @@ describe 'openstack-common::default' do
node.automatic['network'] = {
'interfaces' => {
'lo' => {
'addresses' => nil
}
}
'addresses' => nil,
},
},
}
expect { subject.address_for('lo') }
.to raise_error(RuntimeError, 'Interface lo has no addresses assigned')
@ -127,9 +127,9 @@ describe 'openstack-common::default' do
node.automatic['network'] = {
'interfaces' => {
'lo' => {
'addresses' => {}
}
}
'addresses' => {},
},
},
}
expect { subject.address_for('lo') }
.to raise_error(RuntimeError, 'Interface lo has no addresses assigned')
@ -144,11 +144,11 @@ describe 'openstack-common::default' do
'family' => 'inet',
'prefixlen' => '8',
'netmask' => '255.0.0.0',
'scope' => 'Node'
}
}
}
}
'scope' => 'Node',
},
},
},
},
}
expect { subject.address_for('lo', 'inet6') }
.to raise_error(RuntimeError, 'No address for family inet6 found')
@ -163,11 +163,11 @@ describe 'openstack-common::default' do
'family' => 'inet',
'prefixlen' => '32',
'netmask' => '255.255.255.255',
'scope' => 'Node'
}
}
}
}
'scope' => 'Node',
},
},
},
},
}
expect { subject.address_for('lo', 'inet') }
.to raise_error(RuntimeError, 'No address for family inet found')

View File

@ -49,7 +49,7 @@ describe 'openstack-common::default' do
it 'returns memcached list' do
nodes = [
{ 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } },
{ 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } }
{ 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } },
]
allow(subject).to receive(:node).and_return(chef_run.node)
allow(subject).to receive(:search_for)
@ -64,7 +64,7 @@ describe 'openstack-common::default' do
nodes = [
{ 'memcached' => { 'listen' => '3.3.3.3', 'port' => '11211' } },
{ 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } },
{ 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } }
{ 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } },
]
allow(subject).to receive(:node).and_return(chef_run.node)
allow(subject).to receive(:search_for)
@ -78,8 +78,8 @@ describe 'openstack-common::default' do
it 'returns memcached servers as defined by attributes' do
nodes = {
'openstack' => {
'memcached_servers' => ['1.1.1.1:11211', '2.2.2.2:11211']
}
'memcached_servers' => ['1.1.1.1:11211', '2.2.2.2:11211'],
},
}
allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes))
expect(
@ -90,8 +90,8 @@ describe 'openstack-common::default' do
it 'returns empty memcached servers as defined by attributes' do
nodes = {
'openstack' => {
'memcached_servers' => []
}
'memcached_servers' => [],
},
}
allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes))
expect(
@ -104,7 +104,7 @@ describe 'openstack-common::default' do
it 'returns rabbit servers' do
nodes = [
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
]
allow(subject).to receive(:node).and_return(chef_run.node)
allow(subject).to receive(:search_for)
@ -118,7 +118,7 @@ describe 'openstack-common::default' do
nodes = [
{ 'openstack' => { 'mq' => { 'listen' => '3.3.3.3' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
{ 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }
{ 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } },
]
allow(subject).to receive(:node).and_return(chef_run.node)
allow(subject).to receive(:search_for)

View File

@ -8,12 +8,12 @@ LOG_LEVEL = :fatal
UBUNTU_OPTS = {
platform: 'ubuntu',
version: '16.04',
log_level: LOG_LEVEL
log_level: LOG_LEVEL,
}.freeze
REDHAT_OPTS = {
platform: 'redhat',
version: '7.1',
log_level: LOG_LEVEL
log_level: LOG_LEVEL,
}.freeze
# We set a default platform for non-platform specific test cases
CHEFSPEC_OPTS = UBUNTU_OPTS
@ -32,9 +32,9 @@ shared_context 'common-stubs' do
'openstack' => {
'identity' => {
'admin_tenant_name' => 'admin',
'admin_user' => 'admin'
}
}
'admin_user' => 'admin',
},
},
}]
)
allow_any_instance_of(Chef::Recipe).to receive(:get_password)

View File

@ -12,7 +12,7 @@ describe 'Openstack uri' do
hash = {
'port' => 8888,
'path' => '/path',
'uri' => uri
'uri' => uri,
}
result = subject.uri_from_hash(hash)
expect(result).to be_a URI
@ -25,7 +25,7 @@ describe 'Openstack uri' do
'scheme' => 'https',
'port' => 8888,
'path' => '/path',
'host' => 'localhost'
'host' => 'localhost',
}
expect(
subject.uri_from_hash(hash).to_s
@ -36,7 +36,7 @@ describe 'Openstack uri' do
uri = 'https://localhost'
hash = {
'scheme' => 'https',
'host' => 'localhost'
'host' => 'localhost',
}
expect(
subject.uri_from_hash(hash).to_s

View File

@ -8,7 +8,7 @@ describe 'Openstack wrappers' do
describe '#recipe_included' do
it 'returns boolean for recipe list' do
node_hash = {
'recipes' => 'included_recipe'
'recipes' => 'included_recipe',
}
allow(subject).to receive(:node).and_return(node_hash)
expect(subject.recipe_included?('included_recipe')).to be_truthy
@ -19,7 +19,7 @@ describe 'Openstack wrappers' do
describe '#role_included' do
it 'returns boolean for role list' do
node_hash = {
'roles' => 'included_role'
'roles' => 'included_role',
}
allow(subject).to receive(:node).and_return(node_hash)
expect(subject.role_included?('included_role')).to be_truthy