[ARVADOS] updated: 34e461fe9d33283d8e2135802ee9accb30a5e34f

git at public.curoverse.com git at public.curoverse.com
Wed Oct 1 13:55:29 EDT 2014


Summary of changes:
 .../workbench/app/assets/javascripts/log_viewer.js |  2 +-
 apps/workbench/app/views/jobs/_show_log.html.erb   | 17 ++++---
 apps/workbench/test/integration/jobs_test.rb       | 56 ++++++++++++++++++++++
 services/api/test/fixtures/collections.yml         | 14 ++++++
 services/api/test/fixtures/jobs.yml                |  8 ++++
 5 files changed, 89 insertions(+), 8 deletions(-)

       via  34e461fe9d33283d8e2135802ee9accb30a5e34f (commit)
      from  3cdc055b90fd859cbd0e101becb4abd78f4d467f (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 34e461fe9d33283d8e2135802ee9accb30a5e34f
Author: Tim Pierce <twp at curoverse.com>
Date:   Wed Oct 1 13:50:53 2014 -0400

    3782: bugfix and added integration test
    
    * Fixed bug where log viewer would always request partial log and receive
      206, even when total log size is shorter than log_viewer_max_bytes.
    * Added integration tests:
    ** set up KEEP_LOCAL_STORE with dummy log
    ** test retrieving full job log
    ** test retrieving partial job log

diff --git a/apps/workbench/app/assets/javascripts/log_viewer.js b/apps/workbench/app/assets/javascripts/log_viewer.js
index 93681cc..0e12f9c 100644
--- a/apps/workbench/app/assets/javascripts/log_viewer.js
+++ b/apps/workbench/app/assets/javascripts/log_viewer.js
@@ -94,7 +94,7 @@ function addToLogViewer(logViewer, lines, taskState) {
             });
             count += 1;
         } else {
-            console.log("Did not parse: " + lines[a]);
+            console.log("Did not parse line " + a + ": " + lines[a]);
         }
     }
     logViewer.add(items);
