From f3c371a1bbf51d410ff4c4d6c7bd70417043053d Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 22 Oct 2021 15:23:46 -0700 Subject: [PATCH] CentOS 8 support - Update packages for EL8 - Update ChefSpec Depends-On: https://review.opendev.org/c/openstack/openstack-chef/+/814234 Depends-On: https://review.opendev.org/c/openstack/cookbook-openstack-ops-database/+/815139 Depends-On: https://review.opendev.org/c/openstack/cookbook-openstack-ops-messaging/+/815137 Change-Id: Icf3119067dd4dd45291c0565d97b3fcc89ca3cac Signed-off-by: Lance Albertson --- attributes/default.rb | 70 ++++++++++++++--------- recipes/setup.rb | 6 +- spec/dns-rhel_spec.rb | 114 +++++++++++++++++++------------------- spec/setup-redhat_spec.rb | 27 ++++++--- spec/setup_spec.rb | 2 +- spec/spec_helper.rb | 13 ++++- 6 files changed, 138 insertions(+), 94 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 556e825..977e436 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -63,43 +63,63 @@ default['openstack']['integration-test'] = { # platform-specific settings case node['platform_family'] -when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this - default['openstack']['integration-test']['platform'] = { - tempest_packages: - %w( - git - curl - libxslt-devel - libxml2-devel - python-testrepository - libffi-devel - python-devel - python-gabbi - python-testscenarios - python-ddt - ), - package_overrides: '', - } +when 'rhel' + case node['platform_version'].to_i + when 8 + default['openstack']['integration-test']['platform'] = { + tempest_packages: + %w( + curl + git + libffi-devel + libxml2-devel + libxslt-devel + python3-ddt + python3-gabbi + python3-testrepository + python3-testscenarios + python36-devel + ), + package_overrides: '', + } + when 7 + default['openstack']['integration-test']['platform'] = { + tempest_packages: + %w( + curl + git + libffi-devel + libxml2-devel + libxslt-devel + python-ddt + python-devel + python-gabbi + python-testrepository + python-testscenarios + ), + package_overrides: '', + } + end when 'debian' default['openstack']['integration-test']['platform'] = { 'tempest_packages' => %w( - git curl - libssl-dev + git libffi-dev - python-dev + libffi-dev + libpq-dev + libssl-dev + libxml2-dev libxml2-dev libxslt1-dev - libpq-dev - libxml2-dev libxslt-dev - testrepository + python-ddt + python-dev python-dev - libffi-dev python-gabbi python-testscenarios - python-ddt + testrepository ), 'package_overrides' => '', } diff --git a/recipes/setup.rb b/recipes/setup.rb index 7af4eee..76bc1ac 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -96,8 +96,10 @@ execute 'create virtualenv for tempest' do creates venv_path end -# TODO(ramereth): RDO Train ships a cacert.pem which contains the expired LetsEncrypt root cert -cookbook_file "#{venv_path}/lib/python2.7/site-packages/pip/_vendor/requests/cacert.pem" if platform_family?('rhel') +if platform_family?('rhel') && node['platform_version'].to_i == 7 + # TODO(ramereth): RDO Train ships a cacert.pem which contains the expired LetsEncrypt root cert + cookbook_file "#{venv_path}/lib/python2.7/site-packages/pip/_vendor/requests/cacert.pem" +end # Note(jh): Make sure to keep the constraint definition in sync with # the tempest version diff --git a/spec/dns-rhel_spec.rb b/spec/dns-rhel_spec.rb index df01972..ed543c1 100644 --- a/spec/dns-rhel_spec.rb +++ b/spec/dns-rhel_spec.rb @@ -1,72 +1,74 @@ require_relative 'spec_helper' describe 'openstack-integration-test::dns' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) do + runner.converge(described_recipe) + end - include_context 'tempest-stubs' + include_context 'tempest-stubs' - it do - expect(chef_run).to set_resolver_config('/etc/resolv.conf').with( - nameservers: %w(1.0.0.1 8.8.8.8) - ) - end + it do + expect(chef_run).to set_resolver_config('/etc/resolv.conf').with( + nameservers: %w(1.0.0.1 8.8.8.8) + ) + end - it do - expect(chef_run).to disable_service('unbound') - end + it do + expect(chef_run).to disable_service('unbound') + end - it do - expect(chef_run).to stop_service('unbound') - end + it do + expect(chef_run).to stop_service('unbound') + end - it do - expect(chef_run).to create_bind_service('default') - expect(chef_run).to start_bind_service('default') - end + it do + expect(chef_run).to create_bind_service('default') + expect(chef_run).to start_bind_service('default') + end - it do - expect(chef_run).to create_template('/etc/named/rndc.key').with( - source: 'rndc.key.erb', - owner: 'named', - group: 'named', - mode: '440', - sensitive: true, - variables: { - secret: 'rndc-key', - } - ) - end + it do + expect(chef_run).to create_template('/etc/named/rndc.key').with( + source: 'rndc.key.erb', + owner: 'named', + group: 'named', + mode: '440', + sensitive: true, + variables: { + secret: 'rndc-key', + } + ) + end - it do - expect(chef_run.template('/etc/named/rndc.key')).to notify('bind_service[default]').to(:restart) - end + it do + expect(chef_run.template('/etc/named/rndc.key')).to notify('bind_service[default]').to(:restart) + end - it do - expect(chef_run).to create_template('/etc/named/named.designate').with( - owner: 'named', - group: 'named', - variables: { - bind_sysconfig: '/etc/named', - } - ) - end + it do + expect(chef_run).to create_template('/etc/named/named.designate').with( + owner: 'named', + group: 'named', + variables: { + bind_sysconfig: '/etc/named', + } + ) + end - it do - expect(chef_run.template('/etc/named/named.designate')).to notify('bind_service[default]').to(:restart) - end + it do + expect(chef_run.template('/etc/named/named.designate')).to notify('bind_service[default]').to(:restart) + end - it do - expect(chef_run).to create_bind_config('default').with( - options: [ - 'allow-new-zones yes', - ], - additional_config_files: %w(named.designate) - ) + it do + expect(chef_run).to create_bind_config('default').with( + options: [ + 'allow-new-zones yes', + ], + additional_config_files: %w(named.designate) + ) + end end end end diff --git a/spec/setup-redhat_spec.rb b/spec/setup-redhat_spec.rb index 79acae6..ba2448f 100644 --- a/spec/setup-redhat_spec.rb +++ b/spec/setup-redhat_spec.rb @@ -1,17 +1,26 @@ require_relative 'spec_helper' describe 'openstack-integration-test::setup' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) do - runner.converge(described_recipe) - end + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) do + runner.converge(described_recipe) + end - include_context 'tempest-stubs' + include_context 'tempest-stubs' - it 'installs tempest dependencies' do - expect(chef_run).to upgrade_package %w(git curl libxslt-devel libxml2-devel python-testrepository libffi-devel python-devel python-gabbi python-testscenarios python-ddt) + case p + when REDHAT_7 + it 'installs tempest dependencies' do + expect(chef_run).to upgrade_package %w(curl git libffi-devel libxml2-devel libxslt-devel python-ddt python-devel python-gabbi python-testrepository python-testscenarios) + end + when REDHAT_8 + it 'installs tempest dependencies' do + expect(chef_run).to upgrade_package %w(curl git libffi-devel libxml2-devel libxslt-devel python3-ddt python3-gabbi python3-testrepository python3-testscenarios python36-devel) + end + end end end end diff --git a/spec/setup_spec.rb b/spec/setup_spec.rb index 3da35da..1cf73df 100644 --- a/spec/setup_spec.rb +++ b/spec/setup_spec.rb @@ -20,7 +20,7 @@ describe 'openstack-integration-test::setup' do } it 'installs tempest dependencies' do - expect(chef_run).to upgrade_package %w(git curl libssl-dev libffi-dev python-dev libxml2-dev libxslt1-dev libpq-dev libxml2-dev libxslt-dev testrepository python-dev libffi-dev python-gabbi python-testscenarios python-ddt) + expect(chef_run).to upgrade_package %w(curl git libffi-dev libffi-dev libpq-dev libssl-dev libxml2-dev libxml2-dev libxslt1-dev libxslt-dev python-ddt python-dev python-dev python-gabbi python-testscenarios testrepository) end it 'registers tempest_project1 Project' do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index e6b8bf6..b343609 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,10 +8,21 @@ RSpec.configure do |config| config.log_level = :warn end -REDHAT_OPTS = { +REDHAT_7 = { platform: 'redhat', version: '7', }.freeze + +REDHAT_8 = { + platform: 'redhat', + version: '8', +}.freeze + +ALL_RHEL = [ + REDHAT_7, + REDHAT_8, +].freeze + UBUNTU_OPTS = { platform: 'ubuntu', version: '18.04',