From 133a49e150b862cd8e419db87c77e5867bed3dd2 Mon Sep 17 00:00:00 2001 From: Mark Vanderwiel Date: Fri, 29 May 2015 10:20:01 -0500 Subject: [PATCH] Cleanup minor rubocop offenses Cleaned up all the minor rubocop issues, the ones left relate to complex logic and what I think is a bug in rubocop for nested vs compact modules/class definitions. Change-Id: I94577ea628c4f6ee81f3f9dadb24309ca7c856a3 --- .rubocop_todo.yml | 25 +---------- attributes/default.rb | 64 ++++++++++++++-------------- metadata.rb | 26 +++++------ recipes/setup.rb | 90 +++++++++++++++++++-------------------- spec/setup-redhat_spec.rb | 4 +- spec/setup_spec.rb | 4 +- spec/spec_helper.rb | 10 ++--- 7 files changed, 100 insertions(+), 123 deletions(-) mode change 100644 => 100755 .rubocop_todo.yml diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml old mode 100644 new mode 100755 index e4e3b95..a704ced --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,5 +1,5 @@ # This configuration was generated by `rubocop --auto-gen-config` -# on 2015-02-27 14:31:02 -0600 using RuboCop version 0.29.1. +# on 2015-05-29 10:19:10 -0500 using RuboCop version 0.29.1. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new @@ -9,26 +9,3 @@ # Configuration parameters: EnforcedStyle, SupportedStyles. Style/ClassAndModuleChildren: Enabled: false - -# Offense count: 1 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/FirstParameterIndentation: - Enabled: false - -# Offense count: 6 -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, SupportedStyles. -Style/IndentHash: - Enabled: false - -# Offense count: 7 -# Cop supports --auto-correct. -# Configuration parameters: PreferredDelimiters. -Style/PercentLiteralDelimiters: - Enabled: false - -# Offense count: 27 -# Cop supports --auto-correct. -Style/SingleSpaceBeforeFirstArg: - Enabled: false diff --git a/attributes/default.rb b/attributes/default.rb index 6cb982a..db827ce 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -19,49 +19,49 @@ # default['openstack']['integration-test'] = { - 'branch' => nil, - 'disable_ssl_validation' => false, - 'tenant_isolation' => true, - 'tenant_reuse' => true, - 'alt_ssh_user' => 'cirros', - 'ssh_user' => 'cirros', - 'user1' => { - 'user_name' => 'tempest_user1', - 'password' => 'tempest_user1_pass', - 'tenant_name' => 'tempest_tenant1' - }, - 'user2' => { - 'user_name' => 'tempest_user2', - 'password' => 'tempest_user2_pass', - 'tenant_name' => 'tempest_tenant2' - }, - 'image1' => { - 'name' => 'cirros', - 'id' => nil, - 'flavor' => 1, - 'source' => 'http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img' - }, - 'image2' => { - 'name' => 'cirros', - 'id' => nil, - 'flavor' => 1, - 'source' => 'http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img' - } + 'branch' => nil, + 'disable_ssl_validation' => false, + 'tenant_isolation' => true, + 'tenant_reuse' => true, + 'alt_ssh_user' => 'cirros', + 'ssh_user' => 'cirros', + 'user1' => { + 'user_name' => 'tempest_user1', + 'password' => 'tempest_user1_pass', + 'tenant_name' => 'tempest_tenant1' + }, + 'user2' => { + 'user_name' => 'tempest_user2', + 'password' => 'tempest_user2_pass', + 'tenant_name' => 'tempest_tenant2' + }, + 'image1' => { + 'name' => 'cirros', + 'id' => nil, + 'flavor' => 1, + 'source' => 'http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img' + }, + 'image2' => { + 'name' => 'cirros', + 'id' => nil, + 'flavor' => 1, + 'source' => 'http://download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img' + } } # platform-specific settings case platform_family when 'fedora', 'rhel' # :pragma-foodcritic: ~FC024 - won't fix this default['openstack']['integration-test']['platform'] = { - 'tempest_packages' => %w{git python-virtualenv libxslt-devel + 'tempest_packages' => %w(git python-virtualenv libxslt-devel libxml2-devel python-testrepository - libffi-devel}, + libffi-devel), 'package_overrides' => '' } when 'debian' default['openstack']['integration-test']['platform'] = { - 'tempest_packages' => %w{git libxml2-dev libxslt-dev testrepository - python-dev libffi-dev}, + 'tempest_packages' => %w(git libxml2-dev libxslt-dev testrepository + python-dev libffi-dev), 'package_overrides' => "-o Dpkg::Options::='--force-confold' -o Dpkg::Options::='--force-confdef'" } end diff --git a/metadata.rb b/metadata.rb index 940ba36..0fcaaec 100644 --- a/metadata.rb +++ b/metadata.rb @@ -1,18 +1,18 @@ # encoding: UTF-8 -name 'openstack-integration-test' -maintainer 'Rackspace US, Inc.' -license 'Apache 2.0' -description 'Installs and configures the Tempest Integration Test Suite' -long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) -version '11.0.0' -recipe 'openstack-integration-test::setup', 'Installs and configures Tempest' +name 'openstack-integration-test' +maintainer 'Rackspace US, Inc.' +license 'Apache 2.0' +description 'Installs and configures the Tempest Integration Test Suite' +long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) +version '11.0.0' +recipe 'openstack-integration-test::setup', 'Installs and configures Tempest' -%w{ ubuntu fedora redhat centos }.each do |os| +%w(ubuntu fedora redhat centos).each do |os| supports os end -depends 'openstack-common', '>= 11.0.0' -depends 'openstack-identity', '>= 11.0.0' -depends 'openstack-image', '>= 11.0.0' -depends 'openstack-compute', '>= 11.0.0' -depends 'openstack-block-storage', '>= 11.0.0' +depends 'openstack-common', '>= 11.0.0' +depends 'openstack-identity', '>= 11.0.0' +depends 'openstack-image', '>= 11.0.0' +depends 'openstack-compute', '>= 11.0.0' +depends 'openstack-block-storage', '>= 11.0.0' diff --git a/recipes/setup.rb b/recipes/setup.rb index fc388e6..c06abf7 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -43,45 +43,45 @@ bootstrap_token = get_secret 'openstack_identity_bootstrap_token' auth_uri = ::URI.decode identity_admin_endpoint.to_s admin_pass = get_password 'user', node['openstack']['identity']['admin_user'] -%w{user1 user2}.each_with_index do |user, i| +%w(user1 user2).each_with_index do |user, i| i += 1 openstack_identity_register "Register tempest tenant #{i}" do - auth_uri auth_uri - bootstrap_token bootstrap_token - tenant_name node['openstack']['integration-test'][user]['tenant_name'] + auth_uri auth_uri + bootstrap_token bootstrap_token + tenant_name node['openstack']['integration-test'][user]['tenant_name'] tenant_description "Tempest tenant #{i}" action :create_tenant end openstack_identity_register "Register tempest user #{i}" do - auth_uri auth_uri + auth_uri auth_uri bootstrap_token bootstrap_token - tenant_name node['openstack']['integration-test'][user]['tenant_name'] - user_name node['openstack']['integration-test'][user]['user_name'] - user_pass node['openstack']['integration-test'][user]['password'] + tenant_name node['openstack']['integration-test'][user]['tenant_name'] + user_name node['openstack']['integration-test'][user]['user_name'] + user_pass node['openstack']['integration-test'][user]['password'] action :create_user end openstack_identity_register "Create tempest role #{i}" do - auth_uri auth_uri + auth_uri auth_uri bootstrap_token bootstrap_token - tenant_name node['openstack']['integration-test'][user]['tenant_name'] - user_name node['openstack']['integration-test'][user]['user_name'] - user_pass node['openstack']['integration-test'][user]['password'] - role_name 'Member' + tenant_name node['openstack']['integration-test'][user]['tenant_name'] + user_name node['openstack']['integration-test'][user]['user_name'] + user_pass node['openstack']['integration-test'][user]['password'] + role_name 'Member' action :create_role end openstack_identity_register "Grant 'member' Role to tempest user for tempest tenant ##{i}" do - auth_uri auth_uri + auth_uri auth_uri bootstrap_token bootstrap_token - tenant_name node['openstack']['integration-test'][user]['tenant_name'] - user_name node['openstack']['integration-test'][user]['user_name'] - role_name 'Member' + tenant_name node['openstack']['integration-test'][user]['tenant_name'] + user_name node['openstack']['integration-test'][user]['user_name'] + role_name 'Member' action :grant_role end @@ -89,14 +89,14 @@ end git '/opt/tempest' do repository 'https://github.com/openstack/tempest' - reference 'master' + reference 'master' depth 1 action :sync end -%w{image1 image2}.each do |img| - image_name = node['openstack']['integration-test'][img]['name'] - admin_user = node['openstack']['identity']['admin_user'] +%w(image1 image2).each do |img| + image_name = node['openstack']['integration-test'][img]['name'] + admin_user = node['openstack']['identity']['admin_user'] admin_tenant = node['openstack']['identity']['admin_tenant_name'] openstack_image_image img do @@ -113,8 +113,8 @@ end ruby_block "Get and set #{img}'s ID" do block do begin - env = openstack_command_env admin_user, admin_tenant - id = image_id image_name, env + env = openstack_command_env admin_user, admin_tenant + id = image_id image_name, env node.set['openstack']['integration-test'][img]['id'] = id rescue RuntimeError => e Chef::Log.error("UUID not found for Glance image #{image_name}. Error was #{e.message}") @@ -126,31 +126,31 @@ end template '/opt/tempest/etc/tempest.conf' do source 'tempest.conf.erb' - owner 'root' - group 'root' - mode 00600 + owner 'root' + group 'root' + mode 00600 # NOTE: We do not pass the image1/image2 node attributes above to the # template but embed directly in the template itself instead to work # around the variables being evaluated at compile time (prior to # get_image_id being executed). variables( - 'tempest_disable_ssl_validation' => node['openstack']['integration-test']['disable_ssl_validation'], - 'identity_endpoint_host' => identity_api_endpoint.host, - 'identity_endpoint_port' => identity_api_endpoint.port, - 'tempest_tenant_isolation' => node['openstack']['integration-test']['tenant_isolation'], - 'tempest_tenant_reuse' => node['openstack']['integration-test']['tenant_reuse'], - 'tempest_user1' => node['openstack']['integration-test']['user1']['user_name'], - 'tempest_user1_pass' => node['openstack']['integration-test']['user1']['password'], - 'tempest_user1_tenant' => node['openstack']['integration-test']['user1']['tenant_name'], - 'tempest_img_flavor1' => node['openstack']['integration-test']['image1']['flavor'], - 'tempest_img_flavor2' => node['openstack']['integration-test']['image2']['flavor'], - 'tempest_admin' => node['openstack']['identity']['admin_user'], - 'tempest_admin_tenant' => node['openstack']['identity']['admin_tenant_name'], - 'tempest_admin_pass' => admin_pass, - 'tempest_alt_ssh_user' => node['openstack']['integration-test']['alt_ssh_user'], - 'tempest_ssh_user' => node['openstack']['integration-test']['ssh_user'], - 'tempest_user2' => node['openstack']['integration-test']['user2']['user_name'], - 'tempest_user2_pass' => node['openstack']['integration-test']['user2']['password'], - 'tempest_user2_tenant' => node['openstack']['integration-test']['user2']['tenant_name'] - ) + 'tempest_disable_ssl_validation' => node['openstack']['integration-test']['disable_ssl_validation'], + 'identity_endpoint_host' => identity_api_endpoint.host, + 'identity_endpoint_port' => identity_api_endpoint.port, + 'tempest_tenant_isolation' => node['openstack']['integration-test']['tenant_isolation'], + 'tempest_tenant_reuse' => node['openstack']['integration-test']['tenant_reuse'], + 'tempest_user1' => node['openstack']['integration-test']['user1']['user_name'], + 'tempest_user1_pass' => node['openstack']['integration-test']['user1']['password'], + 'tempest_user1_tenant' => node['openstack']['integration-test']['user1']['tenant_name'], + 'tempest_img_flavor1' => node['openstack']['integration-test']['image1']['flavor'], + 'tempest_img_flavor2' => node['openstack']['integration-test']['image2']['flavor'], + 'tempest_admin' => node['openstack']['identity']['admin_user'], + 'tempest_admin_tenant' => node['openstack']['identity']['admin_tenant_name'], + 'tempest_admin_pass' => admin_pass, + 'tempest_alt_ssh_user' => node['openstack']['integration-test']['alt_ssh_user'], + 'tempest_ssh_user' => node['openstack']['integration-test']['ssh_user'], + 'tempest_user2' => node['openstack']['integration-test']['user2']['user_name'], + 'tempest_user2_pass' => node['openstack']['integration-test']['user2']['password'], + 'tempest_user2_tenant' => node['openstack']['integration-test']['user2']['tenant_name'] + ) end diff --git a/spec/setup-redhat_spec.rb b/spec/setup-redhat_spec.rb index 808c75b..623ef40 100644 --- a/spec/setup-redhat_spec.rb +++ b/spec/setup-redhat_spec.rb @@ -12,8 +12,8 @@ describe 'openstack-integration-test::setup' do include_context 'tempest-stubs' it 'installs tempest dependencies' do - packages = %w{git python-virtualenv libxslt-devel libxml2-devel - python-testrepository libffi-devel} + packages = %w(git python-virtualenv libxslt-devel libxml2-devel + python-testrepository libffi-devel) packages.each do |pkg| expect(chef_run).to upgrade_package(pkg) diff --git a/spec/setup_spec.rb b/spec/setup_spec.rb index 6d3f570..548abcf 100644 --- a/spec/setup_spec.rb +++ b/spec/setup_spec.rb @@ -12,8 +12,8 @@ describe 'openstack-integration-test::setup' do include_context 'tempest-stubs' it 'installs tempest dependencies' do - packages = %w{git libxml2-dev libxslt-dev testrepository python-dev - libffi-dev} + packages = %w(git libxml2-dev libxslt-dev testrepository python-dev + libffi-dev) packages.each do |pkg| expect(chef_run).to upgrade_package(pkg) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 1747c07..190237c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -8,14 +8,14 @@ require 'chef/application' LOG_LEVEL = :fatal REDHAT_OPTS = { - platform: 'redhat', - version: '7.1', + platform: 'redhat', + version: '7.1', log_level: LOG_LEVEL } UBUNTU_OPTS = { - platform: 'ubuntu', - version: '14.04', - log_level: LOG_LEVEL + platform: 'ubuntu', + version: '14.04', + log_level: LOG_LEVEL } shared_context 'tempest-stubs' do