2011-11-03 13:57:21 -04:00
|
|
|
Shindo.tests('AWS::EMR | job flows', ['aws', 'emr']) do
|
|
|
|
|
2011-11-09 11:26:12 -05:00
|
|
|
pending if Fog.mocking?
|
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
@job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}"
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
@job_flow_options = {
|
|
|
|
'Instances' => {
|
|
|
|
'MasterInstanceType' => 'm1.small',
|
|
|
|
'SlaveInstanceType' => 'm1.small',
|
|
|
|
'InstanceCount' => 2,
|
|
|
|
'Placement' => {
|
|
|
|
'AvailabilityZone' => 'us-east-1a'
|
|
|
|
},
|
|
|
|
'KeepJobFlowAliveWhenNoSteps' => false,
|
|
|
|
'TerminationProtected' => false,
|
|
|
|
'HadoopVersion' => '0.20'
|
|
|
|
}
|
|
|
|
}
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
@step_name = "fog_job_flow_step_#{Time.now.to_f.to_s.gsub('.','')}"
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
@job_flow_steps = {
|
|
|
|
'Steps' => [{
|
|
|
|
'Name' => @step_name,
|
|
|
|
'ActionOnFailure' => 'CONTINUE',
|
|
|
|
'HadoopJarStep' => {
|
|
|
|
'Jar' => 'FakeJar',
|
|
|
|
'MainClass' => 'FakeMainClass',
|
|
|
|
'Args' => ['arg1', 'arg2']
|
|
|
|
}
|
|
|
|
}]
|
|
|
|
}
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
@job_flow_id = nil
|
|
|
|
|
|
|
|
tests('success') do
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
tests("#run_job_flow").formats(AWS::EMR::Formats::RUN_JOB_FLOW) do
|
|
|
|
pending if Fog.mocking?
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body
|
|
|
|
@job_flow_id = result['JobFlowId']
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
tests("#add_job_flow_steps").formats(AWS::EMR::Formats::BASIC) do
|
|
|
|
pending if Fog.mocking?
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result = AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps).body
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
tests("#set_termination_protection").formats(AWS::EMR::Formats::BASIC) do
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result = AWS[:emr].set_termination_protection(true, 'JobFlowIds' => [@job_flow_id]).body
|
|
|
|
|
|
|
|
test("protected?") do
|
|
|
|
res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
|
|
|
|
jf = res['JobFlows'].first
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
jf['Instances']['TerminationProtected'] == 'true'
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
tests("#terminate_job_flow").formats(AWS::EMR::Formats::BASIC) do
|
|
|
|
pending if Fog.mocking?
|
|
|
|
AWS[:emr].set_termination_protection(false, 'JobFlowIds' => [@job_flow_id])
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result = AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id]).body
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
tests("#describe_job_flows").formats(AWS::EMR::Formats::SIMPLE_DESCRIBE_JOB_FLOW) do
|
|
|
|
pending if Fog.mocking?
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
result
|
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
|
2011-11-03 13:57:21 -04:00
|
|
|
end
|
2011-11-09 11:26:12 -05:00
|
|
|
end
|