1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: AGPL-3.0
6 require 'helpers/git_test_helper'
8 class Arvados::V1::JobReuseControllerTest < ActionController::TestCase
9 fixtures :repositories, :users, :jobs, :links, :collections
12 @controller = Arvados::V1::JobsController.new
13 authorize_with :active
17 'repository' => ['=', 'active/foo'],
18 'script' => ['=', 'hash'],
19 'script_version' => ['in git', 'main'],
20 'docker_image_locator' => ['=', nil],
21 'arvados_sdk_version' => ['=', nil],
24 def filters_from_hash(hash)
25 hash.each_pair.map { |name, filter| [name] + filter }
28 test "find Job with script version range" do
30 filters: [["repository", "=", "active/foo"],
31 ["script", "=", "hash"],
32 ["script_version", "in git", "tag1"]]
34 assert_response :success
35 assert_not_nil assigns(:objects)
36 assert_includes(assigns(:objects).map { |job| job.uuid },
37 jobs(:previous_job_run).uuid)
40 test "find Job with script version range exclusions" do
42 filters: [["repository", "=", "active/foo"],
43 ["script", "=", "hash"],
44 ["script_version", "not in git", "tag1"]]
46 assert_response :success
47 assert_not_nil assigns(:objects)
48 refute_includes(assigns(:objects).map { |job| job.uuid },
49 jobs(:previous_job_run).uuid)
52 test "find Job with Docker image range" do
54 filters: [["docker_image_locator", "in docker",
55 "arvados/apitestfixture"]]
57 assert_response :success
58 assert_not_nil assigns(:objects)
59 assert_includes(assigns(:objects).map { |job| job.uuid },
60 jobs(:previous_docker_job_run).uuid)
61 refute_includes(assigns(:objects).map { |job| job.uuid },
62 jobs(:previous_job_run).uuid)
65 test "find Job with Docker image using reader tokens" do
66 authorize_with :inactive
68 filters: [["docker_image_locator", "in docker",
69 "arvados/apitestfixture"]],
70 reader_tokens: [api_token(:active)],
72 assert_response :success
73 assert_not_nil assigns(:objects)
74 assert_includes(assigns(:objects).map { |job| job.uuid },
75 jobs(:previous_docker_job_run).uuid)
76 refute_includes(assigns(:objects).map { |job| job.uuid },
77 jobs(:previous_job_run).uuid)
80 test "'in docker' filter accepts arrays" do
82 filters: [["docker_image_locator", "in docker",
83 ["_nonesuchname_", "arvados/apitestfixture"]]]
85 assert_response :success
86 assert_not_nil assigns(:objects)
87 assert_includes(assigns(:objects).map { |job| job.uuid },
88 jobs(:previous_docker_job_run).uuid)
89 refute_includes(assigns(:objects).map { |job| job.uuid },
90 jobs(:previous_job_run).uuid)
93 test "'not in docker' filter accepts arrays" do
95 filters: [["docker_image_locator", "not in docker",
96 ["_nonesuchname_", "arvados/apitestfixture"]]]
98 assert_response :success
99 assert_not_nil assigns(:objects)
100 assert_includes(assigns(:objects).map { |job| job.uuid },
101 jobs(:previous_job_run).uuid)
102 refute_includes(assigns(:objects).map { |job| job.uuid },
103 jobs(:previous_docker_job_run).uuid)