Update specs to be rubocop compliant

It appears orchestration was missing in the rubocop blueprints. Bringing it
up to par with the other cookbooks.

- Update rubocop config to include spec/**
- Update specs to comply with rubocop
- Delete unused default spec file

Change-Id: Ie96c16fc82a4ca2c04e20fc7db2b036937f0ba04
This commit is contained in:
Christopher H. Laco 2014-02-04 17:02:09 -05:00
parent bb4a576b7c
commit 27bdc745f2
9 changed files with 194 additions and 194 deletions

View File

@ -7,7 +7,6 @@ AllCops:
- providers/**
- recipes/**
- resources/**
Excludes:
- spec/**
Encoding:

View File

@ -1,29 +1,30 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::api-cfn" do
describe 'openstack-orchestration::api-cfn' do
before { orchestration_stubs }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["orchestration"]["syslog"]["use"] = true
n.set['openstack']['orchestration']['syslog']['use'] = true
end
@chef_run.converge "openstack-orchestration::api-cfn"
@chef_run.converge 'openstack-orchestration::api-cfn'
end
expect_runs_openstack_orchestration_common_recipe
expect_runs_openstack_common_logging_recipe
it "installs heat client packages" do
expect(@chef_run).to upgrade_package "python-heatclient"
it 'installs heat client packages' do
expect(@chef_run).to upgrade_package 'python-heatclient'
end
expect_creates_api_paste "service[heat-api-cfn]"
expect_creates_api_paste 'service[heat-api-cfn]'
expect_creates_policy_json "service[heat-api-cfn]","heat","heat"
expect_creates_policy_json 'service[heat-api-cfn]', 'heat', 'heat'
it "starts heat api-cfn on boot" do
expect(@chef_run).to enable_service("openstack-heat-api-cfn")
it 'starts heat api-cfn on boot' do
expect(@chef_run).to enable_service('openstack-heat-api-cfn')
end
end
end

View File

@ -1,29 +1,30 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::api-cloudwatch" do
describe 'openstack-orchestration::api-cloudwatch' do
before { orchestration_stubs }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS do |n|
n.set["openstack"]["orchestration"]["syslog"]["use"] = true
n.set['openstack']['orchestration']['syslog']['use'] = true
end
@chef_run.converge "openstack-orchestration::api-cloudwatch"
@chef_run.converge 'openstack-orchestration::api-cloudwatch'
end
expect_runs_openstack_orchestration_common_recipe
expect_runs_openstack_common_logging_recipe
it "installs heat client packages" do
expect(@chef_run).to upgrade_package "python-heatclient"
it 'installs heat client packages' do
expect(@chef_run).to upgrade_package 'python-heatclient'
end
expect_creates_api_paste "service[heat-api-cloudwatch]"
expect_creates_api_paste 'service[heat-api-cloudwatch]'
expect_creates_policy_json "service[heat-api-cloudwatch]","heat","heat"
expect_creates_policy_json 'service[heat-api-cloudwatch]', 'heat', 'heat'
it "starts heat api-cloudwatch on boot" do
expect(@chef_run).to enable_service("openstack-heat-api-cloudwatch")
it 'starts heat api-cloudwatch on boot' do
expect(@chef_run).to enable_service('openstack-heat-api-cloudwatch')
end
end
end

View File

@ -1,29 +1,30 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::api" do
describe 'openstack-orchestration::api' do
before { orchestration_stubs }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-orchestration::api"
@chef_run.converge 'openstack-orchestration::api'
end
expect_runs_openstack_orchestration_common_recipe
it "doesn't run logging recipe" do
expect(@chef_run).not_to include_recipe "openstack-common::logging"
it 'does not run logging recipe' do
expect(@chef_run).not_to include_recipe 'openstack-common::logging'
end
it "installs heat client packages" do
expect(@chef_run).to upgrade_package "python-heatclient"
it 'installs heat client packages' do
expect(@chef_run).to upgrade_package 'python-heatclient'
end
expect_creates_api_paste "service[heat-api]"
expect_creates_api_paste 'service[heat-api]'
expect_creates_policy_json "service[heat-api]","heat","heat"
expect_creates_policy_json 'service[heat-api]', 'heat', 'heat'
it "starts heat api on boot" do
expect(@chef_run).to enable_service("openstack-heat-api")
it 'starts heat api on boot' do
expect(@chef_run).to enable_service('openstack-heat-api')
end
end
end

View File

@ -1,115 +1,115 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::common" do
describe 'openstack-orchestration::common' do
before { orchestration_stubs }
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-orchestration::common"
@chef_run.converge 'openstack-orchestration::common'
end
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
it "installs the openstack-heat package" do
expect(@chef_run).to upgrade_package "openstack-heat"
it 'installs the openstack-heat package' do
expect(@chef_run).to upgrade_package 'openstack-heat'
end
it "installs mysql python packages by default" do
expect(@chef_run).to upgrade_package "MySQL-python"
it 'installs mysql python packages by default' do
expect(@chef_run).to upgrade_package 'MySQL-python'
end
it "installs postgresql python packages if explicitly told" do
it 'installs postgresql python packages if explicitly told' do
chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
node = chef_run.node
node.set["openstack"]["db"]["orchestration"]["service_type"] = "postgresql"
chef_run.converge "openstack-orchestration::common"
node.set['openstack']['db']['orchestration']['service_type'] = 'postgresql'
chef_run.converge 'openstack-orchestration::common'
expect(chef_run).to upgrade_package "python-psycopg2"
expect(chef_run).not_to upgrade_package "MySQL-python"
expect(chef_run).to upgrade_package 'python-psycopg2'
expect(chef_run).not_to upgrade_package 'MySQL-python'
end
describe "/etc/heat" do
describe '/etc/heat' do
before do
@dir = @chef_run.directory "/etc/heat"
@dir = @chef_run.directory '/etc/heat'
end
it "has proper owner" do
expect(@dir.owner).to eq("heat")
it 'has proper owner' do
expect(@dir.owner).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "700"
it 'has proper modes' do
expect(sprintf('%o', @dir.mode)).to eq '700'
end
end
describe "/etc/heat/environment.d" do
describe '/etc/heat/environment.d' do
before do
@dir = @chef_run.directory "/etc/heat/environment.d"
@dir = @chef_run.directory '/etc/heat/environment.d'
end
it "has proper owner" do
expect(@dir.owner).to eq("heat")
it 'has proper owner' do
expect(@dir.owner).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "700"
it 'has proper modes' do
expect(sprintf('%o', @dir.mode)).to eq '700'
end
end
describe "/var/cache/heat" do
describe '/var/cache/heat' do
before do
@dir = @chef_run.directory "/var/cache/heat"
@dir = @chef_run.directory '/var/cache/heat'
end
it "has proper owner" do
expect(@dir.owner).to eq("heat")
it 'has proper owner' do
expect(@dir.owner).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @dir.mode)).to eq "700"
it 'has proper modes' do
expect(sprintf('%o', @dir.mode)).to eq '700'
end
end
describe "heat.conf" do
describe 'heat.conf' do
before do
@template = @chef_run.template "/etc/heat/heat.conf"
@template = @chef_run.template '/etc/heat/heat.conf'
end
it "has proper owner" do
expect(@template.owner).to eq("heat")
expect(@template.group).to eq("heat")
it 'has proper owner' do
expect(@template.owner).to eq('heat')
expect(@template.group).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @template.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
end
# Pending on https://review.openstack.org/#/c/59088/
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
end
describe "default.yaml" do
describe 'default.yaml' do
before do
@template = @chef_run.template "/etc/heat/environment.d/default.yaml"
@template = @chef_run.template '/etc/heat/environment.d/default.yaml'
end
it "has proper owner" do
expect(@template.owner).to eq("heat")
expect(@template.group).to eq("heat")
it 'has proper owner' do
expect(@template.owner).to eq('heat')
expect(@template.group).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @template.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
end
end
it "runs db migrations" do
cmd = "heat-manage db_sync"
it 'runs db migrations' do
cmd = 'heat-manage db_sync'
expect(@chef_run).to run_execute(cmd)
end
end

View File

@ -1,4 +0,0 @@
require_relative "spec_helper"
describe "openstack-orchestration::default" do
end

View File

@ -1,21 +1,22 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::engine" do
describe 'openstack-orchestration::engine' do
before { orchestration_stubs }
describe "redhat" do
describe 'redhat' do
before do
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-orchestration::engine"
@chef_run.converge 'openstack-orchestration::engine'
end
expect_runs_openstack_orchestration_common_recipe
it "doesn't run logging recipe" do
expect(@chef_run).not_to include_recipe "openstack-common::logging"
it 'does not run logging recipe' do
expect(@chef_run).not_to include_recipe 'openstack-common::logging'
end
it "starts heat engine on boot" do
expect(@chef_run).to enable_service("openstack-heat-engine")
it 'starts heat engine on boot' do
expect(@chef_run).to enable_service('openstack-heat-engine')
end
end
end

View File

@ -1,86 +1,85 @@
require_relative "spec_helper"
# encoding: UTF-8
require_relative 'spec_helper'
describe "openstack-orchestration::identity_registration" do
describe 'openstack-orchestration::identity_registration' do
before do
orchestration_stubs
@chef_run = ::ChefSpec::Runner.new ::REDHAT_OPTS
@chef_run.converge "openstack-orchestration::identity_registration"
@chef_run.converge 'openstack-orchestration::identity_registration'
end
it "Register Heat Orchestration Service" do
it 'Register Heat Orchestration Service' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Heat Orchestration Service"
'openstack-identity_register',
'Register Heat Orchestration Service'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_name => "heat",
:service_type => "orchestration",
:service_description => "Heat Orchestration Service",
:action => [:create_service]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'heat',
service_type: 'orchestration',
service_description: 'Heat Orchestration Service',
action: [:create_service]
)
end
# Pending on https://review.openstack.org/#/c/59088/
it "Register Heat Orchestration Endpoint" do
pending "TODO: implement"
it 'Register Heat Orchestration Endpoint' do
pending 'TODO: implement'
end
it "Register Heat Cloudformation Service" do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Heat Cloudformation Service"
it 'Register Heat Cloudformation Service' do
resource = @chef_run.find_resource(
'openstack-identity_register',
'Register Heat Cloudformation Service'
).to_hash
expect(resource).to include(
:auth_uri => "http://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
:service_name => "heat-cfn",
:service_type => "cloudformation",
:service_description => "Heat Cloudformation Service",
:action => [:create_service]
expect(resource).to include(
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
service_name: 'heat-cfn',
service_type: 'cloudformation',
service_description: 'Heat Cloudformation Service',
action: [:create_service]
)
end
# Pending on https://review.openstack.org/#/c/59088/
it "Register Heat Cloudformation Endpoint" do
pending "TODO: implement"
it 'Register Heat Cloudformation Endpoint' do
pending 'TODO: implement'
end
it "registers service user" do
it 'registers service user' do
resource = @chef_run.find_resource(
"openstack-identity_register",
"Register Heat Service User"
'openstack-identity_register',
'Register Heat 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 => "heat",
:user_pass => "heat-pass",
:user_enabled => true,
:action => [:create_user]
auth_uri: 'http://127.0.0.1:35357/v2.0',
bootstrap_token: 'bootstrap-token',
tenant_name: 'service',
user_name: 'heat',
user_pass: 'heat-pass',
user_enabled: true,
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 heat 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 => "heat",
: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: 'heat',
role_name: 'admin',
action: [:grant_role]
)
end

View File

@ -1,95 +1,97 @@
require "chefspec"
require "chefspec/berkshelf"
require "chef/application"
# encoding: UTF-8
require 'chefspec'
require 'chefspec/berkshelf'
require 'chef/application'
::LOG_LEVEL = :fatal
::REDHAT_OPTS = {
:platform => "redhat",
:version => "6.3",
:log_level => ::LOG_LEVEL
platform: 'redhat',
version: '6.3',
log_level: ::LOG_LEVEL
}
def orchestration_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(:secret).
with("secrets", "openstack_identity_bootstrap_token").
and_return "bootstrap-token"
::Chef::Recipe.any_instance.stub(:db_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).and_return String.new
::Chef::Recipe.any_instance.stub(:user_password).
with("guest").
and_return "rabbit-pass"
::Chef::Recipe.any_instance.stub(:user_password).
with("admin-user").
and_return "admin-pass"
::Chef::Recipe.any_instance.stub(:service_password).with("openstack-orchestration").
and_return "heat-pass"
# TDODO(chrislaco) factor these into shared_context/examples
def orchestration_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(:secret)
.with('secrets', 'openstack_identity_bootstrap_token')
.and_return 'bootstrap-token'
::Chef::Recipe.any_instance.stub(:db_password).and_return ''
::Chef::Recipe.any_instance.stub(:user_password).and_return ''
::Chef::Recipe.any_instance.stub(:user_password)
.with('guest')
.and_return 'rabbit-pass'
::Chef::Recipe.any_instance.stub(:user_password)
.with('admin-user')
.and_return 'admin-pass'
::Chef::Recipe.any_instance.stub(:service_password).with('openstack-orchestration')
.and_return 'heat-pass'
::Chef::Application.stub(:fatal!)
end
def expect_runs_openstack_orchestration_common_recipe
it "runs orchestration common recipe" do
expect(@chef_run).to include_recipe "openstack-orchestration::common"
it 'runs orchestration common recipe' do
expect(@chef_run).to include_recipe 'openstack-orchestration::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_runs_openstack_common_logging_recipe
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
end
def expect_creates_api_paste service, action=:restart
describe "api-paste.ini" do
def expect_creates_api_paste(service, action = :restart) # rubocop:disable MethodLength
describe 'api-paste.ini' do
before do
@template = @chef_run.template "/etc/heat/api-paste.ini"
@template = @chef_run.template '/etc/heat/api-paste.ini'
end
it "has proper owner" do
expect(@template.owner).to eq("heat")
expect(@template.group).to eq("heat")
it 'has proper owner' do
expect(@template.owner).to eq('heat')
expect(@template.group).to eq('heat')
end
it "has proper modes" do
expect(sprintf("%o", @template.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
end
it "template contents" do
pending "TODO: implement"
it 'template contents' do
pending 'TODO: implement'
end
it "notifies heat-api restart" do
it 'notifies heat-api restart' do
expect(@template).to notify(service).to(action)
end
end
end
def expect_creates_policy_json service, user, group, action=:restart
describe "policy.json" do
def expect_creates_policy_json(service, user, group, action = :restart) # rubocop:disable MethodLength
describe 'policy.json' do
before do
@template = @chef_run.template "/etc/heat/policy.json"
@template = @chef_run.template '/etc/heat/policy.json'
end
it "has proper owner" do
it 'has proper owner' do
expect(@template.owner).to eq(user)
expect(@template.group).to eq(group)
end
it "has proper modes" do
expect(sprintf("%o", @template.mode)).to eq "644"
it 'has proper modes' do
expect(sprintf('%o', @template.mode)).to eq '644'
end
it "notifies service restart" do
it 'notifies service restart' do
expect(@template).to notify(service).to(action)
end
end