Update spec files to be rubocop compliant

- Update .rubocop.yml to include spec/**
- Update spec files to be rubocop compliant

Change-Id: I2ba55825cf6a80ffa338f849c6c2f274b915886b
Addresses: blueprint rubocop-for-compute
This commit is contained in:
Andy McCrae 2014-01-21 16:44:41 +00:00
parent c9813a0f4c
commit f9c4e3198e
29 changed files with 706 additions and 690 deletions

View File

@ -3,12 +3,12 @@ AllCops:
- metadata.rb - metadata.rb
- Gemfile - Gemfile
- attributes/** - attributes/**
- spec/**
Excludes: Excludes:
- libraries/** - libraries/**
- providers/** - providers/**
- recipes/** - recipes/**
- resources/** - resources/**
- spec/**
Encoding: Encoding:
Exclude: Exclude:

View File

@ -1,19 +1,21 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-ec2" do require_relative 'spec_helper'
describe 'openstack-compute::api-ec2' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-ec2" @chef_run.converge 'openstack-compute::api-ec2'
end end
it "installs ec2 api packages" do it 'installs ec2 api packages' do
expect(@chef_run).to upgrade_package "openstack-nova-api" expect(@chef_run).to upgrade_package 'openstack-nova-api'
end end
it "starts ec2 api on boot" do it 'starts ec2 api on boot' do
expect(@chef_run).to enable_service "openstack-nova-api" expect(@chef_run).to enable_service 'openstack-nova-api'
end end
end end
end end

View File

@ -1,11 +1,13 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-ec2" do require_relative 'spec_helper'
describe 'openstack-compute::api-ec2' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-ec2" @chef_run.converge 'openstack-compute::api-ec2'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
@ -14,14 +16,14 @@ describe "openstack-compute::api-ec2" do
expect_installs_python_keystone expect_installs_python_keystone
it "installs ec2 api packages" do it 'installs ec2 api packages' do
expect(@chef_run).to upgrade_package "nova-api-ec2" expect(@chef_run).to upgrade_package 'nova-api-ec2'
end end
it "starts ec2 api on boot" do it 'starts ec2 api on boot' do
expect(@chef_run).to enable_service "nova-api-ec2" expect(@chef_run).to enable_service 'nova-api-ec2'
end end
expect_creates_api_paste "service[nova-api-ec2]" expect_creates_api_paste 'service[nova-api-ec2]'
end end
end end

View File

@ -1,19 +1,21 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-metadata" do require_relative 'spec_helper'
describe 'openstack-compute::api-metadata' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-metadata" @chef_run.converge 'openstack-compute::api-metadata'
end end
it "installs metadata api packages" do it 'installs metadata api packages' do
expect(@chef_run).to upgrade_package "openstack-nova-api" expect(@chef_run).to upgrade_package 'openstack-nova-api'
end end
it "starts metadata api on boot" do it 'starts metadata api on boot' do
expect(@chef_run).to enable_service "openstack-nova-api" expect(@chef_run).to enable_service 'openstack-nova-api'
end end
end end
end end

View File

@ -1,11 +1,13 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-metadata" do require_relative 'spec_helper'
describe 'openstack-compute::api-metadata' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-metadata" @chef_run.converge 'openstack-compute::api-metadata'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
@ -14,14 +16,14 @@ describe "openstack-compute::api-metadata" do
expect_installs_python_keystone expect_installs_python_keystone
it "installs metadata api packages" do it 'installs metadata api packages' do
expect(@chef_run).to upgrade_package "nova-api-metadata" expect(@chef_run).to upgrade_package 'nova-api-metadata'
end end
it "starts metadata api on boot" do it 'starts metadata api on boot' do
expect(@chef_run).to enable_service "nova-api-metadata" expect(@chef_run).to enable_service 'nova-api-metadata'
end end
expect_creates_api_paste "service[nova-api-metadata]" expect_creates_api_paste 'service[nova-api-metadata]'
end end
end end

View File

@ -1,19 +1,21 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-os-compute" do require_relative 'spec_helper'
describe 'openstack-compute::api-os-compute' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-os-compute" @chef_run.converge 'openstack-compute::api-os-compute'
end end
it "installs openstack api packages" do it 'installs openstack api packages' do
expect(@chef_run).to upgrade_package "openstack-nova-api" expect(@chef_run).to upgrade_package 'openstack-nova-api'
end end
it "starts openstack api on boot" do it 'starts openstack api on boot' do
expect(@chef_run).to enable_service "openstack-nova-api" expect(@chef_run).to enable_service 'openstack-nova-api'
end end
end end
end end

View File

@ -1,39 +1,41 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::api-os-compute" do require_relative 'spec_helper'
describe 'openstack-compute::api-os-compute' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-os-compute" @chef_run.converge 'openstack-compute::api-os-compute'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
expect_creates_nova_lock_dir expect_creates_nova_lock_dir
it "creates the /var/cache/nova directory" do it 'creates the /var/cache/nova directory' do
expect(@chef_run).to create_directory("/var/cache/nova").with( expect(@chef_run).to create_directory('/var/cache/nova').with(
user: "nova", user: 'nova',
group: "nova", group: 'nova',
mode: 0700 mode: 0700
) )
end end
expect_installs_python_keystone expect_installs_python_keystone
it "installs openstack api packages" do it 'installs openstack api packages' do
expect(@chef_run).to upgrade_package "nova-api-os-compute" expect(@chef_run).to upgrade_package 'nova-api-os-compute'
end end
it "starts openstack api on boot" do it 'starts openstack api on boot' do
expect(@chef_run).to enable_service "nova-api-os-compute" expect(@chef_run).to enable_service 'nova-api-os-compute'
end end
it "starts openstack api now" do it 'starts openstack api now' do
expect(@chef_run).to start_service "nova-api-os-compute" expect(@chef_run).to start_service 'nova-api-os-compute'
end end
expect_creates_api_paste "service[nova-api-os-compute]" expect_creates_api_paste 'service[nova-api-os-compute]'
end end
end end

View File

@ -1,16 +1,18 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::compute" do require_relative 'spec_helper'
describe 'openstack-compute::compute' do
before { compute_stubs } before { compute_stubs }
describe "opensuse" do describe 'opensuse' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-compute::compute" @chef_run.converge 'openstack-compute::compute'
end end
it "installs nfs client packages" do it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package "nfs-utils" expect(@chef_run).to upgrade_package 'nfs-utils'
expect(@chef_run).not_to upgrade_package "nfs-utils-lib" expect(@chef_run).not_to upgrade_package 'nfs-utils-lib'
end end
end end
end end

View File

@ -1,45 +1,47 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::compute" do require_relative 'spec_helper'
describe 'openstack-compute::compute' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::compute" @chef_run.converge 'openstack-compute::compute'
end end
it "does not install kvm when virt_type is 'kvm'" do it "does not install kvm when virt_type is 'kvm'" do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "kvm" node.set['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
chef_run.converge "openstack-compute::compute" chef_run.converge 'openstack-compute::compute'
expect(chef_run).to_not upgrade_package "nova-compute-kvm" expect(chef_run).to_not upgrade_package 'nova-compute-kvm'
end end
it "does not install qemu when virt_type is 'qemu'" do it "does not install qemu when virt_type is 'qemu'" do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu" node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
chef_run.converge "openstack-compute::compute" chef_run.converge 'openstack-compute::compute'
expect(chef_run).to_not upgrade_package "nova-compute-qemu" expect(chef_run).to_not upgrade_package 'nova-compute-qemu'
end end
it "installs nova compute packages" do it 'installs nova compute packages' do
expect(@chef_run).to upgrade_package "openstack-nova-compute" expect(@chef_run).to upgrade_package 'openstack-nova-compute'
end end
it "installs nfs client packages" do it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package "nfs-utils" expect(@chef_run).to upgrade_package 'nfs-utils'
expect(@chef_run).to upgrade_package "nfs-utils-lib" expect(@chef_run).to upgrade_package 'nfs-utils-lib'
end end
it "starts nova compute on boot" do it 'starts nova compute on boot' do
expected = "openstack-nova-compute" expected = 'openstack-nova-compute'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
it "starts nova compute" do it 'starts nova compute' do
expect(@chef_run).to start_service "openstack-nova-compute" expect(@chef_run).to start_service 'openstack-nova-compute'
end end
end end
end end

View File

@ -1,84 +1,86 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::compute" do require_relative 'spec_helper'
describe 'openstack-compute::compute' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::compute" @chef_run.converge 'openstack-compute::compute'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "runs api-metadata recipe" do it 'runs api-metadata recipe' do
expect(@chef_run).to include_recipe "openstack-compute::api-metadata" expect(@chef_run).to include_recipe 'openstack-compute::api-metadata'
end end
it "runs network recipe" do it 'runs network recipe' do
expect(@chef_run).to include_recipe "openstack-compute::network" expect(@chef_run).to include_recipe 'openstack-compute::network'
end end
# stubbing the run_context properly is non-trivial, fix with ChefSpec 3.0 # stubbing the run_context properly is non-trivial, fix with ChefSpec 3.0
# it "doesn't run network recipe with openstack-network::server" do # it 'doesn't run network recipe with openstack-network::server' do
# chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS # chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
# node = chef_run.node # node = chef_run.node
# node.run_list.stub("include?").and_return true # node.run_list.stub('include?').and_return true
# chef_run.converge "openstack-compute::compute" # chef_run.converge 'openstack-compute::compute'
# expect(chef_run).not_to include_recipe "openstack-compute::network" # expect(chef_run).not_to include_recipe 'openstack-compute::network'
# end # end
it "installs nova compute packages" do it 'installs nova compute packages' do
expect(@chef_run).to upgrade_package "nova-compute" expect(@chef_run).to upgrade_package 'nova-compute'
end end
it "installs nfs client packages" do it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package "nfs-common" expect(@chef_run).to upgrade_package 'nfs-common'
end end
it "installs kvm when virt_type is 'kvm'" do it "installs kvm when virt_type is 'kvm'" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "kvm" node.set['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
chef_run.converge "openstack-compute::compute" chef_run.converge 'openstack-compute::compute'
expect(chef_run).to upgrade_package "nova-compute-kvm" expect(chef_run).to upgrade_package 'nova-compute-kvm'
expect(chef_run).not_to upgrade_package "nova-compute-qemu" expect(chef_run).not_to upgrade_package 'nova-compute-qemu'
end end
it "installs qemu when virt_type is 'qemu'" do it "installs qemu when virt_type is 'qemu'" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu" node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
chef_run.converge "openstack-compute::compute" chef_run.converge 'openstack-compute::compute'
expect(chef_run).to upgrade_package "nova-compute-qemu" expect(chef_run).to upgrade_package 'nova-compute-qemu'
expect(chef_run).not_to upgrade_package "nova-compute-kvm" expect(chef_run).not_to upgrade_package 'nova-compute-kvm'
end end
describe "nova-compute.conf" do describe 'nova-compute.conf' do
before do before do
@file = @chef_run.cookbook_file "/etc/nova/nova-compute.conf" @file = @chef_run.cookbook_file '/etc/nova/nova-compute.conf'
end end
it "has proper modes" do it 'has proper modes' do
expect(sprintf("%o", @file.mode)).to eq "644" expect(sprintf('%o', @file.mode)).to eq '644'
end end
it "template contents" do it 'template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
end end
it "starts nova compute on boot" do it 'starts nova compute on boot' do
expect(@chef_run).to enable_service "nova-compute" expect(@chef_run).to enable_service 'nova-compute'
end end
it "starts nova compute" do it 'starts nova compute' do
expect(@chef_run).to start_service "nova-compute" expect(@chef_run).to start_service 'nova-compute'
end end
it "runs libvirt recipe" do it 'runs libvirt recipe' do
expect(@chef_run).to include_recipe "openstack-compute::libvirt" expect(@chef_run).to include_recipe 'openstack-compute::libvirt'
end end
end end
end end

View File

@ -1,25 +1,27 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::conductor" do require_relative 'spec_helper'
describe 'openstack-compute::conductor' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::conductor" @chef_run.converge 'openstack-compute::conductor'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs conductor packages" do it 'installs conductor packages' do
expect(@chef_run).to upgrade_package "openstack-nova-conductor" expect(@chef_run).to upgrade_package 'openstack-nova-conductor'
end end
it "starts nova-conductor on boot" do it 'starts nova-conductor on boot' do
expect(@chef_run).to enable_service "openstack-nova-conductor" expect(@chef_run).to enable_service 'openstack-nova-conductor'
end end
it "starts nova-conductor" do it 'starts nova-conductor' do
expect(@chef_run).to start_service "openstack-nova-conductor" expect(@chef_run).to start_service 'openstack-nova-conductor'
end end
end end
end end

View File

@ -1,25 +1,27 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::conductor" do require_relative 'spec_helper'
describe 'openstack-compute::conductor' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::conductor" @chef_run.converge 'openstack-compute::conductor'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs conductor packages" do it 'installs conductor packages' do
expect(@chef_run).to upgrade_package "nova-conductor" expect(@chef_run).to upgrade_package 'nova-conductor'
end end
it "starts nova-conductor on boot" do it 'starts nova-conductor on boot' do
expect(@chef_run).to enable_service "nova-conductor" expect(@chef_run).to enable_service 'nova-conductor'
end end
it "starts nova-conductor" do it 'starts nova-conductor' do
expect(@chef_run).to start_service "nova-conductor" expect(@chef_run).to start_service 'nova-conductor'
end end
end end
end end

View File

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

View File

@ -1,150 +1,152 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::identity_registration" do require_relative 'spec_helper'
describe 'openstack-compute::identity_registration' do
before do before do
compute_stubs compute_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::identity_registration" @chef_run.converge 'openstack-compute::identity_registration'
end end
it "registers service tenant" do it 'registers service tenant' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Service Tenant" 'Register Service Tenant'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:tenant_name => "service", tenant_name: 'service',
:tenant_description => "Service Tenant", tenant_description: 'Service Tenant',
:action => [:create_tenant] action: [:create_tenant]
) )
end end
it "registers service user" do it 'registers service user' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Service User" 'Register Service User'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:tenant_name => "service", tenant_name: 'service',
:user_name => "nova", user_name: 'nova',
:user_pass => "nova-pass", user_pass: 'nova-pass',
:action => [:create_user] action: [:create_user]
) )
end end
it "grants admin role to service user for service tenant" do it 'grants admin role to service user for service tenant' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Grant 'admin' Role to Service User for Service Tenant" "Grant 'admin' Role to Service User for Service Tenant"
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:tenant_name => "service", tenant_name: 'service',
:user_name => "nova", user_name: 'nova',
:role_name => "admin", role_name: 'admin',
:action => [:grant_role] action: [:grant_role]
) )
end end
it "registers compute service" do it 'registers compute service' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Compute Service" 'Register Compute Service'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_name => "nova", service_name: 'nova',
:service_type => "compute", service_type: 'compute',
:service_description => "Nova Compute Service", service_description: 'Nova Compute Service',
:action => [:create_service] action: [:create_service]
) )
end end
it "registers compute endpoint" do it 'registers compute endpoint' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register Compute Endpoint" 'Register Compute Endpoint'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_type => "compute", service_type: 'compute',
:endpoint_region => "RegionOne", endpoint_region: 'RegionOne',
:endpoint_adminurl => "http://127.0.0.1:8774/v2/%(tenant_id)s", endpoint_adminurl: 'http://127.0.0.1:8774/v2/%(tenant_id)s',
:endpoint_internalurl => "http://127.0.0.1:8774/v2/%(tenant_id)s", endpoint_internalurl: 'http://127.0.0.1:8774/v2/%(tenant_id)s',
:endpoint_publicurl => "http://127.0.0.1:8774/v2/%(tenant_id)s", endpoint_publicurl: 'http://127.0.0.1:8774/v2/%(tenant_id)s',
:action => [:create_endpoint] action: [:create_endpoint]
) )
end end
it "registers ec2 service" do it 'registers ec2 service' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register EC2 Service" 'Register EC2 Service'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_name => "ec2", service_name: 'ec2',
:service_type => "ec2", service_type: 'ec2',
:service_description => "EC2 Compatibility Layer", service_description: 'EC2 Compatibility Layer',
:action => [:create_service] action: [:create_service]
) )
end end
it "registers ec2 endpoint" do it 'registers ec2 endpoint' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register EC2 Endpoint" 'Register EC2 Endpoint'
).to_hash ).to_hash
expect(resource).to include( expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0", auth_uri: 'http://127.0.0.1:35357/v2.0',
:bootstrap_token => "bootstrap-token", bootstrap_token: 'bootstrap-token',
:service_type => "ec2", service_type: 'ec2',
:endpoint_region => "RegionOne", endpoint_region: 'RegionOne',
:endpoint_adminurl => "http://127.0.0.1:8773/services/Admin", endpoint_adminurl: 'http://127.0.0.1:8773/services/Admin',
:endpoint_internalurl => "http://127.0.0.1:8773/services/Cloud", endpoint_internalurl: 'http://127.0.0.1:8773/services/Cloud',
:endpoint_publicurl => "http://127.0.0.1:8773/services/Cloud", endpoint_publicurl: 'http://127.0.0.1:8773/services/Cloud',
:action => [:create_endpoint] action: [:create_endpoint]
) )
end end
end end
describe "openstack-compute::identity_registration_disable_ec2" do describe 'openstack-compute::identity_registration_disable_ec2' do
before do before do
compute_stubs compute_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.node.set['openstack']['compute']['enabled_apis'] = "osapi_compute,metadata" @chef_run.node.set['openstack']['compute']['enabled_apis'] = 'osapi_compute,metadata'
@chef_run.converge "openstack-compute::identity_registration" @chef_run.converge 'openstack-compute::identity_registration'
end end
it "disable ec2 service registry" do it 'disable ec2 service registry' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register EC2 Service" 'Register EC2 Service'
) )
expect(resource).to be_nil expect(resource).to be_nil
end end
it "disable ec2 endpoint registry" do it 'disable ec2 endpoint registry' do
resource = @chef_run.find_resource( resource = @chef_run.find_resource(
"openstack-identity_register", 'openstack-identity_register',
"Register EC2 Endpoint" 'Register EC2 Endpoint'
) )
expect(resource).to be_nil expect(resource).to be_nil

View File

@ -1,6 +1,8 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::libvirt" do require_relative 'spec_helper'
describe 'openstack-compute::libvirt' do
before do before do
compute_stubs compute_stubs
@ -10,62 +12,62 @@ describe "openstack-compute::libvirt" do
::File.stub(:open).and_call_original ::File.stub(:open).and_call_original
end end
describe "suse" do describe 'suse' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS @chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
end end
it "installs libvirt packages" do it 'installs libvirt packages' do
expect(@chef_run).to install_package "libvirt" expect(@chef_run).to install_package 'libvirt'
end end
it "starts libvirt" do it 'starts libvirt' do
expect(@chef_run).to start_service "libvirtd" expect(@chef_run).to start_service 'libvirtd'
end end
it "starts libvirt on boot" do it 'starts libvirt on boot' do
expect(@chef_run).to enable_service "libvirtd" expect(@chef_run).to enable_service 'libvirtd'
end end
it "does not install /etc/sysconfig/libvirtd" do it 'does not install /etc/sysconfig/libvirtd' do
expect(@chef_run).not_to create_template("/etc/sysconfig/libvirtd") expect(@chef_run).not_to create_template('/etc/sysconfig/libvirtd')
end end
it "installs kvm packages" do it 'installs kvm packages' do
expect(@chef_run).to install_package "kvm" expect(@chef_run).to install_package 'kvm'
end end
it "installs qemu packages" do it 'installs qemu packages' do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu" @chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
expect(@chef_run).to install_package "kvm" expect(@chef_run).to install_package 'kvm'
end end
it "installs xen packages" do it 'installs xen packages' do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "xen" @chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'xen'
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
["kernel-xen", "xen", "xen-tools"].each do |pkg| ['kernel-xen', 'xen', 'xen-tools'].each do |pkg|
expect(@chef_run).to install_package pkg expect(@chef_run).to install_package pkg
end end
end end
describe "lxc" do describe 'lxc' do
before do before do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "lxc" @chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'lxc'
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
end end
it "installs packages" do it 'installs packages' do
expect(@chef_run).to install_package "lxc" expect(@chef_run).to install_package 'lxc'
end end
it "starts boot.cgroupslxc" do it 'starts boot.cgroupslxc' do
expect(@chef_run).to start_service "boot.cgroup" expect(@chef_run).to start_service 'boot.cgroup'
end end
it "starts boot.cgroups on boot" do it 'starts boot.cgroups on boot' do
expect(@chef_run).to enable_service "boot.cgroup" expect(@chef_run).to enable_service 'boot.cgroup'
end end
end end
end end

View File

@ -1,57 +1,59 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::libvirt" do require_relative 'spec_helper'
describe 'openstack-compute::libvirt' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
end end
it "installs libvirt packages" do it 'installs libvirt packages' do
expect(@chef_run).to install_package "libvirt" expect(@chef_run).to install_package 'libvirt'
end end
it "creates libvirtd group and adds nova as a member" do it 'creates libvirtd group and adds nova as a member' do
expect(@chef_run).to create_group "libvirtd" expect(@chef_run).to create_group 'libvirtd'
libvirt_group = @chef_run.group("libvirtd") libvirt_group = @chef_run.group('libvirtd')
libvirt_group.members.should == ["nova"] libvirt_group.members.should == ['nova']
end end
it "symlinks qemu-kvm" do it 'symlinks qemu-kvm' do
link = @chef_run.link "/usr/bin/qemu-system-x86_64" link = @chef_run.link '/usr/bin/qemu-system-x86_64'
expect(link).to link_to "/usr/libexec/qemu-kvm" expect(link).to link_to '/usr/libexec/qemu-kvm'
end end
it "starts libvirt" do it 'starts libvirt' do
expect(@chef_run).to start_service "libvirtd" expect(@chef_run).to start_service 'libvirtd'
end end
it "starts libvirt on boot" do it 'starts libvirt on boot' do
expect(@chef_run).to enable_service "libvirtd" expect(@chef_run).to enable_service 'libvirtd'
end end
it "does not create /etc/default/libvirt-bin" do it 'does not create /etc/default/libvirt-bin' do
pending "TODO: how to test this" pending 'TODO: how to test this'
end end
describe "/etc/sysconfig/libvirtd" do describe '/etc/sysconfig/libvirtd' do
before { @filename = "/etc/sysconfig/libvirtd" } before { @filename = '/etc/sysconfig/libvirtd' }
it "creates the /etc/sysconfig/libvirtd file" do it 'creates the /etc/sysconfig/libvirtd file' do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
owner: "root", owner: 'root',
group: "root", group: 'root',
mode: 0644 mode: 0644
) )
end end
it "template contents" do it 'template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
it "notifies libvirt-bin restart" do it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart) expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
end end
end end
end end

View File

@ -1,93 +1,95 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::libvirt" do require_relative 'spec_helper'
describe 'openstack-compute::libvirt' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::libvirt" @chef_run.converge 'openstack-compute::libvirt'
end end
it "installs libvirt packages" do it 'installs libvirt packages' do
expect(@chef_run).to install_package "libvirt-bin" expect(@chef_run).to install_package 'libvirt-bin'
end end
it "does not create libvirtd group and add to nova" do it 'does not create libvirtd group and add to nova' do
pending "TODO: how to test this" pending 'TODO: how to test this'
end end
it "does not symlink qemu-kvm" do it 'does not symlink qemu-kvm' do
pending "TODO: how to test this" pending 'TODO: how to test this'
end end
it "starts dbus" do it 'starts dbus' do
expect(@chef_run).to start_service "dbus" expect(@chef_run).to start_service 'dbus'
end end
it "starts dbus on boot" do it 'starts dbus on boot' do
expect(@chef_run).to enable_service "dbus" expect(@chef_run).to enable_service 'dbus'
end end
it "starts libvirt" do it 'starts libvirt' do
expect(@chef_run).to start_service "libvirt-bin" expect(@chef_run).to start_service 'libvirt-bin'
end end
it "starts libvirt on boot" do it 'starts libvirt on boot' do
expect(@chef_run).to enable_service "libvirt-bin" expect(@chef_run).to enable_service 'libvirt-bin'
end end
it "disables default libvirt network" do it 'disables default libvirt network' do
expect(@chef_run).to run_execute("virsh net-autostart default --disable") expect(@chef_run).to run_execute('virsh net-autostart default --disable')
end end
it "deletes default libvirt network" do it 'deletes default libvirt network' do
expect(@chef_run).to run_execute("virsh net-destroy default") expect(@chef_run).to run_execute('virsh net-destroy default')
end end
describe "/etc/libvirt/libvirtd.conf" do describe '/etc/libvirt/libvirtd.conf' do
before { @filename = "/etc/libvirt/libvirtd.conf" } before { @filename = '/etc/libvirt/libvirtd.conf' }
it "creates the /etc/libvirt/libvirtd.conf file" do it 'creates the /etc/libvirt/libvirtd.conf file' do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
owner: "root", owner: 'root',
group: "root", group: 'root',
mode: 0644 mode: 0644
) )
end end
it "has proper processing controls" do 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(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end
it "notifies libvirt-bin restart" do it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart) expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
end end
end end
describe "/etc/default/libvirt-bin" do describe '/etc/default/libvirt-bin' do
before { @filename = "/etc/default/libvirt-bin" } before { @filename = '/etc/default/libvirt-bin' }
it "creates the /etc/default/libvirt-bin file" do it 'creates the /etc/default/libvirt-bin file' do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
owner: "root", owner: 'root',
group: "root", group: 'root',
mode: 0644 mode: 0644
) )
end end
it "template contents" do it 'template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
it "notifies libvirt-bin restart" do it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart) expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
end end
end end
it "does not create /etc/sysconfig/libvirtd" do it 'does not create /etc/sysconfig/libvirtd' do
pending "TODO: how to test this" pending 'TODO: how to test this'
end end
end end
end end

View File

@ -1,20 +1,22 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::network" do require_relative 'spec_helper'
describe 'openstack-compute::network' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::network" @chef_run.converge 'openstack-compute::network'
end end
it "installs nova network packages" do it 'installs nova network packages' do
expect(@chef_run).to upgrade_package "iptables" expect(@chef_run).to upgrade_package 'iptables'
expect(@chef_run).to upgrade_package "openstack-nova-network" expect(@chef_run).to upgrade_package 'openstack-nova-network'
end end
it "starts nova network on boot" do it 'starts nova network on boot' do
expected = "openstack-nova-network" expected = 'openstack-nova-network'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
end end

View File

@ -1,30 +1,32 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::network" do require_relative 'spec_helper'
describe 'openstack-compute::network' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@node = @chef_run.node @node = @chef_run.node
@node.set["openstack"]["compute"]["network"]["service_type"] = "nova" @node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge "openstack-compute::network" @chef_run.converge 'openstack-compute::network'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs nova network packages" do it 'installs nova network packages' do
expect(@chef_run).to upgrade_package "iptables" expect(@chef_run).to upgrade_package 'iptables'
expect(@chef_run).to upgrade_package "nova-network" expect(@chef_run).to upgrade_package 'nova-network'
end end
it "starts nova network on boot" do it 'starts nova network on boot' do
expect(@chef_run).to enable_service "nova-network" expect(@chef_run).to enable_service 'nova-network'
end end
it "includes openstack-network recipes for neutron when service type is neutron" do it 'includes openstack-network recipes for neutron when service type is neutron' do
@chef_run.node.set["openstack"]["compute"]["network"]["service_type"] = "neutron" @chef_run.node.set['openstack']['compute']['network']['service_type'] = 'neutron'
@chef_run.converge "openstack-compute::network" @chef_run.converge 'openstack-compute::network'
expect(@chef_run).to include_recipe "openstack-network::openvswitch" expect(@chef_run).to include_recipe 'openstack-network::openvswitch'
end end
end end
end end

View File

@ -1,19 +1,21 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::nova-cert" do require_relative 'spec_helper'
describe 'openstack-compute::nova-cert' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::nova-cert" @chef_run.converge 'openstack-compute::nova-cert'
end end
it "installs nova cert packages" do it 'installs nova cert packages' do
expect(@chef_run).to upgrade_package "openstack-nova-cert" expect(@chef_run).to upgrade_package 'openstack-nova-cert'
end end
it "starts nova cert on boot" do it 'starts nova cert on boot' do
expect(@chef_run).to enable_service "openstack-nova-cert" expect(@chef_run).to enable_service 'openstack-nova-cert'
end end
end end
end end

View File

@ -1,21 +1,23 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::nova-cert" do require_relative 'spec_helper'
describe 'openstack-compute::nova-cert' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::nova-cert" @chef_run.converge 'openstack-compute::nova-cert'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs nova cert packages" do it 'installs nova cert packages' do
expect(@chef_run).to upgrade_package "nova-cert" expect(@chef_run).to upgrade_package 'nova-cert'
end end
it "starts nova cert on boot" do it 'starts nova cert on boot' do
expect(@chef_run).to enable_service "nova-cert" expect(@chef_run).to enable_service 'nova-cert'
end end
end end
end end

View File

@ -1,50 +1,51 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::nova-common" do require_relative 'spec_helper'
describe 'openstack-compute::nova-common' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::nova-common" @chef_run.converge 'openstack-compute::nova-common'
end end
it "runs epel recipe" do it 'runs epel recipe' do
expect(@chef_run).to include_recipe "yum::epel" expect(@chef_run).to include_recipe 'yum::epel'
end end
it "installs nova common packages" do it 'installs nova common packages' do
expect(@chef_run).to upgrade_package "openstack-nova-common" expect(@chef_run).to upgrade_package 'openstack-nova-common'
end end
it "installs mysql python packages by default" do it 'installs mysql python packages by default' do
expect(@chef_run).to install_package "MySQL-python" expect(@chef_run).to install_package 'MySQL-python'
end end
it "installs db2 python packages if explicitly told" do it 'installs db2 python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["db"]["compute"]["service_type"] = "db2" node.set['openstack']['db']['compute']['service_type'] = 'db2'
chef_run.converge "openstack-compute::nova-common" chef_run.converge 'openstack-compute::nova-common'
['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg|
expect(chef_run).to install_package pkg expect(chef_run).to install_package pkg
end end
end end
it "installs memcache python packages" do it 'installs memcache python packages' do
expect(@chef_run).to install_package "python-memcached" expect(@chef_run).to install_package 'python-memcached'
end end
describe "nova.conf" do describe 'nova.conf' do
before do before do
@filename = "/etc/nova/nova.conf" @filename = '/etc/nova/nova.conf'
# README(shep) need this to evaluate nova.conf.erb template # README(shep) need this to evaluate nova.conf.erb template
@chef_run.node.set['cpu'] = Hash.new() @chef_run.node.set['cpu'] = Hash.new
@chef_run.node.set.cpu.total = "2" @chef_run.node.set.cpu.total = '2'
end end
[/^ec2_private_dns_show_ip=True$/, /^force_dhcp_release=false$/].each do |content| [/^ec2_private_dns_show_ip=True$/, /^force_dhcp_release=false$/].each do |content|
it "has a \"#{content.source[1...-1]}\" line" do it "has a #{content.source[1...-1]} line" do
expect(@chef_run).to render_file(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end

View File

@ -1,271 +1,234 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::nova-common" do require_relative 'spec_helper'
describe 'openstack-compute::nova-common' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["mq"] = { n.set['openstack']['mq'] = {
"host" => "127.0.0.1" 'host' => '127.0.0.1'
} }
n.set["openstack"]["compute"]["syslog"]["use"] = true n.set['openstack']['compute']['syslog']['use'] = true
end end
@chef_run.converge "openstack-compute::nova-common" @chef_run.converge 'openstack-compute::nova-common'
end end
it "doesn't run epel recipe" do it "doesn't run epel recipe" do
expect(@chef_run).to_not include_recipe 'yum::epel' expect(@chef_run).to_not include_recipe 'yum::epel'
end end
it "runs logging recipe if node attributes say to" do it 'runs logging recipe if node attributes say to' do
expect(@chef_run).to include_recipe "openstack-common::logging" expect(@chef_run).to include_recipe 'openstack-common::logging'
end end
it "doesn't run logging recipe" do it "doesn't run logging recipe" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-compute::nova-common" chef_run.converge 'openstack-compute::nova-common'
expect(chef_run).not_to include_recipe "openstack-common::logging" expect(chef_run).not_to include_recipe 'openstack-common::logging'
end end
it "can converge with neutron service type" do it 'can converge with neutron service type' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "neutron" node.set['openstack']['compute']['network']['service_type'] = 'neutron'
chef_run.converge "openstack-compute::nova-common" chef_run.converge 'openstack-compute::nova-common'
end end
it "installs nova common packages" do it 'installs nova common packages' do
expect(@chef_run).to upgrade_package "nova-common" expect(@chef_run).to upgrade_package 'nova-common'
end end
it "installs memcache python packages" do it 'installs memcache python packages' do
expect(@chef_run).to install_package "python-memcache" expect(@chef_run).to install_package 'python-memcache'
end end
it "creates the /etc/nova directory" do it 'creates the /etc/nova directory' do
expect(@chef_run).to create_directory("/etc/nova").with( expect(@chef_run).to create_directory('/etc/nova').with(
owner: "nova", owner: 'nova',
group: "nova", group: 'nova',
mode: 0700 mode: 0700
) )
end end
describe "nova.conf" do describe 'nova.conf' do
before do before do
@filename = "/etc/nova/nova.conf" @filename = '/etc/nova/nova.conf'
# need this to evaluate nova.conf.erb template # need this to evaluate nova.conf.erb template
@chef_run.node.set['cpu'] = Hash.new() @chef_run.node.set['cpu'] = Hash.new
@chef_run.node.set.cpu.total = "2" @chef_run.node.set.cpu.total = '2'
end end
it "creates the file" do it 'creates the file' do
expect(@chef_run).to create_template("/etc/nova/nova.conf").with( expect(@chef_run).to create_template('/etc/nova/nova.conf').with(
owner: "nova", owner: 'nova',
group: "nova", group: 'nova',
mode: 0644 mode: 0644
) )
end end
array = [/^rpc_thread_pool_size=64$/, array = [/^rpc_thread_pool_size=64$/,
/^rpc_conn_pool_size=30$/, /^rpc_conn_pool_size=30$/,
/^rpc_response_timeout=60$/, /^rpc_response_timeout=60$/,
/^rabbit_userid=guest$/, /^rabbit_userid=guest$/,
/^rabbit_password=rabbit-pass$/, /^rabbit_password=rabbit-pass$/,
/^rabbit_virtual_host=\/$/, /^rabbit_virtual_host=\/$/,
/^rabbit_host=127.0.0.1$/, /^rabbit_host=127.0.0.1$/,
/^rabbit_port=5672$/, /^rabbit_port=5672$/,
/^rabbit_use_ssl=false$/, /^rabbit_use_ssl=false$/,
/^allow_resize_to_same_host=false$/, /^allow_resize_to_same_host=false$/,
/^vncserver_listen=127.0.1.1$/, /^vncserver_listen=127.0.1.1$/,
/^vncserver_proxyclient_address=127.0.1.1$/, /^vncserver_proxyclient_address=127.0.1.1$/,
/^xvpvncproxy_host=127.0.1.1$/, /^xvpvncproxy_host=127.0.1.1$/,
/^novncproxy_host=127.0.1.1$/, /^novncproxy_host=127.0.1.1$/,
/^force_dhcp_release=true$/, /^force_dhcp_release=true$/,
/^rpc_backend=nova.openstack.common.rpc.impl_kombu$/, /^rpc_backend=nova.openstack.common.rpc.impl_kombu$/,
/^libvirt_use_virtio_for_bridges=true$/ /^libvirt_use_virtio_for_bridges=true$/
] ]
array.each do |content| array.each do |content|
it "has a \"#{content.source[1...-1]}\" line" do it "has a #{content.source[1...-1]} line" do
expect(@chef_run).to render_file(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end
[/^rabbit_hosts=/, /^rabbit_ha_queues=/, /^ec2_private_dns_show_ip$/].each do |content| [/^rabbit_hosts=/, /^rabbit_ha_queues=/, /^ec2_private_dns_show_ip$/].each do |content|
it "does not have a \"#{content.source[1..-1]}\" line" do it "does not have a #{content.source[1..-1]} line" do
expect(@chef_run).not_to render_file(@filename).with_content(content) expect(@chef_run).not_to render_file(@filename).with_content(content)
end end
end end
it "the libvirt_cpu_mode is none when virt_type is 'qemu'" do it "the libvirt_cpu_mode is none when virt_type is 'qemu'" do
@chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = "qemu" @chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
expect(@chef_run).to render_file(@filename).with_content( expect(@chef_run).to render_file(@filename).with_content(
"libvirt_cpu_mode=none") 'libvirt_cpu_mode=none')
end end
it "has disk_allocation_ratio when the right filter is set" do it 'has disk_allocation_ratio when the right filter is set' do
@chef_run.node.set['openstack']['compute']['scheduler']['default_filters'] = [ @chef_run.node.set['openstack']['compute']['scheduler']['default_filters'] = %w(
"AvailabilityZoneFilter", AvailabilityZoneFilter
"DiskFilter", DiskFilter
"RamFilter", RamFilter
"ComputeFilter", ComputeFilter
"CoreFilter", CoreFilter
"SameHostFilter", SameHostFilter
"DifferentHostFilter" DifferentHostFilter
] )
@chef_run.converge("openstack-compute::nova-common") @chef_run.converge('openstack-compute::nova-common')
expect(@chef_run).to render_file(@filename).with_content( expect(@chef_run).to render_file(@filename).with_content(
"disk_allocation_ratio=1.0") 'disk_allocation_ratio=1.0')
end end
it "has no auto_assign_floating_ip" do it 'has no auto_assign_floating_ip' do
@chef_run.node.set['openstack']['compute']['network']['service_type'] = "neutron" @chef_run.node.set['openstack']['compute']['network']['service_type'] = 'neutron'
expect(@chef_run).not_to render_file(@filename).with_content( expect(@chef_run).not_to render_file(@filename).with_content(
"auto_assign_floating_ip=false") 'auto_assign_floating_ip=false')
end end
it "has misc option" do it 'has misc option' do
@chef_run.node.set['openstack']['compute']['misc_nova'] = ["MISC_OPTION","FOO"] @chef_run.node.set['openstack']['compute']['misc_nova'] = ['MISC_OPTION', 'FOO']
expect(@chef_run).to render_file(@filename).with_content( expect(@chef_run).to render_file(@filename).with_content(
"MISC_OPTION") 'MISC_OPTION')
end end
context "qpid" do context 'qpid' do
before { before do
@chef_run.node.set['openstack']['mq']['compute']['service_type'] = "qpid" @chef_run.node.set['openstack']['mq']['compute']['service_type'] = 'qpid'
@chef_run.converge "openstack-compute::nova-common" @chef_run.converge 'openstack-compute::nova-common'
} end
array = [/^qpid_hostname=127.0.0.1$/, array = [/^qpid_hostname=127.0.0.1$/,
/^qpid_port=5672$/, /^qpid_port=5672$/,
/^qpid_username=$/, /^qpid_username=$/,
/^qpid_password=$/, /^qpid_password=$/,
/^qpid_sasl_mechanisms=$/, /^qpid_sasl_mechanisms=$/,
/^qpid_reconnect_timeout=0$/, /^qpid_reconnect_timeout=0$/,
/^qpid_reconnect_limit=0$/, /^qpid_reconnect_limit=0$/,
/^qpid_reconnect_interval_min=0$/, /^qpid_reconnect_interval_min=0$/,
/^qpid_reconnect_interval_max=0$/, /^qpid_reconnect_interval_max=0$/,
/^qpid_reconnect_interval=0$/, /^qpid_reconnect_interval=0$/,
/^qpid_heartbeat=60$/, /^qpid_heartbeat=60$/,
/^qpid_protocol=tcp$/, /^qpid_protocol=tcp$/,
/^qpid_tcp_nodelay=true$/ /^qpid_tcp_nodelay=true$/
] ]
array.each do |content| array.each do |content|
it "has a \"#{content.source[1...-1]}\" line" do it "has a #{content.source[1...-1]} line" do
expect(@chef_run).to render_file(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end
end end
describe "rabbit ha" do describe 'rabbit ha' do
before do before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n| @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["mq"]["compute"]["rabbit"]["ha"] = true n.set['openstack']['mq']['compute']['rabbit']['ha'] = true
n.set["cpu"] = { n.set['cpu'] = {
"total" => "2" 'total' => '2'
} }
end end
@chef_run.converge "openstack-compute::nova-common" @chef_run.converge 'openstack-compute::nova-common'
end end
[/^rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672$/, /^rabbit_ha_queues=True$/].each do |content| [/^rabbit_hosts=1.1.1.1:5672,2.2.2.2:5672$/, /^rabbit_ha_queues=True$/].each do |content|
it "has a \"#{content.source[1...-1]}\" line" do it "has a #{content.source[1...-1]} line" do
expect(@chef_run).to render_file(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end
[/^rabbit_host=127.0.0.1$/, /^rabbit_port=5672$/].each do |content| [/^rabbit_host=127.0.0.1$/, /^rabbit_port=5672$/].each do |content|
it "does not have a \"#{content.source[1..-1]}\" line" do it "does not have a #{content.source[1..-1]} line" do
expect(@chef_run).not_to render_file(@filename).with_content(content) expect(@chef_run).not_to render_file(@filename).with_content(content)
end end
end end
end end
end end
describe 'rootwrap.conf' do
before { @filename = '/etc/nova/rootwrap.conf' }
# describe "identity role local node" do it 'creates the /etc/nova/rootwrap.conf file' do
# before do
# @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
# n.set["openstack"]["identity"]["admin_tenant_name"] = "admin-tenant"
# n.set["openstack"]["identity"]["admin_user"] = "admin-user"
# end
# @chef_run.converge 'role[os-identity]', "openstack-compute::nova-common"
# end
# it "has keystone_hash" do
# expect(@chef_run).to log 'openstack-compute::nova-common:keystone|node[???]'
# end
# it "has ksadmin_user" do
# expect(@chef_run).to log 'openstack-compute::nova-common:ksadmin_user|admin-user'
# end
# it "has ksadmin_tenant_name" do
# expect(@chef_run).to log 'openstack-compute::nova-common:ksadmin_tenant_name|admin-tenant'
# end
# end
# describe "identity role search" do
# before do
# @chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
# n.set["openstack"]["compute"]["identity_service_chef_role"] = "os-identity"
# end
# @chef_run.converge "openstack-compute::nova-common"
# end
# it "has keystone_hash" do
# expect(@chef_run).to log 'openstack-compute::nova-common:keystone|node[???]'
# end
# it "has ksadmin_user" do
# expect(@chef_run).to log 'openstack-compute::nova-common:ksadmin_user|admin-user'
# end
# it "has ksadmin_tenant_name" do
# expect(@chef_run).to log 'openstack-compute::nova-common:ksadmin_tenant_name|admin-tenant'
# end
# end
describe "rootwrap.conf" do
before { @filename = "/etc/nova/rootwrap.conf" }
it "creates the /etc/nova/rootwrap.conf file" do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
user: "root", user: 'root',
group: "root", group: 'root',
mode: 0644 mode: 0644
) )
end end
it "template contents" do it 'template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
end end
describe "/root/openrc" do describe '/root/openrc' do
before { @filename = "/root/openrc" } before { @filename = '/root/openrc' }
it "creates the /root/openrc file" do it 'creates the /root/openrc file' do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
user: "root", user: 'root',
group: "root", group: 'root',
mode: 0600 mode: 0600
) )
end end
[/^export OS_USERNAME=admin/, /^export OS_TENANT_NAME=admin$/, /^export OS_PASSWORD=admin$/].each do |content| [/^export OS_USERNAME=admin/, /^export OS_TENANT_NAME=admin$/, /^export OS_PASSWORD=admin$/].each do |content|
it "has a \"#{content.source[1...-1]}\" line" do it "has a #{content.source[1...-1]} line" do
expect(@chef_run).to render_file(@filename).with_content(content) expect(@chef_run).to render_file(@filename).with_content(content)
end end
end end
it "has misc option" do it 'has misc option' do
@chef_run.node.set['openstack']['compute']['misc_openrc'] = ["MISC_OPTION", "FOO"] @chef_run.node.set['openstack']['compute']['misc_openrc'] = ['MISC_OPTION', 'FOO']
expect(@chef_run).to render_file(@filename).with_content( expect(@chef_run).to render_file(@filename).with_content(
"MISC_OPTION") 'MISC_OPTION')
end end
it "rest of template contents" do it 'rest of template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
end end
it "enables nova login" do it 'enables nova login' do
expect(@chef_run).to run_execute("usermod -s /bin/sh nova") expect(@chef_run).to run_execute('usermod -s /bin/sh nova')
end end
end end
end end

View File

@ -1,72 +1,74 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::nova-setup" do require_relative 'spec_helper'
describe 'openstack-compute::nova-setup' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::nova-setup" @chef_run.converge 'openstack-compute::nova-setup'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "runs db migrations" do it 'runs db migrations' do
expect(@chef_run).to run_execute("nova-manage db sync") expect(@chef_run).to run_execute('nova-manage db sync')
end end
it "adds nova network ipv4 addresses" do it 'adds nova network ipv4 addresses' do
cmd = ["nova-manage network create --label=public", cmd = ['nova-manage network create --label=public',
"--fixed_range_v4=192.168.100.0/24", '--fixed_range_v4=192.168.100.0/24',
"--multi_host='T'", "--multi_host='T'",
"--num_networks=1", '--num_networks=1',
"--network_size=255", '--network_size=255',
"--bridge=br100", '--bridge=br100',
"--bridge_interface=eth2", '--bridge_interface=eth2',
"--dns1=8.8.8.8", '--dns1=8.8.8.8',
"--dns2=8.8.4.4"].join(' ') '--dns2=8.8.4.4'].join(' ')
expect(@chef_run).to run_execute(cmd) expect(@chef_run).to run_execute(cmd)
end end
it "add_floaters.py has proper modes" do it 'add_floaters.py has proper modes' do
file = @chef_run.cookbook_file "/usr/local/bin/add_floaters.py" file = @chef_run.cookbook_file '/usr/local/bin/add_floaters.py'
expect(sprintf("%o", file.mode)).to eq "755" expect(sprintf('%o', file.mode)).to eq '755'
end end
it "adds cidr range of floating ipv4 addresses" do it 'adds cidr range of floating ipv4 addresses' do
@chef_run.node.set["openstack"]["compute"]["network"]["floating"]["ipv4_cidr"] = "10.10.10.0/24" @chef_run.node.set['openstack']['compute']['network']['floating']['ipv4_cidr'] = '10.10.10.0/24'
@chef_run.converge "openstack-compute::nova-setup" @chef_run.converge 'openstack-compute::nova-setup'
expect(@chef_run).to run_execute( expect(@chef_run).to run_execute(
"/usr/local/bin/add_floaters.py nova --cidr=10.10.10.0/24") '/usr/local/bin/add_floaters.py nova --cidr=10.10.10.0/24')
end end
it "adds range of floating ipv4 addresses" do it 'adds range of floating ipv4 addresses' do
@chef_run.node.set["openstack"]["compute"]["network"] = { @chef_run.node.set['openstack']['compute']['network'] = {
"floating" => { 'floating' => {
"ipv4_range" => "10.10.10.1,10.10.10.5" 'ipv4_range' => '10.10.10.1,10.10.10.5'
} }
} }
@chef_run.converge "openstack-compute::nova-setup" @chef_run.converge 'openstack-compute::nova-setup'
expect(@chef_run).to run_execute("/usr/local/bin/add_floaters.py nova --ip-range=10.10.10.1,10.10.10.5") expect(@chef_run).to run_execute('/usr/local/bin/add_floaters.py nova --ip-range=10.10.10.1,10.10.10.5')
end end
context "when neutron is used" do context 'when neutron is used' do
before do before do
@chef_run.node.set["openstack"]["compute"]["network"]["service_type"] = "neutron" @chef_run.node.set['openstack']['compute']['network']['service_type'] = 'neutron'
@chef_run.node.set["openstack"]["compute"]["network"]["floating"]["ipv4_cidr"] = "10.10.10.0/24" @chef_run.node.set['openstack']['compute']['network']['floating']['ipv4_cidr'] = '10.10.10.0/24'
@chef_run.node.set["openstack"]["compute"]["network"]["floating"]["public_network_name"] = "public" @chef_run.node.set['openstack']['compute']['network']['floating']['public_network_name'] = 'public'
@chef_run.converge "openstack-compute::nova-setup" @chef_run.converge 'openstack-compute::nova-setup'
end end
it "installs the neutron python packages" do it 'installs the neutron python packages' do
expect(@chef_run).to upgrade_package("python-neutronclient") expect(@chef_run).to upgrade_package('python-neutronclient')
expect(@chef_run).to upgrade_package("python-pyparsing") expect(@chef_run).to upgrade_package('python-pyparsing')
end end
it "adds cidr range of floating ipv4 addresses to neutron" do it 'adds cidr range of floating ipv4 addresses to neutron' do
resource = @chef_run.find_resource("execute", "neutron floating create").to_hash resource = @chef_run.find_resource('execute', 'neutron floating create').to_hash
expect(resource).to include(:action=>[:run], :command=>". /root/openrc && /usr/local/bin/add_floaters.py neutron --cidr=10.10.10.0/24 --pool=public") expect(resource).to include(action: [:run], command: '. /root/openrc && /usr/local/bin/add_floaters.py neutron --cidr=10.10.10.0/24 --pool=public')
end end
end end
end end

View File

@ -1,23 +1,25 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::scheduler" do require_relative 'spec_helper'
describe 'openstack-compute::scheduler' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::scheduler" @chef_run.converge 'openstack-compute::scheduler'
end end
it "installs nova scheduler packages" do it 'installs nova scheduler packages' do
expect(@chef_run).to upgrade_package "openstack-nova-scheduler" expect(@chef_run).to upgrade_package 'openstack-nova-scheduler'
end end
it "starts nova scheduler" do it 'starts nova scheduler' do
expect(@chef_run).to start_service "openstack-nova-scheduler" expect(@chef_run).to start_service 'openstack-nova-scheduler'
end end
it "starts nova scheduler on boot" do it 'starts nova scheduler on boot' do
expected = "openstack-nova-scheduler" expected = 'openstack-nova-scheduler'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
end end

View File

@ -1,27 +1,29 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::scheduler" do require_relative 'spec_helper'
describe 'openstack-compute::scheduler' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::scheduler" @chef_run.converge 'openstack-compute::scheduler'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
expect_creates_nova_lock_dir expect_creates_nova_lock_dir
it "installs nova scheduler packages" do it 'installs nova scheduler packages' do
expect(@chef_run).to upgrade_package "nova-scheduler" expect(@chef_run).to upgrade_package 'nova-scheduler'
end end
it "starts nova scheduler" do it 'starts nova scheduler' do
expect(@chef_run).to start_service "nova-scheduler" expect(@chef_run).to start_service 'nova-scheduler'
end end
it "starts nova scheduler on boot" do it 'starts nova scheduler on boot' do
expect(@chef_run).to enable_service "nova-scheduler" expect(@chef_run).to enable_service 'nova-scheduler'
end end
end end
end end

View File

@ -1,32 +1,34 @@
require "chefspec" # encoding: UTF-8
require "chefspec/berkshelf"
require "chef/application" require 'chefspec'
require 'chefspec/berkshelf'
require 'chef/application'
::LOG_LEVEL = :fatal ::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = { ::OPENSUSE_OPTS = {
:platform => "opensuse", platform: 'opensuse',
:version => "12.3", version: '12.3',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
::REDHAT_OPTS = { ::REDHAT_OPTS = {
:platform => "redhat", platform: 'redhat',
:version => "6.3", version: '6.3',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
::UBUNTU_OPTS = { ::UBUNTU_OPTS = {
:platform => "ubuntu", platform: 'ubuntu',
:version => "12.04", version: '12.04',
:log_level => ::LOG_LEVEL log_level: ::LOG_LEVEL
} }
def compute_stubs def compute_stubs # rubocop:disable MethodLength
::Chef::Recipe.any_instance.stub(:rabbit_servers). ::Chef::Recipe.any_instance.stub(:rabbit_servers)
and_return "1.1.1.1:5672,2.2.2.2:5672" .and_return '1.1.1.1:5672,2.2.2.2:5672'
::Chef::Recipe.any_instance.stub(:address_for). ::Chef::Recipe.any_instance.stub(:address_for)
with("lo"). .with('lo')
and_return "127.0.1.1" .and_return '127.0.1.1'
::Chef::Recipe.any_instance.stub(:search_for). ::Chef::Recipe.any_instance.stub(:search_for)
with("os-identity").and_return( .with('os-identity').and_return(
[{ [{
'openstack' => { 'openstack' => {
'identity' => { 'identity' => {
@ -36,78 +38,78 @@ def compute_stubs
} }
}] }]
) )
::Chef::Recipe.any_instance.stub(:secret). ::Chef::Recipe.any_instance.stub(:secret)
with("secrets", "openstack_identity_bootstrap_token"). .with('secrets', 'openstack_identity_bootstrap_token')
and_return "bootstrap-token" .and_return 'bootstrap-token'
::Chef::Recipe.any_instance.stub(:secret). ::Chef::Recipe.any_instance.stub(:secret)
with("secrets", "neutron_metadata_secret"). .with('secrets', 'neutron_metadata_secret')
and_return "metadata-secret" .and_return 'metadata-secret'
::Chef::Recipe.any_instance.stub(:get_password). ::Chef::Recipe.any_instance.stub(:get_password)
and_return String.new .and_return ''
::Chef::Recipe.any_instance.stub(:get_password). ::Chef::Recipe.any_instance.stub(:get_password)
with("user", "guest"). .with('user', 'guest')
and_return "rabbit-pass" .and_return 'rabbit-pass'
::Chef::Recipe.any_instance.stub(:get_password). ::Chef::Recipe.any_instance.stub(:get_password)
with("user", "admin"). .with('user', 'admin')
and_return "admin" .and_return 'admin'
::Chef::Recipe.any_instance.stub(:get_password). ::Chef::Recipe.any_instance.stub(:get_password)
with("service", "openstack-compute"). .with('service', 'openstack-compute')
and_return "nova-pass" .and_return 'nova-pass'
::Chef::Recipe.any_instance.stub(:get_password). ::Chef::Recipe.any_instance.stub(:get_password)
with("service", "openstack-network"). .with('service', 'openstack-network')
and_return "neutron-pass" .and_return 'neutron-pass'
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return [] ::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
::Chef::Recipe.any_instance.stub(:system). ::Chef::Recipe.any_instance.stub(:system)
with("grub2-set-default 'openSUSE GNU/Linux, with Xen hypervisor'"). .with("grub2-set-default 'openSUSE GNU/Linux, with Xen hypervisor'")
and_return true .and_return true
::Chef::Application.stub(:fatal!) ::Chef::Application.stub(:fatal!)
stub_command("nova-manage network list | grep 192.168.100.0/24").and_return(false) stub_command('nova-manage network list | grep 192.168.100.0/24').and_return(false)
stub_command("nova-manage network list | grep 192.168.200.0/24").and_return(false) stub_command('nova-manage network list | grep 192.168.200.0/24').and_return(false)
stub_command("nova-manage floating list |grep -E '.*([0-9]{1,3}[.]){3}[0-9]{1,3}*'").and_return(false) stub_command("nova-manage floating list |grep -E '.*([0-9]{1,3}[.]){3}[0-9]{1,3}*'").and_return(false)
stub_command("virsh net-list | grep -q default").and_return(true) stub_command('virsh net-list | grep -q default').and_return(true)
stub_command("ovs-vsctl show | grep 'Bridge br-int'").and_return(true) stub_command("ovs-vsctl show | grep 'Bridge br-int'").and_return(true)
stub_command("ovs-vsctl show | grep 'Bridge br-tun'").and_return(true) stub_command("ovs-vsctl show | grep 'Bridge br-tun'").and_return(true)
end end
def expect_runs_nova_common_recipe def expect_runs_nova_common_recipe
it "installs nova-common" do it 'installs nova-common' do
expect(@chef_run).to include_recipe "openstack-compute::nova-common" expect(@chef_run).to include_recipe 'openstack-compute::nova-common'
end end
end end
def expect_installs_python_keystone def expect_installs_python_keystone
it "installs python-keystone" do it 'installs python-keystone' do
expect(@chef_run).to upgrade_package "python-keystone" expect(@chef_run).to upgrade_package 'python-keystone'
end end
end end
def expect_creates_nova_lock_dir def expect_creates_nova_lock_dir
it "creates the /var/lock/nova directory" do it 'creates the /var/lock/nova directory' do
expect(@chef_run).to create_directory("/var/lock/nova").with( expect(@chef_run).to create_directory('/var/lock/nova').with(
user: "nova", user: 'nova',
group: "nova", group: 'nova',
mode: 0700 mode: 0700
) )
end end
end end
def expect_creates_api_paste service, action=:restart def expect_creates_api_paste(service, action = :restart) # rubocop:disable MethodLength
describe "/etc/nova/api-paste.ini" do describe '/etc/nova/api-paste.ini' do
before { @filename = "/etc/nova/api-paste.ini" } before { @filename = '/etc/nova/api-paste.ini' }
it "creates api-paste.ini" do it 'creates api-paste.ini' do
expect(@chef_run).to create_template(@filename).with( expect(@chef_run).to create_template(@filename).with(
user: "nova", user: 'nova',
group: "nova", group: 'nova',
mode: 0644, mode: 0644,
) )
end end
it "template contents" do it 'template contents' do
pending "TODO: implement" pending 'TODO: implement'
end end
it "notifies #{service} #{action}" do it 'notifies #{service} #{action}' do
expect(@chef_run.template("/etc/nova/api-paste.ini")).to notify(service).to(action) expect(@chef_run.template('/etc/nova/api-paste.ini')).to notify(service).to(action)
end end
end end
end end

View File

@ -1,38 +1,40 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::vncproxy" do require_relative 'spec_helper'
describe 'openstack-compute::vncproxy' do
before { compute_stubs } before { compute_stubs }
describe "redhat" do describe 'redhat' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS @chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::vncproxy" @chef_run.converge 'openstack-compute::vncproxy'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs nova vncproxy packages" do it 'installs nova vncproxy packages' do
expect(@chef_run).to upgrade_package "openstack-nova-novncproxy" expect(@chef_run).to upgrade_package 'openstack-nova-novncproxy'
end end
it "installs nova consoleauth packages" do it 'installs nova consoleauth packages' do
expect(@chef_run).to upgrade_package "openstack-nova-console" expect(@chef_run).to upgrade_package 'openstack-nova-console'
end end
it "starts nova vncproxy" do it 'starts nova vncproxy' do
expect(@chef_run).to start_service "openstack-nova-novncproxy" expect(@chef_run).to start_service 'openstack-nova-novncproxy'
end end
it "starts nova vncproxy on boot" do it 'starts nova vncproxy on boot' do
expected = "openstack-nova-novncproxy" expected = 'openstack-nova-novncproxy'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
it "starts nova consoleauth" do it 'starts nova consoleauth' do
expect(@chef_run).to start_service "openstack-nova-consoleauth" expect(@chef_run).to start_service 'openstack-nova-consoleauth'
end end
it "starts nova consoleauth on boot" do it 'starts nova consoleauth on boot' do
expected = "openstack-nova-consoleauth" expected = 'openstack-nova-consoleauth'
expect(@chef_run).to enable_service expected expect(@chef_run).to enable_service expected
end end
end end

View File

@ -1,39 +1,41 @@
require_relative "spec_helper" # encoding: UTF-8
describe "openstack-compute::vncproxy" do require_relative 'spec_helper'
describe 'openstack-compute::vncproxy' do
before { compute_stubs } before { compute_stubs }
describe "ubuntu" do describe 'ubuntu' do
before do before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS @chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::vncproxy" @chef_run.converge 'openstack-compute::vncproxy'
end end
expect_runs_nova_common_recipe expect_runs_nova_common_recipe
it "installs nova vncproxy packages" do it 'installs nova vncproxy packages' do
expect(@chef_run).to upgrade_package "novnc" expect(@chef_run).to upgrade_package 'novnc'
expect(@chef_run).to upgrade_package "websockify" expect(@chef_run).to upgrade_package 'websockify'
expect(@chef_run).to upgrade_package "nova-novncproxy" expect(@chef_run).to upgrade_package 'nova-novncproxy'
end end
it "installs nova consoleauth packages" do it 'installs nova consoleauth packages' do
expect(@chef_run).to upgrade_package "nova-consoleauth" expect(@chef_run).to upgrade_package 'nova-consoleauth'
end end
it "starts nova vncproxy" do it 'starts nova vncproxy' do
expect(@chef_run).to start_service "nova-novncproxy" expect(@chef_run).to start_service 'nova-novncproxy'
end end
it "starts nova vncproxy on boot" do it 'starts nova vncproxy on boot' do
expect(@chef_run).to enable_service "nova-novncproxy" expect(@chef_run).to enable_service 'nova-novncproxy'
end end
it "starts nova consoleauth" do it 'starts nova consoleauth' do
expect(@chef_run).to start_service "nova-consoleauth" expect(@chef_run).to start_service 'nova-consoleauth'
end end
it "starts nova consoleauth on boot" do it 'starts nova consoleauth on boot' do
expect(@chef_run).to enable_service "nova-consoleauth" expect(@chef_run).to enable_service 'nova-consoleauth'
end end
end end
end end