Refactoring ChefSpec tests
Change-Id: I6c9148e0981f7c01eae4e09545ef011bf38bedfe Addresses: blueprint refactor-spec-files
This commit is contained in:
parent
eb15ff73a5
commit
5ae67ff44f
|
@ -1,22 +1,22 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-central' do
|
||||
before { telemetry_stubs }
|
||||
describe 'rhel' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-central'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'installs the agent-central package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-central'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-central'
|
||||
end
|
||||
|
||||
it 'starts the agent-central service' do
|
||||
expect(@chef_run).to start_service 'openstack-ceilometer-central'
|
||||
expect(chef_run).to start_service 'openstack-ceilometer-central'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-central' do
|
||||
before { telemetry_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-central'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the agent-central package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-agent-central'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-agent-central'
|
||||
end
|
||||
|
||||
it 'starts the agent-central service' do
|
||||
expect(@chef_run).to start_service 'openstack-ceilometer-agent-central'
|
||||
expect(chef_run).to start_service 'openstack-ceilometer-agent-central'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-central' do
|
||||
before { telemetry_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-central'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'installs the agent-central package' do
|
||||
expect(@chef_run).to install_package 'ceilometer-agent-central'
|
||||
expect(chef_run).to install_package 'ceilometer-agent-central'
|
||||
end
|
||||
|
||||
it 'starts agent-central service' do
|
||||
expect(@chef_run).to start_service('ceilometer-agent-central')
|
||||
expect(chef_run).to start_service('ceilometer-agent-central')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-compute' do
|
||||
before { telemetry_stubs }
|
||||
describe 'rhel' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-compute'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'installs the agent-compute package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-compute'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-compute'
|
||||
end
|
||||
|
||||
it 'starts ceilometer-agent-compute service' do
|
||||
expect(@chef_run).to start_service('openstack-ceilometer-compute')
|
||||
expect(chef_run).to start_service('openstack-ceilometer-compute')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-compute' do
|
||||
before { telemetry_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-compute'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the agent-compute package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-agent-compute'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-agent-compute'
|
||||
end
|
||||
|
||||
it 'starts the agent-compute service' do
|
||||
expect(@chef_run).to start_service 'openstack-ceilometer-agent-compute'
|
||||
expect(chef_run).to start_service 'openstack-ceilometer-agent-compute'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,22 +1,22 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::agent-compute' do
|
||||
before { telemetry_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::agent-compute'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'installs the agent-compute package' do
|
||||
expect(@chef_run).to install_package 'ceilometer-agent-compute'
|
||||
expect(chef_run).to install_package 'ceilometer-agent-compute'
|
||||
end
|
||||
|
||||
it 'starts ceilometer-agent-compute service' do
|
||||
expect(@chef_run).to start_service('ceilometer-agent-compute')
|
||||
expect(chef_run).to start_service('ceilometer-agent-compute')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::api' do
|
||||
before { telemetry_stubs }
|
||||
describe 'rhel' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'creates the /var/cache/ceilometer directory' do
|
||||
expect(@chef_run).to create_directory('/var/cache/ceilometer').with(
|
||||
expect(chef_run).to create_directory('/var/cache/ceilometer').with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0700
|
||||
|
@ -20,11 +20,11 @@ describe 'openstack-telemetry::api' do
|
|||
end
|
||||
|
||||
it 'installs the api package' do
|
||||
expect(@chef_run).to install_package('openstack-ceilometer-api')
|
||||
expect(chef_run).to install_package('openstack-ceilometer-api')
|
||||
end
|
||||
|
||||
it 'starts api service' do
|
||||
expect(@chef_run).to start_service('openstack-ceilometer-api')
|
||||
expect(chef_run).to start_service('openstack-ceilometer-api')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::api' do
|
||||
before { telemetry_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the api package' do
|
||||
expect(@chef_run).to install_package('openstack-ceilometer-api')
|
||||
expect(chef_run).to install_package('openstack-ceilometer-api')
|
||||
end
|
||||
|
||||
it 'starts api service' do
|
||||
expect(@chef_run).to start_service('openstack-ceilometer-api')
|
||||
expect(chef_run).to start_service('openstack-ceilometer-api')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::api' do
|
||||
before { telemetry_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::api'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'creates the /var/cache/ceilometer directory' do
|
||||
expect(@chef_run).to create_directory('/var/cache/ceilometer').with(
|
||||
expect(chef_run).to create_directory('/var/cache/ceilometer').with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0700
|
||||
|
@ -20,11 +20,11 @@ describe 'openstack-telemetry::api' do
|
|||
end
|
||||
|
||||
it 'starts api service' do
|
||||
expect(@chef_run).to start_service('ceilometer-api')
|
||||
expect(chef_run).to start_service('ceilometer-api')
|
||||
end
|
||||
|
||||
it 'starts api service' do
|
||||
expect(@chef_run).to start_service('ceilometer-api')
|
||||
expect(chef_run).to start_service('ceilometer-api')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::client' do
|
||||
|
||||
describe 'redhat' do
|
||||
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'installs packages' do
|
||||
expect(chef_run).to upgrade_package('python-ceilometerclient')
|
||||
|
|
|
@ -1,15 +1,13 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::client' do
|
||||
|
||||
describe 'ubuntu' do
|
||||
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) do
|
||||
runner.converge(described_recipe)
|
||||
end
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'installs packages' do
|
||||
expect(chef_run).to upgrade_package('python-ceilometerclient')
|
||||
|
|
|
@ -1,27 +1,27 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::collector' do
|
||||
before { telemetry_stubs }
|
||||
describe 'rhel' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::collector'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'executes ceilometer dbsync' do
|
||||
command = 'ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf'
|
||||
expect(@chef_run).to run_execute command
|
||||
expect(chef_run).to run_execute command
|
||||
end
|
||||
|
||||
it 'installs the collector package' do
|
||||
expect(@chef_run).to install_package('openstack-ceilometer-collector')
|
||||
expect(chef_run).to install_package('openstack-ceilometer-collector')
|
||||
end
|
||||
|
||||
it 'starts collector service' do
|
||||
expect(@chef_run).to start_service('openstack-ceilometer-collector')
|
||||
expect(chef_run).to start_service('openstack-ceilometer-collector')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::collector' do
|
||||
before { telemetry_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::collector'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the collector package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-collector'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-collector'
|
||||
end
|
||||
|
||||
it 'starts the collector service' do
|
||||
expect(@chef_run).to start_service 'openstack-ceilometer-collector'
|
||||
expect(chef_run).to start_service 'openstack-ceilometer-collector'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,33 +1,33 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::collector' do
|
||||
before { telemetry_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::collector'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
expect_runs_common_recipe
|
||||
include_context 'telemetry-stubs'
|
||||
include_examples 'expect-runs-common-recipe'
|
||||
|
||||
it 'executes ceilometer dbsync' do
|
||||
command = 'ceilometer-dbsync --config-file /etc/ceilometer/ceilometer.conf'
|
||||
expect(@chef_run).to run_execute command
|
||||
expect(chef_run).to run_execute command
|
||||
end
|
||||
|
||||
it 'does not execute ceilometer dbsync when nosql database is used' do
|
||||
@chef_run.node.set['openstack']['db']['telemetry']['nosql']['used'] = true
|
||||
resource = 'execute[database migration]'
|
||||
expect(@chef_run).not_to run_execute resource
|
||||
node.set['openstack']['db']['telemetry']['nosql']['used'] = true
|
||||
|
||||
expect(chef_run).not_to run_execute('execute[database migration]')
|
||||
end
|
||||
|
||||
it 'installs python-mysqldb', A: true do
|
||||
expect(@chef_run).to install_package 'python-mysqldb'
|
||||
it 'installs python-mysqldb' do
|
||||
expect(chef_run).to install_package('python-mysqldb')
|
||||
end
|
||||
|
||||
it 'starts collector service' do
|
||||
expect(@chef_run).to start_service('ceilometer-collector')
|
||||
expect(chef_run).to start_service('ceilometer-collector')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::common' do
|
||||
before { telemetry_stubs }
|
||||
describe 'rhel' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::common'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(REDHAT_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the common package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer-common'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer-common'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::common' do
|
||||
before { telemetry_stubs }
|
||||
describe 'suse' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new ::SUSE_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::common'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(SUSE_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'installs the common package' do
|
||||
expect(@chef_run).to install_package 'openstack-ceilometer'
|
||||
expect(chef_run).to install_package 'openstack-ceilometer'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,146 +1,162 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::common' do
|
||||
before { telemetry_stubs }
|
||||
describe 'ubuntu' do
|
||||
before do
|
||||
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
|
||||
n.set['openstack']['telemetry']['syslog']['use'] = true
|
||||
end
|
||||
@chef_run.converge 'openstack-telemetry::common'
|
||||
end
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'runs logging recipe' do
|
||||
expect(@chef_run).to include_recipe 'openstack-common::logging'
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
context 'with logging enabled' do
|
||||
before do
|
||||
node.set['openstack']['telemetry']['syslog']['use'] = true
|
||||
end
|
||||
|
||||
it 'runs logging recipe' do
|
||||
expect(chef_run).to include_recipe 'openstack-common::logging'
|
||||
end
|
||||
end
|
||||
|
||||
it 'installs the common package' do
|
||||
expect(@chef_run).to install_package 'ceilometer-common'
|
||||
end
|
||||
|
||||
it 'creates the /etc/ceilometer directory' do
|
||||
expect(@chef_run).to create_directory('/etc/ceilometer').with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0750
|
||||
)
|
||||
expect(chef_run).to install_package 'ceilometer-common'
|
||||
end
|
||||
|
||||
describe '/etc/ceilometer' do
|
||||
before do
|
||||
@filename = '/etc/ceilometer/ceilometer.conf'
|
||||
let(:dir) { chef_run.directory('/etc/ceilometer') }
|
||||
|
||||
it 'creates the /etc/ceilometer directory' do
|
||||
expect(chef_run).to create_directory(dir.name).with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0750
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'ceilometer.conf' do
|
||||
let(:file) { chef_run.template('/etc/ceilometer/ceilometer.conf') }
|
||||
|
||||
it 'creates the file' do
|
||||
expect(@chef_run).to create_template(@filename).with(
|
||||
expect(chef_run).to create_template(file.name).with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0640
|
||||
)
|
||||
end
|
||||
|
||||
context 'with rabbitmq default' do
|
||||
[/^rabbit_userid = guest$/,
|
||||
/^rabbit_password = mq-pass$/,
|
||||
/^rabbit_port = 5672$/,
|
||||
/^rabbit_host = 127.0.0.1$/,
|
||||
/^rabbit_virtual_host = \/$/,
|
||||
/^rabbit_use_ssl = false$/,
|
||||
%r{^auth_uri = http://127.0.0.1:5000/v2.0$},
|
||||
/^auth_host = 127.0.0.1$/,
|
||||
/^auth_port = 35357$/,
|
||||
/^auth_protocol = http$/
|
||||
].each do |content|
|
||||
it 'has a \#{content.source[1...-1]}\' line' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(content)
|
||||
context 'rabbit mq backend' do
|
||||
before do
|
||||
node.set['openstack']['mq']['telemetry']['service_type'] = 'rabbitmq'
|
||||
end
|
||||
|
||||
it 'has default rabbit_* options set' do
|
||||
[
|
||||
/^rabbit_userid = guest$/,
|
||||
/^rabbit_password = mq-pass$/,
|
||||
/^rabbit_port = 5672$/,
|
||||
/^rabbit_host = 127.0.0.1$/,
|
||||
/^rabbit_virtual_host = \/$/,
|
||||
/^rabbit_use_ssl = false$/,
|
||||
%r{^auth_uri = http://127.0.0.1:5000/v2.0$},
|
||||
/^auth_host = 127.0.0.1$/,
|
||||
/^auth_port = 35357$/,
|
||||
/^auth_protocol = http$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with qpid enabled' do
|
||||
context 'qpid mq backend' do
|
||||
before do
|
||||
@chef_run.node.set['openstack']['mq']['telemetry']['service_type'] = 'qpid'
|
||||
@chef_run.node.set['openstack']['mq']['telemetry']['qpid']['username'] = 'guest'
|
||||
@chef_run.converge 'openstack-telemetry::common'
|
||||
node.set['openstack']['mq']['telemetry']['service_type'] = 'qpid'
|
||||
node.set['openstack']['mq']['telemetry']['qpid']['username'] = 'guest'
|
||||
end
|
||||
|
||||
[/^qpid_hostname=127.0.0.1$/,
|
||||
/^qpid_port=5672$/,
|
||||
/^qpid_username=guest$/,
|
||||
/^qpid_password=mq-pass$/,
|
||||
/^qpid_sasl_mechanisms=$/,
|
||||
/^qpid_reconnect=true$/,
|
||||
/^qpid_reconnect_timeout=0$/,
|
||||
/^qpid_reconnect_limit=0$/,
|
||||
/^qpid_reconnect_interval_min=0$/,
|
||||
/^qpid_reconnect_interval_max=0$/,
|
||||
/^qpid_reconnect_interval_max=0$/,
|
||||
/^qpid_reconnect_interval=0$/,
|
||||
/^qpid_heartbeat=60$/,
|
||||
/^qpid_protocol=tcp$/,
|
||||
/^qpid_tcp_nodelay=true$/
|
||||
].each do |content|
|
||||
it 'has a \#{content.source[1...-1]}\' line' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(content)
|
||||
it 'has default qpid_* options set' do
|
||||
[
|
||||
/^qpid_hostname=127.0.0.1$/,
|
||||
/^qpid_port=5672$/,
|
||||
/^qpid_username=guest$/,
|
||||
/^qpid_password=mq-pass$/,
|
||||
/^qpid_sasl_mechanisms=$/,
|
||||
/^qpid_reconnect=true$/,
|
||||
/^qpid_reconnect_timeout=0$/,
|
||||
/^qpid_reconnect_limit=0$/,
|
||||
/^qpid_reconnect_interval_min=0$/,
|
||||
/^qpid_reconnect_interval_max=0$/,
|
||||
/^qpid_reconnect_interval_max=0$/,
|
||||
/^qpid_reconnect_interval=0$/,
|
||||
/^qpid_heartbeat=60$/,
|
||||
/^qpid_protocol=tcp$/,
|
||||
/^qpid_tcp_nodelay=true$/
|
||||
].each do |line|
|
||||
expect(chef_run).to render_file(file.name).with_content(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'has keystone authtoken configuration' do
|
||||
it 'has auth_uri' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^#{Regexp.quote('auth_uri = http://127.0.0.1:5000/v2.0')}$/)
|
||||
end
|
||||
|
||||
it 'has auth_host' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^#{Regexp.quote('auth_host = 127.0.0.1')}$/)
|
||||
end
|
||||
|
||||
it 'has auth_port' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^auth_port = 35357$/)
|
||||
end
|
||||
|
||||
it 'has auth_protocol' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^auth_protocol = http$/)
|
||||
end
|
||||
|
||||
it 'has no auth_version' do
|
||||
expect(@chef_run).not_to render_file(@filename).with_content(
|
||||
expect(chef_run).not_to render_file(file.name).with_content(
|
||||
/^auth_version = v2.0$/)
|
||||
end
|
||||
|
||||
it 'has admin_tenant_name' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^admin_tenant_name = service$/)
|
||||
end
|
||||
|
||||
it 'has admin_user' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^admin_user = ceilometer$/)
|
||||
end
|
||||
|
||||
it 'has admin_password' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^admin_password = ceilometer-pass$/)
|
||||
end
|
||||
|
||||
it 'has signing_dir' do
|
||||
expect(@chef_run).to render_file(@filename).with_content(
|
||||
expect(chef_run).to render_file(file.name).with_content(
|
||||
/^#{Regexp.quote('signing_dir = /var/cache/ceilometer/api')}$/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
it 'installs the /etc/ceilometer/policy.json file' do
|
||||
expect(@chef_run).to create_cookbook_file('/etc/ceilometer/policy.json').with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0640
|
||||
)
|
||||
describe 'policy.json' do
|
||||
let(:file) { chef_run.cookbook_file('/etc/ceilometer/policy.json') }
|
||||
|
||||
it 'installs the /etc/ceilometer/policy.json file' do
|
||||
expect(chef_run).to create_cookbook_file(file.name).with(
|
||||
user: 'ceilometer',
|
||||
group: 'ceilometer',
|
||||
mode: 0640
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,84 +1,83 @@
|
|||
# encoding: UTF-8
|
||||
|
||||
require_relative 'spec_helper'
|
||||
|
||||
describe 'openstack-telemetry::identity_registration' do
|
||||
before do
|
||||
telemetry_stubs
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
|
||||
@chef_run.converge 'openstack-telemetry::identity_registration'
|
||||
end
|
||||
describe 'ubuntu' do
|
||||
let(:runner) { ChefSpec::Runner.new(UBUNTU_OPTS) }
|
||||
let(:node) { runner.node }
|
||||
let(:chef_run) { runner.converge(described_recipe) }
|
||||
|
||||
it 'registers service tenant' do
|
||||
expect(@chef_run).to create_tenant_openstack_identity_register(
|
||||
'Register Service Tenant'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
tenant_description: 'Service Tenant'
|
||||
)
|
||||
end
|
||||
include_context 'telemetry-stubs'
|
||||
|
||||
it 'registers service user' do
|
||||
expect(@chef_run).to create_user_openstack_identity_register(
|
||||
'Register Service User'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'ceilometer',
|
||||
user_pass: 'ceilometer-pass'
|
||||
)
|
||||
end
|
||||
|
||||
it 'grants admin role to service user for service tenant' do
|
||||
expect(@chef_run).to grant_role_openstack_identity_register(
|
||||
"Grant 'admin' Role to Service User for Service Tenant"
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'ceilometer',
|
||||
role_name: 'admin',
|
||||
action: [:grant_role]
|
||||
)
|
||||
end
|
||||
|
||||
it 'registers metering service' do
|
||||
expect(@chef_run).to create_service_openstack_identity_register(
|
||||
'Register Metering Service'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'ceilometer',
|
||||
service_type: 'metering'
|
||||
)
|
||||
end
|
||||
|
||||
it 'registers metering endpoint' do
|
||||
expect(@chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Metering Endpoint'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_type: 'metering',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8777',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8777',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8777'
|
||||
)
|
||||
end
|
||||
|
||||
it 'overrides metering endpoint region' do
|
||||
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS do |n|
|
||||
n.set['openstack']['telemetry']['region'] = 'meteringRegion'
|
||||
it 'registers service tenant' do
|
||||
expect(chef_run).to create_tenant_openstack_identity_register(
|
||||
'Register Service Tenant'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
tenant_description: 'Service Tenant'
|
||||
)
|
||||
end
|
||||
@chef_run.converge 'openstack-telemetry::identity_registration'
|
||||
|
||||
expect(@chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Metering Endpoint'
|
||||
).with(
|
||||
endpoint_region: 'meteringRegion'
|
||||
)
|
||||
it 'registers service user' do
|
||||
expect(chef_run).to create_user_openstack_identity_register(
|
||||
'Register Service User'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'ceilometer',
|
||||
user_pass: 'ceilometer-pass'
|
||||
)
|
||||
end
|
||||
|
||||
it 'grants admin role to service user for service tenant' do
|
||||
expect(chef_run).to grant_role_openstack_identity_register(
|
||||
"Grant 'admin' Role to Service User for Service Tenant"
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
tenant_name: 'service',
|
||||
user_name: 'ceilometer',
|
||||
role_name: 'admin'
|
||||
)
|
||||
end
|
||||
|
||||
it 'registers metering service' do
|
||||
expect(chef_run).to create_service_openstack_identity_register(
|
||||
'Register Metering Service'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_name: 'ceilometer',
|
||||
service_type: 'metering'
|
||||
)
|
||||
end
|
||||
|
||||
context 'registers metering endpoint' do
|
||||
it 'with default values' do
|
||||
expect(chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Metering Endpoint'
|
||||
).with(
|
||||
auth_uri: 'http://127.0.0.1:35357/v2.0',
|
||||
bootstrap_token: 'bootstrap-token',
|
||||
service_type: 'metering',
|
||||
endpoint_region: 'RegionOne',
|
||||
endpoint_adminurl: 'http://127.0.0.1:8777',
|
||||
endpoint_internalurl: 'http://127.0.0.1:8777',
|
||||
endpoint_publicurl: 'http://127.0.0.1:8777'
|
||||
)
|
||||
end
|
||||
|
||||
it 'with custom region override' do
|
||||
node.set['openstack']['telemetry']['region'] = 'meteringRegion'
|
||||
|
||||
expect(chef_run).to create_endpoint_openstack_identity_register(
|
||||
'Register Metering Endpoint'
|
||||
).with(endpoint_region: 'meteringRegion')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,44 +3,45 @@ require 'chefspec'
|
|||
require 'chefspec/berkshelf'
|
||||
require 'chef/application'
|
||||
|
||||
::LOG_LEVEL = :fatal
|
||||
::SUSE_OPTS = {
|
||||
LOG_LEVEL = :fatal
|
||||
SUSE_OPTS = {
|
||||
platform: 'suse',
|
||||
version: '11.03',
|
||||
log_level: ::LOG_LEVEL
|
||||
}
|
||||
::REDHAT_OPTS = {
|
||||
REDHAT_OPTS = {
|
||||
platform: 'redhat',
|
||||
version: '6.3',
|
||||
log_level: ::LOG_LEVEL
|
||||
}
|
||||
::UBUNTU_OPTS = {
|
||||
UBUNTU_OPTS = {
|
||||
platform: 'ubuntu',
|
||||
version: '12.04',
|
||||
log_level: ::LOG_LEVEL
|
||||
}
|
||||
|
||||
# TODO(chrislaco): Factor this into proper RSpec shared_contexts
|
||||
def telemetry_stubs # rubocop:disable MethodLength
|
||||
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return([])
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack-ceilometer')
|
||||
.and_return('ceilometer-pass')
|
||||
::Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
::Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
::Chef::Application.stub(:fatal!)
|
||||
shared_context 'telemetry-stubs' do
|
||||
before do
|
||||
Chef::Recipe.any_instance.stub(:memcached_servers).and_return([])
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('db', anything)
|
||||
.and_return('')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('service', 'openstack-ceilometer')
|
||||
.and_return('ceilometer-pass')
|
||||
Chef::Recipe.any_instance.stub(:get_password)
|
||||
.with('user', 'guest')
|
||||
.and_return('mq-pass')
|
||||
Chef::Recipe.any_instance.stub(:secret)
|
||||
.with('secrets', 'openstack_identity_bootstrap_token')
|
||||
.and_return('bootstrap-token')
|
||||
Chef::Application.stub(:fatal!)
|
||||
end
|
||||
end
|
||||
|
||||
def expect_runs_common_recipe
|
||||
shared_examples 'expect-runs-common-recipe' do
|
||||
it 'runs common recipe' do
|
||||
expect(@chef_run).to include_recipe 'openstack-telemetry::common'
|
||||
expect(chef_run).to include_recipe 'openstack-telemetry::common'
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue