Merge branch 'master' into 9687-container-request-display
authorLucas Di Pentima <lucas@curoverse.com>
Tue, 30 Aug 2016 19:37:48 +0000 (16:37 -0300)
committerLucas Di Pentima <lucas@curoverse.com>
Tue, 30 Aug 2016 19:37:48 +0000 (16:37 -0300)
apps/workbench/app/models/container_work_unit.rb
apps/workbench/app/models/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 1ed182c35f8482e39537e0591c849f8538d5934f..944dc02a5578224d2e85696a817862db088f0925 100644 (file)
@@ -75,9 +75,15 @@ class ContainerWorkUnit < ProxyWorkUnit
   end
 
   def state_label
+    ec = exit_code
+    return "Failed" if (ec && ec != 0)
     get_combined(:state)
   end
 
+  def exit_code
+    get_combined(:exit_code)
+  end
+
   def docker_image
     get_combined(:container_image)
   end
index 7373bc242353b99c43f3cd73708e1ce9c7235599..924e067815718fc0fddf52a836c99cd2d6ffd94b 100644 (file)
@@ -41,6 +41,10 @@ class WorkUnit
     # returns a string representing state of the work unit
   end
 
+  def exit_code
+    # returns the work unit's execution exit code
+  end
+
   def state_bootstrap_class
     # returns a class like "danger", "success", or "warning" that a view can use directly to make a display class
   end
index c737982fc664db1e9dc5a9408383584c23bad251..304dc8ba328aefb6f38708a96b833b1c1e4bf6b8 100644 (file)
@@ -35,6 +35,19 @@ class WorkUnitTest < ActiveSupport::TestCase
     end
   end
 
+  [
+    ['cr_for_failed', 'Failed', 33],
+    ['completed', 'Complete', 0],
+  ].each do |cr_fixture, state, exit_code|
+    test "Completed ContainerRequest state = #{state} with exit_code = #{exit_code}" do
+      use_token 'active'
+      obj = find_fixture(ContainerRequest, cr_fixture)
+      wu = obj.work_unit
+      assert_equal state, wu.state_label
+      assert_equal exit_code, wu.exit_code
+    end
+  end
+
   [
     [Job, 'running_job_with_components', 1, 1, nil],
     [Job, 'queued', nil, nil, 1],
index 2216524be834c8ab55a6d4345d7216dbf863c1b9..433aff210a58b667301459277bbb5924933c3fdb 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
+
 uncommitted:
   uuid: zzzzz-xvhdp-cr4uncommittedc
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
index 79e472b0978edebd285977108b395737a8f9a8f1..049cd3c6db0307d7ce029f641f8dc93fb8ce917e 100644 (file)
@@ -69,6 +69,7 @@ completed:
   uuid: zzzzz-dz642-compltcontainer
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
+  exit_code: 0
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
@@ -88,6 +89,7 @@ completed_older:
   uuid: zzzzz-dz642-compltcontainr2
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
+  exit_code: 0
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
@@ -106,6 +108,7 @@ requester:
   uuid: zzzzz-dz642-requestingcntnr
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
+  exit_code: 0
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
@@ -122,6 +125,7 @@ requester_container:
   uuid: zzzzz-dz642-requestercntnr1
   owner_uuid: zzzzz-tpzed-xurymjxw79nv3jz
   state: Complete
+  exit_code: 0
   priority: 1
   created_at: 2016-01-11 11:11:11.111111111 Z
   updated_at: 2016-01-11 11:11:11.111111111 Z
@@ -134,3 +138,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