Improve ChefSpec test speed by enabling caching

This updates all references of let(:chef_run) to cached(:chef_run) to
speed up tests. By doing this, we have to create a new cached(:chef_run)
block whenever we need to adjust node attributes for testing.

- Remove unused default recipe ChefSpec
- Formatting cleanup

Speed was improved from 7 minutes 17 seconds to 1 minute 34.18 seconds

Change-Id: I8bdde8b68371d25275aa78d9438f5aeff960062f
This commit is contained in:
Lance Albertson 2019-12-18 10:30:27 -08:00
parent baa1464918
commit ef4adacafa
24 changed files with 235 additions and 166 deletions

View File

@ -6,39 +6,29 @@ describe 'openstack-compute::_nova_cell' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_cell_recipe'
it 'creates the cell0 mapping' do
expect(chef_run).to run_execute('map cell0')
.with(user: 'nova',
group: 'nova')
expect(chef_run).to run_execute('map cell0').with(user: 'nova', group: 'nova')
end
it 'creates a new cell' do
expect(chef_run).to run_execute('create cell1')
.with(user: 'nova',
group: 'nova')
expect(chef_run).to run_execute('create cell1').with(user: 'nova', group: 'nova')
end
it 'executes api_db sync' do
expect(chef_run).to run_execute('api db sync')
.with(user: 'nova',
group: 'nova')
expect(chef_run).to run_execute('api db sync').with(user: 'nova', group: 'nova')
end
it 'executes db sync' do
expect(chef_run).to run_execute('db sync')
.with(user: 'nova',
group: 'nova')
expect(chef_run).to run_execute('db sync').with(user: 'nova', group: 'nova')
end
it 'discovers compute hosts' do
expect(chef_run).to run_execute('discover hosts')
.with(user: 'nova',
group: 'nova')
expect(chef_run).to run_execute('discover hosts').with(user: 'nova', group: 'nova')
end
end
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::api-metadata' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::api-metadata' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::api-os-compute' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'
@ -15,10 +15,12 @@ describe 'openstack-compute::api-os-compute' do
it 'executes nova-manage api_db sync' do
expect(chef_run).to run_execute('nova-manage api_db sync')
.with(timeout: 3600,
user: 'nova',
group: 'nova',
command: 'nova-manage api_db sync')
.with(
timeout: 3600,
user: 'nova',
group: 'nova',
command: 'nova-manage api_db sync'
)
end
it 'upgrades openstack api packages' do

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::api-os-compute' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'
@ -16,10 +16,12 @@ describe 'openstack-compute::api-os-compute' do
it do
expect(chef_run).to run_execute('nova-manage api_db sync')
.with(timeout: 3600,
user: 'nova',
group: 'nova',
command: 'nova-manage api_db sync')
.with(
timeout: 3600,
user: 'nova',
group: 'nova',
command: 'nova-manage api_db sync'
)
end
it 'upgrades openstack api packages' do

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::compute' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'
@ -15,16 +15,24 @@ describe 'openstack-compute::compute' do
include_examples 'expect_creates_nova_instances_dir'
include_examples 'expect_volume_packages'
it "does not upgrade kvm when virt_type is 'kvm'" do
node.override['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
expect(chef_run).to_not upgrade_package('nova-compute-kvm')
context "does not upgrade kvm when virt_type is 'kvm'" do
cached(:chef_run) do
node.override['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
runner.converge(described_recipe)
end
it do
expect(chef_run).to_not upgrade_package('nova-compute-kvm')
end
end
it "does not upgrade qemu when virt_type is 'qemu'" do
node.override['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
expect(chef_run).to_not upgrade_package('nova-compute-qemu')
context "does not upgrade qemu when virt_type is 'qemu'" do
cached(:chef_run) do
node.override['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
runner.converge(described_recipe)
end
it do
expect(chef_run).to_not upgrade_package('nova-compute-qemu')
end
end
it 'upgrades nova compute package' do

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::compute' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'
@ -32,26 +32,38 @@ describe 'openstack-compute::compute' do
expect(chef_run).to upgrade_package 'nova-compute'
end
it "upgrades kvm when virt_type is 'kvm'" do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'kvm'
expect(chef_run).to upgrade_package 'nova-compute-kvm'
expect(chef_run).not_to upgrade_package 'nova-compute-qemu'
context "upgrades kvm when virt_type is 'kvm'" do
cached(:chef_run) do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'kvm'
runner.converge(described_recipe)
end
it do
expect(chef_run).to upgrade_package 'nova-compute-kvm'
expect(chef_run).not_to upgrade_package 'nova-compute-qemu'
end
end
it 'upgrades qemu when virt_type is qemu' do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'qemu'
expect(chef_run).to upgrade_package 'nova-compute-qemu'
expect(chef_run).not_to upgrade_package 'nova-compute-kvm'
context 'upgrades qemu when virt_type is qemu' do
cached(:chef_run) do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = 'qemu'
runner.converge(described_recipe)
end
it do
expect(chef_run).to upgrade_package 'nova-compute-qemu'
expect(chef_run).not_to upgrade_package 'nova-compute-kvm'
end
end
%w(qemu kvm).each do |virt_type|
it "honors the package name platform overrides for #{virt_type}" do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = virt_type
node.override['openstack']['compute']['platform']["#{virt_type}_compute_packages"] = ["my-nova-#{virt_type}"]
expect(chef_run).to upgrade_package("my-nova-#{virt_type}")
context "honors the package name platform overrides for #{virt_type}" do
cached(:chef_run) do
node.override['openstack']['compute']['conf']['libvirt']['virt_type'] = virt_type
node.override['openstack']['compute']['platform']["#{virt_type}_compute_packages"] = ["my-nova-#{virt_type}"]
runner.converge(described_recipe)
end
it do
expect(chef_run).to upgrade_package("my-nova-#{virt_type}")
end
end
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::conductor' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::conductor' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -1,6 +0,0 @@
# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-compute::default' do
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::identity_registration' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::libvirt' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::libvirt' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
@ -56,7 +56,12 @@ describe 'openstack-compute::libvirt' do
end
it 'has proper processing controls' do
[/^max_clients = 20$/, /^max_workers = 20$/, /^max_requests = 20$/, /^max_client_requests = 5$/].each do |content|
[
/^max_clients = 20$/,
/^max_workers = 20$/,
/^max_requests = 20$/,
/^max_client_requests = 5$/,
].each do |content|
expect(chef_run).to render_file(file.name).with_content(content)
end
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::nova-common' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_creates_nova_state_dir'

View File

@ -6,12 +6,9 @@ describe 'openstack-compute::nova-common' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
node.override['openstack']['mq'] = {
'host' => '127.0.0.1',
}
cached(:chef_run) do
node.override['openstack']['mq'] = { 'host' => '127.0.0.1' }
node.override['openstack']['mq']['compute']['rabbit']['ha'] = true
runner.converge(described_recipe)
end
@ -40,8 +37,9 @@ describe 'openstack-compute::nova-common' do
end
context 'with logging enabled' do
before do
cached(:chef_run) do
node.override['openstack']['compute']['syslog']['use'] = true
runner.converge(described_recipe)
end
it 'runs logging recipe if node attributes say to' do
@ -50,8 +48,9 @@ describe 'openstack-compute::nova-common' do
end
context 'with logging disabled' do
before do
cached(:chef_run) do
node.override['openstack']['compute']['syslog']['use'] = false
runner.converge(described_recipe)
end
it "doesn't run logging recipe" do
@ -71,10 +70,12 @@ describe 'openstack-compute::nova-common' do
end
it 'has default *_path options set' do
[%r{^log_dir = /var/log/nova$},
%r{^state_path = /var/lib/nova$},
%r{^instances_path = /var/lib/nova/instances$},
%r{^lock_path = /var/lib/nova/lock$}].each do |line|
[
%r{^log_dir = /var/log/nova$},
%r{^state_path = /var/lib/nova$},
%r{^instances_path = /var/lib/nova/instances$},
%r{^lock_path = /var/lib/nova/lock$},
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
@ -86,8 +87,10 @@ describe 'openstack-compute::nova-common' do
end
it 'has default misc config attributes defaults not set' do
[/^osapi_compute_link_prefix = /,
/^osapi_glance_link_prefix = /].each do |line|
[
/^osapi_compute_link_prefix = /,
/^osapi_glance_link_prefix = /,
].each do |line|
expect(chef_run).not_to render_config_file(file.name).with_section_content('DEFAULT', line)
end
end
@ -171,52 +174,76 @@ describe 'openstack-compute::nova-common' do
context 'rabbit mq backend' do
describe 'ha rabbit disabled' do
before do
cached(:chef_run) do
# README(galstrom21): There is a order of operations issue here
# if you use node.override, these tests will fail.
node.override['openstack']['mq']['compute']['rabbit']['ha'] = false
runner.converge(described_recipe)
end
it 'does not have ha rabbit options set' do
[/^rabbit_hosts = /, /^rabbit_ha_queues = /].each do |line|
expect(chef_run).not_to render_config_file(file.name).with_section_content('oslo_messaging_rabbit', line)
[
/^rabbit_hosts = /,
/^rabbit_ha_queues = /,
].each do |line|
expect(chef_run).not_to render_config_file(file.name)
.with_section_content('oslo_messaging_rabbit', line)
end
end
end
end
it 'has default server_* options set' do
node.override['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = 'lo'
[/^server_listen = 127.0.0.1$/,
/^server_proxyclient_address = 127.0.0.1$/].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
context 'has default server_* options set' do
cached(:chef_run) do
node.override['openstack']['endpoints']['compute-vnc-bind']['bind_interface'] = 'lo'
runner.converge(described_recipe)
end
it do
[
/^server_listen = 127.0.0.1$/,
/^server_proxyclient_address = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
end
it 'has override server_* options set' do
node.override['openstack']['bind_service']['all']['compute-vnc']['host'] = '1.1.1.1'
node.override['openstack']['bind_service']['all']['compute-vnc-proxy']['host'] = '2.2.2.2'
[/^server_listen = 1.1.1.1$/,
/^server_proxyclient_address = 2.2.2.2$/].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
context 'has override server_* options set' do
cached(:chef_run) do
node.override['openstack']['bind_service']['all']['compute-vnc']['host'] = '1.1.1.1'
node.override['openstack']['bind_service']['all']['compute-vnc-proxy']['host'] = '2.2.2.2'
runner.converge(described_recipe)
end
it do
[
/^server_listen = 1.1.1.1$/,
/^server_proxyclient_address = 2.2.2.2$/,
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
end
it 'has default *vncproxy_* options set' do
[/^xvpvncproxy_host = 127.0.0.1$/,
/^xvpvncproxy_port = 6081$/,
/^novncproxy_host = 127.0.0.1$/,
/^novncproxy_port = 6080$/].each do |line|
[
/^xvpvncproxy_host = 127.0.0.1$/,
/^xvpvncproxy_port = 6081$/,
/^novncproxy_host = 127.0.0.1$/,
/^novncproxy_port = 6080$/,
].each do |line|
expect(chef_run).to render_file(file.name).with_content(line)
end
end
it 'has a os_region_name setting' do
chef_run.node.override['openstack']['node'] = 'RegionOne'
expect(chef_run).to render_config_file(file.name)\
.with_section_content('cinder', /^os_region_name = RegionOne$/)
context 'has a os_region_name setting' do
cached(:chef_run) do
node.override['openstack']['node'] = 'RegionOne'
runner.converge(described_recipe)
end
it do
expect(chef_run).to render_config_file(file.name)
.with_section_content('cinder', /^os_region_name = RegionOne$/)
end
end
it 'has no auto_assign_floating_ip' do
@ -226,9 +253,10 @@ describe 'openstack-compute::nova-common' do
end
context 'lvm backend' do
before do
cached(:chef_run) do
node.override['openstack']['compute']['conf']['libvirt']['images_type'] = 'lvm'
node.override['openstack']['compute']['conf']['libvirt']['images_volume_group'] = 'instances'
runner.converge(described_recipe)
end
it 'sets the lvm options correctly' do
@ -237,17 +265,17 @@ describe 'openstack-compute::nova-common' do
/^images_volume_group = instances$/,
/^sparse_logical_volumes = false$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)\
.with_section_content('libvirt', line)
expect(chef_run).to render_config_file(file.name).with_section_content('libvirt', line)
end
end
describe 'override settings' do
before do
context 'override settings' do
cached(:chef_run) do
node.override['openstack']['compute']['conf']['libvirt']['images_type'] = 'lvm'
node.override['openstack']['compute']['conf']['libvirt']['images_volume_group'] = 'instances'
node.override['openstack']['compute']['conf']['libvirt']['sparse_logical_volumes'] = true
# node.override['openstack']['compute']['libvirt']['cpu_mode'] = 'none'
runner.converge(described_recipe)
end
it 'sets the overridden lvm options correctly' do
@ -277,54 +305,75 @@ describe 'openstack-compute::nova-common' do
end
end
it 'sets overide serial console options set' do
node.override['openstack']['endpoints']['compute-serial-console-bind']['bind_interface'] = 'lo'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['scheme'] = 'wss'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['host'] = '1.1.1.1'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['port'] = '6082'
# node.override['openstack']['compute']['serial_console']['enable'] = 'True'
# node.override['openstack']['compute']['serial_console']['port_range'] = '11000:15000'
[
# /^enabled = True$/,
%r{base_url = wss://1.1.1.1:6082$},
# /^port_range = 11000:15000$/,
/^proxyclient_address = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)\
.with_section_content('serial_console', line)
context 'sets overide serial console options set' do
cached(:chef_run) do
node.override['openstack']['endpoints']['compute-serial-console-bind']['bind_interface'] = 'lo'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['scheme'] = 'wss'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['host'] = '1.1.1.1'
node.override['openstack']['endpoints']['public']['compute-serial-proxy']['port'] = '6082'
# node.override['openstack']['compute']['serial_console']['enable'] = 'True'
# node.override['openstack']['compute']['serial_console']['port_range'] = '11000:15000'
runner.converge(described_recipe)
end
it do
[
# /^enabled = True$/,
%r{base_url = wss://1.1.1.1:6082$},
# /^port_range = 11000:15000$/,
/^proxyclient_address = 127.0.0.1$/,
].each do |line|
expect(chef_run).to render_config_file(file.name)\
.with_section_content('serial_console', line)
end
end
end
end
it do
node.override['openstack']['db']['compute_api']['username'] = 'nova_api'
expect(chef_run).to render_config_file(file.name)
.with_section_content(
'api_database',
%(connection = mysql+pymysql://nova_api:nova_api_db_pass@127.0.0.1:3306/nova_api?charset=utf8)
)
context 'override compute_api username' do
cached(:chef_run) do
node.override['openstack']['db']['compute_api']['username'] = 'nova_api'
runner.converge(described_recipe)
end
it do
expect(chef_run).to render_config_file(file.name)
.with_section_content(
'api_database',
%(connection = mysql+pymysql://nova_api:nova_api_db_pass@127.0.0.1:3306/nova_api?charset=utf8)
)
end
end
context 'set enabled_slave attribute' do
it 'sets overide database enabled_slave attribute as true' do
cached(:chef_run) do
node.override['openstack']['endpoints']['db']['enabled_slave'] = true
node.override['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1'
node.override['openstack']['endpoints']['db']['slave_port'] = '3326'
node.override['openstack']['db']['compute']['username'] = 'nova'
runner.converge(described_recipe)
end
it 'sets overide database enabled_slave attribute as true' do
expect(chef_run).to render_config_file(file.name)\
.with_section_content('database', %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8))
.with_section_content(
'database',
%(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8)
)
end
it 'sets overide database enabled_slave attribute as false' do
node.override['openstack']['endpoints']['db']['enabled_slave'] = false
node.override['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1'
node.override['openstack']['endpoints']['db']['slave_port'] = '3326'
node.override['openstack']['db']['compute']['username'] = 'nova'
expect(chef_run).to_not render_config_file(file.name)\
.with_section_content('database', %(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8))
context 'sets overide database enabled_slave attribute as false' do
cached(:chef_run) do
node.override['openstack']['endpoints']['db']['enabled_slave'] = false
node.override['openstack']['endpoints']['db']['slave_host'] = '10.10.1.1'
node.override['openstack']['endpoints']['db']['slave_port'] = '3326'
node.override['openstack']['db']['compute']['username'] = 'nova'
runner.converge(described_recipe)
end
it do
expect(chef_run).to_not render_config_file(file.name)\
.with_section_content(
'database',
%(slave_connection = mysql+pymysql://nova:nova_db_pass@10.10.1.1:3326/nova?charset=utf8)
)
end
end
end
end
@ -341,9 +390,11 @@ describe 'openstack-compute::nova-common' do
end
context 'template contents' do
it 'shows the custom banner' do
cached(:chef_run) do
node.override['openstack']['compute']['custom_template_banner'] = 'banner'
runner.converge(described_recipe)
end
it 'shows the custom banner' do
expect(chef_run).to render_file(file.name).with_content(/^banner$/)
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::nova-setup' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'
@ -19,13 +19,18 @@ describe 'openstack-compute::nova-setup' do
)
end
it 'runs db migrations with timeout override' do
node.override['openstack']['compute']['dbsync_timeout'] = 1234
expect(chef_run).to run_execute('nova-manage db sync').with(
user: 'nova',
group: 'nova',
timeout: 1234
)
context 'runs db migrations with timeout override' do
cached(:chef_run) do
node.override['openstack']['compute']['dbsync_timeout'] = 1234
runner.converge(described_recipe)
end
it do
expect(chef_run).to run_execute('nova-manage db sync').with(
user: 'nova',
group: 'nova',
timeout: 1234
)
end
end
end
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::placement_api' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::scheduler' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::scheduler' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::serialproxy' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::serialproxy' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -2,26 +2,23 @@
require 'chefspec'
require 'chefspec/berkshelf'
ChefSpec::Coverage.start! { add_filter 'openstack-compute' }
require 'chef/application'
require 'securerandom'
RSpec.configure do |config|
config.color = true
config.formatter = :documentation
config.log_level = :fatal
config.log_level = :warn
config.file_cache_path = '/var/chef/cache'
end
REDHAT_OPTS = {
platform: 'redhat',
version: '7.4',
version: '7',
}.freeze
UBUNTU_OPTS = {
platform: 'ubuntu',
version: '16.04',
version: '18.04',
}.freeze
shared_context 'compute_stubs' do
@ -160,8 +157,11 @@ shared_examples 'expect_creates_api_paste_template' do
end
context 'template contents' do
it 'pastes the misc attributes' do
cached(:chef_run) do
node.override['openstack']['compute']['misc_paste'] = %w(paste1 paste2)
runner.converge(described_recipe)
end
it 'pastes the misc attributes' do
expect(chef_run).to render_file(file.name)
.with_content(/^paste1$/).with_content(/^paste2$/)
end

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::vncproxy' do
describe 'redhat' do
let(:runner) { ChefSpec::SoloRunner.new(REDHAT_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'

View File

@ -6,7 +6,7 @@ describe 'openstack-compute::vncproxy' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) { runner.converge(described_recipe) }
cached(:chef_run) { runner.converge(described_recipe) }
include_context 'compute_stubs'
include_examples 'expect_runs_nova_common_recipe'