Clearer registraton LWRP tests

This is a much clearer way to test LWRPs are executed with
the proper options.  The previous approach was hacky, and
relied upon too much stubbing and ruby magik.  Also, updated
to berkshelf 2.0 where Berksfile.lock is respected.  This
is necessary for berkshelf to lock to the proper cookbook
deps in openstack's CI system.

Change-Id: I21c1c000581f2d3c94ff2f9628f0cea0f6536013
This commit is contained in:
John Dewey
2013-06-08 21:56:38 -07:00
parent 1b08dc7153
commit 2f7915360a
5 changed files with 165 additions and 122 deletions

1
.gitignore vendored
View File

@@ -1,2 +1 @@
.bundle/ .bundle/
Berksfile.lock

68
Berksfile.lock Normal file
View File

@@ -0,0 +1,68 @@
{
"sha": "ba71763fac936d414bd4a63f004357f86f6e1bfb",
"sources": {
"openstack-block-storage": {
"locked_version": "7.0.0",
"constraint": "= 7.0.0",
"path": "."
},
"openstack-image": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-image.git",
"ref": "5cc19cee1cb0becba653cdf7781e492bbe5f84e7"
},
"openstack-identity": {
"locked_version": "7.0.0",
"git": "git://github.com/stackforge/cookbook-openstack-identity.git",
"ref": "a1ae0fd1d2bba23975b3c6852411383be982faa5"
},
"openstack-common": {
"locked_version": "0.2.6",
"git": "git://github.com/stackforge/cookbook-openstack-common.git",
"ref": "f8781d13de30fb3a191e97e91b13a3ccac139d6f"
},
"apt": {
"locked_version": "1.10.0"
},
"database": {
"locked_version": "1.4.0"
},
"mysql": {
"locked_version": "3.0.0",
"constraint": ">= 1.3.0"
},
"openssl": {
"locked_version": "1.0.2"
},
"build-essential": {
"locked_version": "1.4.0"
},
"postgresql": {
"locked_version": "3.0.0",
"constraint": ">= 1.0.0"
},
"aws": {
"locked_version": "0.101.0"
},
"xfs": {
"locked_version": "1.1.0"
},
"openssh": {
"locked_version": "1.1.4"
},
"rabbitmq": {
"locked_version": "2.1.0"
},
"erlang": {
"locked_version": "1.3.0",
"constraint": ">= 0.9.0"
},
"yum": {
"locked_version": "2.2.2",
"constraint": ">= 0.5.0"
},
"selinux": {
"locked_version": "0.5.6"
}
}
}

View File

@@ -2,7 +2,7 @@ source "https://rubygems.org"
gem "chef", "~> 11.4.4" gem "chef", "~> 11.4.4"
gem "json", "<= 1.7.7" # chef 11 dependency gem "json", "<= 1.7.7" # chef 11 dependency
gem "berkshelf", "~> 1.4.5" gem "berkshelf", "~> 2.0.3"
gem "chefspec", "~> 1.3.0" gem "chefspec", "~> 1.3.0"
gem "foodcritic" gem "foodcritic"
gem "strainer" gem "strainer"

View File

