7753: Add a Log link to pipeline_instance component panel
authorradhika <radhika@curoverse.com>
Thu, 3 Dec 2015 21:00:52 +0000 (16:00 -0500)
committerradhika <radhika@curoverse.com>
Fri, 4 Dec 2015 20:08:04 +0000 (15:08 -0500)
apps/workbench/app/models/pipeline_instance.rb
apps/workbench/app/views/pipeline_instances/_running_component.html.erb
apps/workbench/app/views/pipeline_instances/_show_log.html.erb
apps/workbench/test/integration/anonymous_access_test.rb
apps/workbench/test/integration/pipeline_instances_test.rb
services/api/test/fixtures/jobs.yml

index 03d70b2897063435298707e3068dfa79ca16ff34..6e556d5b75cae13626aad29d1c0a816a5a78b583 100644 (file)
@@ -92,6 +92,10 @@ class PipelineInstance < ArvadosBase
     components_map { |cspec| cspec[:job][:log] rescue nil }
   end
 
+  def job_ids
+    components_map { |cspec| cspec[:job][:uuid] rescue nil }
+  end
+
   def stderr_log_object_uuids
     result = job_uuids.values.compact
     result << uuid
index 63a2371a1b3dd2dc398c9b672311bd606d64bdf7..d4a87b3725f6fc5573b0fdd7d26fa922890190a5 100644 (file)
@@ -4,7 +4,7 @@
     <div class="container-fluid">
       <div class="row-fluid">
         <%# column offset 0 %>
-        <div class="col-md-3" style="word-break:break-all;">
+        <div class="col-md-2" style="word-break:break-all;">
           <h4 class="panel-title">
             <a data-toggle="collapse" href="#collapse<%= i %>">
               <%= pj[:name] %> <span class="caret"></span>
           </h4>
         </div>
 
-        <%# column offset 3 %>
+        <%# column offset 2 %>
         <div class="col-md-2 pipeline-instance-spacing">
           <%= pj[:progress_bar] %>
         </div>
 
         <% if current_job %>
+          <%# column offset 4 %>
+          <% if current_job[:state].in? ["Running", "Complete", "Failed", "Cancelled"] %>
+          <div class="col-md-1">
+            <% if current_job[:log] %>
+                <% logCollection = Collection.find? current_job[:log] %>
+                <% if logCollection %>
+                  <%= link_to "Job log", job_path(current_job[:uuid], anchor: "Log") %>
+                <% else %>
+                  Log unavailable
+                <% end %>
+            <% end %>
+          </div>
+          <% end %>
+
           <%# column offset 5 %>
           <% if current_job[:state] != "Queued" %>
           <div class="col-md-3">
index 187dce7bd244e44468edbdda111c0ce1166406f6..3a4ec4ead092a68bcd4e1031287019730f55b030 100644 (file)
@@ -1,4 +1,5 @@
 <% log_ids = @object.job_log_ids
+   job_ids = @object.job_ids
    still_logging, done_logging = log_ids.keys.partition { |k| log_ids[k].nil? }
 %>
 
@@ -19,7 +20,7 @@
       <tr>
         <td><%= cname %></td>
         <td><%= link_to("Log for #{cname}",
-                {controller: "collections", action: "show", id: log_ids[cname]})
+                job_path(job_ids[cname], anchor: "Log"))
                 %></td>
       </tr>
       <% end %>
index aabbf00dc206e77090d1d9096c3abed23eec8530..be9799c2a61b7e60710fd35f80be26bcc7b4589f 100644 (file)
@@ -218,18 +218,18 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
 
       if pipeline_page
         object = api_fixture('pipeline_instances')[fixture]
-        page = "/pipeline_instances/#{object['uuid']}"
+        page_link = "/pipeline_instances/#{object['uuid']}"
         expect_log_text = "Log for foo"
       else      # job
         object = api_fixture('jobs')[fixture]
-        page = "/jobs/#{object['uuid']}"
+        page_link = "/jobs/#{object['uuid']}"
         expect_log_text = "stderr crunchstat"
       end
 
       if user
-        visit page_with_token user, page
+        visit page_with_token user, page_link
       else
-        visit page
+        visit page_link
       end
 
       # click job link, if in pipeline page
@@ -241,7 +241,12 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
         assert_no_text 'Output data not available'
         if pipeline_page
           assert_text 'This pipeline was created from'
-          assert_selector 'a', text: object['components']['foo']['job']['uuid']
+          job_id = object['components']['foo']['job']['uuid']
+          assert_selector 'a', text: job_id
+          if object['components']['foo']['job']['log']
+            assert_selector "a[href=\"/jobs/#{job_id}#Log\"]", text: 'Job log'
+          end
+
           # We'd like to test the Log tab on job pages too, but we can't right
           # now because Poltergeist 1.x doesn't support JavaScript's
           # Function.prototype.bind, which is used by job_log_graph.js.
@@ -250,6 +255,7 @@ class AnonymousAccessTest < ActionDispatch::IntegrationTest
         end
       else
         assert_selector 'a[data-toggle="disabled"]', text: 'Log'
+        assert_text 'Log unavailable'
         assert_text 'Output data not available'
         assert_text object['job']
         if pipeline_page
index 8617c370bcbfd84ea885c8d9ce67e5317cfe4219..612493adf0f6f2ec2ecdb991b8144e9eb5a973af 100644 (file)
@@ -550,7 +550,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       assert_text "Log for previous"
       log_link = find("a", text: "Log for previous")
       assert_includes(log_link[:href],
-                      pi["components"]["previous"]["job"]["log"])
+                      "/jobs/#{pi["components"]["previous"]["job"]["uuid"]}#Log")
       assert_selector "#event_log_div"
     end
   end
@@ -563,7 +563,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       assert_text "Log for previous"
       pi["components"].each do |cname, cspec|
         log_link = find("a", text: "Log for #{cname}")
-        assert_includes(log_link[:href], cspec["job"]["log"])
+        assert_includes(log_link[:href], "/jobs/#{cspec["job"]["uuid"]}#Log")
       end
       assert_no_selector "#event_log_div"
     end
@@ -577,7 +577,7 @@ class PipelineInstancesTest < ActionDispatch::IntegrationTest
       assert_text "Log for previous"
       pi["components"].each do |cname, cspec|
         log_link = find("a", text: "Log for #{cname}")
-        assert_includes(log_link[:href], cspec["job"]["log"])
+        assert_includes(log_link[:href], "/jobs/#{cspec["job"]["uuid"]}#Log")
       end
       assert_no_selector "#event_log_div"
     end
index 8a4c34557c4e45c3cf1e0ae22a675901e8b3754e..12493e35514714dfdffc1e6f5aeabdf09d0dd223 100644 (file)
@@ -482,7 +482,7 @@ completed_job_in_publicly_accessible_project:
   script_parameters:
     input: fa7aeb5140e2848d39b416daeef4ffc5+45
     input2: "stuff2"
-  log: ~
+  log: zzzzz-4zz18-4en62shvi99lxd4
   output: b519d9cb706a29fc7ea24dbea2f05851+93
 
 job_in_publicly_accessible_project_but_other_objects_elsewhere: