[ARVADOS] updated: aface0b74e6b3cfaaa8d773218a5ada423a7654b

Git user git at public.curoverse.com
Sat Jun 4 19:04:11 EDT 2016


Summary of changes:
 apps/workbench/app/models/proxy_work_unit.rb       |  2 -
 .../pipeline_instances_controller_test.rb          |  8 ++-
 apps/workbench/test/unit/work_unit_test.rb         | 69 ++++++++++++++++++++--
 services/api/test/fixtures/pipeline_instances.yml  |  2 +
 4 files changed, 73 insertions(+), 8 deletions(-)

       via  aface0b74e6b3cfaaa8d773218a5ada423a7654b (commit)
      from  d1d4aba8c3eb7e3b605639a4b02cb9d26c033ad2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit aface0b74e6b3cfaaa8d773218a5ada423a7654b
Author: radhika <radhika at curoverse.com>
Date:   Sat Jun 4 19:03:32 2016 -0400

    8876: add tests for link_to_log and queuedtime etc.

diff --git a/apps/workbench/app/models/proxy_work_unit.rb b/apps/workbench/app/models/proxy_work_unit.rb
index 0fb2607..231145a 100644
--- a/apps/workbench/app/models/proxy_work_unit.rb
+++ b/apps/workbench/app/models/proxy_work_unit.rb
@@ -223,8 +223,6 @@ class ProxyWorkUnit < WorkUnit
       else
         "Log unavailable"
       end
-    else
-      ""
     end
   end
 
diff --git a/apps/workbench/test/controllers/pipeline_instances_controller_test.rb b/apps/workbench/test/controllers/pipeline_instances_controller_test.rb
index ac36f19..f55c3ac 100644
--- a/apps/workbench/test/controllers/pipeline_instances_controller_test.rb
+++ b/apps/workbench/test/controllers/pipeline_instances_controller_test.rb
@@ -85,8 +85,12 @@ class PipelineInstancesControllerTest < ActionController::TestCase
     assert_response :success
     assert_not_nil assigns(:object)
     assert_not_nil assigns(:object).components[:foo][:job]
-    assert assigns(:object).components[:foo][:job][:started_at].is_a? Time
-    assert assigns(:object).components[:foo][:job][:finished_at].is_a? Time
+    start_at = assigns(:object).components[:foo][:job][:started_at]
+    start_at = Time.parse(start_at) if (start_at.andand.class == String)
+    assert start_at.is_a? Time
+    finished_at = assigns(:object).components[:foo][:job][:started_at]
+    finished_at = Time.parse(finished_at) if (finished_at.andand.class == String)
+    assert finished_at.is_a? Time
   end
 
   # The next two tests ensure that a pipeline instance can be copied
diff --git a/apps/workbench/test/unit/work_unit_test.rb b/apps/workbench/test/unit/work_unit_test.rb
index a1de629..e8af04c 100644
--- a/apps/workbench/test/unit/work_unit_test.rb
+++ b/apps/workbench/test/unit/work_unit_test.rb
@@ -1,15 +1,19 @@
 require 'test_helper'
 
 class WorkUnitTest < ActiveSupport::TestCase
+  setup do
+    Rails.configuration.anonymous_user_token = api_fixture('api_client_authorizations')['anonymous']['api_token']
+  end
+
   [
     [Job, 'running_job_with_components', "jwu", 2, "Running", nil, 0.5],
     [PipelineInstance, 'pipeline_in_running_state', nil, 1, "Running", nil, 0.0],
     [PipelineInstance, 'has_component_with_completed_jobs', nil, 3, "Complete", true, 1.0],
     [PipelineInstance, 'pipeline_with_tagged_collection_input', "pwu", 1, "Ready", nil, 0.0],
-  ].each do |type, name, label, num_children, state, success, progress|
-    test "children of #{name}" do
-      use_token 'admin'
-      obj = find_fixture(type, name)
+  ].each do |type, fixture, label, num_children, state, success, progress|
+    test "children of #{fixture}" do
+      use_token 'active'
+      obj = find_fixture(type, fixture)
       wu = obj.work_unit(label)
 
       if label != nil
@@ -28,4 +32,61 @@ class WorkUnitTest < ActiveSupport::TestCase
       end
     end
   end
+
+  [
+    [Job, 'running_job_with_components', 1, 1, nil],
+    [Job, 'queued', nil, nil, 1],
+    [PipelineInstance, 'pipeline_in_running_state', 1, 1, nil],
+    [PipelineInstance, 'has_component_with_completed_jobs', 60, 60, nil],
+  ].each do |type, fixture, walltime, cputime, queuedtime|
+    test "times for #{fixture}" do
+      use_token 'active'
+      obj = find_fixture(type, fixture)
+      wu = obj.work_unit
+
+      if walltime
+        assert_equal true, (wu.walltime >= walltime)
+      else
+        assert_equal walltime, wu.walltime
+      end
+
+      if cputime
+        assert_equal true, (wu.cputime >= cputime)
+      else
+        assert_equal cputime, wu.cputime
+      end
+
+      if queuedtime
+        assert_equal true, (wu.queuedtime >= queuedtime)
+      else
+        assert_equal queuedtime, wu.queuedtime
+      end
+    end
+  end
+
+  [
+    [Job, 'active', 'running_job_with_components', true],
+    [Job, 'active', 'queued', false],
+    [Job, nil, 'completed_job_in_publicly_accessible_project', true],
+    [Job, 'active', 'completed_job_in_publicly_accessible_project', true],
+    [PipelineInstance, 'active', 'pipeline_in_running_state', true],  # no log, but while running the log link points to pi Log tab
+    [PipelineInstance, nil, 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false],
+    [PipelineInstance, 'active', 'pipeline_in_publicly_accessible_project_but_other_objects_elsewhere', false], #no log for completed pi
+    [Job, nil, 'job_in_publicly_accessible_project_but_other_objects_elsewhere', false, "Log unavailable"],
+  ].each do |type, token, fixture, has_log, log_link|
+    test "link_to_log for #{fixture} for #{token}" do
+      use_token token if token
+      obj = find_fixture(type, fixture)
+      wu = obj.work_unit
+
+      link = "#{wu.uri}#Log" if has_log
+      link_to_log = wu.link_to_log
+
+      if has_log
+        assert_includes link_to_log, link
+      else
+        assert_equal log_link, link_to_log
+      end
+    end
+  end
 end
diff --git a/services/api/test/fixtures/pipeline_instances.yml b/services/api/test/fixtures/pipeline_instances.yml
index 41a7fc9..f51b78a 100644
--- a/services/api/test/fixtures/pipeline_instances.yml
+++ b/services/api/test/fixtures/pipeline_instances.yml
@@ -42,6 +42,8 @@ has_component_with_completed_jobs:
   state: Complete
   uuid: zzzzz-d1hrv-i3e77t9z5y8j9cc
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  started_at: <%= 10.minute.ago.to_s(:db) %>
+  finished_at: <%= 9.minute.ago.to_s(:db) %>
   components:
    foo:
     script: foo

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list