diff --git a/lib/oar/job.rb b/lib/oar/job.rb index 85a86c9dec5d42adc1dd1cb0f52d46d211b1aacf..d4c3ca059fe05324b8ccc6f6a370d6af89ff68ad 100644 --- a/lib/oar/job.rb +++ b/lib/oar/job.rb @@ -22,6 +22,11 @@ module OAR belongs_to :gantt, :foreign_key => 'assigned_moldable_job', :class_name => 'Gantt' # There may be a way to do that more cleanly ;-) + + # abasu : 4 lines introduced below by for correction to bug ref 5694 -- 2015.01.26 + # GROUP BY resources.network_address + # ORDER BY resources.network_address ASC + QUERY_RESOURCES = Proc.new{ " ( SELECT resources.* @@ -33,6 +38,8 @@ module OAR INNER JOIN moldable_job_descriptions ON assigned_resources.moldable_job_id = moldable_job_descriptions.moldable_id AND jobs.job_id = moldable_job_descriptions.moldable_job_id + GROUP BY resources.network_address + ORDER BY resources.network_address ASC ) UNION ( @@ -45,6 +52,8 @@ module OAR INNER JOIN moldable_job_descriptions ON gantt_jobs_resources.moldable_job_id = moldable_job_descriptions.moldable_id AND jobs.job_id = moldable_job_descriptions.moldable_job_id + GROUP BY resources.network_address + ORDER BY resources.network_address ASC )" } diff --git a/spec/lib/oar/job_spec.rb b/spec/lib/oar/job_spec.rb index 7d144989c8f7011a7eadbb7cdd7b1498d63af3b8..868bed4d811948fb7f9f7224f252da85a982d445 100644 --- a/spec/lib/oar/job_spec.rb +++ b/spec/lib/oar/job_spec.rb @@ -36,7 +36,7 @@ describe OAR::Job do it "should fetch the list of active jobs" do OAR::Job.active.map(&:uid).should == [374173, 374179, 374180, 374185, 374186, 374190, 374191] end - + # abasu : test introduced below for correction to bug ref 5347 -- 2015.03.09 it "should fetch the job with the jobid AND match all job parameters" do params = { @@ -100,7 +100,7 @@ describe OAR::Job do OAR::Job.list(params).should_not exist end - it "should fetch the list of resources" do + it "should fetch the list of resources" do resources = OAR::Job.active.last.resources resources.map(&:id).should == [752, 753, 754, 755, 856, 857, 858, 859, 864, 865, 866, 867, 868, 869, 870, 871] end @@ -162,6 +162,15 @@ describe OAR::Job do ] } end + + # abasu : test introduced below for correction to bug ref 5694 -- 2015.03.13 + it "should return a list of assigned nodes sorted by network_address (nodes)" do + result = OAR::Job.active.last.assigned_nodes # Just the list of assigned nodes returned + sorted_result = OAR::Job.active.last.assigned_nodes.sort # The list of assigned nodes returned and then sorted + result.should == sorted_result # the list of assigned nodes should be already sorted + # double verification : the list of assigned nodes should be already sorted + result.should == ["paramount-30.rennes.grid5000.fr", "paramount-32.rennes.grid5000.fr", "paramount-33.rennes.grid5000.fr", "paramount-4.rennes.grid5000.fr"] + end # "should return a list of assigned nodes sorted by network_address (nodes)" it "should build a hash of resources indexed by their type [cores]" do result = OAR::Job.active.last.resources_by_type