[ARVADOS] updated: 5054334a7417e35990e020aecf852a5eb3056108

Git user git at public.curoverse.com
Fri Sep 2 15:48:28 EDT 2016


Summary of changes:
 .../arvados/v1/containers_controller.rb            |  2 +-
 .../arvados/v1/containers_controller_test.rb       | 50 ++++++++++++++++++++++
 2 files changed, 51 insertions(+), 1 deletion(-)

       via  5054334a7417e35990e020aecf852a5eb3056108 (commit)
      from  67afdf7bd1d53164e91e38e3b3a801ae83da778d (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 5054334a7417e35990e020aecf852a5eb3056108
Author: radhika <radhika at curoverse.com>
Date:   Fri Sep 2 15:34:59 2016 -0400

    9898: controller test with lock / unlock state transitions.

diff --git a/services/api/app/controllers/arvados/v1/containers_controller.rb b/services/api/app/controllers/arvados/v1/containers_controller.rb
index 0da228f..3ed1e9b 100644
--- a/services/api/app/controllers/arvados/v1/containers_controller.rb
+++ b/services/api/app/controllers/arvados/v1/containers_controller.rb
@@ -21,7 +21,7 @@ class Arvados::V1::ContainersController < ApplicationController
   end
 
   def lock
-    @object.lock
+    @object.lock or raise Exception.new("Error locking container")
     show
   end
 
diff --git a/services/api/test/functional/arvados/v1/containers_controller_test.rb b/services/api/test/functional/arvados/v1/containers_controller_test.rb
index 28ffbbc..b443cee 100644
--- a/services/api/test/functional/arvados/v1/containers_controller_test.rb
+++ b/services/api/test/functional/arvados/v1/containers_controller_test.rb
@@ -71,4 +71,54 @@ class Arvados::V1::ContainersControllerTest < ActionController::TestCase
     assert_nil container.locked_by_uuid
     assert_nil container.auth_uuid
   end
+
+  def create_new_container attrs={}
+    attrs = {
+      command: ['echo', 'foo'],
+      container_image: 'img',
+      output_path: '/tmp',
+      priority: 1,
+      runtime_constraints: {"vcpus" => 1, "ram" => 1},
+    }
+    c = Container.new attrs.merge(attrs)
+    c.save!
+    cr = ContainerRequest.new attrs.merge(attrs)
+    cr.save!
+    assert cr.update_attributes(container_uuid: c.uuid,
+                                state: ContainerRequest::Committed,
+                               ), show_errors(cr)
+
+    return c
+  end
+
+  [
+    [['Queued', :success], ['Locked', :success]],
+    [['Queued', :success], ['Locked', :success], ['Locked', 422]],
+    [['Queued', :success], ['Locked', :success], ['Queued', :success]],
+    [['Queued', :success], ['Locked', :success], ['Running', :success], ['Queued', 422]],
+  ].each do |transitions|
+    test "lock and unlock state transitions #{transitions}" do
+      authorize_with :dispatch1
+
+      container = create_new_container()
+
+      transitions.each do |state, status|
+        @test_counter = 0  # Reset executed action counter
+        @controller = Arvados::V1::ContainersController.new
+        authorize_with :dispatch1
+
+        if state == 'Locked'
+          post :lock, {id: container.uuid}
+        elsif state == 'Queued'
+          post :unlock, {id: container.uuid}
+        else
+          container.update_attributes!(state: state)
+        end
+        assert_response status
+
+        container = Container.where(uuid: container['uuid']).first
+        assert_equal state, container.state if status == :success
+      end
+    end
+  end
 end

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list