@@ -8,26 +8,25 @@ GEM
akami (1.2.0) akami (1.2.0)
gyoku (>= 0.4.0) gyoku (>= 0.4.0)
nokogiri (>= 1.4.0) nokogiri (>= 1.4.0)
berkshelf (1.4.5) berkshelf (2.0.3)
activesupport (>= 3.2.0) activesupport (>= 3.2.0)
addressable addressable (~> 2.3.4)
celluloid (>= 0.14.0) celluloid (>= 0.14.0)
chozo (>= 0.6.1) chozo (>= 0.6.1)
faraday (>= 0.8.5) faraday (>= 0.8.5)
hashie (>= 2.0.2) hashie (>= 2.0.2)
json (>= 1.5.0) minitar (~> 0.5.4)
minitar retryable (~> 1.3.3)
mixlib-config (~> 1.1) ridley (~> 1.0.2)
mixlib-shellout (~> 1.1) solve (>= 0.4.4)
multi_json (~> 1.5) test-kitchen (>= 1.0.0.alpha7)
retryable
ridley (~> 0.12.4)
solve (>= 0.4.2)
thor (~> 0.18.0) thor (~> 0.18.0)
yajl-ruby
builder (3.2.2) builder (3.2.2)
celluloid (0.14.1) celluloid (0.14.1)
timers (>= 1.0.0) timers (>= 1.0.0)
celluloid-io (0.14.1)
celluloid (>= 0.14.1)
nio4r (>= 0.4.5)
chef (11.4.4) chef (11.4.4)
erubis erubis
highline (>= 1.6.9) highline (>= 1.6.9)
@@ -42,7 +41,7 @@ GEM
ohai (>= 0.6.0) ohai (>= 0.6.0)
rest-client (>= 1.0.4, < 1.7.0) rest-client (>= 1.0.4, < 1.7.0)
yajl-ruby (~> 1.1) yajl-ruby (~> 1.1)
chefspec (1.3.0) chefspec (1.3.1)
chef (>= 10.0) chef (>= 10.0)
erubis erubis
fauxhai (>= 0.1.1, < 2.0) fauxhai (>= 0.1.1, < 2.0)
@@ -54,6 +53,7 @@ GEM
multi_json (>= 1.3.0) multi_json (>= 1.3.0)
ci_reporter (1.8.4) ci_reporter (1.8.4)
builder (>= 2.1.2) builder (>= 2.1.2)
coderay (1.0.9)
diff-lcs (1.2.4) diff-lcs (1.2.4)
erubis (2.7.0) erubis (2.7.0)
faraday (0.8.7) faraday (0.8.7)
@@ -62,7 +62,7 @@ GEM
httparty httparty
net-ssh net-ssh
ohai ohai
ffi (1.8.1) ffi (1.9.0)
foodcritic (2.1.0) foodcritic (2.1.0)
erubis erubis
gherkin (~> 2.11.7) gherkin (~> 2.11.7)
@@ -91,6 +91,7 @@ GEM
log_switch (0.4.0) log_switch (0.4.0)
logging (1.6.2) logging (1.6.2)
little-plugger (>= 1.1.3) little-plugger (>= 1.1.3)
method_source (0.8.1)
mime-types (1.23) mime-types (1.23)
minitar (0.5.4) minitar (0.5.4)
minitest (4.7.4) minitest (4.7.4)
@@ -108,13 +109,16 @@ GEM
multi_xml (0.5.4) multi_xml (0.5.4)
multipart-post (1.2.0) multipart-post (1.2.0)
net-http-persistent (2.8) net-http-persistent (2.8)
net-scp (1.1.1)
net-ssh (>= 2.6.5)
net-ssh (2.6.7) net-ssh (2.6.7)
net-ssh-gateway (1.2.0) net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5) net-ssh (>= 2.6.5)
net-ssh-multi (1.1) net-ssh-multi (1.1)
net-ssh (>= 2.1.4) net-ssh (>= 2.1.4)
net-ssh-gateway (>= 0.99.0) net-ssh-gateway (>= 0.99.0)
nokogiri (1.5.9) nio4r (0.4.6)
nokogiri (1.5.10)
nori (1.1.5) nori (1.1.5)
ohai (6.16.0) ohai (6.16.0)
ipaddress ipaddress
@@ -125,22 +129,24 @@ GEM
systemu systemu
yajl-ruby yajl-ruby
polyglot (0.3.3) polyglot (0.3.3)
pry (0.9.12.2)
coderay (~> 1.0.5)
method_source (~> 0.8)
slop (~> 3.4)
rack (1.5.2) rack (1.5.2)
rak (1.4) rak (1.4)
rest-client (1.6.7) rest-client (1.6.7)
mime-types (>= 1.16) mime-types (>= 1.16)
retryable (1.3.3) retryable (1.3.3)
ridley (0.12.4) ridley (1.0.2)
addressable addressable
celluloid (~> 0.14.0) celluloid (~> 0.14.0)
celluloid-io (~> 0.14.0)
chozo (>= 0.6.0) chozo (>= 0.6.0)
erubis erubis
faraday (>= 0.8.4) faraday (>= 0.8.4)
hashie (>= 2.0.2) hashie (>= 2.0.2)
mixlib-authentication (>= 1.3.0) mixlib-authentication (>= 1.3.0)
mixlib-config (>= 1.1.0)
mixlib-log (>= 1.3.0)
mixlib-shellout (>= 1.1.0)
net-http-persistent (>= 2.8) net-http-persistent (>= 2.8)
net-ssh net-ssh
retryable retryable
@@ -155,6 +161,7 @@ GEM
diff-lcs (>= 1.1.3, < 2.0) diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.13.1) rspec-mocks (2.13.1)
rubyntlm (0.1.1) rubyntlm (0.1.1)
safe_yaml (0.9.3)
savon (0.9.5) savon (0.9.5)
akami (~> 1.0) akami (~> 1.0)
builder (>= 2.1.2) builder (>= 2.1.2)
@@ -163,10 +170,11 @@ GEM
nokogiri (>= 1.4.0) nokogiri (>= 1.4.0)
nori (~> 1.0) nori (~> 1.0)
wasabi (~> 1.0) wasabi (~> 1.0)
slop (3.4.5)
solve (0.4.4) solve (0.4.4)
json json
strainer (2.1.0) strainer (3.0.1)
berkshelf (~> 1.3) berkshelf (~> 2.0)
systemu (2.5.2) systemu (2.5.2)
tailor (1.2.1) tailor (1.2.1)
log_switch (>= 0.3.0) log_switch (>= 0.3.0)
@@ -174,6 +182,14 @@ GEM
text-table (>= 1.2.2) text-table (>= 1.2.2)
term-ansicolor (1.2.2) term-ansicolor (1.2.2)
tins (~> 0.8) tins (~> 0.8)
test-kitchen (1.0.0.alpha.7)
celluloid
mixlib-shellout
net-scp
net-ssh
pry
safe_yaml
thor
text-table (1.2.3) text-table (1.2.3)
thor (0.18.1) thor (0.18.1)
timers (1.1.0) timers (1.1.0)
@@ -198,7 +214,7 @@ PLATFORMS
ruby ruby
DEPENDENCIES DEPENDENCIES
berkshelf (~> 1.4.5) berkshelf (~> 2.0.3)
chef (~> 11.4.4) chef (~> 11.4.4)
chefspec (~> 1.3.0) chefspec (~> 1.3.0)
foodcritic foodcritic

