1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'helpers/docker_migration_helper'
8 class ContainerRequestTest < ActiveSupport::TestCase
9 include DockerMigrationHelper
12 def create_minimal_req! attrs={}
14 command: ["echo", "foo"],
15 container_image: links(:docker_image_collection_tag).name,
18 mounts: {"/out" => {"kind" => "tmp", "capacity" => 1000000}},
20 runtime_constraints: {"vcpus" => 1, "ram" => 2},
24 cr = ContainerRequest.create!(defaults.merge(attrs))
29 def check_bogus_states cr
30 [nil, "Flubber"].each do |state|
31 assert_raises(ActiveRecord::RecordInvalid) do
39 test "Container request create" do
40 set_user_from_auth :active
41 cr = create_minimal_req!
43 assert_nil cr.container_uuid
44 assert_equal 0, cr.priority
48 # Ensure we can modify all attributes
49 cr.command = ["echo", "foo3"]
50 cr.container_image = "img3"
52 cr.environment = {"BUP" => "BOP"}
53 cr.mounts = {"BAR" => "BAZ"}
54 cr.output_path = "/tmp4"
56 cr.runtime_constraints = {"vcpus" => 4}
58 cr.description = "bar3"
61 assert_nil cr.container_uuid
66 {"vcpus" => 1, "ram" => nil},
67 {"vcpus" => 0, "ram" => 123},
68 {"vcpus" => "1", "ram" => "123"}
69 ].each do |invalid_constraints|
70 test "Create with #{invalid_constraints}" do
71 set_user_from_auth :active
72 assert_raises(ActiveRecord::RecordInvalid) do
73 cr = create_minimal_req!(state: "Committed",
75 runtime_constraints: invalid_constraints)
80 test "Update with #{invalid_constraints}" do
81 set_user_from_auth :active
82 cr = create_minimal_req!(state: "Uncommitted", priority: 1)
84 assert_raises(ActiveRecord::RecordInvalid) do
85 cr = ContainerRequest.find_by_uuid cr.uuid
86 cr.update_attributes!(state: "Committed",
87 runtime_constraints: invalid_constraints)
92 test "Update from fixture" do
93 set_user_from_auth :active
94 cr = ContainerRequest.find_by_uuid(container_requests(:running).uuid)
95 cr.update_attributes!(description: "New description")
96 assert_equal "New description", cr.description
99 test "Update with valid runtime constraints" do
100 set_user_from_auth :active
101 cr = create_minimal_req!(state: "Uncommitted", priority: 1)
103 cr = ContainerRequest.find_by_uuid cr.uuid
104 cr.update_attributes!(state: "Committed",
105 runtime_constraints: {"vcpus" => 1, "ram" => 23})
106 assert_not_nil cr.container_uuid
109 test "Container request priority must be non-nil" do
110 set_user_from_auth :active
111 cr = create_minimal_req!
113 cr.state = "Committed"
114 assert_raises(ActiveRecord::RecordInvalid) do
119 test "Container request commit" do
120 set_user_from_auth :active
121 cr = create_minimal_req!(runtime_constraints: {"vcpus" => 2, "ram" => 30})
123 assert_nil cr.container_uuid
126 cr.state = "Committed"
132 assert_equal({"vcpus" => 2, "ram" => 30}, cr.runtime_constraints)
134 assert_not_nil cr.container_uuid
135 c = Container.find_by_uuid cr.container_uuid
137 assert_equal ["echo", "foo"], c.command
138 assert_equal collections(:docker_image).portable_data_hash, c.container_image
139 assert_equal "/tmp", c.cwd
140 assert_equal({}, c.environment)
141 assert_equal({"/out" => {"kind"=>"tmp", "capacity"=>1000000}}, c.mounts)
142 assert_equal "/out", c.output_path
143 assert_equal({"keep_cache_ram"=>268435456, "vcpus" => 2, "ram" => 30}, c.runtime_constraints)
144 assert_equal 1, c.priority
146 assert_raises(ActiveRecord::RecordInvalid) do
156 assert_equal 0, cr.priority
157 assert_equal 0, c.priority
161 test "Container request max priority" do
162 set_user_from_auth :active
163 cr = create_minimal_req!(priority: 5, state: "Committed")
165 c = Container.find_by_uuid cr.container_uuid
166 assert_equal 5, c.priority
168 cr2 = create_minimal_req!
170 cr2.state = "Committed"
171 cr2.container_uuid = cr.container_uuid
172 act_as_system_user do
176 # cr and cr2 have priority 5 and 10, and are being satisfied by
177 # the same container c, so c's priority should be
180 assert_equal 10, c.priority
182 cr2.update_attributes!(priority: 0)
185 assert_equal 5, c.priority
187 cr.update_attributes!(priority: 0)
190 assert_equal 0, c.priority
194 test "Independent container requests" do
195 set_user_from_auth :active
196 cr1 = create_minimal_req!(command: ["foo", "1"], priority: 5, state: "Committed")
197 cr2 = create_minimal_req!(command: ["foo", "2"], priority: 10, state: "Committed")
199 c1 = Container.find_by_uuid cr1.container_uuid
200 assert_equal 5, c1.priority
202 c2 = Container.find_by_uuid cr2.container_uuid
203 assert_equal 10, c2.priority
205 cr1.update_attributes!(priority: 0)
208 assert_equal 0, c1.priority
211 assert_equal 10, c2.priority
214 test "Request is finalized when its container is cancelled" do
215 set_user_from_auth :active
216 cr = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 1)
218 act_as_system_user do
219 Container.find_by_uuid(cr.container_uuid).
220 update_attributes!(state: Container::Cancelled)
224 assert_equal "Final", cr.state
227 test "Request is finalized when its container is completed" do
228 set_user_from_auth :active
229 project = groups(:private)
230 cr = create_minimal_req!(owner_uuid: project.uuid,
234 c = act_as_system_user do
235 c = Container.find_by_uuid(cr.container_uuid)
236 c.update_attributes!(state: Container::Locked)
237 c.update_attributes!(state: Container::Running)
242 assert_equal "Committed", cr.state
244 output_pdh = '1f4b0bc7583c2a7f9102c395f4ffc5e3+45'
245 log_pdh = 'fa7aeb5140e2848d39b416daeef4ffc5+45'
246 act_as_system_user do
247 c.update_attributes!(state: Container::Complete,
253 assert_equal "Final", cr.state
254 ['output', 'log'].each do |out_type|
255 pdh = Container.find_by_uuid(cr.container_uuid).send(out_type)
256 assert_equal(1, Collection.where(portable_data_hash: pdh,
257 owner_uuid: project.uuid).count,
258 "Container #{out_type} should be copied to #{project.uuid}")
260 assert_not_nil cr.output_uuid
261 assert_not_nil cr.log_uuid
262 output = Collection.find_by_uuid cr.output_uuid
263 assert_equal output_pdh, output.portable_data_hash
264 log = Collection.find_by_uuid cr.log_uuid
265 assert_equal log_pdh, log.portable_data_hash
268 test "Container makes container request, then is cancelled" do
269 set_user_from_auth :active
270 cr = create_minimal_req!(priority: 5, state: "Committed", container_count_max: 1)
272 c = Container.find_by_uuid cr.container_uuid
273 assert_equal 5, c.priority
275 cr2 = create_minimal_req!
276 cr2.update_attributes!(priority: 10, state: "Committed", requesting_container_uuid: c.uuid, command: ["echo", "foo2"], container_count_max: 1)
279 c2 = Container.find_by_uuid cr2.container_uuid
280 assert_equal 10, c2.priority
282 act_as_system_user do
283 c.state = "Cancelled"
288 assert_equal "Final", cr.state
291 assert_equal 0, cr2.priority
294 assert_equal 0, c2.priority
298 test "Container makes container request, then changes priority" do
299 set_user_from_auth :active
300 cr = create_minimal_req!(priority: 5, state: "Committed", container_count_max: 1)
302 c = Container.find_by_uuid cr.container_uuid
303 assert_equal 5, c.priority
305 cr2 = create_minimal_req!
306 cr2.update_attributes!(priority: 5, state: "Committed", requesting_container_uuid: c.uuid, command: ["echo", "foo2"], container_count_max: 1)
309 c2 = Container.find_by_uuid cr2.container_uuid
310 assert_equal 5, c2.priority
312 act_as_system_user do
320 assert_equal 10, cr2.priority
323 assert_equal 10, c2.priority
327 ['running_container_auth', 'zzzzz-dz642-runningcontainr', 12],
328 ['active_no_prefs', nil, 0],
329 ].each do |token, expected, expected_priority|
330 test "create as #{token} and expect requesting_container_uuid to be #{expected}" do
331 set_user_from_auth token
332 cr = ContainerRequest.create(container_image: "img", output_path: "/tmp", command: ["echo", "foo"])
333 assert_not_nil cr.uuid, 'uuid should be set for newly created container_request'
334 assert_equal expected, cr.requesting_container_uuid
335 assert_equal expected_priority, cr.priority
339 [[{"vcpus" => [2, nil]},
340 lambda { |resolved| resolved["vcpus"] == 2 }],
341 [{"vcpus" => [3, 7]},
342 lambda { |resolved| resolved["vcpus"] == 3 }],
344 lambda { |resolved| resolved["vcpus"] == 4 }],
345 [{"ram" => [1000000000, 2000000000]},
346 lambda { |resolved| resolved["ram"] == 1000000000 }],
347 [{"ram" => [1234234234]},
348 lambda { |resolved| resolved["ram"] == 1234234234 }],
349 ].each do |rc, okfunc|
350 test "resolve runtime constraint range #{rc} to values" do
351 resolved = Container.resolve_runtime_constraints(rc)
352 assert(okfunc.call(resolved),
353 "container runtime_constraints was #{resolved.inspect}")
358 "kind" => "collection",
359 "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
362 resolved["/out"] == {
363 "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
364 "kind" => "collection",
369 "kind" => "collection",
370 "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
371 "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
374 resolved["/out"] == {
375 "portable_data_hash" => "1f4b0bc7583c2a7f9102c395f4ffc5e3+45",
376 "kind" => "collection",
380 ].each do |mounts, okfunc|
381 test "resolve mounts #{mounts.inspect} to values" do
382 set_user_from_auth :active
383 resolved = Container.resolve_mounts(mounts)
384 assert(okfunc.call(resolved),
385 "Container.resolve_mounts returned #{resolved.inspect}")
389 test 'mount unreadable collection' do
390 set_user_from_auth :spectator
393 "kind" => "collection",
394 "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
398 assert_raises(ArvadosModel::UnresolvableContainerError) do
399 Container.resolve_mounts(m)
403 test 'mount collection with mismatched UUID and PDH' do
404 set_user_from_auth :active
407 "kind" => "collection",
408 "uuid" => "zzzzz-4zz18-znfnqtbbv4spc3w",
409 "portable_data_hash" => "fa7aeb5140e2848d39b416daeef4ffc5+45",
413 assert_raises(ArgumentError) do
414 Container.resolve_mounts(m)
418 ['arvados/apitestfixture:latest',
419 'arvados/apitestfixture',
420 'd8309758b8fe2c81034ffc8a10c36460b77db7bc5e7b448c4e5b684f9d95a678',
422 test "Container.resolve_container_image(#{tag.inspect})" do
423 set_user_from_auth :active
424 resolved = Container.resolve_container_image(tag)
425 assert_equal resolved, collections(:docker_image).portable_data_hash
429 test "Container.resolve_container_image(pdh)" do
430 set_user_from_auth :active
431 [[:docker_image, 'v1'], [:docker_image_1_12, 'v2']].each do |coll, ver|
432 Rails.configuration.docker_image_formats = [ver]
433 pdh = collections(coll).portable_data_hash
434 resolved = Container.resolve_container_image(pdh)
435 assert_equal resolved, pdh
439 ['acbd18db4cc2f85cedef654fccc4a4d8+3',
441 'arvados/apitestfixture:ENOEXIST',
443 test "container_image_for_container(#{img.inspect}) => 422" do
444 set_user_from_auth :active
445 assert_raises(ArvadosModel::UnresolvableContainerError) do
446 Container.resolve_container_image(img)
451 test "migrated docker image" do
452 Rails.configuration.docker_image_formats = ['v2']
453 add_docker19_migration_link
455 # Test that it returns only v2 images even though request is for v1 image.
457 set_user_from_auth :active
458 cr = create_minimal_req!(command: ["true", "1"],
459 container_image: collections(:docker_image).portable_data_hash)
460 assert_equal(Container.resolve_container_image(cr.container_image),
461 collections(:docker_image_1_12).portable_data_hash)
463 cr = create_minimal_req!(command: ["true", "2"],
464 container_image: links(:docker_image_collection_tag).name)
465 assert_equal(Container.resolve_container_image(cr.container_image),
466 collections(:docker_image_1_12).portable_data_hash)
469 test "use unmigrated docker image" do
470 Rails.configuration.docker_image_formats = ['v1']
471 add_docker19_migration_link
473 # Test that it returns only supported v1 images even though there is a
476 set_user_from_auth :active
477 cr = create_minimal_req!(command: ["true", "1"],
478 container_image: collections(:docker_image).portable_data_hash)
479 assert_equal(Container.resolve_container_image(cr.container_image),
480 collections(:docker_image).portable_data_hash)
482 cr = create_minimal_req!(command: ["true", "2"],
483 container_image: links(:docker_image_collection_tag).name)
484 assert_equal(Container.resolve_container_image(cr.container_image),
485 collections(:docker_image).portable_data_hash)
488 test "incompatible docker image v1" do
489 Rails.configuration.docker_image_formats = ['v1']
490 add_docker19_migration_link
492 # Don't return unsupported v2 image even if we ask for it directly.
493 set_user_from_auth :active
494 cr = create_minimal_req!(command: ["true", "1"],
495 container_image: collections(:docker_image_1_12).portable_data_hash)
496 assert_raises(ArvadosModel::UnresolvableContainerError) do
497 Container.resolve_container_image(cr.container_image)
501 test "incompatible docker image v2" do
502 Rails.configuration.docker_image_formats = ['v2']
503 # No migration link, don't return unsupported v1 image,
505 set_user_from_auth :active
506 cr = create_minimal_req!(command: ["true", "1"],
507 container_image: collections(:docker_image).portable_data_hash)
508 assert_raises(ArvadosModel::UnresolvableContainerError) do
509 Container.resolve_container_image(cr.container_image)
511 cr = create_minimal_req!(command: ["true", "2"],
512 container_image: links(:docker_image_collection_tag).name)
513 assert_raises(ArvadosModel::UnresolvableContainerError) do
514 Container.resolve_container_image(cr.container_image)
518 test "requestor can retrieve container owned by dispatch" do
519 assert_not_empty Container.readable_by(users(:admin)).where(uuid: containers(:running).uuid)
520 assert_not_empty Container.readable_by(users(:active)).where(uuid: containers(:running).uuid)
521 assert_empty Container.readable_by(users(:spectator)).where(uuid: containers(:running).uuid)
525 [{"var" => "value1"}, {"var" => "value1"}, nil],
526 [{"var" => "value1"}, {"var" => "value1"}, true],
527 [{"var" => "value1"}, {"var" => "value1"}, false],
528 [{"var" => "value1"}, {"var" => "value2"}, nil],
529 ].each do |env1, env2, use_existing|
530 test "Container request #{((env1 == env2) and (use_existing.nil? or use_existing == true)) ? 'does' : 'does not'} reuse container when committed#{use_existing.nil? ? '' : use_existing ? ' and use_existing == true' : ' and use_existing == false'}" do
531 common_attrs = {cwd: "test",
533 command: ["echo", "hello"],
535 runtime_constraints: {"vcpus" => 4,
536 "ram" => 12000000000},
537 mounts: {"test" => {"kind" => "json"}}}
538 set_user_from_auth :active
539 cr1 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Committed,
542 # Testing with use_existing default value
543 cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
547 cr2 = create_minimal_req!(common_attrs.merge({state: ContainerRequest::Uncommitted,
549 use_existing: use_existing}))
551 assert_not_nil cr1.container_uuid
552 assert_nil cr2.container_uuid
554 # Update cr2 to commited state and check for container equality on different cases:
555 # * When env1 and env2 are equal and use_existing is true, the same container
556 # should be assigned.
557 # * When use_existing is false, a different container should be assigned.
558 # * When env1 and env2 are different, a different container should be assigned.
559 cr2.update_attributes!({state: ContainerRequest::Committed})
560 assert_equal (cr2.use_existing == true and (env1 == env2)),
561 (cr1.container_uuid == cr2.container_uuid)
565 test "requesting_container_uuid at create is not allowed" do
566 set_user_from_auth :active
567 assert_raises(ActiveRecord::RecordNotSaved) do
568 create_minimal_req!(state: "Uncommitted", priority: 1, requesting_container_uuid: 'youcantdothat')
572 test "Retry on container cancelled" do
573 set_user_from_auth :active
574 cr = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 2)
575 cr2 = create_minimal_req!(priority: 1, state: "Committed", container_count_max: 2, command: ["echo", "baz"])
576 prev_container_uuid = cr.container_uuid
578 c = act_as_system_user do
579 c = Container.find_by_uuid(cr.container_uuid)
580 c.update_attributes!(state: Container::Locked)
581 c.update_attributes!(state: Container::Running)
587 assert_equal "Committed", cr.state
588 assert_equal prev_container_uuid, cr.container_uuid
589 assert_not_equal cr2.container_uuid, cr.container_uuid
590 prev_container_uuid = cr.container_uuid
592 act_as_system_user do
593 c.update_attributes!(state: Container::Cancelled)
598 assert_equal "Committed", cr.state
599 assert_not_equal prev_container_uuid, cr.container_uuid
600 assert_not_equal cr2.container_uuid, cr.container_uuid
601 prev_container_uuid = cr.container_uuid
603 c = act_as_system_user do
604 c = Container.find_by_uuid(cr.container_uuid)
605 c.update_attributes!(state: Container::Cancelled)
611 assert_equal "Final", cr.state
612 assert_equal prev_container_uuid, cr.container_uuid
613 assert_not_equal cr2.container_uuid, cr.container_uuid
616 test "Output collection name setting using output_name with name collision resolution" do
617 set_user_from_auth :active
618 output_name = 'unimaginative name'
619 Collection.create!(name: output_name)
621 cr = create_minimal_req!(priority: 1,
622 state: ContainerRequest::Committed,
623 output_name: output_name)
626 assert_equal ContainerRequest::Final, cr.state
627 output_coll = Collection.find_by_uuid(cr.output_uuid)
628 # Make sure the resulting output collection name include the original name
630 assert_not_equal output_name, output_coll.name,
631 "more than one collection with the same owner and name"
632 assert output_coll.name.include?(output_name),
633 "New name should include original name"
634 assert_match /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d+Z/, output_coll.name,
635 "New name should include ISO8601 date"
638 [[0, :check_output_ttl_0],
639 [1, :check_output_ttl_1s],
640 [365*86400, :check_output_ttl_1y],
641 ].each do |ttl, checker|
642 test "output_ttl=#{ttl}" do
643 act_as_user users(:active) do
644 cr = create_minimal_req!(priority: 1,
645 state: ContainerRequest::Committed,
650 output = Collection.find_by_uuid(cr.output_uuid)
651 send(checker, db_current_time, output.trash_at, output.delete_at)
656 def check_output_ttl_0(now, trash, delete)
661 def check_output_ttl_1s(now, trash, delete)
662 assert_not_nil(trash)
663 assert_not_nil(delete)
664 assert_in_delta(trash, now + 1.second, 10)
665 assert_in_delta(delete, now + Rails.configuration.blob_signature_ttl.second, 10)
668 def check_output_ttl_1y(now, trash, delete)
669 year = (86400*365).second
670 assert_not_nil(trash)
671 assert_not_nil(delete)
672 assert_in_delta(trash, now + year, 10)
673 assert_in_delta(delete, now + year, 10)
676 def run_container(cr)
677 act_as_system_user do
678 c = Container.find_by_uuid(cr.container_uuid)
679 c.update_attributes!(state: Container::Locked)
680 c.update_attributes!(state: Container::Running)
681 c.update_attributes!(state: Container::Complete,
683 output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45',
684 log: 'fa7aeb5140e2848d39b416daeef4ffc5+45')
689 test "Finalize committed request when reusing a finished container" do
690 set_user_from_auth :active
691 cr = create_minimal_req!(priority: 1, state: ContainerRequest::Committed)
693 assert_equal ContainerRequest::Committed, cr.state
696 assert_equal ContainerRequest::Final, cr.state
698 cr2 = create_minimal_req!(priority: 1, state: ContainerRequest::Committed)
699 assert_equal cr.container_uuid, cr2.container_uuid
700 assert_equal ContainerRequest::Final, cr2.state
702 cr3 = create_minimal_req!(priority: 1, state: ContainerRequest::Uncommitted)
703 assert_equal ContainerRequest::Uncommitted, cr3.state
704 cr3.update_attributes!(state: ContainerRequest::Committed)
705 assert_equal cr.container_uuid, cr3.container_uuid
706 assert_equal ContainerRequest::Final, cr3.state
710 [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
711 [{"partitions" => ["fastcpu","vfastcpu", 100]}, ContainerRequest::Uncommitted],
712 [{"partitions" => "fastcpu"}, ContainerRequest::Committed, ActiveRecord::RecordInvalid],
713 [{"partitions" => "fastcpu"}, ContainerRequest::Uncommitted],
714 [{"partitions" => ["fastcpu","vfastcpu"]}, ContainerRequest::Committed],
715 ].each do |sp, state, expected|
716 test "create container request with scheduling_parameters #{sp} in state #{state} and verify #{expected}" do
717 common_attrs = {cwd: "test",
719 command: ["echo", "hello"],
721 scheduling_parameters: sp,
722 mounts: {"test" => {"kind" => "json"}}}
723 set_user_from_auth :active
725 if expected == ActiveRecord::RecordInvalid
726 assert_raises(ActiveRecord::RecordInvalid) do
727 create_minimal_req!(common_attrs.merge({state: state}))
730 cr = create_minimal_req!(common_attrs.merge({state: state}))
731 assert_equal sp, cr.scheduling_parameters
733 if state == ContainerRequest::Committed
734 c = Container.find_by_uuid(cr.container_uuid)
735 assert_equal sp, c.scheduling_parameters
741 [['Committed', true, {name: "foobar", priority: 123}],
742 ['Committed', false, {container_count: 2}],
743 ['Committed', false, {container_count: 0}],
744 ['Committed', false, {container_count: nil}],
745 ['Final', false, {state: ContainerRequest::Committed, name: "foobar"}],
746 ['Final', false, {name: "foobar", priority: 123}],
747 ['Final', false, {name: "foobar", output_uuid: "zzzzz-4zz18-znfnqtbbv4spc3w"}],
748 ['Final', false, {name: "foobar", log_uuid: "zzzzz-4zz18-znfnqtbbv4spc3w"}],
749 ['Final', false, {log_uuid: "zzzzz-4zz18-znfnqtbbv4spc3w"}],
750 ['Final', false, {priority: 123}],
751 ['Final', false, {mounts: {}}],
752 ['Final', false, {container_count: 2}],
753 ['Final', true, {name: "foobar"}],
754 ['Final', true, {name: "foobar", description: "baz"}],
755 ].each do |state, permitted, updates|
756 test "state=#{state} can#{'not' if !permitted} update #{updates.inspect}" do
757 act_as_user users(:active) do
758 cr = create_minimal_req!(priority: 1,
760 container_count_max: 1)
765 act_as_system_user do
766 Container.find_by_uuid(cr.container_uuid).
767 update_attributes!(state: Container::Cancelled)
771 raise 'broken test case'
773 assert_equal state, cr.state
775 assert cr.update_attributes!(updates)
777 assert_raises(ActiveRecord::RecordInvalid) do
778 cr.update_attributes!(updates)
785 test "delete container_request and check its container's priority" do
786 act_as_user users(:active) do
787 cr = ContainerRequest.find_by_uuid container_requests(:running_to_be_deleted).uuid
789 # initially the cr's container has priority > 0
790 c = Container.find_by_uuid(cr.container_uuid)
791 assert_equal 1, c.priority
794 assert_nothing_raised {cr.destroy}
796 # the cr's container now has priority of 0
797 c = Container.find_by_uuid(cr.container_uuid)
798 assert_equal 0, c.priority
802 test "delete container_request in final state and expect no error due to before_destroy callback" do
803 act_as_user users(:active) do
804 cr = ContainerRequest.find_by_uuid container_requests(:completed).uuid
805 assert_nothing_raised {cr.destroy}
809 test "Container request valid priority" do
810 set_user_from_auth :active
811 cr = create_minimal_req!
813 assert_raises(ActiveRecord::RecordInvalid) do
833 assert_raises(ActiveRecord::RecordInvalid) do