9687: For a ContainerRequest being committed, if its container has the state "Complet...
authorLucas Di Pentima <lucas@curoverse.com>
Wed, 24 Aug 2016 19:05:27 +0000 (16:05 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Wed, 24 Aug 2016 19:05:27 +0000 (16:05 -0300)
apps/workbench/app/models/container_work_unit.rb
apps/workbench/test/unit/work_unit_test.rb
services/api/test/fixtures/container_requests.yml
services/api/test/fixtures/containers.yml

index 4f4c915e066ce3d8c2ef4427336e5a71b0b87b2e..43871c51515a2b63d004cee099e6caa368cff2c8 100644 (file)
@@ -75,7 +75,14 @@ class ContainerWorkUnit < ProxyWorkUnit
   end
 
   def state_label
-    get_combined(:state)
+    if @proxied.is_a? ContainerRequest and
+       get(:state) == "Committed" and
+       get(:state, @container) == "Complete" and
+       get(:exit_code, @container) != 0
+      "Failed"
+    else
+      get_combined(:state)
+    end
   end
 
   def docker_image
index c737982fc664db1e9dc5a9408383584c23bad251..236e7a2d9e98951ed976293b5a2a5e7052cdb0cb 100644 (file)
@@ -35,6 +35,13 @@ class WorkUnitTest < ActiveSupport::TestCase
     end
   end
 
+  test "state_label should be Failed if container exit_code not 0" do
+    use_token 'active'
+    obj = find_fixture(ContainerRequest, 'cr_for_failed')
+    wu = obj.work_unit
+    assert_equal "Failed", wu.state_label
+  end
+
   [
     [Job, 'running_job_with_components', 1, 1, nil],
     [Job, 'queued', nil, nil, 1],
index de41ff0e9465682e51dd6be30033c06a8f70520e..e9b3fd47e8a3b574a918a0186b02b77b35bda29b 100644 (file)
@@ -151,6 +151,25 @@ running_anonymous_accessible:
     vcpus: 1
     ram: 123
 
+cr_for_failed:
+  uuid: zzzzz-xvhdp-cr4failedcontnr
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  name: cr for container exit code not 0
+  state: Committed
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  modified_at: 2016-01-11 11:11:11.111111111 Z
+  modified_by_user_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  container_image: test
+  cwd: test
+  output_path: test
+  command: ["echo", "hello"]
+  container_uuid: zzzzz-dz642-failedcntnr
+  runtime_constraints:
+    vcpus: 1
+    ram: 123
+
 # 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 79e472b0978edebd285977108b395737a8f9a8f1..f9d18be42ebeb308c5e46001a5f26f712d8551c7 100644 (file)
@@ -134,3 +134,20 @@ requester_container:
     ram: 12000000000
     vcpus: 4
   auth_uuid: zzzzz-gj3su-077z32aux8dg2s1
+
+failed_container:
+  uuid: zzzzz-dz642-failedcntnr
+  owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
+  state: Complete
+  exit_code: 33
+  priority: 1
+  created_at: 2016-01-11 11:11:11.111111111 Z
+  updated_at: 2016-01-11 11:11:11.111111111 Z
+  container_image: test
+  cwd: test
+  output: test
+  output_path: test
+  command: ["echo", "hello"]
+  runtime_constraints:
+    ram: 12000000000
+    vcpus: 4