[ARVADOS] updated: 5c5e51e7fd601d4e760c76099e3225845d91bb5f

Git user git at public.curoverse.com
Wed Oct 19 16:09:52 EDT 2016


Summary of changes:
 services/api/test/unit/container_request_test.rb | 53 ++++++++++--------------
 1 file changed, 23 insertions(+), 30 deletions(-)

       via  5c5e51e7fd601d4e760c76099e3225845d91bb5f (commit)
      from  b1578a5e964e1a04d8c96c541017c44498e966cb (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 5c5e51e7fd601d4e760c76099e3225845d91bb5f
Author: Lucas Di Pentima <lucas at curoverse.com>
Date:   Wed Oct 19 17:08:24 2016 -0300

    10216: Modified test case, adding it to an already existing test.

diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb
index 46029ed..2ebbd3d 100644
--- a/services/api/test/unit/container_request_test.rb
+++ b/services/api/test/unit/container_request_test.rb
@@ -410,10 +410,12 @@ class ContainerRequestTest < ActiveSupport::TestCase
   end
 
   [
-    [{"var" => "value1"}, {"var" => "value1"}],
-    [{"var" => "value1"}, {"var" => "value2"}]
-  ].each do |env1, env2|
-    test "Container request #{(env1 == env2) ? 'does' : 'does not'} reuse container when committed" do
+    [{"var" => "value1"}, {"var" => "value1"}, nil],
+    [{"var" => "value1"}, {"var" => "value1"}, true],
+    [{"var" => "value1"}, {"var" => "value1"}, false],
+    [{"var" => "value1"}, {"var" => "value2"}, nil],
+  ].each do |env1, env2, use_existing|
+    test "Container request #{((env1 == env2) and (use_existing.nil? or use_existing == true)) ? 'does' : 'does not'} reuse container when committed#{use_existing.nil? ? '' : use_existing ? ' and use_existing == true' : ' and use_existing == false'}" do
       common_attrs = {cwd: "test",
                       priority: 1,
                       command: ["echo", "hello"],
@@ -424,39 +426,30 @@ class ContainerRequestTest < ActiveSupport::TestCase
       set_user_from_auth :active
       cr1 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Committed,
                                                     environment: env1}))
-      cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
-                                                    environment: env2}))
+      if use_existing.nil?
+        # Testing with use_existing default value
+        cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
+                                                      environment: env2}))
+      else
+
+        cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
+                                                      environment: env2,
+                                                      use_existing: use_existing}))
+      end
       assert_not_nil cr1.container_uuid
       assert_nil cr2.container_uuid
 
-      # Update cr2 to commited state and check for container equality on both cases,
-      # when env1 and env2 are equal the same container should be assigned, and
-      # when env1 and env2 are different, cr2 container should be different.
+      # Update cr2 to commited state and check for container equality on different cases:
+      # * When env1 and env2 are equal and use_existing is true, the same container
+      #   should be assigned.
+      # * When use_existing is false, a different container should be assigned.
+      # * When env1 and env2 are different, a different container should be assigned.
       cr2.update_attributes!({state: ContainerRequest::Committed})
-      assert_equal (env1 == env2), (cr1.container_uuid == cr2.container_uuid)
+      assert_equal (cr2.use_existing == true and (env1 == env2)),
+                   (cr1.container_uuid == cr2.container_uuid)
     end
   end
 
-  test "Container request doesn't reuse container when explicitly asked" do
-      common_attrs = {cwd: "test",
-                      priority: 1,
-                      command: ["echo", "hello"],
-                      output_path: "test",
-                      runtime_constraints: {"vcpus" => 4,
-                                            "ram" => 12000000000},
-                      mounts: {"test" => {"kind" => "json"}}}
-      set_user_from_auth :active
-      cr1 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Committed}))
-      cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
-                                                    use_existing: false}))
-      assert_not_nil cr1.container_uuid
-      assert_nil cr2.container_uuid
-
-      # Update cr2 to commited state and check for container equality.
-      cr2.update_attributes!({state: ContainerRequest::Committed})
-      assert_not_equal cr1.container_uuid, cr2.container_uuid
-  end
-
   test "requesting_container_uuid at create is not allowed" do
     set_user_from_auth :active
     assert_raises(ActiveRecord::RecordNotSaved) do

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list