From a45cea15d7041691af3d3d2942babc01567fcb2a Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Sat, 23 May 2020 14:21:33 -0700 Subject: [PATCH] Updates for Train Added: - Placement service Changed: - Update release to train - Cookstyle fixes - Update to mariadb ~> 4.0 Removed: - Unused rubocop rules Fixed: - ChefSpec for wrapper now correctly works with node.role? Depends-On: https://review.opendev.org/731849 Change-Id: I3e809350541e9c7beab311e5b3e768df1612d9f5 --- .rubocop.yml | 18 ----------- .rubocop_todo.yml | 10 +++++- README.rst | 4 +-- attributes/default.rb | 3 +- attributes/messaging.rb | 20 ++++++++++-- libraries/matchers.rb | 69 ----------------------------------------- libraries/wrappers.rb | 2 +- metadata.rb | 4 +-- spec/default_spec.rb | 8 ++--- spec/wrappers_spec.rb | 49 +++++++++++++++++------------ 10 files changed, 66 insertions(+), 121 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index f2902468..cc32da4b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,19 +1 @@ inherit_from: .rubocop_todo.yml - -AllCops: - Include: - - ./metadata.rb - - ./Gemfile - - attributes/**/* - - libraries/**/* - - providers/**/* - - recipes/**/* - - resources/**/* - - spec/**/* - Exclude: - - .cookbooks/**/* - - berks-cookbooks/**/* - - .bundle/**/* - -ChefModernize/DefinesChefSpecMatchers: - Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0c138c07..e8c7b5ac 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,11 +1,19 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-02-05 22:58:21 +0000 using RuboCop version 0.75.1. +# on 2020-05-29 17:26:38 -0700 using RuboCop version 0.82.0. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Include. +# Include: **/libraries/*.rb +ChefModernize/DefinesChefSpecMatchers: + Exclude: + - 'libraries/matchers.rb' + # Offense count: 2 Lint/NestedMethodDefinition: Exclude: diff --git a/README.rst b/README.rst index 10d005ac..17d30fa9 100644 --- a/README.rst +++ b/README.rst @@ -24,7 +24,7 @@ Requirements ============ - Chef 15 or higher -- Chef Workstation 0.15.18 for testing (also includes berkshelf for +- Chef Workstation 0.18.3 for testing (also includes berkshelf for cookbook dependency resolution) Platform @@ -40,7 +40,7 @@ Cookbooks The following cookbooks are dependencies: - 'etcd', '~> 5.6' -- 'mariadb', '~> 3.1' +- 'mariadb', '~> 4.0' - 'memcached', '~> 6.0' - 'selinux' - 'yum-epel' diff --git a/attributes/default.rb b/attributes/default.rb index ba13ef69..9fa2ed1a 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -49,6 +49,7 @@ default['openstack']['common']['services'] = { 'network' => 'neutron', 'object_storage' => 'swift', 'orchestration' => 'heat', + 'placement' => 'placement', 'telemetry' => 'ceilometer', 'telemetry_metric' => 'gnocchi', 'application_catalog' => 'murano', @@ -125,7 +126,7 @@ default['openstack']['secret']['user_passwords_data_bag'] = 'user_passwords' # needs. # The coordinated release of OpenStack codename -default['openstack']['release'] = 'stein' +default['openstack']['release'] = 'train' # The Ubuntu Cloud Archive has packages for multiple Ubuntu releases. For # more information, see: https://wiki.ubuntu.com/ServerTeam/CloudArchive. diff --git a/attributes/messaging.rb b/attributes/messaging.rb index 516d8653..b0467148 100644 --- a/attributes/messaging.rb +++ b/attributes/messaging.rb @@ -34,9 +34,23 @@ default['openstack']['bind_service']['mq']['interface'] = nil ################################################################### # Services to assign mq attributes for ################################################################### -services = %w(aodh bare_metal block_storage compute database dns image - identity telemetry network orchestration - baremetal block-storage) +services = + %w( + aodh + bare_metal + baremetal + block-storage + block_storage + compute + database + dns + identity + image + network + orchestration + placement + telemetry + ) ################################################################### # Generic default attributes diff --git a/libraries/matchers.rb b/libraries/matchers.rb index 25cef1df..d8b1dfb4 100644 --- a/libraries/matchers.rb +++ b/libraries/matchers.rb @@ -100,73 +100,4 @@ if defined?(ChefSpec) @expected_content.empty? end end - - ## matchers for openstack_database LWRP - def create_openstack_common_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:openstack_common_database, :create, resource_name) - end - - # database - # - ChefSpec.define_matcher :database - - def create_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database, :create, resource_name) - end - - def drop_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database, :drop, resource_name) - end - - def query_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database, :query, resource_name) - end - - # database user - # - ChefSpec.define_matcher :database_user - - def create_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database_user, :create, resource_name) - end - - def drop_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database_user, :drop, resource_name) - end - - def grant_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:database_user, :grant, resource_name) - end - - # mysql database - # - ChefSpec.define_matcher :mysql_database - - def create_mysql_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database, :create, resource_name) - end - - def drop_mysql_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database, :drop, resource_name) - end - - def query_mysql_database(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database, :query, resource_name) - end - - # mysql database user - # - ChefSpec.define_matcher :mysql_database_user - - def create_mysql_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database_user, :create, resource_name) - end - - def drop_mysql_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database_user, :drop, resource_name) - end - - def grant_mysql_database_user(resource_name) - ChefSpec::Matchers::ResourceMatcher.new(:mysql_database_user, :grant, resource_name) - end end diff --git a/libraries/wrappers.rb b/libraries/wrappers.rb index 3ed05ad6..2685e7ae 100644 --- a/libraries/wrappers.rb +++ b/libraries/wrappers.rb @@ -23,6 +23,6 @@ module ::Openstack # Wrapper method to allow to easier spec testing def role_included?(role) - node['roles'].include?(role) + node.role?(role) end end diff --git a/metadata.rb b/metadata.rb index ab4393f9..e3c8d3b4 100644 --- a/metadata.rb +++ b/metadata.rb @@ -3,14 +3,14 @@ maintainer 'openstack-chef' maintainer_email 'openstack-discuss@lists.openstack.org' license 'Apache-2.0' description 'Common OpenStack attributes, libraries and recipes.' -version '19.0.0' +version '20.0.0' %w(ubuntu redhat centos).each do |os| supports os end depends 'etcd', '~> 5.6' -depends 'mariadb', '~> 3.1' +depends 'mariadb', '~> 4.0' depends 'memcached', '~> 6.0' depends 'selinux' depends 'yum-epel' diff --git a/spec/default_spec.rb b/spec/default_spec.rb index df1f1680..7cfa3be3 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -48,7 +48,7 @@ describe 'openstack-common::default' do # https://github.com/sethvargo/chefspec#packaging-custom-matchers expect(chef_run).to add_apt_repository('openstack-ppa').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-updates/stein', + distribution: 'bionic-updates/train', components: ['main'], cache_rebuild: true ) @@ -63,7 +63,7 @@ describe 'openstack-common::default' do it 'disables openstack live updates' do expect(chef_run).to_not add_apt_repository('openstack-ppa').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-updates/stein', + distribution: 'bionic-updates/train', components: ['main'] ) end @@ -72,7 +72,7 @@ describe 'openstack-common::default' do 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: 'bionic-proposed/stein', + distribution: 'bionic-proposed/train', components: ['main'], cache_rebuild: true ) @@ -86,7 +86,7 @@ describe 'openstack-common::default' do it 'disables openstack proposed repository' do expect(chef_run).to_not add_apt_repository('openstack-ppa-proposed').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - distribution: 'bionic-proposed/stein', + distribution: 'bionic-proposed/train', components: ['main'] ) end diff --git a/spec/wrappers_spec.rb b/spec/wrappers_spec.rb index 6bbad8ec..dc02a178 100644 --- a/spec/wrappers_spec.rb +++ b/spec/wrappers_spec.rb @@ -2,28 +2,37 @@ require_relative 'spec_helper' require ::File.join ::File.dirname(__FILE__), '..', 'libraries', 'wrappers' -describe 'Openstack wrappers' do - let(:subject) { Object.new.extend(Openstack) } - - describe '#recipe_included' do - it 'returns boolean for recipe list' do - node_hash = { - 'recipes' => 'included_recipe', - } - allow(subject).to receive(:node).and_return(node_hash) - expect(subject.recipe_included?('included_recipe')).to be_truthy - expect(subject.recipe_included?('not_included_recipe')).to be_falsey +describe 'openstack-common::default' do + describe 'Openstack wrappers' do + let(:runner) { ChefSpec::SoloRunner.new(CHEFSPEC_OPTS) } + let(:node) { runner.node } + cached(:chef_run) do + runner.converge(described_recipe) end - end + let(:subject) { Object.new.extend(Openstack) } - describe '#role_included' do - it 'returns boolean for role list' do - node_hash = { - 'roles' => 'included_role', - } - allow(subject).to receive(:node).and_return(node_hash) - expect(subject.role_included?('included_role')).to be_truthy - expect(subject.role_included?('not_included_role')).to be_falsey + include_context 'library-stubs' + + describe '#recipe_included' do + it 'returns boolean for recipe list' do + node_hash = { + 'recipes' => 'included_recipe', + } + allow(subject).to receive(:node).and_return(node_hash) + expect(subject.recipe_included?('included_recipe')).to be_truthy + expect(subject.recipe_included?('not_included_recipe')).to be_falsey + end + end + + describe '#role_included' do + it 'returns boolean for role list' do + node_hash_true = double('node', automatic: { 'roles' => 'included_role' }, role?: true) + node_hash_false = double('node', automatic: { 'roles' => 'included_role' }, role?: false) + allow(subject).to receive(:node).and_return(node_hash_true) + expect(subject.role_included?('included_role')).to be_truthy + allow(subject).to receive(:node).and_return(node_hash_false) + expect(subject.role_included?('not_included_role')).to be_falsey + end end end end