From 9cbc878c8c5151afb844ebc198a4ae9bcdc08a16 Mon Sep 17 00:00:00 2001 From: Jacob Shafton Date: Thu, 20 Nov 2014 14:18:20 -0600 Subject: [PATCH] Add job flow role to configuration --- lib/elasticity/job_flow.rb | 4 +++- spec/lib/elasticity/job_flow_spec.rb | 28 +++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/lib/elasticity/job_flow.rb b/lib/elasticity/job_flow.rb index eb99118..23e464e 100644 --- a/lib/elasticity/job_flow.rb +++ b/lib/elasticity/job_flow.rb @@ -22,6 +22,7 @@ class JobFlow attr_accessor :region attr_accessor :visible_to_all_users attr_accessor :enable_debugging + attr_accessor :job_flow_role attr_reader :access_key attr_reader :secret_key @@ -185,6 +186,7 @@ def jobflow_config steps.insert(0, Elasticity::SetupHadoopDebuggingStep.new.to_aws_step(self)) if @enable_debugging config[:steps] = steps config[:log_uri] = @log_uri if @log_uri + config[:job_flow_role] = @job_flow_role if @job_flow_role config[:bootstrap_actions] = @bootstrap_actions.map{|a| a.to_aws_bootstrap_action} unless @bootstrap_actions.empty? config end @@ -229,4 +231,4 @@ def jobflow_instance_groups end -end \ No newline at end of file +end diff --git a/spec/lib/elasticity/job_flow_spec.rb b/spec/lib/elasticity/job_flow_spec.rb index a5133d4..7ca4112 100644 --- a/spec/lib/elasticity/job_flow_spec.rb +++ b/spec/lib/elasticity/job_flow_spec.rb @@ -344,6 +344,32 @@ end + describe 'job flow role' do + + context 'when a job flow role is specified' do + let(:jobflow_with_job_flow_role) do + Elasticity::JobFlow.new('_', '_').tap do |jf| + jf.job_flow_role = 'JOB_FLOW_ROLE' + end + end + it 'should incorporate it into the jobflow config' do + jobflow_with_job_flow_role.send(:jobflow_config).should be_a_hash_including({:job_flow_role => 'JOB_FLOW_ROLE'}) + end + end + + context 'when a log URI is not specified' do + let(:jobflow_with_no_job_flow_role) do + Elasticity::JobFlow.new('_', '_').tap do |jf| + jf.job_flow_role = nil + end + end + it 'should not make space for it in the jobflow config' do + jobflow_with_no_job_flow_role.send(:jobflow_config).should_not have_key(:job_flow_role) + end + end + + end + describe 'bootstrap actions' do context 'when bootstrap actions are specified' do @@ -686,4 +712,4 @@ end -end \ No newline at end of file +end