1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[aws|emr] mark tests pending when mocked

This commit is contained in:
geemus 2011-11-09 10:26:12 -06:00
parent 2dc1bf98c7
commit 005ccd9189
2 changed files with 50 additions and 47 deletions

View file

@ -1,7 +1,9 @@
Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
pending if Fog.mocking?
@job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}" @job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}"
@job_flow_options = { @job_flow_options = {
'Instances' => { 'Instances' => {
'MasterInstanceType' => 'm1.small', 'MasterInstanceType' => 'm1.small',
@ -15,7 +17,7 @@ Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
'HadoopVersion' => '0.20' 'HadoopVersion' => '0.20'
} }
} }
@job_flow_steps = { @job_flow_steps = {
'Steps' => [{ 'Steps' => [{
'Name' => 'Dummy streaming job', 'Name' => 'Dummy streaming job',
@ -27,7 +29,7 @@ Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
} }
}] }]
} }
@instance_group_name = "fog_instance_group_#{Time.now.to_f.to_s.gsub('.','')}" @instance_group_name = "fog_instance_group_#{Time.now.to_f.to_s.gsub('.','')}"
@instance_groups = { @instance_groups = {
'InstanceGroups' => [{ 'InstanceGroups' => [{
@ -37,53 +39,53 @@ Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
'InstanceCount' => 2 'InstanceCount' => 2
}] }]
} }
result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body
@job_flow_id = result['JobFlowId'] @job_flow_id = result['JobFlowId']
tests('success') do tests('success') do
tests("#add_instance_groups").formats(AWS::EMR::Formats::ADD_INSTANCE_GROUPS) do tests("#add_instance_groups").formats(AWS::EMR::Formats::ADD_INSTANCE_GROUPS) do
pending if Fog.mocking? pending if Fog.mocking?
result = AWS[:emr].add_instance_groups(@job_flow_id, @instance_groups).body result = AWS[:emr].add_instance_groups(@job_flow_id, @instance_groups).body
@instance_group_id = result['InstanceGroupIds'].first @instance_group_id = result['InstanceGroupIds'].first
result result
end end
tests("#describe_job_flows_with_instance_groups").formats(AWS::EMR::Formats::DESCRIBE_JOB_FLOW_WITH_INSTANCE_GROUPS) do tests("#describe_job_flows_with_instance_groups").formats(AWS::EMR::Formats::DESCRIBE_JOB_FLOW_WITH_INSTANCE_GROUPS) do
pending if Fog.mocking? pending if Fog.mocking?
result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
result result
end end
tests("#modify_instance_groups").formats(AWS::EMR::Formats::BASIC) do tests("#modify_instance_groups").formats(AWS::EMR::Formats::BASIC) do
pending if Fog.mocking? pending if Fog.mocking?
# Add a step so the state doesn't go directly from STARTING to SHUTTING_DOWN # Add a step so the state doesn't go directly from STARTING to SHUTTING_DOWN
AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps) AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps)
# Wait until job has started before modifying the instance group # Wait until job has started before modifying the instance group
begin begin
sleep 10 sleep 10
result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
job_flow = result['JobFlows'].first job_flow = result['JobFlows'].first
state = job_flow['ExecutionStatusDetail']['State'] state = job_flow['ExecutionStatusDetail']['State']
print "." print "."
end while(state == 'STARTING') end while(state == 'STARTING')
# Check results # Check results
result = AWS[:emr].modify_instance_groups('InstanceGroups' => [{'InstanceGroupId' => @instance_group_id, 'InstanceCount' => 4}]).body result = AWS[:emr].modify_instance_groups('InstanceGroups' => [{'InstanceGroupId' => @instance_group_id, 'InstanceCount' => 4}]).body
# Check the it actually modified the instance count # Check the it actually modified the instance count
tests("modify worked?") do tests("modify worked?") do
ig_res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body ig_res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
matched = false matched = false
jf = ig_res['JobFlows'].first jf = ig_res['JobFlows'].first
jf['Instances']['InstanceGroups'].each do | ig | jf['Instances']['InstanceGroups'].each do | ig |
@ -91,15 +93,14 @@ Shindo.tests('AWS::EMR | instance groups', ['aws', 'emr']) do
matched = true if ig['InstanceRequestCount'].to_i == 4 matched = true if ig['InstanceRequestCount'].to_i == 4
end end
end end
matched matched
end end
result result
end end
end end
AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id]) AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id])
end end

