From 31cfd02374dadffe6408c9832fa06b6982eb559f Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 1 Aug 2016 21:50:32 -0700 Subject: [PATCH 1/3] Update Ruboop from 0.27.1 to 0.42.0 --- .rubocop.yml | 16 ++++++++-------- Gemfile | 2 +- metadata.rb | 8 +++++++- recipes/spark-standalone-worker.rb | 10 +++++----- .../files/default/tests/minitest/spark_test.rb | 6 ++++-- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 761e0ec..8e615da 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -8,17 +8,17 @@ AllCops: Exclude: - vendor/**/* -Documentation: +Metrics/LineLength: Enabled: false -FileName: +Style/Documentation: Enabled: false -SignalException: +Style/ExtraSpacing: Enabled: false -Encoding: +Style/FileName: Enabled: false -HashSyntax: +Style/HashSyntax: Enabled: false -LineLength: - Enabled: false -ExtraSpacing: +Style/NumericLiteralPrefix: + EnforcedOctalStyle: zero_only +Style/SignalException: Enabled: false diff --git a/Gemfile b/Gemfile index 84cdb79..6e7f838 100644 --- a/Gemfile +++ b/Gemfile @@ -9,7 +9,7 @@ group :test do gem 'chefspec', '~> 4.2' gem 'rspec', '~> 3.2' gem 'foodcritic', '~> 4.0' - gem 'rubocop', '~> 0.27.1' + gem 'rubocop', '~> 0.42.0' end group :integration do diff --git a/metadata.rb b/metadata.rb index 0a6cee9..6c2b5f9 100644 --- a/metadata.rb +++ b/metadata.rb @@ -21,7 +21,13 @@ source_url 'https://github.com/clearstorydata-cookbooks/apache_spark' issues_url 'https://github.com/clearstorydata-cookbooks/apache_spark/issues' -%w( debian ubuntu centos redhat fedora ).each do |os| +%w( + centos + debian + fedora + redhat + ubuntu +).each do |os| supports os end diff --git a/recipes/spark-standalone-worker.rb b/recipes/spark-standalone-worker.rb index b09c736..5734bc6 100644 --- a/recipes/spark-standalone-worker.rb +++ b/recipes/spark-standalone-worker.rb @@ -21,11 +21,11 @@ spark_user = node['apache_spark']['user'] spark_group = node['apache_spark']['group'] -if node['apache_spark']['standalone']['master_url'].nil? - spark_master_url = "spark://#{node['apache_spark']['standalone']['master_host']}:#{node['apache_spark']['standalone']['master_port']}" -else - spark_master_url = node['apache_spark']['standalone']['master_url'] -end +spark_master_url = if node['apache_spark']['standalone']['master_url'].nil? + "spark://#{node['apache_spark']['standalone']['master_host']}:#{node['apache_spark']['standalone']['master_port']}" + else + node['apache_spark']['standalone']['master_url'] + end template worker_runner_script do source 'spark_worker_runner.sh.erb' diff --git a/test/cookbooks/apache_spark_test/files/default/tests/minitest/spark_test.rb b/test/cookbooks/apache_spark_test/files/default/tests/minitest/spark_test.rb index 0a2c209..79ce546 100644 --- a/test/cookbooks/apache_spark_test/files/default/tests/minitest/spark_test.rb +++ b/test/cookbooks/apache_spark_test/files/default/tests/minitest/spark_test.rb @@ -58,11 +58,13 @@ '--class org.apache.spark.examples.SparkPi ' \ '--deploy-mode client ' \ '--master spark://localhost:7077 ' \ - "#{spark_examples_jar} 100") + "#{spark_examples_jar} 100" + ) expected_msg = 'Pi is roughly 3.14' assert( spark_pi_result.stdout.include?(expected_msg), "Expected stdout to say '#{expected_msg}'. " \ - "Actual stdout:\n#{spark_pi_result.stdout}\n\nStderr:\n#{spark_pi_result.stderr}") + "Actual stdout:\n#{spark_pi_result.stdout}\n\nStderr:\n#{spark_pi_result.stderr}" + ) end end From e20b23a24cf824779a3c140812e5aa4b73d6b4f9 Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 1 Aug 2016 22:05:28 -0700 Subject: [PATCH 2/3] Remove excess logging Chef will log the resource changes so there is no need to log them again --- recipes/spark-install.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/recipes/spark-install.rb b/recipes/spark-install.rb index 39304a0..a097ab6 100644 --- a/recipes/spark-install.rb +++ b/recipes/spark-install.rb @@ -38,7 +38,7 @@ tarball_basename = ::File.basename(URI.parse(node['apache_spark']['download_url']).path) downloaded_tarball_path = ::File.join(Chef::Config[:file_cache_path], tarball_basename) tarball_url = node['apache_spark']['download_url'] - Chef::Log.warn("#{tarball_url} will be downloaded to #{downloaded_tarball_path}") + remote_file downloaded_tarball_path do source tarball_url checksum node['apache_spark']['checksum'] @@ -46,7 +46,6 @@ extracted_dir_name = tarball_basename.sub(/[.](tar[.]gz|tgz)$/, '') - Chef::Log.warn("#{downloaded_tarball_path} will be extracted in #{install_base_dir}") actual_install_dir = ::File.join(install_base_dir, extracted_dir_name) tar_extract downloaded_tarball_path do action :extract_local From 2793a0785efe43305fa8ef67e6267225266f4fbb Mon Sep 17 00:00:00 2001 From: Grant Ridder Date: Mon, 1 Aug 2016 22:07:57 -0700 Subject: [PATCH 3/3] source_url and issues_url should be guarded with respond_to? --- metadata.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/metadata.rb b/metadata.rb index 6c2b5f9..ad4c7a7 100644 --- a/metadata.rb +++ b/metadata.rb @@ -18,8 +18,9 @@ license 'Apache License 2.0' description 'A cookbook to install and configure Apache Spark' version '1.2.14' -source_url 'https://github.com/clearstorydata-cookbooks/apache_spark' -issues_url 'https://github.com/clearstorydata-cookbooks/apache_spark/issues' + +source_url 'https://github.com/clearstorydata-cookbooks/apache_spark' if respond_to?(:source_url) +issues_url 'https://github.com/clearstorydata-cookbooks/apache_spark/issues' if respond_to?(:issues_url) %w( centos