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
- Gemfile
- attributes/**
- spec/**
Excludes:
- libraries/**
- providers/**
- recipes/**
- resources/**
- spec/**
Encoding:
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-ec2"
@chef_run.converge 'openstack-compute::api-ec2'
end
it "installs ec2 api packages" do
expect(@chef_run).to upgrade_package "openstack-nova-api"
it 'installs ec2 api packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-api'
end
it "starts ec2 api on boot" do
expect(@chef_run).to enable_service "openstack-nova-api"
it 'starts ec2 api on boot' do
expect(@chef_run).to enable_service 'openstack-nova-api'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-ec2"
@chef_run.converge 'openstack-compute::api-ec2'
end
expect_runs_nova_common_recipe
@ -14,14 +16,14 @@ describe "openstack-compute::api-ec2" do
expect_installs_python_keystone
it "installs ec2 api packages" do
expect(@chef_run).to upgrade_package "nova-api-ec2"
it 'installs ec2 api packages' do
expect(@chef_run).to upgrade_package 'nova-api-ec2'
end
it "starts ec2 api on boot" do
expect(@chef_run).to enable_service "nova-api-ec2"
it 'starts ec2 api on boot' do
expect(@chef_run).to enable_service 'nova-api-ec2'
end
expect_creates_api_paste "service[nova-api-ec2]"
expect_creates_api_paste 'service[nova-api-ec2]'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-metadata"
@chef_run.converge 'openstack-compute::api-metadata'
end
it "installs metadata api packages" do
expect(@chef_run).to upgrade_package "openstack-nova-api"
it 'installs metadata api packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-api'
end
it "starts metadata api on boot" do
expect(@chef_run).to enable_service "openstack-nova-api"
it 'starts metadata api on boot' do
expect(@chef_run).to enable_service 'openstack-nova-api'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-metadata"
@chef_run.converge 'openstack-compute::api-metadata'
end
expect_runs_nova_common_recipe
@ -14,14 +16,14 @@ describe "openstack-compute::api-metadata" do
expect_installs_python_keystone
it "installs metadata api packages" do
expect(@chef_run).to upgrade_package "nova-api-metadata"
it 'installs metadata api packages' do
expect(@chef_run).to upgrade_package 'nova-api-metadata'
end
it "starts metadata api on boot" do
expect(@chef_run).to enable_service "nova-api-metadata"
it 'starts metadata api on boot' do
expect(@chef_run).to enable_service 'nova-api-metadata'
end
expect_creates_api_paste "service[nova-api-metadata]"
expect_creates_api_paste 'service[nova-api-metadata]'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::api-os-compute"
@chef_run.converge 'openstack-compute::api-os-compute'
end
it "installs openstack api packages" do
expect(@chef_run).to upgrade_package "openstack-nova-api"
it 'installs openstack api packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-api'
end
it "starts openstack api on boot" do
expect(@chef_run).to enable_service "openstack-nova-api"
it 'starts openstack api on boot' do
expect(@chef_run).to enable_service 'openstack-nova-api'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::api-os-compute"
@chef_run.converge 'openstack-compute::api-os-compute'
end
expect_runs_nova_common_recipe
expect_creates_nova_lock_dir
it "creates the /var/cache/nova directory" do
expect(@chef_run).to create_directory("/var/cache/nova").with(
user: "nova",
group: "nova",
it 'creates the /var/cache/nova directory' do
expect(@chef_run).to create_directory('/var/cache/nova').with(
user: 'nova',
group: 'nova',
mode: 0700
)
end
expect_installs_python_keystone
it "installs openstack api packages" do
expect(@chef_run).to upgrade_package "nova-api-os-compute"
it 'installs openstack api packages' do
expect(@chef_run).to upgrade_package 'nova-api-os-compute'
end
it "starts openstack api on boot" do
expect(@chef_run).to enable_service "nova-api-os-compute"
it 'starts openstack api on boot' do
expect(@chef_run).to enable_service 'nova-api-os-compute'
end
it "starts openstack api now" do
expect(@chef_run).to start_service "nova-api-os-compute"
it 'starts openstack api now' do
expect(@chef_run).to start_service 'nova-api-os-compute'
end
expect_creates_api_paste "service[nova-api-os-compute]"
expect_creates_api_paste 'service[nova-api-os-compute]'
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 }
describe "opensuse" do
describe 'opensuse' do
before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-compute::compute"
@chef_run.converge 'openstack-compute::compute'
end
it "installs nfs client packages" do
expect(@chef_run).to upgrade_package "nfs-utils"
expect(@chef_run).not_to upgrade_package "nfs-utils-lib"
it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package 'nfs-utils'
expect(@chef_run).not_to upgrade_package 'nfs-utils-lib'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::compute"
@chef_run.converge 'openstack-compute::compute'
end
it "does not install kvm when virt_type is 'kvm'" do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "kvm"
chef_run.converge "openstack-compute::compute"
expect(chef_run).to_not upgrade_package "nova-compute-kvm"
node.set['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
chef_run.converge 'openstack-compute::compute'
expect(chef_run).to_not upgrade_package 'nova-compute-kvm'
end
it "does not install qemu when virt_type is 'qemu'" do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu"
chef_run.converge "openstack-compute::compute"
expect(chef_run).to_not upgrade_package "nova-compute-qemu"
node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
chef_run.converge 'openstack-compute::compute'
expect(chef_run).to_not upgrade_package 'nova-compute-qemu'
end
it "installs nova compute packages" do
expect(@chef_run).to upgrade_package "openstack-nova-compute"
it 'installs nova compute packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-compute'
end
it "installs nfs client packages" do
expect(@chef_run).to upgrade_package "nfs-utils"
expect(@chef_run).to upgrade_package "nfs-utils-lib"
it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package 'nfs-utils'
expect(@chef_run).to upgrade_package 'nfs-utils-lib'
end
it "starts nova compute on boot" do
expected = "openstack-nova-compute"
it 'starts nova compute on boot' do
expected = 'openstack-nova-compute'
expect(@chef_run).to enable_service expected
end
it "starts nova compute" do
expect(@chef_run).to start_service "openstack-nova-compute"
it 'starts nova compute' do
expect(@chef_run).to start_service 'openstack-nova-compute'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::compute"
@chef_run.converge 'openstack-compute::compute'
end
expect_runs_nova_common_recipe
it "runs api-metadata recipe" do
expect(@chef_run).to include_recipe "openstack-compute::api-metadata"
it 'runs api-metadata recipe' do
expect(@chef_run).to include_recipe 'openstack-compute::api-metadata'
end
it "runs network recipe" do
expect(@chef_run).to include_recipe "openstack-compute::network"
it 'runs network recipe' do
expect(@chef_run).to include_recipe 'openstack-compute::network'
end
# 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
# node = chef_run.node
# node.run_list.stub("include?").and_return true
# chef_run.converge "openstack-compute::compute"
# expect(chef_run).not_to include_recipe "openstack-compute::network"
# node.run_list.stub('include?').and_return true
# chef_run.converge 'openstack-compute::compute'
# expect(chef_run).not_to include_recipe 'openstack-compute::network'
# end
it "installs nova compute packages" do
expect(@chef_run).to upgrade_package "nova-compute"
it 'installs nova compute packages' do
expect(@chef_run).to upgrade_package 'nova-compute'
end
it "installs nfs client packages" do
expect(@chef_run).to upgrade_package "nfs-common"
it 'installs nfs client packages' do
expect(@chef_run).to upgrade_package 'nfs-common'
end
it "installs kvm when virt_type is 'kvm'" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "kvm"
chef_run.converge "openstack-compute::compute"
node.set['openstack']['compute']['libvirt']['virt_type'] = 'kvm'
chef_run.converge 'openstack-compute::compute'
expect(chef_run).to upgrade_package "nova-compute-kvm"
expect(chef_run).not_to upgrade_package "nova-compute-qemu"
expect(chef_run).to upgrade_package 'nova-compute-kvm'
expect(chef_run).not_to upgrade_package 'nova-compute-qemu'
end
it "installs qemu when virt_type is 'qemu'" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu"
chef_run.converge "openstack-compute::compute"
node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
chef_run.converge 'openstack-compute::compute'
expect(chef_run).to upgrade_package "nova-compute-qemu"
expect(chef_run).not_to upgrade_package "nova-compute-kvm"
expect(chef_run).to upgrade_package 'nova-compute-qemu'
expect(chef_run).not_to upgrade_package 'nova-compute-kvm'
end
describe "nova-compute.conf" do
describe 'nova-compute.conf' do
before do
@file = @chef_run.cookbook_file "/etc/nova/nova-compute.conf"
@file = @chef_run.cookbook_file '/etc/nova/nova-compute.conf'
end
it "has proper modes" do
expect(sprintf("%o", @file.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @file.mode)).to eq '644'
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
end
it "starts nova compute on boot" do
expect(@chef_run).to enable_service "nova-compute"
it 'starts nova compute on boot' do
expect(@chef_run).to enable_service 'nova-compute'
end
it "starts nova compute" do
expect(@chef_run).to start_service "nova-compute"
it 'starts nova compute' do
expect(@chef_run).to start_service 'nova-compute'
end
it "runs libvirt recipe" do
expect(@chef_run).to include_recipe "openstack-compute::libvirt"
it 'runs libvirt recipe' do
expect(@chef_run).to include_recipe 'openstack-compute::libvirt'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::conductor"
@chef_run.converge 'openstack-compute::conductor'
end
expect_runs_nova_common_recipe
it "installs conductor packages" do
expect(@chef_run).to upgrade_package "openstack-nova-conductor"
it 'installs conductor packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-conductor'
end
it "starts nova-conductor on boot" do
expect(@chef_run).to enable_service "openstack-nova-conductor"
it 'starts nova-conductor on boot' do
expect(@chef_run).to enable_service 'openstack-nova-conductor'
end
it "starts nova-conductor" do
expect(@chef_run).to start_service "openstack-nova-conductor"
it 'starts nova-conductor' do
expect(@chef_run).to start_service 'openstack-nova-conductor'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::conductor"
@chef_run.converge 'openstack-compute::conductor'
end
expect_runs_nova_common_recipe
it "installs conductor packages" do
expect(@chef_run).to upgrade_package "nova-conductor"
it 'installs conductor packages' do
expect(@chef_run).to upgrade_package 'nova-conductor'
end
it "starts nova-conductor on boot" do
expect(@chef_run).to enable_service "nova-conductor"
it 'starts nova-conductor on boot' do
expect(@chef_run).to enable_service 'nova-conductor'
end
it "starts nova-conductor" do
expect(@chef_run).to start_service "nova-conductor"
it 'starts nova-conductor' do
expect(@chef_run).to start_service 'nova-conductor'
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

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
compute_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::identity_registration"
@chef_run.converge 'openstack-compute::identity_registration'
end
it "registers service tenant" do
it 'registers service tenant' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Service Tenant"
'openstack-identity_register',
'Register Service Tenant'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:tenant_description => "Service Tenant",
:action => [:create_tenant]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
tenant_description: 'Service Tenant',
action: [:create_tenant]
)
end
it "registers service user" do
it 'registers service user' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Service User"
'openstack-identity_register',
'Register Service User'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:user_name => "nova",
:user_pass => "nova-pass",
:action => [:create_user]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'nova',
user_pass: 'nova-pass',
action: [:create_user]
)
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(
"openstack-identity_register",
'openstack-identity_register',
"Grant 'admin' Role to Service User for Service Tenant"
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:tenant_name => "service",
:user_name => "nova",
:role_name => "admin",
:action => [:grant_role]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'nova',
role_name: 'admin',
action: [:grant_role]
)
end
it "registers compute service" do
it 'registers compute service' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Compute Service"
'openstack-identity_register',
'Register Compute Service'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_name => "nova",
:service_type => "compute",
:service_description => "Nova Compute Service",
:action => [:create_service]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'nova',
service_type: 'compute',
service_description: 'Nova Compute Service',
action: [:create_service]
)
end
it "registers compute endpoint" do
it 'registers compute endpoint' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Compute Endpoint"
'openstack-identity_register',
'Register Compute Endpoint'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_type => "compute",
:endpoint_region => "RegionOne",
: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_publicurl => "http://127.0.0.1:8774/v2/%(tenant_id)s",
:action => [:create_endpoint]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'compute',
endpoint_region: 'RegionOne',
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_publicurl: 'http://127.0.0.1:8774/v2/%(tenant_id)s',
action: [:create_endpoint]
)
end
it "registers ec2 service" do
it 'registers ec2 service' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register EC2 Service"
'openstack-identity_register',
'Register EC2 Service'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_name => "ec2",
:service_type => "ec2",
:service_description => "EC2 Compatibility Layer",
:action => [:create_service]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'ec2',
service_type: 'ec2',
service_description: 'EC2 Compatibility Layer',
action: [:create_service]
)
end
it "registers ec2 endpoint" do
it 'registers ec2 endpoint' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register EC2 Endpoint"
'openstack-identity_register',
'Register EC2 Endpoint'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_type => "ec2",
:endpoint_region => "RegionOne",
:endpoint_adminurl => "http://127.0.0.1:8773/services/Admin",
:endpoint_internalurl => "http://127.0.0.1:8773/services/Cloud",
:endpoint_publicurl => "http://127.0.0.1:8773/services/Cloud",
:action => [:create_endpoint]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_type: 'ec2',
endpoint_region: 'RegionOne',
endpoint_adminurl: 'http://127.0.0.1:8773/services/Admin',
endpoint_internalurl: 'http://127.0.0.1:8773/services/Cloud',
endpoint_publicurl: 'http://127.0.0.1:8773/services/Cloud',
action: [:create_endpoint]
)
end
end
describe "openstack-compute::identity_registration_disable_ec2" do
describe 'openstack-compute::identity_registration_disable_ec2' do
before do
compute_stubs
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.node.set['openstack']['compute']['enabled_apis'] = "osapi_compute,metadata"
@chef_run.converge "openstack-compute::identity_registration"
@chef_run.node.set['openstack']['compute']['enabled_apis'] = 'osapi_compute,metadata'
@chef_run.converge 'openstack-compute::identity_registration'
end
it "disable ec2 service registry" do
it 'disable ec2 service registry' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register EC2 Service"
'openstack-identity_register',
'Register EC2 Service'
)
expect(resource).to be_nil
end
it "disable ec2 endpoint registry" do
it 'disable ec2 endpoint registry' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register EC2 Endpoint"
'openstack-identity_register',
'Register EC2 Endpoint'
)
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
compute_stubs
@ -10,62 +12,62 @@ describe "openstack-compute::libvirt" do
::File.stub(:open).and_call_original
end
describe "suse" do
describe 'suse' do
before do
@chef_run = ::ChefSpec::Runner.new ::OPENSUSE_OPTS
@chef_run.converge "openstack-compute::libvirt"
@chef_run.converge 'openstack-compute::libvirt'
end
it "installs libvirt packages" do
expect(@chef_run).to install_package "libvirt"
it 'installs libvirt packages' do
expect(@chef_run).to install_package 'libvirt'
end
it "starts libvirt" do
expect(@chef_run).to start_service "libvirtd"
it 'starts libvirt' do
expect(@chef_run).to start_service 'libvirtd'
end
it "starts libvirt on boot" do
expect(@chef_run).to enable_service "libvirtd"
it 'starts libvirt on boot' do
expect(@chef_run).to enable_service 'libvirtd'
end
it "does not install /etc/sysconfig/libvirtd" do
expect(@chef_run).not_to create_template("/etc/sysconfig/libvirtd")
it 'does not install /etc/sysconfig/libvirtd' do
expect(@chef_run).not_to create_template('/etc/sysconfig/libvirtd')
end
it "installs kvm packages" do
expect(@chef_run).to install_package "kvm"
it 'installs kvm packages' do
expect(@chef_run).to install_package 'kvm'
end
it "installs qemu packages" do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "qemu"
@chef_run.converge "openstack-compute::libvirt"
expect(@chef_run).to install_package "kvm"
it 'installs qemu packages' do
@chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'qemu'
@chef_run.converge 'openstack-compute::libvirt'
expect(@chef_run).to install_package 'kvm'
end
it "installs xen packages" do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "xen"
@chef_run.converge "openstack-compute::libvirt"
["kernel-xen", "xen", "xen-tools"].each do |pkg|
it 'installs xen packages' do
@chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'xen'
@chef_run.converge 'openstack-compute::libvirt'
['kernel-xen', 'xen', 'xen-tools'].each do |pkg|
expect(@chef_run).to install_package pkg
end
end
describe "lxc" do
describe 'lxc' do
before do
@chef_run.node.set["openstack"]["compute"]["libvirt"]["virt_type"] = "lxc"
@chef_run.converge "openstack-compute::libvirt"
@chef_run.node.set['openstack']['compute']['libvirt']['virt_type'] = 'lxc'
@chef_run.converge 'openstack-compute::libvirt'
end
it "installs packages" do
expect(@chef_run).to install_package "lxc"
it 'installs packages' do
expect(@chef_run).to install_package 'lxc'
end
it "starts boot.cgroupslxc" do
expect(@chef_run).to start_service "boot.cgroup"
it 'starts boot.cgroupslxc' do
expect(@chef_run).to start_service 'boot.cgroup'
end
it "starts boot.cgroups on boot" do
expect(@chef_run).to enable_service "boot.cgroup"
it 'starts boot.cgroups on boot' do
expect(@chef_run).to enable_service 'boot.cgroup'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::libvirt"
@chef_run.converge 'openstack-compute::libvirt'
end
it "installs libvirt packages" do
expect(@chef_run).to install_package "libvirt"
it 'installs libvirt packages' do
expect(@chef_run).to install_package 'libvirt'
end
it "creates libvirtd group and adds nova as a member" do
expect(@chef_run).to create_group "libvirtd"
libvirt_group = @chef_run.group("libvirtd")
libvirt_group.members.should == ["nova"]
it 'creates libvirtd group and adds nova as a member' do
expect(@chef_run).to create_group 'libvirtd'
libvirt_group = @chef_run.group('libvirtd')
libvirt_group.members.should == ['nova']
end
it "symlinks qemu-kvm" do
link = @chef_run.link "/usr/bin/qemu-system-x86_64"
expect(link).to link_to "/usr/libexec/qemu-kvm"
it 'symlinks qemu-kvm' do
link = @chef_run.link '/usr/bin/qemu-system-x86_64'
expect(link).to link_to '/usr/libexec/qemu-kvm'
end
it "starts libvirt" do
expect(@chef_run).to start_service "libvirtd"
it 'starts libvirt' do
expect(@chef_run).to start_service 'libvirtd'
end
it "starts libvirt on boot" do
expect(@chef_run).to enable_service "libvirtd"
it 'starts libvirt on boot' do
expect(@chef_run).to enable_service 'libvirtd'
end
it "does not create /etc/default/libvirt-bin" do
pending "TODO: how to test this"
it 'does not create /etc/default/libvirt-bin' do
pending 'TODO: how to test this'
end
describe "/etc/sysconfig/libvirtd" do
before { @filename = "/etc/sysconfig/libvirtd" }
describe '/etc/sysconfig/libvirtd' do
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(
owner: "root",
group: "root",
owner: 'root',
group: 'root',
mode: 0644
)
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
it "notifies libvirt-bin restart" do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart)
it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::libvirt"
@chef_run.converge 'openstack-compute::libvirt'
end
it "installs libvirt packages" do
expect(@chef_run).to install_package "libvirt-bin"
it 'installs libvirt packages' do
expect(@chef_run).to install_package 'libvirt-bin'
end
it "does not create libvirtd group and add to nova" do
pending "TODO: how to test this"
it 'does not create libvirtd group and add to nova' do
pending 'TODO: how to test this'
end
it "does not symlink qemu-kvm" do
pending "TODO: how to test this"
it 'does not symlink qemu-kvm' do
pending 'TODO: how to test this'
end
it "starts dbus" do
expect(@chef_run).to start_service "dbus"
it 'starts dbus' do
expect(@chef_run).to start_service 'dbus'
end
it "starts dbus on boot" do
expect(@chef_run).to enable_service "dbus"
it 'starts dbus on boot' do
expect(@chef_run).to enable_service 'dbus'
end
it "starts libvirt" do
expect(@chef_run).to start_service "libvirt-bin"
it 'starts libvirt' do
expect(@chef_run).to start_service 'libvirt-bin'
end
it "starts libvirt on boot" do
expect(@chef_run).to enable_service "libvirt-bin"
it 'starts libvirt on boot' do
expect(@chef_run).to enable_service 'libvirt-bin'
end
it "disables default libvirt network" do
expect(@chef_run).to run_execute("virsh net-autostart default --disable")
it 'disables default libvirt network' do
expect(@chef_run).to run_execute('virsh net-autostart default --disable')
end
it "deletes default libvirt network" do
expect(@chef_run).to run_execute("virsh net-destroy default")
it 'deletes default libvirt network' do
expect(@chef_run).to run_execute('virsh net-destroy default')
end
describe "/etc/libvirt/libvirtd.conf" do
before { @filename = "/etc/libvirt/libvirtd.conf" }
describe '/etc/libvirt/libvirtd.conf' do
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(
owner: "root",
group: "root",
owner: 'root',
group: 'root',
mode: 0644
)
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|
expect(@chef_run).to render_file(@filename).with_content(content)
end
end
it "notifies libvirt-bin restart" do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart)
it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
end
end
describe "/etc/default/libvirt-bin" do
before { @filename = "/etc/default/libvirt-bin" }
describe '/etc/default/libvirt-bin' do
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(
owner: "root",
group: "root",
owner: 'root',
group: 'root',
mode: 0644
)
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
it "notifies libvirt-bin restart" do
expect(@chef_run.template(@filename)).to notify("service[libvirt-bin]").to(:restart)
it 'notifies libvirt-bin restart' do
expect(@chef_run.template(@filename)).to notify('service[libvirt-bin]').to(:restart)
end
end
it "does not create /etc/sysconfig/libvirtd" do
pending "TODO: how to test this"
it 'does not create /etc/sysconfig/libvirtd' do
pending 'TODO: how to test this'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::network"
@chef_run.converge 'openstack-compute::network'
end
it "installs nova network packages" do
expect(@chef_run).to upgrade_package "iptables"
expect(@chef_run).to upgrade_package "openstack-nova-network"
it 'installs nova network packages' do
expect(@chef_run).to upgrade_package 'iptables'
expect(@chef_run).to upgrade_package 'openstack-nova-network'
end
it "starts nova network on boot" do
expected = "openstack-nova-network"
it 'starts nova network on boot' do
expected = 'openstack-nova-network'
expect(@chef_run).to enable_service expected
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@node = @chef_run.node
@node.set["openstack"]["compute"]["network"]["service_type"] = "nova"
@chef_run.converge "openstack-compute::network"
@node.set['openstack']['compute']['network']['service_type'] = 'nova'
@chef_run.converge 'openstack-compute::network'
end
expect_runs_nova_common_recipe
it "installs nova network packages" do
expect(@chef_run).to upgrade_package "iptables"
expect(@chef_run).to upgrade_package "nova-network"
it 'installs nova network packages' do
expect(@chef_run).to upgrade_package 'iptables'
expect(@chef_run).to upgrade_package 'nova-network'
end
it "starts nova network on boot" do
expect(@chef_run).to enable_service "nova-network"
it 'starts nova network on boot' do
expect(@chef_run).to enable_service 'nova-network'
end
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.converge "openstack-compute::network"
expect(@chef_run).to include_recipe "openstack-network::openvswitch"
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.converge 'openstack-compute::network'
expect(@chef_run).to include_recipe 'openstack-network::openvswitch'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::nova-cert"
@chef_run.converge 'openstack-compute::nova-cert'
end
it "installs nova cert packages" do
expect(@chef_run).to upgrade_package "openstack-nova-cert"
it 'installs nova cert packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-cert'
end
it "starts nova cert on boot" do
expect(@chef_run).to enable_service "openstack-nova-cert"
it 'starts nova cert on boot' do
expect(@chef_run).to enable_service 'openstack-nova-cert'
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::nova-cert"
@chef_run.converge 'openstack-compute::nova-cert'
end
expect_runs_nova_common_recipe
it "installs nova cert packages" do
expect(@chef_run).to upgrade_package "nova-cert"
it 'installs nova cert packages' do
expect(@chef_run).to upgrade_package 'nova-cert'
end
it "starts nova cert on boot" do
expect(@chef_run).to enable_service "nova-cert"
it 'starts nova cert on boot' do
expect(@chef_run).to enable_service 'nova-cert'
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::nova-common"
@chef_run.converge 'openstack-compute::nova-common'
end
it "runs epel recipe" do
expect(@chef_run).to include_recipe "yum::epel"
it 'runs epel recipe' do
expect(@chef_run).to include_recipe 'yum::epel'
end
it "installs nova common packages" do
expect(@chef_run).to upgrade_package "openstack-nova-common"
it 'installs nova common packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-common'
end
it "installs mysql python packages by default" do
expect(@chef_run).to install_package "MySQL-python"
it 'installs mysql python packages by default' do
expect(@chef_run).to install_package 'MySQL-python'
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
node = chef_run.node
node.set["openstack"]["db"]["compute"]["service_type"] = "db2"
chef_run.converge "openstack-compute::nova-common"
["db2-odbc", "python-ibm-db", "python-ibm-db-sa"].each do |pkg|
node.set['openstack']['db']['compute']['service_type'] = 'db2'
chef_run.converge 'openstack-compute::nova-common'
['db2-odbc', 'python-ibm-db', 'python-ibm-db-sa'].each do |pkg|
expect(chef_run).to install_package pkg
end
end
it "installs memcache python packages" do
expect(@chef_run).to install_package "python-memcached"
it 'installs memcache python packages' do
expect(@chef_run).to install_package 'python-memcached'
end
describe "nova.conf" do
describe 'nova.conf' do
before do
@filename = "/etc/nova/nova.conf"
@filename = '/etc/nova/nova.conf'
# README(shep) need this to evaluate nova.conf.erb template
@chef_run.node.set['cpu'] = Hash.new()
@chef_run.node.set.cpu.total = "2"
@chef_run.node.set['cpu'] = Hash.new
@chef_run.node.set.cpu.total = '2'
end
[/^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)
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["mq"] = {
"host" => "127.0.0.1"
n.set['openstack']['mq'] = {
'host' => '127.0.0.1'
}
n.set["openstack"]["compute"]["syslog"]["use"] = true
n.set['openstack']['compute']['syslog']['use'] = true
end
@chef_run.converge "openstack-compute::nova-common"
@chef_run.converge 'openstack-compute::nova-common'
end
it "doesn't run epel recipe" do
expect(@chef_run).to_not include_recipe 'yum::epel'
end
it "runs logging recipe if node attributes say to" do
expect(@chef_run).to include_recipe "openstack-common::logging"
it 'runs logging recipe if node attributes say to' do
expect(@chef_run).to include_recipe 'openstack-common::logging'
end
it "doesn't run logging recipe" do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
chef_run.converge "openstack-compute::nova-common"
expect(chef_run).not_to include_recipe "openstack-common::logging"
chef_run.converge 'openstack-compute::nova-common'
expect(chef_run).not_to include_recipe 'openstack-common::logging'
end
it "can converge with neutron service type" do
it 'can converge with neutron service type' do
chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
node = chef_run.node
node.set["openstack"]["compute"]["network"]["service_type"] = "neutron"
chef_run.converge "openstack-compute::nova-common"
node.set['openstack']['compute']['network']['service_type'] = 'neutron'
chef_run.converge 'openstack-compute::nova-common'
end
it "installs nova common packages" do
expect(@chef_run).to upgrade_package "nova-common"
it 'installs nova common packages' do
expect(@chef_run).to upgrade_package 'nova-common'
end
it "installs memcache python packages" do
expect(@chef_run).to install_package "python-memcache"
it 'installs memcache python packages' do
expect(@chef_run).to install_package 'python-memcache'
end
it "creates the /etc/nova directory" do
expect(@chef_run).to create_directory("/etc/nova").with(
owner: "nova",
group: "nova",
it 'creates the /etc/nova directory' do
expect(@chef_run).to create_directory('/etc/nova').with(
owner: 'nova',
group: 'nova',
mode: 0700
)
end
describe "nova.conf" do
describe 'nova.conf' do
before do
@filename = "/etc/nova/nova.conf"
@filename = '/etc/nova/nova.conf'
# need this to evaluate nova.conf.erb template
@chef_run.node.set['cpu'] = Hash.new()
@chef_run.node.set.cpu.total = "2"
@chef_run.node.set['cpu'] = Hash.new
@chef_run.node.set.cpu.total = '2'
end
it "creates the file" do
expect(@chef_run).to create_template("/etc/nova/nova.conf").with(
owner: "nova",
group: "nova",
it 'creates the file' do
expect(@chef_run).to create_template('/etc/nova/nova.conf').with(
owner: 'nova',
group: 'nova',
mode: 0644
)
end
array = [/^rpc_thread_pool_size=64$/,
/^rpc_conn_pool_size=30$/,
/^rpc_response_timeout=60$/,
/^rabbit_userid=guest$/,
/^rabbit_password=rabbit-pass$/,
/^rabbit_virtual_host=\/$/,
/^rabbit_host=127.0.0.1$/,
/^rabbit_port=5672$/,
/^rabbit_use_ssl=false$/,
/^allow_resize_to_same_host=false$/,
/^vncserver_listen=127.0.1.1$/,
/^vncserver_proxyclient_address=127.0.1.1$/,
/^xvpvncproxy_host=127.0.1.1$/,
/^novncproxy_host=127.0.1.1$/,
/^force_dhcp_release=true$/,
/^rpc_backend=nova.openstack.common.rpc.impl_kombu$/,
/^libvirt_use_virtio_for_bridges=true$/
/^rpc_conn_pool_size=30$/,
/^rpc_response_timeout=60$/,
/^rabbit_userid=guest$/,
/^rabbit_password=rabbit-pass$/,
/^rabbit_virtual_host=\/$/,
/^rabbit_host=127.0.0.1$/,
/^rabbit_port=5672$/,
/^rabbit_use_ssl=false$/,
/^allow_resize_to_same_host=false$/,
/^vncserver_listen=127.0.1.1$/,
/^vncserver_proxyclient_address=127.0.1.1$/,
/^xvpvncproxy_host=127.0.1.1$/,
/^novncproxy_host=127.0.1.1$/,
/^force_dhcp_release=true$/,
/^rpc_backend=nova.openstack.common.rpc.impl_kombu$/,
/^libvirt_use_virtio_for_bridges=true$/
]
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)
end
end
[/^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)
end
end
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(
"libvirt_cpu_mode=none")
'libvirt_cpu_mode=none')
end
it "has disk_allocation_ratio when the right filter is set" do
@chef_run.node.set['openstack']['compute']['scheduler']['default_filters'] = [
"AvailabilityZoneFilter",
"DiskFilter",
"RamFilter",
"ComputeFilter",
"CoreFilter",
"SameHostFilter",
"DifferentHostFilter"
]
@chef_run.converge("openstack-compute::nova-common")
it 'has disk_allocation_ratio when the right filter is set' do
@chef_run.node.set['openstack']['compute']['scheduler']['default_filters'] = %w(
AvailabilityZoneFilter
DiskFilter
RamFilter
ComputeFilter
CoreFilter
SameHostFilter
DifferentHostFilter
)
@chef_run.converge('openstack-compute::nova-common')
expect(@chef_run).to render_file(@filename).with_content(
"disk_allocation_ratio=1.0")
'disk_allocation_ratio=1.0')
end
it "has no auto_assign_floating_ip" do
@chef_run.node.set['openstack']['compute']['network']['service_type'] = "neutron"
it 'has no auto_assign_floating_ip' do
@chef_run.node.set['openstack']['compute']['network']['service_type'] = 'neutron'
expect(@chef_run).not_to render_file(@filename).with_content(
"auto_assign_floating_ip=false")
'auto_assign_floating_ip=false')
end
it "has misc option" do
@chef_run.node.set['openstack']['compute']['misc_nova'] = ["MISC_OPTION","FOO"]
it 'has misc option' do
@chef_run.node.set['openstack']['compute']['misc_nova'] = ['MISC_OPTION', 'FOO']
expect(@chef_run).to render_file(@filename).with_content(
"MISC_OPTION")
'MISC_OPTION')
end
context "qpid" do
before {
@chef_run.node.set['openstack']['mq']['compute']['service_type'] = "qpid"
@chef_run.converge "openstack-compute::nova-common"
}
context 'qpid' do
before do
@chef_run.node.set['openstack']['mq']['compute']['service_type'] = 'qpid'
@chef_run.converge 'openstack-compute::nova-common'
end
array = [/^qpid_hostname=127.0.0.1$/,
/^qpid_port=5672$/,
/^qpid_username=$/,
/^qpid_password=$/,
/^qpid_sasl_mechanisms=$/,
/^qpid_reconnect_timeout=0$/,
/^qpid_reconnect_limit=0$/,
/^qpid_reconnect_interval_min=0$/,
/^qpid_reconnect_interval_max=0$/,
/^qpid_reconnect_interval=0$/,
/^qpid_heartbeat=60$/,
/^qpid_protocol=tcp$/,
/^qpid_tcp_nodelay=true$/
/^qpid_port=5672$/,
/^qpid_username=$/,
/^qpid_password=$/,
/^qpid_sasl_mechanisms=$/,
/^qpid_reconnect_timeout=0$/,
/^qpid_reconnect_limit=0$/,
/^qpid_reconnect_interval_min=0$/,
/^qpid_reconnect_interval_max=0$/,
/^qpid_reconnect_interval=0$/,
/^qpid_heartbeat=60$/,
/^qpid_protocol=tcp$/,
/^qpid_tcp_nodelay=true$/
]
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)
end
end
end
describe "rabbit ha" do
describe 'rabbit ha' do
before do
@chef_run = ::ChefSpec::Runner.new(::UBUNTU_OPTS) do |n|
n.set["openstack"]["mq"]["compute"]["rabbit"]["ha"] = true
n.set["cpu"] = {
"total" => "2"
n.set['openstack']['mq']['compute']['rabbit']['ha'] = true
n.set['cpu'] = {
'total' => '2'
}
end
@chef_run.converge "openstack-compute::nova-common"
@chef_run.converge 'openstack-compute::nova-common'
end
[/^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)
end
end
[/^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)
end
end
end
end
describe 'rootwrap.conf' do
before { @filename = '/etc/nova/rootwrap.conf' }
# describe "identity role local node" 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
it 'creates the /etc/nova/rootwrap.conf file' do
expect(@chef_run).to create_template(@filename).with(
user: "root",
group: "root",
user: 'root',
group: 'root',
mode: 0644
)
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
end
describe "/root/openrc" do
before { @filename = "/root/openrc" }
describe '/root/openrc' do
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(
user: "root",
group: "root",
user: 'root',
group: 'root',
mode: 0600
)
end
[/^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)
end
end
it "has misc option" do
@chef_run.node.set['openstack']['compute']['misc_openrc'] = ["MISC_OPTION", "FOO"]
it 'has misc option' do
@chef_run.node.set['openstack']['compute']['misc_openrc'] = ['MISC_OPTION', 'FOO']
expect(@chef_run).to render_file(@filename).with_content(
"MISC_OPTION")
'MISC_OPTION')
end
it "rest of template contents" do
pending "TODO: implement"
it 'rest of template contents' do
pending 'TODO: implement'
end
end
it "enables nova login" do
expect(@chef_run).to run_execute("usermod -s /bin/sh nova")
it 'enables nova login' do
expect(@chef_run).to run_execute('usermod -s /bin/sh nova')
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::nova-setup"
@chef_run.converge 'openstack-compute::nova-setup'
end
expect_runs_nova_common_recipe
it "runs db migrations" do
expect(@chef_run).to run_execute("nova-manage db sync")
it 'runs db migrations' do
expect(@chef_run).to run_execute('nova-manage db sync')
end
it "adds nova network ipv4 addresses" do
cmd = ["nova-manage network create --label=public",
"--fixed_range_v4=192.168.100.0/24",
"--multi_host='T'",
"--num_networks=1",
"--network_size=255",
"--bridge=br100",
"--bridge_interface=eth2",
"--dns1=8.8.8.8",
"--dns2=8.8.4.4"].join(' ')
it 'adds nova network ipv4 addresses' do
cmd = ['nova-manage network create --label=public',
'--fixed_range_v4=192.168.100.0/24',
"--multi_host='T'",
'--num_networks=1',
'--network_size=255',
'--bridge=br100',
'--bridge_interface=eth2',
'--dns1=8.8.8.8',
'--dns2=8.8.4.4'].join(' ')
expect(@chef_run).to run_execute(cmd)
end
it "add_floaters.py has proper modes" do
file = @chef_run.cookbook_file "/usr/local/bin/add_floaters.py"
expect(sprintf("%o", file.mode)).to eq "755"
it 'add_floaters.py has proper modes' do
file = @chef_run.cookbook_file '/usr/local/bin/add_floaters.py'
expect(sprintf('%o', file.mode)).to eq '755'
end
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.converge "openstack-compute::nova-setup"
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.converge 'openstack-compute::nova-setup'
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
it "adds range of floating ipv4 addresses" do
@chef_run.node.set["openstack"]["compute"]["network"] = {
"floating" => {
"ipv4_range" => "10.10.10.1,10.10.10.5"
it 'adds range of floating ipv4 addresses' do
@chef_run.node.set['openstack']['compute']['network'] = {
'floating' => {
'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
context "when neutron is used" do
context 'when neutron is used' do
before do
@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"]["public_network_name"] = "public"
@chef_run.converge "openstack-compute::nova-setup"
@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']['public_network_name'] = 'public'
@chef_run.converge 'openstack-compute::nova-setup'
end
it "installs the neutron python packages" do
expect(@chef_run).to upgrade_package("python-neutronclient")
expect(@chef_run).to upgrade_package("python-pyparsing")
it 'installs the neutron python packages' do
expect(@chef_run).to upgrade_package('python-neutronclient')
expect(@chef_run).to upgrade_package('python-pyparsing')
end
it "adds cidr range of floating ipv4 addresses to neutron" do
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")
it 'adds cidr range of floating ipv4 addresses to neutron' do
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')
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::scheduler"
@chef_run.converge 'openstack-compute::scheduler'
end
it "installs nova scheduler packages" do
expect(@chef_run).to upgrade_package "openstack-nova-scheduler"
it 'installs nova scheduler packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-scheduler'
end
it "starts nova scheduler" do
expect(@chef_run).to start_service "openstack-nova-scheduler"
it 'starts nova scheduler' do
expect(@chef_run).to start_service 'openstack-nova-scheduler'
end
it "starts nova scheduler on boot" do
expected = "openstack-nova-scheduler"
it 'starts nova scheduler on boot' do
expected = 'openstack-nova-scheduler'
expect(@chef_run).to enable_service expected
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::scheduler"
@chef_run.converge 'openstack-compute::scheduler'
end
expect_runs_nova_common_recipe
expect_creates_nova_lock_dir
it "installs nova scheduler packages" do
expect(@chef_run).to upgrade_package "nova-scheduler"
it 'installs nova scheduler packages' do
expect(@chef_run).to upgrade_package 'nova-scheduler'
end
it "starts nova scheduler" do
expect(@chef_run).to start_service "nova-scheduler"
it 'starts nova scheduler' do
expect(@chef_run).to start_service 'nova-scheduler'
end
it "starts nova scheduler on boot" do
expect(@chef_run).to enable_service "nova-scheduler"
it 'starts nova scheduler on boot' do
expect(@chef_run).to enable_service 'nova-scheduler'
end
end
end

View File

@ -1,32 +1,34 @@
require "chefspec"
require "chefspec/berkshelf"
require "chef/application"
# encoding: UTF-8
require 'chefspec'
require 'chefspec/berkshelf'
require 'chef/application'
::LOG_LEVEL = :fatal
::OPENSUSE_OPTS = {
:platform => "opensuse",
:version => "12.3",
:log_level => ::LOG_LEVEL
platform: 'opensuse',
version: '12.3',
log_level: ::LOG_LEVEL
}
::REDHAT_OPTS = {
:platform => "redhat",
:version => "6.3",
:log_level => ::LOG_LEVEL
platform: 'redhat',
version: '6.3',
log_level: ::LOG_LEVEL
}
::UBUNTU_OPTS = {
:platform => "ubuntu",
:version => "12.04",
:log_level => ::LOG_LEVEL
platform: 'ubuntu',
version: '12.04',
log_level: ::LOG_LEVEL
}
def compute_stubs
::Chef::Recipe.any_instance.stub(:rabbit_servers).
and_return "1.1.1.1:5672,2.2.2.2:5672"
::Chef::Recipe.any_instance.stub(:address_for).
with("lo").
and_return "127.0.1.1"
::Chef::Recipe.any_instance.stub(:search_for).
with("os-identity").and_return(
def compute_stubs # rubocop:disable MethodLength
::Chef::Recipe.any_instance.stub(:rabbit_servers)
.and_return '1.1.1.1:5672,2.2.2.2:5672'
::Chef::Recipe.any_instance.stub(:address_for)
.with('lo')
.and_return '127.0.1.1'
::Chef::Recipe.any_instance.stub(:search_for)
.with('os-identity').and_return(
[{
'openstack' => {
'identity' => {
@ -36,78 +38,78 @@ def compute_stubs
}
}]
)
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
::Chef::Recipe.any_instance.stub(:secret).
with("secrets", "neutron_metadata_secret").
and_return "metadata-secret"
::Chef::Recipe.any_instance.stub(:get_password).
and_return String.new
::Chef::Recipe.any_instance.stub(:get_password).
with("user", "guest").
and_return "rabbit-pass"
::Chef::Recipe.any_instance.stub(:get_password).
with("user", "admin").
and_return "admin"
::Chef::Recipe.any_instance.stub(:get_password).
with("service", "openstack-compute").
and_return "nova-pass"
::Chef::Recipe.any_instance.stub(:get_password).
with("service", "openstack-network").
and_return "neutron-pass"
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'openstack_identity_bootstrap_token')
.and_return 'bootstrap-token'
::Chef::Recipe.any_instance.stub(:secret)
.with('secrets', 'neutron_metadata_secret')
.and_return 'metadata-secret'
::Chef::Recipe.any_instance.stub(:get_password)
.and_return ''
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'guest')
.and_return 'rabbit-pass'
::Chef::Recipe.any_instance.stub(:get_password)
.with('user', 'admin')
.and_return 'admin'
::Chef::Recipe.any_instance.stub(:get_password)
.with('service', 'openstack-compute')
.and_return 'nova-pass'
::Chef::Recipe.any_instance.stub(:get_password)
.with('service', 'openstack-network')
.and_return 'neutron-pass'
::Chef::Recipe.any_instance.stub(:memcached_servers).and_return []
::Chef::Recipe.any_instance.stub(:system).
with("grub2-set-default 'openSUSE GNU/Linux, with Xen hypervisor'").
and_return true
::Chef::Recipe.any_instance.stub(:system)
.with("grub2-set-default 'openSUSE GNU/Linux, with Xen hypervisor'")
.and_return true
::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.200.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 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-tun'").and_return(true)
end
def expect_runs_nova_common_recipe
it "installs nova-common" do
expect(@chef_run).to include_recipe "openstack-compute::nova-common"
it 'installs nova-common' do
expect(@chef_run).to include_recipe 'openstack-compute::nova-common'
end
end
def expect_installs_python_keystone
it "installs python-keystone" do
expect(@chef_run).to upgrade_package "python-keystone"
it 'installs python-keystone' do
expect(@chef_run).to upgrade_package 'python-keystone'
end
end
def expect_creates_nova_lock_dir
it "creates the /var/lock/nova directory" do
expect(@chef_run).to create_directory("/var/lock/nova").with(
user: "nova",
group: "nova",
it 'creates the /var/lock/nova directory' do
expect(@chef_run).to create_directory('/var/lock/nova').with(
user: 'nova',
group: 'nova',
mode: 0700
)
end
end
def expect_creates_api_paste service, action=:restart
describe "/etc/nova/api-paste.ini" do
before { @filename = "/etc/nova/api-paste.ini" }
it "creates api-paste.ini" do
def expect_creates_api_paste(service, action = :restart) # rubocop:disable MethodLength
describe '/etc/nova/api-paste.ini' do
before { @filename = '/etc/nova/api-paste.ini' }
it 'creates api-paste.ini' do
expect(@chef_run).to create_template(@filename).with(
user: "nova",
group: "nova",
user: 'nova',
group: 'nova',
mode: 0644,
)
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
it "notifies #{service} #{action}" do
expect(@chef_run.template("/etc/nova/api-paste.ini")).to notify(service).to(action)
it 'notifies #{service} #{action}' do
expect(@chef_run.template('/etc/nova/api-paste.ini')).to notify(service).to(action)
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 }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-compute::vncproxy"
@chef_run.converge 'openstack-compute::vncproxy'
end
expect_runs_nova_common_recipe
it "installs nova vncproxy packages" do
expect(@chef_run).to upgrade_package "openstack-nova-novncproxy"
it 'installs nova vncproxy packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-novncproxy'
end
it "installs nova consoleauth packages" do
expect(@chef_run).to upgrade_package "openstack-nova-console"
it 'installs nova consoleauth packages' do
expect(@chef_run).to upgrade_package 'openstack-nova-console'
end
it "starts nova vncproxy" do
expect(@chef_run).to start_service "openstack-nova-novncproxy"
it 'starts nova vncproxy' do
expect(@chef_run).to start_service 'openstack-nova-novncproxy'
end
it "starts nova vncproxy on boot" do
expected = "openstack-nova-novncproxy"
it 'starts nova vncproxy on boot' do
expected = 'openstack-nova-novncproxy'
expect(@chef_run).to enable_service expected
end
it "starts nova consoleauth" do
expect(@chef_run).to start_service "openstack-nova-consoleauth"
it 'starts nova consoleauth' do
expect(@chef_run).to start_service 'openstack-nova-consoleauth'
end
it "starts nova consoleauth on boot" do
expected = "openstack-nova-consoleauth"
it 'starts nova consoleauth on boot' do
expected = 'openstack-nova-consoleauth'
expect(@chef_run).to enable_service expected
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 }
describe "ubuntu" do
describe 'ubuntu' do
before do
@chef_run = ::ChefSpec::Runner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-compute::vncproxy"
@chef_run.converge 'openstack-compute::vncproxy'
end
expect_runs_nova_common_recipe
it "installs nova vncproxy packages" do
expect(@chef_run).to upgrade_package "novnc"
expect(@chef_run).to upgrade_package "websockify"
expect(@chef_run).to upgrade_package "nova-novncproxy"
it 'installs nova vncproxy packages' do
expect(@chef_run).to upgrade_package 'novnc'
expect(@chef_run).to upgrade_package 'websockify'
expect(@chef_run).to upgrade_package 'nova-novncproxy'
end
it "installs nova consoleauth packages" do
expect(@chef_run).to upgrade_package "nova-consoleauth"
it 'installs nova consoleauth packages' do
expect(@chef_run).to upgrade_package 'nova-consoleauth'
end
it "starts nova vncproxy" do
expect(@chef_run).to start_service "nova-novncproxy"
it 'starts nova vncproxy' do
expect(@chef_run).to start_service 'nova-novncproxy'
end
it "starts nova vncproxy on boot" do
expect(@chef_run).to enable_service "nova-novncproxy"
it 'starts nova vncproxy on boot' do
expect(@chef_run).to enable_service 'nova-novncproxy'
end
it "starts nova consoleauth" do
expect(@chef_run).to start_service "nova-consoleauth"
it 'starts nova consoleauth' do
expect(@chef_run).to start_service 'nova-consoleauth'
end
it "starts nova consoleauth on boot" do
expect(@chef_run).to enable_service "nova-consoleauth"
it 'starts nova consoleauth on boot' do
expect(@chef_run).to enable_service 'nova-consoleauth'
end
end
end