From 8343638fc185c962c9a4ad7eac8016ddb8b1ae82 Mon Sep 17 00:00:00 2001 From: Lance Albertson Date: Fri, 22 Oct 2021 16:17:48 -0700 Subject: [PATCH] CentOS 8 support - ChefSpec updates Depends-On: https://review.opendev.org/c/openstack/cookbook-openstack-identity/+/815147 Depends-On: https://review.opendev.org/c/openstack/cookbook-openstack-compute/+/815173 Change-Id: I17fc8fafd977c8412f8e9519642ccbcd427c2949 Signed-off-by: Lance Albertson --- spec/api-cfn-redhat_spec.rb | 30 ++-- spec/api-redhat_spec.rb | 30 ++-- spec/common-redhat_spec.rb | 44 +++-- spec/dashboard-redhat_spec.rb | 16 +- spec/engine-redhat_spec.rb | 30 ++-- spec/identity_registration_spec.rb | 258 +++++++++++++++-------------- spec/spec_helper.rb | 24 ++- 7 files changed, 235 insertions(+), 197 deletions(-) diff --git a/spec/api-cfn-redhat_spec.rb b/spec/api-cfn-redhat_spec.rb index fa36720..0eff088 100644 --- a/spec/api-cfn-redhat_spec.rb +++ b/spec/api-cfn-redhat_spec.rb @@ -1,24 +1,26 @@ require_relative 'spec_helper' describe 'openstack-orchestration::api-cfn' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' + include_context 'orchestration_stubs' + include_examples 'expect runs openstack orchestration common recipe' - it 'installs heat cfn packages' do - expect(chef_run).to upgrade_package 'openstack-heat-api-cfn' - end + it 'installs heat cfn packages' do + expect(chef_run).to upgrade_package 'openstack-heat-api-cfn' + end - it 'enables heat api-cfn on boot' do - expect(chef_run).to enable_service('openstack-heat-api-cfn') - end + it 'enables heat api-cfn on boot' do + expect(chef_run).to enable_service('openstack-heat-api-cfn') + end - it 'starts heat api-cfn on boot' do - expect(chef_run).to start_service('openstack-heat-api-cfn') + it 'starts heat api-cfn on boot' do + expect(chef_run).to start_service('openstack-heat-api-cfn') + end end end end diff --git a/spec/api-redhat_spec.rb b/spec/api-redhat_spec.rb index c164798..aa953d2 100644 --- a/spec/api-redhat_spec.rb +++ b/spec/api-redhat_spec.rb @@ -1,24 +1,26 @@ require_relative 'spec_helper' describe 'openstack-orchestration::api' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' + include_context 'orchestration_stubs' + include_examples 'expect runs openstack orchestration common recipe' - it 'installs heat api packages' do - expect(chef_run).to upgrade_package 'openstack-heat-api' - end + it 'installs heat api packages' do + expect(chef_run).to upgrade_package 'openstack-heat-api' + end - it 'enables heat api on boot' do - expect(chef_run).to enable_service('openstack-heat-api') - end + it 'enables heat api on boot' do + expect(chef_run).to enable_service('openstack-heat-api') + end - it 'starts heat api on boot' do - expect(chef_run).to start_service('openstack-heat-api') + it 'starts heat api on boot' do + expect(chef_run).to start_service('openstack-heat-api') + end end end end diff --git a/spec/common-redhat_spec.rb b/spec/common-redhat_spec.rb index 720a962..51e9aaf 100644 --- a/spec/common-redhat_spec.rb +++ b/spec/common-redhat_spec.rb @@ -1,24 +1,34 @@ require_relative 'spec_helper' describe 'openstack-orchestration::common' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' - include_examples 'logging' - include_examples 'expects to create heat directories' - include_examples 'expects to create heat conf' - include_examples 'expects to create heat default.yaml' - include_examples 'expect installs common heat package' - include_examples 'expect installs mysql package' - include_examples 'expect runs db migrations' - it do - expect(chef_run).to upgrade_package 'openstack-heat-common' - end - it do - expect(chef_run).to upgrade_package 'MySQL-python' + include_context 'orchestration_stubs' + include_examples 'logging' + include_examples 'expects to create heat directories' + include_examples 'expects to create heat conf' + include_examples 'expects to create heat default.yaml' + include_examples 'expect installs common heat package' + include_examples 'expect installs mysql package' + include_examples 'expect runs db migrations' + it do + expect(chef_run).to upgrade_package 'openstack-heat-common' + end + + case p + when REDHAT_7 + it do + expect(chef_run).to upgrade_package 'MySQL-python' + end + when REDHAT_8 + it do + expect(chef_run).to upgrade_package 'python3-PyMySQL' + end + end end end end diff --git a/spec/dashboard-redhat_spec.rb b/spec/dashboard-redhat_spec.rb index 447b05d..2343395 100644 --- a/spec/dashboard-redhat_spec.rb +++ b/spec/dashboard-redhat_spec.rb @@ -1,14 +1,16 @@ require_relative 'spec_helper' describe 'openstack-orchestration::dashboard' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' - it do - expect(chef_run).to upgrade_package 'openstack-heat-ui' + include_context 'orchestration_stubs' + it do + expect(chef_run).to upgrade_package 'openstack-heat-ui' + end end end end diff --git a/spec/engine-redhat_spec.rb b/spec/engine-redhat_spec.rb index ee12f3f..cfe3dea 100644 --- a/spec/engine-redhat_spec.rb +++ b/spec/engine-redhat_spec.rb @@ -1,24 +1,26 @@ require_relative 'spec_helper' describe 'openstack-orchestration::engine' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' - include_examples 'expect runs openstack orchestration common recipe' + include_context 'orchestration_stubs' + include_examples 'expect runs openstack orchestration common recipe' - it 'installs heat engine package' do - expect(chef_run).to upgrade_package 'openstack-heat-engine' - end + it 'installs heat engine package' do + expect(chef_run).to upgrade_package 'openstack-heat-engine' + end - it 'enables heat engine on boot' do - expect(chef_run).to enable_service('openstack-heat-engine') - end + it 'enables heat engine on boot' do + expect(chef_run).to enable_service('openstack-heat-engine') + end - it 'starts heat engine on boot' do - expect(chef_run).to start_service('openstack-heat-engine') + it 'starts heat engine on boot' do + expect(chef_run).to start_service('openstack-heat-engine') + end end end end diff --git a/spec/identity_registration_spec.rb b/spec/identity_registration_spec.rb index 31541d0..3c175ed 100644 --- a/spec/identity_registration_spec.rb +++ b/spec/identity_registration_spec.rb @@ -1,147 +1,149 @@ require_relative 'spec_helper' describe 'openstack-orchestration::identity_registration' do - describe 'redhat' do - let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) } - let(:node) { runner.node } - cached(:chef_run) { runner.converge(described_recipe) } + ALL_RHEL.each do |p| + context "redhat #{p[:version]}" do + let(:runner) { ChefSpec::SoloRunner.new(p) } + let(:node) { runner.node } + cached(:chef_run) { runner.converge(described_recipe) } - include_context 'orchestration_stubs' + include_context 'orchestration_stubs' - connection_params = { - openstack_auth_url: 'http://127.0.0.1:5000/v3', - openstack_username: 'admin', - openstack_api_key: 'admin-pass', - openstack_project_name: 'admin', - openstack_domain_name: 'default', - } - service_name = 'heat' - service_type = 'orchestration' - service_user = 'heat' - stack_domain_admin = 'heat_domain_admin' - stack_domain_name = 'heat' - stack_domain_password = 'heat_domain_pass' - url = 'http://127.0.0.1:8004/v1/%(tenant_id)s' - region = 'RegionOne' - project_name = 'service' - role_name = 'service' - password = 'heat-pass' - domain_name = 'Default' + connection_params = { + openstack_auth_url: 'http://127.0.0.1:5000/v3', + openstack_username: 'admin', + openstack_api_key: 'admin-pass', + openstack_project_name: 'admin', + openstack_domain_name: 'default', + } + service_name = 'heat' + service_type = 'orchestration' + service_user = 'heat' + stack_domain_admin = 'heat_domain_admin' + stack_domain_name = 'heat' + stack_domain_password = 'heat_domain_pass' + url = 'http://127.0.0.1:8004/v1/%(tenant_id)s' + region = 'RegionOne' + project_name = 'service' + role_name = 'service' + password = 'heat-pass' + domain_name = 'Default' - it "registers #{project_name} Project" do - expect(chef_run).to create_openstack_project( - project_name - ).with( - connection_params: connection_params - ) - end + it "registers #{project_name} Project" do + expect(chef_run).to create_openstack_project( + project_name + ).with( + connection_params: connection_params + ) + end - it "registers #{service_name} service" do - expect(chef_run).to create_openstack_service( - service_name - ).with( - connection_params: connection_params, - type: service_type - ) - end + it "registers #{service_name} service" do + expect(chef_run).to create_openstack_service( + service_name + ).with( + connection_params: connection_params, + type: service_type + ) + end - context "registers #{service_name} endpoint" do + context "registers #{service_name} endpoint" do + %w(internal public).each do |interface| + it "#{interface} endpoint with default values" do + expect(chef_run).to create_openstack_endpoint( + service_type + ).with( + service_name: service_name, + # interface: interface, + url: url, + region: region, + connection_params: connection_params + ) + end + end + end + + it 'registers service user' do + expect(chef_run).to create_openstack_user( + service_user + ).with( + domain_name: domain_name, + project_name: project_name, + password: password, + connection_params: connection_params + ) + end + + it do + expect(chef_run).to create_openstack_role( + 'heat_stack_owner' + ).with( + connection_params: connection_params + ) + end + + it do + expect(chef_run).to create_openstack_role( + 'heat_stack_user' + ).with( + connection_params: connection_params + ) + end + + it do + expect(chef_run).to grant_role_openstack_user( + service_user + ).with( + project_name: project_name, + role_name: role_name, + connection_params: connection_params + ) + end + + it do + expect(chef_run).to create_openstack_domain( + stack_domain_name + ).with( + connection_params: connection_params + ) + end + + it 'registers stack domain admin user' do + expect(chef_run).to create_openstack_user( + stack_domain_admin + ).with( + password: stack_domain_password, + connection_params: connection_params + ) + end + + it do + expect(chef_run).to grant_domain_openstack_user( + stack_domain_admin + ).with( + domain_name: stack_domain_name, + role_name: 'admin', + connection_params: connection_params + ) + end + it 'register heat cloudformation service' do + expect(chef_run).to create_openstack_service( + 'heat-cfn' + ).with( + connection_params: connection_params + ) + end %w(internal public).each do |interface| - it "#{interface} endpoint with default values" do + it "#{interface} cloudformation endpoint with default values" do expect(chef_run).to create_openstack_endpoint( - service_type + 'cloudformation' ).with( - service_name: service_name, - # interface: interface, - url: url, + service_name: 'heat-cfn', + url: 'http://127.0.0.1:8000/v1', region: region, connection_params: connection_params ) end end end - - it 'registers service user' do - expect(chef_run).to create_openstack_user( - service_user - ).with( - domain_name: domain_name, - project_name: project_name, - password: password, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_role( - 'heat_stack_owner' - ).with( - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_role( - 'heat_stack_user' - ).with( - connection_params: connection_params - ) - end - - it do - expect(chef_run).to grant_role_openstack_user( - service_user - ).with( - project_name: project_name, - role_name: role_name, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to create_openstack_domain( - stack_domain_name - ).with( - connection_params: connection_params - ) - end - - it 'registers stack domain admin user' do - expect(chef_run).to create_openstack_user( - stack_domain_admin - ).with( - password: stack_domain_password, - connection_params: connection_params - ) - end - - it do - expect(chef_run).to grant_domain_openstack_user( - stack_domain_admin - ).with( - domain_name: stack_domain_name, - role_name: 'admin', - connection_params: connection_params - ) - end - it 'register heat cloudformation service' do - expect(chef_run).to create_openstack_service( - 'heat-cfn' - ).with( - connection_params: connection_params - ) - end - %w(internal public).each do |interface| - it "#{interface} cloudformation endpoint with default values" do - expect(chef_run).to create_openstack_endpoint( - 'cloudformation' - ).with( - service_name: 'heat-cfn', - url: 'http://127.0.0.1:8000/v1', - region: region, - connection_params: connection_params - ) - end - end end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index da5396f..cd27138 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', @@ -75,8 +86,15 @@ shared_examples 'expect installs common heat package' do end shared_examples 'expect installs mysql package' do - it 'installs mysql python packages by default' do - expect(chef_run).to upgrade_package 'MySQL-python' + case p + when REDHAT_7 + it 'installs mysql python packages by default' do + expect(chef_run).to upgrade_package 'MySQL-python' + end + when REDHAT_8 + it 'installs mysql python packages by default' do + expect(chef_run).to upgrade_package 'python3-PyMySQL' + end end end