8018: Additional assertions checking when container_uuid changes/does not change.
authorPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 6 Oct 2016 16:54:28 +0000 (12:54 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Thu, 6 Oct 2016 16:54:28 +0000 (12:54 -0400)
services/api/app/models/container.rb
services/api/test/unit/container_request_test.rb

index 82eda473f99589148604eeba7e5b622ab4ae0f65..29af22329c9717989d7d0e4541bdc0c9d40184bd 100644 (file)
@@ -290,13 +290,16 @@ class Container < ArvadosModel
         end
 
         if retryable_requests.any?
-          c = Container.create!(command: self.command,
-                                cwd: self.cwd,
-                                environment: self.environment,
-                                output_path: self.output_path,
-                                container_image: self.container_image,
-                                mounts: self.mounts,
-                                runtime_constraints: self.runtime_constraints)
+          c_attrs = {
+            command: self.command,
+            cwd: self.cwd,
+            environment: self.environment,
+            output_path: self.output_path,
+            container_image: self.container_image,
+            mounts: self.mounts,
+            runtime_constraints: self.runtime_constraints
+          }
+          c = Container.create! c_attrs
           retryable_requests.each do |cr|
             cr.with_lock do
               # Use row locking because this increments container_count
index ff9e6857514f90a08bdcd1f66863fafe37e5534a..a7578d23fce0bf1d47b4d4f53bae8e1199239f76 100644 (file)
@@ -436,6 +436,7 @@ class ContainerRequestTest < ActiveSupport::TestCase
   test "Retry on container cancelled" do
     set_user_from_auth :active
     cr = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 2)
+    prev_container_uuid = cr.container_uuid
 
     c = act_as_system_user do
       c = Container.find_by_uuid(cr.container_uuid)
@@ -446,7 +447,8 @@ class ContainerRequestTest < ActiveSupport::TestCase
 
     cr.reload
     assert_equal "Committed", cr.state
-    old_container_uuid = cr.container_uuid
+    assert_equal prev_container_uuid, cr.container_uuid
+    prev_container_uuid = cr.container_uuid
 
     act_as_system_user do
       c.update_attributes!(state: Container::Cancelled)
@@ -454,7 +456,8 @@ class ContainerRequestTest < ActiveSupport::TestCase
 
     cr.reload
     assert_equal "Committed", cr.state
-    assert_not_equal old_container_uuid, cr.container_uuid
+    assert_not_equal prev_container_uuid, cr.container_uuid
+    prev_container_uuid = cr.container_uuid
 
     c = act_as_system_user do
       c = Container.find_by_uuid(cr.container_uuid)
@@ -464,6 +467,7 @@ class ContainerRequestTest < ActiveSupport::TestCase
 
     cr.reload
     assert_equal "Final", cr.state
+    assert_equal prev_container_uuid, cr.container_uuid
   end
 
 end