X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/f30e59af90558e47a4156566d0209bc8efacd85a..f28c121ae84586bec9cbadcfc5b296f563818112:/services/api/test/unit/container_request_test.rb diff --git a/services/api/test/unit/container_request_test.rb b/services/api/test/unit/container_request_test.rb index 9b35769ef2..e5c0085184 100644 --- a/services/api/test/unit/container_request_test.rb +++ b/services/api/test/unit/container_request_test.rb @@ -469,13 +469,34 @@ class ContainerRequestTest < ActiveSupport::TestCase ].each do |token, expected, expected_priority| test "create as #{token} and expect requesting_container_uuid to be #{expected}" do set_user_from_auth token - cr = ContainerRequest.create(container_image: "img", output_path: "/tmp", command: ["echo", "foo"]) + cr = create_minimal_req! assert_not_nil cr.uuid, 'uuid should be set for newly created container_request' assert_equal expected, cr.requesting_container_uuid assert_equal expected_priority, cr.priority end end + [ + ['running_container_auth', 'zzzzz-dz642-runningcontainr', 501], + ].each do |token, expected, expected_priority| + test "create as #{token} with requesting_container_uuid set and expect output to be intermediate" do + set_user_from_auth token + cr = create_minimal_req! + assert_not_nil cr.uuid, 'uuid should be set for newly created container_request' + assert_equal expected, cr.requesting_container_uuid + assert_equal expected_priority, cr.priority + + cr.state = ContainerRequest::Committed + cr.save! + + run_container(cr) + cr.reload + output = Collection.find_by_uuid(cr.output_uuid) + props = {"type": "intermediate", "container_request": cr.uuid} + assert_equal props.symbolize_keys, output.properties.symbolize_keys + end + end + test "create as container_runtime_token and expect requesting_container_uuid to be zzzzz-dz642-20isqbkl8xwnsao" do set_user_from_auth :container_runtime_token Thread.current[:token] = "#{Thread.current[:token]}/zzzzz-dz642-20isqbkl8xwnsao" @@ -1126,7 +1147,8 @@ class ContainerRequestTest < ActiveSupport::TestCase end end - test "Having preemptible_instances=true create a committed child container request and verify the scheduling parameter of its container" do + test "AlwaysUsePreemptibleInstances makes child containers preemptible" do + Rails.configuration.Containers.AlwaysUsePreemptibleInstances = true common_attrs = {cwd: "test", priority: 1, command: ["echo", "hello"], @@ -1447,4 +1469,46 @@ class ContainerRequestTest < ActiveSupport::TestCase assert_equal ["foo_storage_class"], output1.storage_classes_desired assert_equal ["bar_storage_class"], output2.storage_classes_desired end + + [ + [{}, {}, {"type": "output"}], + [{"a1": "b1"}, {}, {"type": "output", "a1": "b1"}], + [{}, {"a1": "b1"}, {"type": "output", "a1": "b1"}], + [{"a1": "b1"}, {"a1": "c1"}, {"type": "output", "a1": "b1"}], + [{"a1": "b1"}, {"a2": "c2"}, {"type": "output", "a1": "b1", "a2": "c2"}], + [{"type": "blah"}, {}, {"type": "blah"}], + ].each do |cr_prop, container_prop, expect_prop| + test "setting output_properties #{cr_prop} #{container_prop} on current container" do + act_as_user users(:active) do + cr = create_minimal_req!(priority: 1, + state: ContainerRequest::Committed, + output_name: 'foo', + output_properties: cr_prop) + + act_as_system_user do + logc = Collection.new(owner_uuid: system_user_uuid, + manifest_text: ". ef772b2f28e2c8ca84de45466ed19ee9+7815 0:0:arv-mount.txt\n") + logc.save! + + c = Container.find_by_uuid(cr.container_uuid) + c.update_attributes!(state: Container::Locked) + c.update_attributes!(state: Container::Running) + + c.update_attributes!(output_properties: container_prop) + + c.update_attributes!(state: Container::Complete, + exit_code: 0, + output: '1f4b0bc7583c2a7f9102c395f4ffc5e3+45', + log: logc.portable_data_hash) + logc.destroy + end + + cr.reload + expect_prop["container_request"] = cr.uuid + output = Collection.find_by_uuid(cr.output_uuid) + assert_equal expect_prop.symbolize_keys, output.properties.symbolize_keys + end + end + end + end