View file

@ -1,7 +1,9 @@
Shindo.tests('AWS::EMR | job flows', ['aws', 'emr']) do Shindo.tests('AWS::EMR | job flows', ['aws', 'emr']) do
pending if Fog.mocking?
@job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}" @job_flow_name = "fog_job_flow_#{Time.now.to_f.to_s.gsub('.','')}"
@job_flow_options = { @job_flow_options = {
'Instances' => { 'Instances' => {
'MasterInstanceType' => 'm1.small', 'MasterInstanceType' => 'm1.small',
@ -15,9 +17,9 @@ Shindo.tests('AWS::EMR | job flows', ['aws', 'emr']) do
'HadoopVersion' => '0.20' 'HadoopVersion' => '0.20'
} }
} }
@step_name = "fog_job_flow_step_#{Time.now.to_f.to_s.gsub('.','')}" @step_name = "fog_job_flow_step_#{Time.now.to_f.to_s.gsub('.','')}"
@job_flow_steps = { @job_flow_steps = {
'Steps' => [{ 'Steps' => [{
'Name' => @step_name, 'Name' => @step_name,
@ -29,58 +31,58 @@ Shindo.tests('AWS::EMR | job flows', ['aws', 'emr']) do
} }
}] }]
} }
@job_flow_id = nil @job_flow_id = nil
tests('success') do tests('success') do
tests("#run_job_flow").formats(AWS::EMR::Formats::RUN_JOB_FLOW) do tests("#run_job_flow").formats(AWS::EMR::Formats::RUN_JOB_FLOW) do
pending if Fog.mocking? pending if Fog.mocking?
result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body result = AWS[:emr].run_job_flow(@job_flow_name, @job_flow_options).body
@job_flow_id = result['JobFlowId'] @job_flow_id = result['JobFlowId']
result result
end end
tests("#add_job_flow_steps").formats(AWS::EMR::Formats::BASIC) do tests("#add_job_flow_steps").formats(AWS::EMR::Formats::BASIC) do
pending if Fog.mocking? pending if Fog.mocking?
result = AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps).body result = AWS[:emr].add_job_flow_steps(@job_flow_id, @job_flow_steps).body
result result
end end
tests("#set_termination_protection").formats(AWS::EMR::Formats::BASIC) do tests("#set_termination_protection").formats(AWS::EMR::Formats::BASIC) do
result = AWS[:emr].set_termination_protection(true, 'JobFlowIds' => [@job_flow_id]).body result = AWS[:emr].set_termination_protection(true, 'JobFlowIds' => [@job_flow_id]).body
test("protected?") do test("protected?") do
res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body res = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
jf = res['JobFlows'].first jf = res['JobFlows'].first
jf['Instances']['TerminationProtected'] == 'true' jf['Instances']['TerminationProtected'] == 'true'
end end
result result
end end
tests("#terminate_job_flow").formats(AWS::EMR::Formats::BASIC) do tests("#terminate_job_flow").formats(AWS::EMR::Formats::BASIC) do
pending if Fog.mocking? pending if Fog.mocking?
AWS[:emr].set_termination_protection(false, 'JobFlowIds' => [@job_flow_id]) AWS[:emr].set_termination_protection(false, 'JobFlowIds' => [@job_flow_id])
result = AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id]).body result = AWS[:emr].terminate_job_flows('JobFlowIds' => [@job_flow_id]).body
result result
end end
tests("#describe_job_flows").formats(AWS::EMR::Formats::SIMPLE_DESCRIBE_JOB_FLOW) do tests("#describe_job_flows").formats(AWS::EMR::Formats::SIMPLE_DESCRIBE_JOB_FLOW) do
pending if Fog.mocking? pending if Fog.mocking?
result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body result = AWS[:emr].describe_job_flows('JobFlowIds' => [@job_flow_id]).body
result result
end end
end end
end end