Merge branch 'master' into 8654-arv-jobs-cwl-runner
authorPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 31 Mar 2016 14:32:09 +0000 (10:32 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 31 Mar 2016 14:32:09 +0000 (10:32 -0400)
13 files changed:
apps/workbench/test/test_helper.rb
build/run-build-packages.sh
crunch_scripts/crunchrunner
doc/api/schema/Job.html.textile.liquid
sdk/cwl/tests/test_job.py
services/api/app/controllers/arvados/v1/jobs_controller.rb
services/api/app/models/job.rb
services/api/db/migrate/20160324144017_add_components_to_job.rb [new file with mode: 0644]
services/api/db/structure.sql
services/api/test/fixtures/jobs.yml
services/api/test/functional/arvados/v1/groups_controller_test.rb
services/api/test/functional/arvados/v1/jobs_controller_test.rb
services/api/test/test_helper.rb

index 41592af993261b6affd55fa6cba0f05780d475ec..78ef2d21f1a15a106c000710c440984b5a210b16 100644 (file)
@@ -233,12 +233,12 @@ end
 
 class ActionController::TestCase
   setup do
-    @counter = 0
+    @test_counter = 0
   end
 
   def check_counter action
-    @counter += 1
-    if @counter == 2
+    @test_counter += 1
+    if @test_counter == 2
       assert_equal 1, 2, "Multiple actions in controller test"
     end
   end
index 6e086b91875efbdc3ee49c17820a72dc99799ab7..e1006305b805d699bfee31138aaa010cfdb833ae 100755 (executable)
@@ -391,6 +391,8 @@ package_go_binary services/crunchstat crunchstat \
     "Gather cpu/memory/network statistics of running Crunch jobs"
 package_go_binary tools/keep-rsync keep-rsync \
     "Copy all data from one set of Keep servers to another"
+package_go_binary sdk/go/crunchrunner crunchrunner \
+    "Crunchrunner executes a command inside a container and uploads the output"
 
 # The Python SDK
 # Please resist the temptation to add --no-python-fix-name to the fpm call here
index 02b00e44896db0eb76922a2885847bafbcd7f9b6..9e8832bb5553a033fd0847573624203c21d9f5dd 100755 (executable)
@@ -1,2 +1,7 @@
 #!/bin/sh
-exec /usr/local/bin/crunchrunner
+
+if test -n "$JOB_PARAMETER_CRUNCHRUNNER" ; then
+    exec $TASK_KEEPMOUNT/$JOB_PARAMETER_CRUNCHRUNNER
+else
+    exec /usr/local/bin/crunchrunner
+fi
index 5bc7611d0deedede7db25a38af830ffb877dc693..58b6a51cb444c2bc02cc9bf4472c3a474ad55b1e 100644 (file)
@@ -47,6 +47,7 @@ See "Specifying Git versions":#script_version below for more detail about accept
 |arvados_sdk_version|string|Git commit hash that specifies the SDK version to use from the Arvados repository|This is set by searching the Arvados repository for a match for the arvados_sdk_version runtime constraint.|
 |docker_image_locator|string|Portable data hash of the collection that contains the Docker image to use|This is set by searching readable collections for a match for the docker_image runtime constraint.|
 |runtime_constraints|hash|Constraints that must be satisfied by the job/task scheduler in order to run the job.|See below.|
+|components|hash|Name and uuid pairs representing the child work units of this job. The uuids can be of different object types.|Example components hash: @{"name1": "zzzzz-8i9sb-xyz...", "name2": "zzzzz-d1hrv-xyz...",}@|
 
 h3(#script_version). Specifying Git versions
 
index ae482387459d6b63cd81253c00cfab76ed99a640..cb306ed69e1045c6abd4671324c53a7dc4f09841 100644 (file)
@@ -25,14 +25,14 @@ class TestJob(unittest.TestCase):
                 'tasks': [{
                     'task.env': {'TMPDIR': '$(task.tmpdir)'},
                     'command': ['ls']
-                }],
-                'crunchrunner': arvados_cwl.crunchrunner_pdh + '/crunchrunner'
+                }]
             },
             'script_version': 'master',
             'minimum_script_version': '9e5b98e8f5f4727856b53447191f9c06e3da2ba6',
             'repository': 'arvados',
             'script': 'crunchrunner',
             'runtime_constraints': {
+                'docker_image': 'arvados/jobs',
                 'min_cores_per_node': 1,
                 'min_ram_mb_per_node': 1024,
                 'min_scratch_mb_per_node': 2048 # tmpdirSize + outdirSize
@@ -66,14 +66,14 @@ class TestJob(unittest.TestCase):
                 'tasks': [{
                     'task.env': {'TMPDIR': '$(task.tmpdir)'},
                     'command': ['ls']
-                }],
-                'crunchrunner': arvados_cwl.crunchrunner_pdh + '/crunchrunner'
+                }]
             },
             'script_version': 'master',
             'minimum_script_version': '9e5b98e8f5f4727856b53447191f9c06e3da2ba6',
             'repository': 'arvados',
             'script': 'crunchrunner',
             'runtime_constraints': {
+                'docker_image': 'arvados/jobs',
                 'min_cores_per_node': 3,
                 'min_ram_mb_per_node': 3000,
                 'min_scratch_mb_per_node': 5024 # tmpdirSize + outdirSize
index 0190537e8bd918130e44f4855b713e29cb079099..67963388639f9fb352ca42b0abff2a05e86d140c 100644 (file)
@@ -1,4 +1,5 @@
 class Arvados::V1::JobsController < ApplicationController
+  accept_attribute_as_json :components, Hash
   accept_attribute_as_json :script_parameters, Hash
   accept_attribute_as_json :runtime_constraints, Hash
   accept_attribute_as_json :tasks_summary, Hash
index afaae26375b6e8b1659205c439306cbb2e1d4eea..f49d3453e7eed21b8f1309d024cb47e83fc4f05c 100644 (file)
@@ -2,6 +2,7 @@ class Job < ArvadosModel
   include HasUuid
   include KindAndEtag
   include CommonApiTemplate
+  serialize :components, Hash
   attr_protected :arvados_sdk_version, :docker_image_locator
   serialize :script_parameters, Hash
   serialize :runtime_constraints, Hash
@@ -52,6 +53,7 @@ class Job < ArvadosModel
     t.add :queue_position
     t.add :node_uuids
     t.add :description
+    t.add :components
   end
 
   # Supported states for a job
@@ -239,7 +241,8 @@ class Job < ArvadosModel
           output_changed? or
           log_changed? or
           tasks_summary_changed? or
-          state_changed?
+          state_changed? or
+          components_changed?
         logger.warn "User #{current_user.uuid if current_user} tried to change protected job attributes on locked #{self.class.to_s} #{uuid_was}"
         return false
       end
diff --git a/services/api/db/migrate/20160324144017_add_components_to_job.rb b/services/api/db/migrate/20160324144017_add_components_to_job.rb
new file mode 100644 (file)
index 0000000..9595d7f
--- /dev/null
@@ -0,0 +1,11 @@
+class AddComponentsToJob < ActiveRecord::Migration
+  def up
+    add_column :jobs, :components, :text
+  end
+
+  def down
+    if column_exists?(:jobs, :components)
+      remove_column :jobs, :components
+    end
+  end
+end
index e482e6e607b4141bbbc00f9b70352852be62ac90..3ec420c1ddcf1d3ac84991359e02bb03ce1b10e9 100644 (file)
@@ -536,7 +536,8 @@ CREATE TABLE jobs (
     priority integer DEFAULT 0 NOT NULL,
     description character varying(524288),
     state character varying(255),
-    arvados_sdk_version character varying(255)
+    arvados_sdk_version character varying(255),
+    components text
 );
 
 
@@ -2580,4 +2581,6 @@ INSERT INTO schema_migrations (version) VALUES ('20151229214707');
 
 INSERT INTO schema_migrations (version) VALUES ('20160208210629');
 
-INSERT INTO schema_migrations (version) VALUES ('20160209155729');
\ No newline at end of file
+INSERT INTO schema_migrations (version) VALUES ('20160209155729');
+
+INSERT INTO schema_migrations (version) VALUES ('20160324144017');
\ No newline at end of file
index 12493e35514714dfdffc1e6f5aeabdf09d0dd223..13fe1abba8b9bfc5903dc2ebf96a388be67226cf 100644 (file)
@@ -499,6 +499,35 @@ job_in_publicly_accessible_project_but_other_objects_elsewhere:
   log: zzzzz-4zz18-fy296fx3hot09f7
   output: zzzzz-4zz18-bv31uwvy3neko21
 
+running_job_with_components:
+  uuid: zzzzz-8i9sb-with2components
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  cancelled_at: ~
+  cancelled_by_user_uuid: ~
+  cancelled_by_client_uuid: ~
+  created_at: <%= 3.minute.ago.to_s(:db) %>
+  started_at: <%= 3.minute.ago.to_s(:db) %>
+  finished_at: ~
+  script: hash
+  repository: active/foo
+  script_version: 1de84a854e2b440dc53bf42f8548afa4c17da332
+  running: true
+  success: ~
+  output: ~
+  priority: 0
+  log: ~
+  is_locked_by_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  tasks_summary:
+    failed: 0
+    todo: 3
+    running: 1
+    done: 1
+  runtime_constraints: {}
+  state: Running
+  components:
+    component1: zzzzz-8i9sb-jobuuid00000001
+    component2: zzzzz-d1hrv-pipelineuuid001
+
 # Test Helper trims the rest of the file
 
 # Do not add your fixtures below this line as the rest of this file will be trimmed by test_helper
index 6623c726df01923b7227d33f17e6f2098cab649e..00846795b4d7f7501964d0b888ba87739ce6c9d7 100644 (file)
@@ -389,7 +389,7 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     assert_response :success
 
     # verify that the user can no longer see the project
-    @counter = 0  # Reset executed action counter
+    @test_counter = 0  # Reset executed action counter
     @controller = Arvados::V1::GroupsController.new
     authorize_with :project_viewer
     get :index, filters: [['group_class', '=', 'project']], format: :json
@@ -401,7 +401,7 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     assert_equal false, found_projects.include?(groups(:starred_and_shared_active_user_project).uuid)
 
     # share the project
-    @counter = 0
+    @test_counter = 0
     @controller = Arvados::V1::LinksController.new
     authorize_with :system_user
     post :create, link: {
@@ -412,7 +412,7 @@ class Arvados::V1::GroupsControllerTest < ActionController::TestCase
     }
 
     # verify that project_viewer user can now see shared project again
-    @counter = 0
+    @test_counter = 0
     @controller = Arvados::V1::GroupsController.new
     authorize_with :project_viewer
     get :index, filters: [['group_class', '=', 'project']], format: :json
index 1e1425e92b7d27057e89a335c2480b8024b0c444..601f9a7af56f3f4260724eb8eae3bc28f5014ea7 100644 (file)
@@ -433,4 +433,79 @@ class Arvados::V1::JobsControllerTest < ActionController::TestCase
     assert_equal('077ba2ad3ea24a929091a9e6ce545c93199b8e57',
                  internal_tag(json_response['uuid']))
   end
+
+  test 'get job with components' do
+    authorize_with :active
+    get :show, {id: jobs(:running_job_with_components).uuid}
+    assert_response :success
+    assert_not_nil json_response["components"]
+    assert_equal ["component1", "component2"], json_response["components"].keys
+  end
+
+  [
+    [:active, :success],
+    [:system_user, :success],
+    [:admin, 403],
+  ].each do |user, expected|
+    test "add components to job locked by active user as #{user} user and expect #{expected}" do
+      authorize_with user
+      put :update, {
+        id: jobs(:running).uuid,
+        job: {
+          components: {"component1" => "value1", "component2" => "value2"}
+        }
+      }
+      assert_response expected
+      if expected == :success
+        assert_not_nil json_response["components"]
+        keys = json_response["components"].keys
+        assert_equal ["component1", "component2"], keys
+        assert_equal "value1", json_response["components"][keys[0]]
+      end
+    end
+  end
+
+  test 'get_delete components_get again for job with components' do
+    authorize_with :active
+    get :show, {id: jobs(:running_job_with_components).uuid}
+    assert_response :success
+    assert_not_nil json_response["components"]
+    assert_equal ["component1", "component2"], json_response["components"].keys
+
+    # delete second component
+    @test_counter = 0  # Reset executed action counter
+    @controller = Arvados::V1::JobsController.new
+    put :update, {
+      id: jobs(:running_job_with_components).uuid,
+      job: {
+        components: {"component1" => "zzzzz-8i9sb-jobuuid00000001"}
+      }
+    }
+    assert_response :success
+
+    @test_counter = 0  # Reset executed action counter
+    @controller = Arvados::V1::JobsController.new
+    get :show, {id: jobs(:running_job_with_components).uuid}
+    assert_response :success
+    assert_not_nil json_response["components"]
+    assert_equal ["component1"], json_response["components"].keys
+
+    # delete all components
+    @test_counter = 0  # Reset executed action counter
+    @controller = Arvados::V1::JobsController.new
+    put :update, {
+      id: jobs(:running_job_with_components).uuid,
+      job: {
+        components: {}
+      }
+    }
+    assert_response :success
+
+    @test_counter = 0  # Reset executed action counter
+    @controller = Arvados::V1::JobsController.new
+    get :show, {id: jobs(:running_job_with_components).uuid}
+    assert_response :success
+    assert_not_nil json_response["components"]
+    assert_equal [], json_response["components"].keys
+  end
 end
index 68d4bbf5af4b03349b11259f82357e917dd52cf7..7579abf1ffd0234b3f1857516922416e1ff263e1 100644 (file)
@@ -106,12 +106,12 @@ end
 
 class ActionController::TestCase
   setup do
-    @counter = 0
+    @test_counter = 0
   end
 
   def check_counter action
-    @counter += 1
-    if @counter == 2
+    @test_counter += 1
+    if @test_counter == 2
       assert_equal 1, 2, "Multiple actions in functional test"
     end
   end