Merge branch '15928-fs-deadlock'
[arvados.git] / services / api / test / integration / container_dispatch_test.rb
1 # Copyright (C) The Arvados Authors. All rights reserved.
2 #
3 # SPDX-License-Identifier: AGPL-3.0
4
5 require 'test_helper'
6
7 class ContainerDispatchTest < ActionDispatch::IntegrationTest
8   test "lock container with SystemRootToken" do
9     Rails.configuration.SystemRootToken = "xyzzy-SystemRootToken"
10     authheaders = {'HTTP_AUTHORIZATION' => "Bearer "+Rails.configuration.SystemRootToken}
11     get("/arvados/v1/api_client_authorizations/current",
12         headers: authheaders)
13     assert_response 200
14     #assert_not_empty json_response['uuid']
15
16     system_auth_uuid = json_response['uuid']
17     post("/arvados/v1/containers/#{containers(:queued).uuid}/lock",
18          headers: authheaders)
19     assert_response 200
20     assert_equal system_auth_uuid, Container.find_by_uuid(containers(:queued).uuid).locked_by_uuid
21
22     get("/arvados/v1/containers",
23         params: {filters: SafeJSON.dump([['locked_by_uuid', '=', system_auth_uuid]])},
24         headers: authheaders)
25     assert_response 200
26     assert_equal containers(:queued).uuid, json_response['items'][0]['uuid']
27     assert_equal system_auth_uuid, json_response['items'][0]['locked_by_uuid']
28
29     post("/arvados/v1/containers/#{containers(:queued).uuid}/unlock",
30          headers: authheaders)
31     assert_response 200
32   end
33 end