cookbook-openstack-integrat.../spec/setup_spec.rb

195 lines
5.6 KiB
Ruby

# encoding: UTF-8
require_relative 'spec_helper'
describe 'openstack-integration-test::setup' do
describe 'ubuntu' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:node) { runner.node }
let(:chef_run) do
runner.converge(described_recipe)
end
include_context 'tempest-stubs'
connection_params = {
openstack_auth_url: 'http://127.0.0.1:5000/v3/auth/tokens',
openstack_username: 'admin',
openstack_api_key: 'admin',
openstack_project_name: 'admin',
openstack_domain_name: 'default',
}
it 'installs tempest dependencies' do
packages = %w(git libxml2-dev libxslt-dev testrepository python-dev
libffi-dev)
packages.each do |pkg|
expect(chef_run).to upgrade_package(pkg)
end
end
it 'registers tempest_project1 Project' do
expect(chef_run).to create_openstack_project(
'tempest_project1'
).with(
connection_params: connection_params
)
end
it 'registers service user' do
expect(chef_run).to create_openstack_user(
'tempest_user1'
).with(
domain_name: 'Default',
role_name: 'Member',
project_name: 'tempest_project1',
password: 'tempest_user1_pass',
connection_params: connection_params
)
end
it do
expect(chef_run).to grant_role_openstack_user(
'tempest_user1'
).with(
project_name: 'tempest_project1',
role_name: 'Member',
password: 'tempest_user1_pass',
connection_params: connection_params
)
end
it 'registers tempest_project2 Project' do
expect(chef_run).to create_openstack_project(
'tempest_project2'
).with(
connection_params: connection_params
)
end
it 'registers service user' do
expect(chef_run).to create_openstack_user(
'tempest_user2'
).with(
domain_name: 'Default',
role_name: 'Member',
project_name: 'tempest_project2',
password: 'tempest_user2_pass',
connection_params: connection_params
)
end
it do
expect(chef_run).to grant_role_openstack_user(
'tempest_user2'
).with(
project_name: 'tempest_project2',
role_name: 'Member',
password: 'tempest_user2_pass',
connection_params: connection_params
)
end
it 'syncs /opt/tempest from github' do
expect(chef_run).to sync_git(
'/opt/tempest'
).with(
repository: 'https://github.com/openstack/tempest',
reference: '17.2.0',
depth: 1
)
end
it 'uploads image1' do
expect(chef_run).to upload_openstack_image_image('image1').with(
identity_user: 'admin',
identity_pass: 'admin',
identity_tenant: 'admin',
identity_uri: 'http://127.0.0.1:5000/v3',
identity_user_domain_name: 'default',
identity_project_domain_name: 'default',
image_name: 'cirros-test1',
image_id: '1ac790f6-903a-4833-979f-a38f1819e3b1',
image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img'
)
end
it 'uploads image2' do
expect(chef_run).to upload_openstack_image_image('image2').with(
identity_user: 'admin',
identity_pass: 'admin',
identity_tenant: 'admin',
identity_uri: 'http://127.0.0.1:5000/v3',
identity_user_domain_name: 'default',
identity_project_domain_name: 'default',
image_name: 'cirros-test2',
image_id: 'f7c2ac6d-0011-499f-a9ec-ca71348bf2e4',
image_url: 'http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img'
)
end
describe 'tempest.conf default' do
let(:file) { chef_run.template('/opt/tempest/etc/tempest.conf') }
it 'creates tempest.conf' do
expect(chef_run).to create_template(file.name).with(
user: 'root',
group: 'root',
mode: 0o0600
)
end
it 'has a populated entry for image_ref' do
expect(chef_run).to render_file(file.name).with_content(
'image_ref = 1ac790f6-903a-4833-979f-a38f1819e3b1'
)
end
it 'has a populated entry for image_ref_alt' do
expect(chef_run).to render_file(file.name).with_content(
'image_ref_alt = f7c2ac6d-0011-499f-a9ec-ca71348bf2e4'
)
end
it 'has an auth URI with the default scheme' do
expect(chef_run).to render_file(file.name).with_content(
'uri = http://127.0.0.1:5000/v3'
)
end
it 'has a v3 auth URI with the default scheme' do
expect(chef_run).to render_file(file.name).with_content(
'uri_v3 = http://127.0.0.1:5000/v3'
)
end
it 'discovers compute hosts' do
expect(chef_run).to run_execute('discover_hosts')
.with(user: 'nova',
group: 'nova')
end
end
describe 'tempest.conf with HTTPS' do
let(:runner) { ChefSpec::SoloRunner.new(UBUNTU_OPTS) }
let(:chef_run) do
runner.node.override['openstack']['endpoints']['public']['identity']['scheme'] = 'https'
runner.converge(described_recipe)
end
let(:file) { chef_run.template('/opt/tempest/etc/tempest.conf') }
it 'has an auth URI with the secure scheme' do
expect(chef_run).to render_file(file.name).with_content(
'uri = https://127.0.0.1:5000/v3'
)
end
it 'has a v3 auth URI with the secure scheme' do
expect(chef_run).to render_file(file.name).with_content(
'uri_v3 = https://127.0.0.1:5000/v3'
)
end
end
end
end