20831: Fix tests
[arvados.git] / services / api / test / functional / arvados / v1 / container_requests_controller_test.rb
index e99af39c9c18625c40879bc6f96439d0fa3b6131..87eb37cde732b220fe17cd719e299b6c723bcdfc 100644 (file)
@@ -8,8 +8,9 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
   def minimal_cr
     {
       command: ['echo', 'hello'],
-      container_image: 'test',
+      container_image: 'arvados/apitestfixture:latest',
       output_path: 'test',
+      runtime_constraints: {vcpus: 1, ram: 1}
     }
   end
 
@@ -18,7 +19,7 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
 
     sp = {'partitions' => ['test1', 'test2']}
     post :create, params: {
-           container_request: minimal_cr.merge(scheduling_parameters: sp.dup)
+           container_request: minimal_cr.merge(scheduling_parameters: sp.dup, state: "Committed")
          }
     assert_response :success
 
@@ -26,6 +27,20 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
     assert_not_nil cr, 'Expected container request'
     assert_equal sp['partitions'], cr['scheduling_parameters']['partitions']
     assert_equal false, cr['scheduling_parameters']['preemptible']
+    assert_equal false, cr['scheduling_parameters']['supervisor']
+  end
+
+  test 'create a-c-r should be supervisor' do
+    authorize_with :active
+
+    post :create, params: {
+           container_request: minimal_cr.merge(command: ["arvados-cwl-runner", "my-workflow.cwl"], state: "Committed")
+         }
+    assert_response :success
+
+    cr = JSON.parse(@response.body)
+    assert_not_nil cr, 'Expected container request'
+    assert_equal true, cr['scheduling_parameters']['supervisor']
   end
 
   test "secret_mounts not in #create responses" do
@@ -88,7 +103,7 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
   test "update without deleting secret_mounts" do
     authorize_with :active
     req = container_requests(:uncommitted)
-    req.update_attributes!(secret_mounts: {'/foo' => {'kind' => 'json', 'content' => 'bar'}})
+    req.update!(secret_mounts: {'/foo' => {'kind' => 'json', 'content' => 'bar'}})
 
     patch :update, params: {
             id: req.uuid,
@@ -154,7 +169,7 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase
   test "filter on container subproperty runtime_status[foo] = bar" do
     ctr = containers(:running)
     act_as_system_user do
-      ctr.update_attributes!(runtime_status: {foo: 'bar'})
+      ctr.update!(runtime_status: {foo: 'bar'})
     end
     authorize_with :active
     get :index, params: {