X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/94e9d86f85c808e905269cde830341823b1c614b..2f66d4cc05e9442a9bb69969744d0750a02a1ed4:/apps/workbench/test/controllers/pipeline_instances_controller_test.rb diff --git a/apps/workbench/test/controllers/pipeline_instances_controller_test.rb b/apps/workbench/test/controllers/pipeline_instances_controller_test.rb index b518b077bc..4067834efa 100644 --- a/apps/workbench/test/controllers/pipeline_instances_controller_test.rb +++ b/apps/workbench/test/controllers/pipeline_instances_controller_test.rb @@ -1,43 +1,67 @@ +# Copyright (C) The Arvados Authors. All rights reserved. +# +# SPDX-License-Identifier: AGPL-3.0 + require 'test_helper' class PipelineInstancesControllerTest < ActionController::TestCase include PipelineInstancesHelper - test "one" do - r = [{started_at: 1, finished_at: 3}] - assert_equal 2, determine_wallclock_runtime(r) - - r = [{started_at: 1, finished_at: 5}] - assert_equal 4, determine_wallclock_runtime(r) - - r = [{started_at: 1, finished_at: 2}, {started_at: 3, finished_at: 5}] - assert_equal 3, determine_wallclock_runtime(r) - - r = [{started_at: 3, finished_at: 5}, {started_at: 1, finished_at: 2}] - assert_equal 3, determine_wallclock_runtime(r) - - r = [{started_at: 3, finished_at: 5}, {started_at: 1, finished_at: 2}, - {started_at: 2, finished_at: 4}] - assert_equal 4, determine_wallclock_runtime(r) - - r = [{started_at: 1, finished_at: 5}, {started_at: 2, finished_at: 3}] - assert_equal 4, determine_wallclock_runtime(r) - - r = [{started_at: 3, finished_at: 5}, {started_at: 1, finished_at: 4}] - assert_equal 4, determine_wallclock_runtime(r) + def create_instance_long_enough_to(instance_attrs={}) + # create 'two_part' pipeline with the given instance attributes + pt_fixture = api_fixture('pipeline_templates')['two_part'] + post :create, params: { + pipeline_instance: instance_attrs.merge({ + pipeline_template_uuid: pt_fixture['uuid'] + }), + format: :json + }, session: session_for(:active) + assert_response :success + pi_uuid = assigns(:object).uuid + assert_not_nil assigns(:object) + + # yield + yield pi_uuid, pt_fixture + + # delete the pipeline instance + use_token :active + PipelineInstance.where(uuid: pi_uuid).first.destroy + end - r = [{started_at: 1, finished_at: 4}, {started_at: 3, finished_at: 5}] - assert_equal 4, determine_wallclock_runtime(r) + test "can render pipeline instance with tagged collections" do + # Make sure to pass in a tagged collection to test that part of the rendering behavior. + get(:show, + params: {id: api_fixture("pipeline_instances")["pipeline_with_tagged_collection_input"]["uuid"]}, + session: session_for(:active)) + assert_response :success + end - r = [{started_at: 1, finished_at: 4}, {started_at: 3, finished_at: 5}, - {started_at: 5, finished_at: 8}] - assert_equal 7, determine_wallclock_runtime(r) + test "component rendering copes with unexpected components format" do + get(:show, + params: {id: api_fixture("pipeline_instances")["components_is_jobspec"]["uuid"]}, + session: session_for(:active)) + assert_response :success + end - r = [{started_at: 1, finished_at: 4}, {started_at: 3, finished_at: 5}, - {started_at: 6, finished_at: 8}] - assert_equal 6, determine_wallclock_runtime(r) + test "dates in JSON components are parsed" do + get(:show, + params: {id: api_fixture('pipeline_instances')['has_component_with_completed_jobs']['uuid']}, + session: session_for(:active)) + assert_response :success + assert_not_nil assigns(:object) + assert_not_nil assigns(:object).components[:foo][:job] + start_at = assigns(:object).components[:foo][:job][:started_at] + start_at = Time.parse(start_at) if (start_at.andand.class == String) + assert start_at.is_a? Time + finished_at = assigns(:object).components[:foo][:job][:started_at] + finished_at = Time.parse(finished_at) if (finished_at.andand.class == String) + assert finished_at.is_a? Time end + # The next two tests ensure that a pipeline instance can be copied + # when the template has components that do not exist in the + # instance (ticket #4000). + test "generate graph" do use_token 'admin'