diff --git a/apps/workbench/app/views/jobs/_show_log.html.erb b/apps/workbench/app/views/jobs/_show_log.html.erb
index 01d5b18..01d2167 100644
--- a/apps/workbench/app/views/jobs/_show_log.html.erb
+++ b/apps/workbench/app/views/jobs/_show_log.html.erb
@@ -53,20 +53,23 @@ var makeFilter = function() {
 <% if @object.log %>
   <% logcollection = Collection.find @object.log %>
   <% if logcollection %>
-    var log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
+    log_size = <%= logcollection.files[0][2] %>
+    log_maxbytes = <%= Rails.configuration.log_viewer_max_bytes %>;
     logcollection_url = '<%=j url_for logcollection %>/<%=j logcollection.files[0][1] %>';
     $("#log-viewer-download-url").attr('href', logcollection_url);
     $("#log-viewer-download-pane").css('display', 'inline');
-    $.ajax(logcollection_url,
-	   {
-	     headers: {'Range': 'bytes=0-' + log_maxbytes}
-	   }).
+    if (log_size > log_maxbytes) {
+      range_header = { 'Range': 'bytes=0-' + log_maxbytes };
+    } else {
+      range_header = null;
+    }
+    $.ajax(logcollection_url, { headers: range_header }).
 	done(function(data, status, jqxhr) {
 	    logViewer.filter();
 	    addToLogViewer(logViewer, data.split("\n"), taskState);
 	    logViewer.filter(makeFilter());
-	    var v = jqxhr.getResponseHeader('Content-Range')
-	      .match(/bytes \d+-(\d+)\/(.+)/);
+            content_range_hdr = jqxhr.getResponseHeader('Content-Range');
+	    var v = content_range_hdr && content_range_hdr.match(/bytes \d+-(\d+)\/(.+)/);
             short_log = v && (v[2] == '*' || parseInt(v[1]) + 1 < v[2]);
 	    if (jqxhr.status == 206 && short_log) {
 	      $("#log-viewer-overview").html(
diff --git a/apps/workbench/test/integration/jobs_test.rb b/apps/workbench/test/integration/jobs_test.rb
index 50616de..8ecff4d 100644
--- a/apps/workbench/test/integration/jobs_test.rb
+++ b/apps/workbench/test/integration/jobs_test.rb
@@ -1,6 +1,33 @@
+require 'fileutils'
+require 'tmpdir'
+
 require 'integration_helper'
 
 class JobsTest < ActionDispatch::IntegrationTest
+
+  def setup
+    # Set up KEEP_LOCAL_STORE with a file that satisfies
+    # the log collection for job 'job_with_real_log'
+    # TODO: figure out a better way to store this test data
+    # (e.g. in a dummy test fixture)
+    #
+    ENV['KEEP_LOCAL_STORE'] ||= Dir.mktmpdir
+    keepdir = ENV['KEEP_LOCAL_STORE']
+    open(File.join(keepdir, 'b9f7e25b33844d816d8531686f8bf360'), 'w') do |f|
+      f.write("2014-01-01_12:00:01 zzzzz-8i9sb-abcdefghijklmno 0  log message 1\n")
+      f.write("2014-01-01_12:00:02 zzzzz-8i9sb-abcdefghijklmno 0  log message 2\n")
+      f.write("2014-01-01_12:00:03 zzzzz-8i9sb-abcdefghijklmno 0  log message 3\n")
+    end
+
+    @log_viewer_max_bytes = Rails.configuration.log_viewer_max_bytes
+  end
+
+  def teardown
+    keepdir = ENV.delete 'KEEP_LOCAL_STORE'
+    FileUtils.rm_rf(keepdir) if keepdir
+    Rails.configuration.log_viewer_max_bytes = @log_viewer_max_bytes
+  end
+
   test "add job description" do
     Capybara.current_driver = Capybara.javascript_driver
     visit page_with_token("active", "/jobs")
@@ -25,4 +52,33 @@ class JobsTest < ActionDispatch::IntegrationTest
     click_link 'Go to dashboard'
     assert page.has_text? 'Active pipelines'
   end
+
+  test "view job log" do
+    Capybara.current_driver = Capybara.javascript_driver
+    job = api_fixture('jobs')['job_with_real_log']
+
+    visit page_with_token("active", "/jobs/#{job['uuid']}")
+    assert page.has_text? job['script_version']
+
+    click_link 'Log'
+    wait_for_ajax
+    assert page.has_text? 'Started at'
+    assert page.has_text? 'Finished at'
+    assert page.has_text? 'log message 1'
+    assert page.has_text? 'log message 2'
+    assert page.has_text? 'log message 3'
+  end
+
+  test 'view partial job log' do
+    Capybara.current_driver = Capybara.javascript_driver
+    Rails.configuration.log_viewer_max_bytes = 100
+    job = api_fixture('jobs')['job_with_real_log']
+
+    visit page_with_token("active", "/jobs/#{job['uuid']}")
+    assert page.has_text? job['script_version']
+
+    click_link 'Log'
+    wait_for_ajax
+    assert page.has_text? 'Showing only 100 bytes of this log'
+  end
 end
diff --git a/services/api/test/fixtures/collections.yml b/services/api/test/fixtures/collections.yml
index 1853117..ba95b34 100644
--- a/services/api/test/fixtures/collections.yml
+++ b/services/api/test/fixtures/collections.yml
@@ -199,3 +199,17 @@ collection_expires_in_future:
   expires_at: 2038-01-01T00:00:00Z
   manifest_text: ". 37b51d194a7513e45b56f6524f2d51f2+3 0:3:expired\n"
   name: collection_expires_in_future
+
+# a collection with a log file that can be parsed by the log viewer
+# This collection hash matches the following log text:
+#    2014-01-01_12:00:01 zzzzz-8i9sb-abcdefghijklmno 0  log message 1
+#    2014-01-01_12:00:02 zzzzz-8i9sb-abcdefghijklmno 0  log message 2
+#    2014-01-01_12:00:03 zzzzz-8i9sb-abcdefghijklmno 0  log message 3
+#
+real_log_collection:
+  uuid: zzzzz-4zz18-op4e2lbej01tcvu
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  created_at: 2014-09-01 12:00:00
+  portable_data_hash: 3399cbb0953a7823618f3e288a85ee26+81
+  manifest_text: ". b9f7e25b33844d816d8531686f8bf360+195 0:195:zzzzz-8i9sb-abcdefghijklmno.log.txt\n"
+  name: real_log_collection
diff --git a/services/api/test/fixtures/jobs.yml b/services/api/test/fixtures/jobs.yml
index e677240..7c375bc 100644
--- a/services/api/test/fixtures/jobs.yml
+++ b/services/api/test/fixtures/jobs.yml
@@ -212,3 +212,11 @@ queued:
   is_locked_by_uuid: ~
   tasks_summary: {}
   runtime_constraints: {}
+
+# A job with a log collection that can be parsed by the log viewer.
+job_with_real_log:
+  uuid: zzzzz-8i9sb-0vsrcqi7whchuil
+  created_at: 2014-09-01 12:00:00
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  log: 3399cbb0953a7823618f3e288a85ee26+81
+  script_version: 7def43a4d3f20789dda4700f703b5514cc3ed250

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list