1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'update_priority'
8 class UpdatePriorityTest < ActiveSupport::TestCase
9 test 'priority 0 but should be >0' do
10 uuid = containers(:running).uuid
11 ActiveRecord::Base.connection.exec_query('UPDATE containers SET priority=0 WHERE uuid=$1', 'test-setup', [[nil, uuid]])
12 assert_equal 0, Container.find_by_uuid(uuid).priority
13 UpdatePriority.update_priority
14 assert_operator 0, :<, Container.find_by_uuid(uuid).priority
16 uuid = containers(:queued).uuid
17 ActiveRecord::Base.connection.exec_query('UPDATE containers SET priority=0 WHERE uuid=$1', 'test-setup', [[nil, uuid]])
18 assert_equal 0, Container.find_by_uuid(uuid).priority
19 UpdatePriority.update_priority
20 assert_operator 0, :<, Container.find_by_uuid(uuid).priority
23 test 'priority>0 but should be 0' do
24 uuid = containers(:running).uuid
25 ActiveRecord::Base.connection.exec_query('DELETE FROM container_requests WHERE container_uuid=$1', 'test-setup', [[nil, uuid]])
26 assert_operator 0, :<, Container.find_by_uuid(uuid).priority
27 UpdatePriority.update_priority
28 assert_equal 0, Container.find_by_uuid(uuid).priority