diff --git a/Rakefile b/Rakefile index c30901d6..fe1a116b 100644 --- a/Rakefile +++ b/Rakefile @@ -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" diff --git a/attributes/database.rb b/attributes/database.rb index f4608e6d..c3432142 100644 --- a/attributes/database.rb +++ b/attributes/database.rb @@ -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' diff --git a/attributes/default.rb b/attributes/default.rb index 426b32a3..0436632f 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -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', @@ -46,7 +47,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 @@ -120,7 +121,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. @@ -154,52 +155,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', @@ -207,52 +208,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 @@ -260,26 +261,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 @@ -291,11 +292,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 diff --git a/attributes/messaging.rb b/attributes/messaging.rb index 13160ede..e679f5a3 100644 --- a/attributes/messaging.rb +++ b/attributes/messaging.rb @@ -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'], } ################################################################### diff --git a/bootstrap.sh b/bootstrap.sh index 0c90c8b1..0f2bbd97 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -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 diff --git a/libraries/cli.rb b/libraries/cli.rb index 815553ee..840f3c5f 100644 --- a/libraries/cli.rb +++ b/libraries/cli.rb @@ -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 diff --git a/libraries/endpoints.rb b/libraries/endpoints.rb index 036591f6..77c00e97 100644 --- a/libraries/endpoints.rb +++ b/libraries/endpoints.rb @@ -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 diff --git a/libraries/matchers.rb b/libraries/matchers.rb index e2a2450d..031ce5aa 100644 --- a/libraries/matchers.rb +++ b/libraries/matchers.rb @@ -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}\]/ diff --git a/libraries/parse.rb b/libraries/parse.rb index ddbacabb..f9a7ce9f 100644 --- a/libraries/parse.rb +++ b/libraries/parse.rb @@ -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 = [] diff --git a/providers/database.rb b/providers/database.rb index db3a2547..0bd36f2d 100644 --- a/providers/database.rb +++ b/providers/database.rb @@ -57,7 +57,7 @@ def connection_info port: @port.to_i, username: @super_user, password: @super_password, - socket: @socket + socket: @socket, } end diff --git a/recipes/client.rb b/recipes/client.rb index e61a326d..b0f6acfd 100644 --- a/recipes/client.rb +++ b/recipes/client.rb @@ -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' diff --git a/recipes/default.rb b/recipes/default.rb index 5064acd0..9bdb7bac 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -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' diff --git a/recipes/python.rb b/recipes/python.rb new file mode 100644 index 00000000..357eab45 --- /dev/null +++ b/recipes/python.rb @@ -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 diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 7bf09bf0..3da3ec89 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -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) diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 7a6f028e..15c1ab9e 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -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 diff --git a/spec/config_helpers_spec.rb b/spec/config_helpers_spec.rb index 8e480624..35120e62 100644 --- a/spec/config_helpers_spec.rb +++ b/spec/config_helpers_spec.rb @@ -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 diff --git a/spec/default-redhat_spec.rb b/spec/default-redhat_spec.rb index 76f5d252..ad873344 100644 --- a/spec/default-redhat_spec.rb +++ b/spec/default-redhat_spec.rb @@ -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 diff --git a/spec/default_spec.rb b/spec/default_spec.rb index eb93d566..bde978e5 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -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 diff --git a/spec/endpoints_spec.rb b/spec/endpoints_spec.rb index 31be685b..87d9adad 100644 --- a/spec/endpoints_spec.rb +++ b/spec/endpoints_spec.rb @@ -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') diff --git a/spec/logging_spec.rb b/spec/logging_spec.rb index 84769bcd..51bad2ae 100644 --- a/spec/logging_spec.rb +++ b/spec/logging_spec.rb @@ -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) diff --git a/spec/network_spec.rb b/spec/network_spec.rb index 8fea983d..63e5cbfc 100644 --- a/spec/network_spec.rb +++ b/spec/network_spec.rb @@ -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') diff --git a/spec/search_spec.rb b/spec/search_spec.rb index cb28c0d7..ba75775a 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -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) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 665f2180..ec322162 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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) diff --git a/spec/uri_spec.rb b/spec/uri_spec.rb index 423036c0..7dbfd56e 100644 --- a/spec/uri_spec.rb +++ b/spec/uri_spec.rb @@ -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 diff --git a/spec/wrappers_spec.rb b/spec/wrappers_spec.rb index f7df16a7..6bbad8ec 100644 --- a/spec/wrappers_spec.rb +++ b/spec/wrappers_spec.rb @@ -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