From: Peter Amstutz Date: Thu, 6 Oct 2016 16:54:28 +0000 (-0400) Subject: 8018: Additional assertions checking when container_uuid changes/does not change. X-Git-Tag: 1.1.0~684^2 X-Git-Url: https://git.arvados.org/arvados.git/commitdiff_plain/8317b6e41e86f3e5c988906e0a9965479acf7e51 8018: Additional assertions checking when container_uuid changes/does not change. --- diff --git a/services/api/app/models/container.rb b/services/api/app/models/container.rb index 82eda473f9..29af22329c 100644 --- a/services/api/app/models/container.rb +++ b/services/api/app/models/container.rb @@ -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 diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb index ff9e685751..a7578d23fc 100644 --- a/services/api/test/unit/container_request_test.rb +++ b/services/api/test/unit/container_request_test.rb @@ -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