View File

@@ -3,120 +3,80 @@ require_relative "spec_helper"
describe "openstack-block-storage::identity_registration" do describe "openstack-block-storage::identity_registration" do
before do before do
block_storage_stubs block_storage_stubs
@identity_register_mock = double "identity_register" @chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS
@chef_run.converge "openstack-block-storage::identity_registration"
end end
it "registers cinder volume service" do it "registers cinder volume service" do
::Chef::Recipe.any_instance.stub(:openstack_identity_register) resource = @chef_run.find_resource(
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register). "openstack-identity_register",
with("Register Cinder Volume Service") do |&arg| "Register Cinder Volume Service"
@identity_register_mock.should_receive(:auth_uri). ).to_hash
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:service_name).
with "cinder"
@identity_register_mock.should_receive(:service_type).
with "volume"
@identity_register_mock.should_receive(:service_description).
with "Cinder Volume Service"
@identity_register_mock.should_receive(:endpoint_region).
with "RegionOne"
@identity_register_mock.should_receive(:endpoint_adminurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_internalurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_publicurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:action).
with :create_service
@identity_register_mock.instance_eval &arg expect(resource).to include(
end :auth_uri => "https://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS :service_name => "cinder",
chef_run.converge "openstack-block-storage::identity_registration" :service_type => "volume",
:service_description => "Cinder Volume Service",
:endpoint_region => "RegionOne",
:endpoint_adminurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:endpoint_internalurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:endpoint_publicurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:action => [:create_service]
)
end end
it "registers cinder volume endpoint" do it "registers cinder volume endpoint" do
::Chef::Recipe.any_instance.stub(:openstack_identity_register) resource = @chef_run.find_resource(
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register). "openstack-identity_register",
with("Register Cinder Volume Endpoint") do |&arg| "Register Cinder Volume Endpoint"
@identity_register_mock.should_receive(:auth_uri). ).to_hash
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:service_name).
with "cinder"
@identity_register_mock.should_receive(:service_type).
with "volume"
@identity_register_mock.should_receive(:service_description).
with "Cinder Volume Service"
@identity_register_mock.should_receive(:endpoint_region).
with "RegionOne"
@identity_register_mock.should_receive(:endpoint_adminurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_internalurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:endpoint_publicurl).
with "https://127.0.0.1:8776/v1/%(tenant_id)s"
@identity_register_mock.should_receive(:action).
with :create_endpoint
@identity_register_mock.instance_eval &arg expect(resource).to include(
end :auth_uri => "https://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS :service_name => "cinder",
chef_run.converge "openstack-block-storage::identity_registration" :service_type => "volume",
:service_description => "Cinder Volume Service",
:endpoint_region => "RegionOne",
:endpoint_adminurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:endpoint_internalurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:endpoint_publicurl => "https://127.0.0.1:8776/v1/%(tenant_id)s",
:action => [:create_endpoint]
)
end end
it "registers service user" do it "registers service user" do
::Chef::Recipe.any_instance.stub(:openstack_identity_register) resource = @chef_run.find_resource(
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register). "openstack-identity_register",
with("Register Cinder Service User") do |&arg| "Register Cinder Service User"
@identity_register_mock.should_receive(:auth_uri). ).to_hash
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:tenant_name).
with "service"
@identity_register_mock.should_receive(:user_name).
with "cinder"
@identity_register_mock.should_receive(:user_pass).
with "cinder-pass"
@identity_register_mock.should_receive(:user_enabled).
with true
@identity_register_mock.should_receive(:action).
with :create_user
@identity_register_mock.instance_eval &arg expect(resource).to include(
end :auth_uri => "https://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS :tenant_name => "service",
chef_run.converge "openstack-block-storage::identity_registration" :user_name => "cinder",
:user_pass => "cinder-pass",
:user_enabled => true,
: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
::Chef::Recipe.any_instance.stub(:openstack_identity_register) resource = @chef_run.find_resource(
::Chef::Recipe.any_instance.should_receive(:openstack_identity_register). "openstack-identity_register",
with("Grant service Role to Cinder Service User for Cinder Service Tenant") do |&arg| "Grant service Role to Cinder Service User for Cinder Service Tenant"
@identity_register_mock.should_receive(:auth_uri). ).to_hash
with "https://127.0.0.1:35357/v2.0"
@identity_register_mock.should_receive(:bootstrap_token).
with "bootstrap-token"
@identity_register_mock.should_receive(:tenant_name).
with "service"
@identity_register_mock.should_receive(:user_name).
with "cinder"
@identity_register_mock.should_receive(:role_name).
with "admin"
@identity_register_mock.should_receive(:action).
with :grant_role
@identity_register_mock.instance_eval &arg expect(resource).to include(
end :auth_uri => "https://127.0.0.1:35357/v2.0",
:bootstrap_token => "bootstrap-token",
chef_run = ::ChefSpec::ChefRunner.new ::UBUNTU_OPTS :tenant_name => "service",
chef_run.converge "openstack-block-storage::identity_registration" :user_name => "cinder",
:role_name => "admin",
:action => [:grant_role]
)
end end
end end