diff --git a/CHANGELOG.md b/CHANGELOG.md index fda81464..34985660 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # CHANGELOG for cookbook-openstack-common This file is used to list changes made in each version of cookbook-openstack-common. +## 10.0.0 +* Upgrading to Juno ## 9.7.0 * Add new network_uuid cli library method for obtaining ID from various neutron resources diff --git a/Strainerfile b/Strainerfile deleted file mode 100644 index 1c9a3e06..00000000 --- a/Strainerfile +++ /dev/null @@ -1,5 +0,0 @@ -# Strainerfile -rubocop: rubocop $SANDBOX/$COOKBOOK -knife test: knife cookbook test $COOKBOOK -foodcritic: foodcritic -f any -t ~FC003 -t ~FC023 $SANDBOX/$COOKBOOK -chefspec: rspec --format documentation $SANDBOX/$COOKBOOK/spec diff --git a/attributes/default.rb b/attributes/default.rb index 837d9cc3..b2e5b9a2 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -97,7 +97,7 @@ default['openstack']['secret']['user_passwords_data_bag'] = 'user_passwords' # needs. # The coordinated release of OpenStack codename -default['openstack']['release'] = 'icehouse' +default['openstack']['release'] = 'juno' # The Ubuntu Cloud Archive has packages for multiple Ubuntu releases. For # more information, see: https://wiki.ubuntu.com/ServerTeam/CloudArchive. @@ -114,8 +114,8 @@ default['openstack']['zypp']['repo-key'] = 'd85f9316' # 32 bit key ID default['openstack']['zypp']['uri'] = 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/%release%/%suse-release%/' default['openstack']['yum']['rdo_enabled'] = true -default['openstack']['yum']['uri'] = 'http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/epel-6' -default['openstack']['yum']['repo-key'] = 'https://raw.githubusercontent.com/redhat-openstack/rdo-release/master/RPM-GPG-KEY-RDO-Icehouse' +default['openstack']['yum']['uri'] = 'http://repos.fedorapeople.org/repos/openstack/openstack-juno/epel-6' +default['openstack']['yum']['repo-key'] = 'https://raw.githubusercontent.com/redhat-openstack/rdo-release/master/RPM-GPG-KEY-RDO-Juno' # ======================== OpenStack Endpoints ================================ # diff --git a/metadata.rb b/metadata.rb index 3e786934..7b10f8d9 100755 --- a/metadata.rb +++ b/metadata.rb @@ -4,7 +4,7 @@ maintainer_email 'cookbooks@lists.tfoundry.com' license 'Apache 2.0' description 'Common OpenStack attributes, libraries and recipes.' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '9.7.0' +version '10.0.0' recipe 'openstack-common', 'Installs/Configures common recipes' recipe 'openstack-common::set_endpoints_by_interface', 'Set endpoints by interface' diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 55102dba..41eebd92 100755 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -15,7 +15,7 @@ describe 'openstack-common::default' do describe 'openstack_command_env' do it 'returns cli enviroment' do - subject.stub(:get_password) + allow(subject).to receive(:get_password) .with('user', 'name') .and_return('pass') @@ -39,7 +39,7 @@ describe 'openstack-common::default' do 'OS_TENANT_NAME' => 'tenant', 'OS_AUTH_URL' => 'http://127.0.0.1:35357/v2.0' } - subject.stub(:shell_out).with( + allow(subject).to receive(:shell_out).with( ['keystone', 'user-list'], env: env ).and_return double('shell_out', exitstatus: 0, stdout: 'good', stderr: '') @@ -56,7 +56,7 @@ describe 'openstack-common::default' do 'OS_TENANT_NAME' => 'tenant', 'OS_AUTH_URL' => 'http://127.0.0.1:35357/v2.0' } - subject.stub(:shell_out).with( + allow(subject).to receive(:shell_out).with( %w(keystone user-list --key1 value1 --key2 value2), env: env ).and_return double('shell_out', exitstatus: 0, stdout: 'good', stderr: '') @@ -73,7 +73,7 @@ describe 'openstack-common::default' do 'OS_TENANT_NAME' => 'tenant', 'OS_AUTH_URL' => 'http://127.0.0.1:35357/v2.0' } - subject.stub(:shell_out).with( + allow(subject).to receive(:shell_out).with( ['keystone', 'user-list'], env: env ).and_return double('shell_out', exitstatus: 123, stdout: 'fail', stderr: '') @@ -92,8 +92,8 @@ describe 'openstack-common::default' do 'OS_TENANT_NAME' => 'tenant', 'OS_AUTH_URL' => 'http://127.0.0.1:35357/v2.0' } - subject.stub(:openstack_command).with('keystone', 'user-list', env, {}) - subject.stub(:prettytable_to_array) + allow(subject).to receive(:openstack_command).with('keystone', 'user-list', env, {}) + allow(subject).to receive(:prettytable_to_array) .and_return([{ 'name' => 'user1', 'id' => '1234567890ABCDEFGH' }]) result = subject.identity_uuid('user', 'name', 'user1', env) @@ -112,8 +112,8 @@ describe 'openstack-common::default' do end it 'runs glance command to query valid id' do - subject.stub(:openstack_command).with('glance', 'image-list', :env, {}) - subject.stub(:prettytable_to_array) + allow(subject).to receive(:openstack_command).with('glance', 'image-list', :env, {}) + allow(subject).to receive(:prettytable_to_array) .and_return([{ 'ID' => '87f38e15-9737-46cc-a612-7c67ee29a24f', 'Name' => 'cirros' }]) result = subject.image_id('cirros', :env) @@ -121,7 +121,7 @@ describe 'openstack-common::default' do end it 'runs glance command to query invalid id' do - subject.stub(:openstack_command).with('glance', 'image-list', :env, {}) + allow(subject).to receive(:openstack_command).with('glance', 'image-list', :env, {}) .and_raise("No image with a name or ID of 'test' exists. (1)") expect { subject.image_id('test', :env) }.to raise_error @@ -137,8 +137,8 @@ describe 'openstack-common::default' do 'OS_TENANT_NAME' => 'tenant', 'OS_AUTH_URL' => 'http://127.0.0.1:35357/v2.0' } - subject.stub(:openstack_command).with('neutron', 'net-list', env, {}) - subject.stub(:prettytable_to_array) + allow(subject).to receive(:openstack_command).with('neutron', 'net-list', env, {}) + allow(subject).to receive(:prettytable_to_array) .and_return([{ 'name' => 'net1', 'id' => '1234567890ABCDEFGH' }]) result = subject.network_uuid('net', 'name', 'net1', env) diff --git a/spec/database_spec.rb b/spec/database_spec.rb index 593d2d6f..4ce9482c 100644 --- a/spec/database_spec.rb +++ b/spec/database_spec.rb @@ -13,7 +13,7 @@ describe 'openstack-common::default' do describe '#db_create_with_user' do before do - subject.stub(:include_recipe) + allow(subject).to receive(:include_recipe) .with('database::mysql') .and_return('') end @@ -25,8 +25,8 @@ describe 'openstack-common::default' do end it 'returns db info and creates database with user when service found' do - subject.stub(:database).and_return({}) - subject.stub(:database_user).and_return({}) + allow(subject).to receive(:database).and_return({}) + allow(subject).to receive(:database_user).and_return({}) result = subject.db_create_with_user('compute', 'user', 'pass') expect(result['host']).to eq('127.0.0.1') expect(result['port']).to eq('3306') diff --git a/spec/default-redhat_spec.rb b/spec/default-redhat_spec.rb index 508e1690..7715bb4c 100644 --- a/spec/default-redhat_spec.rb +++ b/spec/default-redhat_spec.rb @@ -33,7 +33,7 @@ describe 'openstack-common::default' do end it 'removes RDO yum repository' do - ::FileTest.stub(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true) + allow(FileTest).to receive(:exist?).with('/etc/yum.repos.d/RDO-testrelease.repo').and_return(true) # Using cookbook(yum) LWRP custom matcher # https://github.com/sethvargo/chefspec#packaging-custom-matchers diff --git a/spec/default-suse_spec.rb b/spec/default-suse_spec.rb index d53b2c36..8d94cf32 100644 --- a/spec/default-suse_spec.rb +++ b/spec/default-suse_spec.rb @@ -12,17 +12,17 @@ describe 'openstack-common::default' do end it 'adds the openstack repository key, but not the repository' do - Mixlib::ShellOut.stub_chain( + allow(Mixlib::ShellOut).to receive_message_chain( new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil, new: 'zypper repos --export -').and_return( - 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Icehouse/SLE_11_SP3/') + 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Juno/SLE_11_SP3/') expect(chef_run).to run_bash('add repository key') expect(chef_run).not_to run_execute('add repository').with(command: /zypper addrepo/) end it 'adds the repository and the key' do - Mixlib::ShellOut.stub_chain( + allow(Mixlib::ShellOut).to receive_message_chain( new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil, new: 'zypper repos --export -').and_return('') @@ -30,15 +30,15 @@ describe 'openstack-common::default' do expect(chef_run).to run_execute('add repository').with( command: 'zypper addrepo --check '\ "http://download.opensuse.org/repositories/Cloud:/OpenStack:/#{node['openstack']['release'].capitalize}/SLE_11_SP3/ "\ - 'Cloud:OpenStack:Icehouse') + 'Cloud:OpenStack:Juno') end it 'does not add the repository nor the key' do - Mixlib::ShellOut.stub_chain( + allow(Mixlib::ShellOut).to receive_message_chain( new: 'rpm -qa gpg-pubkey', run_command: nil, stdout: nil, new: 'zypper repos --export -').and_return( 'd85f9316', - 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Icehouse/SLE_11_SP3/') + 'http://download.opensuse.org/repositories/Cloud:/OpenStack:/Juno/SLE_11_SP3/') expect(chef_run).not_to run_bash('add repository key') expect(chef_run).not_to run_execute('add repository').with(command: /zypper addrepo/) end diff --git a/spec/default_spec.rb b/spec/default_spec.rb index 3205ea76..4fc7b957 100644 --- a/spec/default_spec.rb +++ b/spec/default_spec.rb @@ -21,14 +21,14 @@ describe 'openstack-common::default' do node.set['openstack']['apt']['live_updates_enabled'] = true expect(chef_run).to add_apt_repository('openstack-ppa').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - components: ['precise-updates/icehouse', 'main']) + components: ['precise-updates/juno', 'main']) end it 'disables openstack live updates' do node.set['openstack']['apt']['live_updates_enabled'] = false expect(chef_run).to_not add_apt_repository('openstack-ppa').with( uri: 'http://ubuntu-cloud.archive.canonical.com/ubuntu', - components: ['precise-updates/icehouse', 'main']) + components: ['precise-updates/juno', 'main']) end end end diff --git a/spec/endpoints_spec.rb b/spec/endpoints_spec.rb index 3b7536e4..1d7a36de 100644 --- a/spec/endpoints_spec.rb +++ b/spec/endpoints_spec.rb @@ -12,14 +12,14 @@ describe 'openstack-common::set_endpoints_by_interface' do describe '#endpoint' do it 'returns nil when no openstack.endpoints not in node attrs' do - subject.stub(:node).and_return({}) + allow(subject).to receive(:node).and_return({}) expect( subject.endpoint('nonexisting') ).to be_nil end it 'returns nil when no such endpoint was found' do - subject.stub(:node).and_return(node) + allow(subject).to receive(:node).and_return(node) expect( subject.endpoint('nonexisting') ).to be_nil @@ -35,7 +35,7 @@ describe 'openstack-common::set_endpoints_by_interface' do } } } - subject.stub(:node).and_return(uri_hash) + allow(subject).to receive(:node).and_return(uri_hash) expect( subject.endpoint('compute-api').path ).to eq('/v2/%25(tenant_id)s') @@ -51,7 +51,7 @@ describe 'openstack-common::set_endpoints_by_interface' do } } } - subject.stub(:node).and_return(uri_hash) + allow(subject).to receive(:node).and_return(uri_hash) expect( subject.endpoint('compute-api').port ).to eq(8080) @@ -68,7 +68,7 @@ describe 'openstack-common::set_endpoints_by_interface' do } } } - subject.stub(:node).and_return(uri_hash) + allow(subject).to receive(:node).and_return(uri_hash) expect(subject.endpoint('compute-api').to_s).to eq('http://localhost') end @@ -85,7 +85,7 @@ describe 'openstack-common::set_endpoints_by_interface' do } } } - subject.stub(:node).and_return(uri_hash) + allow(subject).to receive(:node).and_return(uri_hash) subject.endpoint 'compute-api' end @@ -113,7 +113,7 @@ describe 'openstack-common::set_endpoints_by_interface' do } } } - subject.stub('address_for').and_return('10.0.0.100') + allow(subject).to receive('address_for').and_return('10.0.0.100') expect( chef_run.node['openstack']['endpoints']['identity-api']['host'] ).to eq('10.0.0.100') @@ -122,12 +122,12 @@ describe 'openstack-common::set_endpoints_by_interface' do describe '#endpoints' do it 'does nothing when no endpoints' do - subject.stub(:node).and_return({}) + allow(subject).to receive(:node).and_return({}) expect(subject.endpoints).to be_nil end it 'does nothing when empty endpoints' do - subject.stub(:node).and_return('openstack' => { 'endpoints' => {} }) + allow(subject).to receive(:node).and_return('openstack' => { 'endpoints' => {} }) count = 0 subject.endpoints do | ep | count += 1 @@ -136,7 +136,7 @@ describe 'openstack-common::set_endpoints_by_interface' do end it 'executes block count when have endpoints' do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) count = 0 subject.endpoints do |ep| count += 1 @@ -147,17 +147,17 @@ describe 'openstack-common::set_endpoints_by_interface' do describe '#db' do it 'returns nil when no openstack.db not in node attrs' do - subject.stub(:node).and_return({}) + allow(subject).to receive(:node).and_return({}) expect(subject.db('nonexisting')).to be_nil end it 'returns nil when no such service was found' do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expect(subject.db('nonexisting')).to be_nil end it 'returns db info hash when service found' do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expect(subject.db('compute')['host']).to eq('127.0.0.1') expect(subject.db('compute').key?('uri')).to be_falsey end @@ -165,19 +165,19 @@ describe 'openstack-common::set_endpoints_by_interface' do describe '#db_uri' do it 'returns nil when no openstack.db not in node attrs' do - subject.stub(:node).and_return({}) + allow(subject).to receive(:node).and_return({}) expect(subject.db_uri('nonexisting', 'user', 'pass')).to be_nil end it 'returns nil when no such service was found' do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expect( subject.db_uri('nonexisting', 'user', 'pass') ).to be_nil end it 'returns compute db info hash when service found for default mysql' do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expected = 'mysql://user:pass@127.0.0.1:3306/nova?charset=utf8' expect( subject.db_uri('compute', 'user', 'pass') @@ -188,7 +188,7 @@ describe 'openstack-common::set_endpoints_by_interface' do node.set['openstack']['db']['service_type'] = 'sqlite' node.set['openstack']['db']['options'] = { 'sqlite' => '?options' } node.set['openstack']['db']['network']['path'] = 'path' - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expected = 'sqlite:///path?options' expect( subject.db_uri('network', 'user', 'pass') @@ -198,7 +198,7 @@ describe 'openstack-common::set_endpoints_by_interface' do it 'returns block-storage db info hash when service found for db2 with options' do node.set['openstack']['db']['service_type'] = 'db2' node.set['openstack']['db']['options'] = { 'db2' => '?options' } - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expected = 'ibm_db_sa://user:pass@127.0.0.1:3306/cinder?options' expect( subject.db_uri('block-storage', 'user', 'pass') @@ -208,7 +208,7 @@ describe 'openstack-common::set_endpoints_by_interface' do it 'returns telemetry db info hash when service found for db2' do node.set['openstack']['db']['service_type'] = 'db2' node.set['openstack']['db']['telemetry']['nosql']['used'] = true - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expected = 'db2://user:pass@127.0.0.1:27017/ceilometer' expect( subject.db_uri('telemetry', 'user', 'pass') @@ -219,7 +219,7 @@ describe 'openstack-common::set_endpoints_by_interface' do node.set['openstack']['db']['service_type'] = 'db2' node.set['openstack']['db']['options'] = { 'nosql' => '?options' } node.set['openstack']['db']['telemetry']['nosql']['used'] = true - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expected = 'db2://user:pass@127.0.0.1:27017/ceilometer?options' expect( subject.db_uri('telemetry', 'user', 'pass') @@ -233,7 +233,7 @@ describe 'openstack-common::set_endpoints_by_interface' do 'bind_interface' => 'eth0', 'host' => '5.6.7.8' } - subject.stub('address_for').and_return('1.2.3.4') + allow(subject).to receive('address_for').and_return('1.2.3.4') expect( subject.address(ep_hash) ).to eq('1.2.3.4') @@ -243,7 +243,7 @@ describe 'openstack-common::set_endpoints_by_interface' do 'bind_interface' => nil, 'host' => '5.6.7.8' } - subject.stub('address_for').and_return('1.2.3.4') + allow(subject).to receive('address_for').and_return('1.2.3.4') expect( subject.address(ep_hash) ).to eq('5.6.7.8') diff --git a/spec/password_spec.rb b/spec/password_spec.rb index a3e7ba7e..f3f69e78 100644 --- a/spec/password_spec.rb +++ b/spec/password_spec.rb @@ -15,8 +15,8 @@ describe 'openstack-common::default' do describe '#secret' do it 'returns databag' do value = { 'nova' => 'this' } - ::Chef::EncryptedDataBagItem.stub(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') - ::Chef::EncryptedDataBagItem.stub(:load).with('passwords', 'nova', 'secret').and_return(value) + allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') + allow(Chef::EncryptedDataBagItem).to receive(:load).with('passwords', 'nova', 'secret').and_return(value) expect(subject.secret('passwords', 'nova')).to eq('this') end end @@ -24,16 +24,16 @@ describe 'openstack-common::default' do describe '#get_secret' do it 'returns databag value' do value = { 'nova' => 'this' } - ::Chef::EncryptedDataBagItem.stub(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') - ::Chef::EncryptedDataBagItem.stub(:load).with('secrets', 'nova', 'secret').and_return(value) + allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') + allow(Chef::EncryptedDataBagItem).to receive(:load).with('secrets', 'nova', 'secret').and_return(value) expect(subject.get_secret('nova')).to eq('this') end it 'returns secret from an alternate databag when secrets_data_bag set' do node.set['openstack']['secret']['secrets_data_bag'] = 'myothersecrets' value = { 'nova' => 'this' } - ::Chef::EncryptedDataBagItem.stub(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') - ::Chef::EncryptedDataBagItem.stub(:load).with('myothersecrets', 'nova', 'secret').and_return(value) + allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') + allow(Chef::EncryptedDataBagItem).to receive(:load).with('myothersecrets', 'nova', 'secret').and_return(value) expect(subject.get_secret('nova')).to eq('this') end end @@ -42,8 +42,8 @@ describe 'openstack-common::default' do ['service', 'db', 'user'].each do |type| it "returns databag value for #{type}" do value = { 'nova' => 'this' } - ::Chef::EncryptedDataBagItem.stub(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') - ::Chef::EncryptedDataBagItem.stub(:load).with("#{type}_passwords", 'nova', 'secret').and_return(value) + allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with('/etc/chef/openstack_data_bag_secret').and_return('secret') + allow(Chef::EncryptedDataBagItem).to receive(:load).with("#{type}_passwords", 'nova', 'secret').and_return(value) expect(subject.get_password(type, 'nova')).to eq('this') end end @@ -54,9 +54,9 @@ describe 'openstack-common::default' do it 'returns tokens from the secrets_data_bag' do bag_content = { 'nova' => 'mysecret' } - ::Chef::EncryptedDataBagItem.stub(:load_secret).with( + allow(Chef::EncryptedDataBagItem).to receive(:load_secret).with( '/etc/chef/openstack_data_bag_secret').and_return('secret') - ::Chef::EncryptedDataBagItem.stub(:load).with( + allow(Chef::EncryptedDataBagItem).to receive(:load).with( 'secrets', 'nova', 'secret').and_return(bag_content) expect(subject.get_password('token', 'nova')).to eq('mysecret') end @@ -68,7 +68,7 @@ describe 'openstack-common::default' do describe '#secret' do it 'returns databag' do value = { 'nova' => 'this' } - ::Chef::DataBagItem.stub(:load).with('passwords', 'nova').and_return(value) + allow(Chef::DataBagItem).to receive(:load).with('passwords', 'nova').and_return(value) expect(subject.secret('passwords', 'nova')).to eq('this') end end @@ -76,14 +76,14 @@ describe 'openstack-common::default' do describe '#get_secret' do it 'returns databag value' do value = { 'nova' => 'this' } - ::Chef::DataBagItem.stub(:load).with('secrets', 'nova').and_return(value) + allow(Chef::DataBagItem).to receive(:load).with('secrets', 'nova').and_return(value) expect(subject.get_secret('nova')).to eq('this') end it 'returns secret from an alternate databag when secrets_data_bag set' do node.set['openstack']['secret']['secrets_data_bag'] = 'myothersecrets' value = { 'nova' => 'this' } - ::Chef::DataBagItem.stub(:load).with('myothersecrets', 'nova').and_return(value) + allow(Chef::DataBagItem).to receive(:load).with('myothersecrets', 'nova').and_return(value) expect(subject.get_secret('nova')).to eq('this') end end @@ -92,7 +92,7 @@ describe 'openstack-common::default' do ['service', 'db', 'user'].each do |type| it "returns databag value for #{type}" do value = { 'nova' => 'this' } - ::Chef::DataBagItem.stub(:load).with("#{type}_passwords", 'nova').and_return(value) + allow(Chef::DataBagItem).to receive(:load).with("#{type}_passwords", 'nova').and_return(value) expect(subject.get_password(type, 'nova')).to eq('this') end end @@ -103,7 +103,7 @@ describe 'openstack-common::default' do it 'returns tokens from the secrets_data_bag' do bag_content = { 'nova' => 'mysecret' } - ::Chef::DataBagItem.stub(:load).with( + allow(Chef::DataBagItem).to receive(:load).with( 'secrets', 'nova').and_return(bag_content) expect(subject.get_password('token', 'nova')).to eq('mysecret') end diff --git a/spec/search_spec.rb b/spec/search_spec.rb index 1af9984c..942af5e4 100644 --- a/spec/search_spec.rb +++ b/spec/search_spec.rb @@ -16,8 +16,8 @@ describe 'openstack-common::default' do describe '#search_for' do it 'returns results' do - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search) .with(:node, '(chef_environment:_default AND roles:role) OR (chef_environment:_default AND recipes:role)') .and_return([chef_run.node]) resp = subject.search_for('role') @@ -25,8 +25,8 @@ describe 'openstack-common::default' do end it 'returns empty results' do - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search) .with(:node, '(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)') .and_return([]) expect( @@ -35,8 +35,8 @@ describe 'openstack-common::default' do end it 'always returns empty results' do - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search) .with(:node, '(chef_environment:_default AND roles:empty-role) OR (chef_environment:_default AND recipes:empty-role)') .and_return(nil) expect( @@ -51,8 +51,8 @@ describe 'openstack-common::default' do { 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } }, { 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } } ] - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search_for) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search_for) .with('role') .and_return(nodes) expect( @@ -66,8 +66,8 @@ describe 'openstack-common::default' do { 'memcached' => { 'listen' => '1.1.1.1', 'port' => '11211' } }, { 'memcached' => { 'listen' => '2.2.2.2', 'port' => '11211' } } ] - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search_for) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search_for) .with('role') .and_return(nodes) expect( @@ -81,7 +81,7 @@ describe 'openstack-common::default' do 'memcached_servers' => ['1.1.1.1:11211', '2.2.2.2:11211'] } } - subject.stub(:node).and_return(chef_run.node.merge(nodes)) + allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes)) expect( subject.memcached_servers('role') ).to eq(['1.1.1.1:11211', '2.2.2.2:11211']) @@ -93,7 +93,7 @@ describe 'openstack-common::default' do 'memcached_servers' => [] } } - subject.stub(:node).and_return(chef_run.node.merge(nodes)) + allow(subject).to receive(:node).and_return(chef_run.node.merge(nodes)) expect( subject.memcached_servers('empty-role') ).to eq([]) @@ -106,8 +106,8 @@ describe 'openstack-common::default' do { 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, { 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } } ] - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search_for) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search_for) .and_return(nodes) expect( subject.rabbit_servers).to eq('1.1.1.1:5672,2.2.2.2:5672') @@ -119,8 +119,8 @@ describe 'openstack-common::default' do { 'openstack' => { 'mq' => { 'listen' => '1.1.1.1' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } }, { 'openstack' => { 'mq' => { 'listen' => '2.2.2.2' }, 'endpoints' => { 'mq' => { 'port' => '5672' } } } } ] - subject.stub(:node).and_return(chef_run.node) - subject.stub(:search_for) + allow(subject).to receive(:node).and_return(chef_run.node) + allow(subject).to receive(:search_for) .and_return(nodes) expect( subject.rabbit_servers @@ -129,7 +129,7 @@ describe 'openstack-common::default' do it 'returns rabbit servers when not searching' do chef_run.node.set['openstack']['mq']['servers'] = ['1.1.1.1', '2.2.2.2'] - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) expect( subject.rabbit_servers ).to eq('1.1.1.1:5672,2.2.2.2:5672') diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4d377057..413ccadb 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -31,13 +31,13 @@ end shared_context 'library-stubs' do before do - subject.stub(:node).and_return(chef_run.node) + allow(subject).to receive(:node).and_return(chef_run.node) end end shared_context 'common-stubs' do before do - Chef::Recipe.any_instance.stub(:search_for) + allow_any_instance_of(Chef::Recipe).to receive(:search_for) .with('os-identity').and_return( [{ 'openstack' => { @@ -48,10 +48,10 @@ shared_context 'common-stubs' do } }] ) - Chef::Recipe.any_instance.stub(:get_password) + allow_any_instance_of(Chef::Recipe).to receive(:get_password) .with('user', 'admin') .and_return('admin') - Chef::Recipe.any_instance.stub(:get_password) + allow_any_instance_of(Chef::Recipe).to receive(:get_password) .with('user', 'admin-user-override') .and_return('admin-user-override') end