X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/c73f87c5fedba20b82a091152353f718d81ba6c3..7a2e9199172a3c102e8a6c7b723fd44bc031bda4:/services/api/test/functional/arvados/v1/container_requests_controller_test.rb diff --git a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb index 95c477f411..87eb37cde7 100644 --- a/services/api/test/functional/arvados/v1/container_requests_controller_test.rb +++ b/services/api/test/functional/arvados/v1/container_requests_controller_test.rb @@ -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,13 +19,28 @@ 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 cr = JSON.parse(@response.body) assert_not_nil cr, 'Expected container request' - assert_equal sp, cr['scheduling_parameters'] + 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 @@ -62,10 +78,32 @@ class Arvados::V1::ContainerRequestsControllerTest < ActionController::TestCase assert_equal 'bar', req.secret_mounts['/foo']['content'] end + test "cancel with runtime_constraints and scheduling_params with default values" do + authorize_with :active + req = container_requests(:queued) + + patch :update, params: { + id: req.uuid, + container_request: { + state: 'Final', + priority: 0, + runtime_constraints: { + 'vcpus' => 1, + 'ram' => 123, + 'keep_cache_ram' => 0, + }, + scheduling_parameters: { + "preemptible"=>false + } + }, + } + assert_response :success + end + 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, @@ -131,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: {