Skip to content
Snippets Groups Projects
Commit 617925d9 authored by Tiffany Rea's avatar Tiffany Rea
Browse files

Merge branch '361338-fix-find-downstream-by-title' into 'master'

Fix finding downstream pipeline by title

See merge request !87832
parents 27851b9c d73fcb46
No related branches found
No related tags found
No related merge requests found
Pipeline #545430369 failed
Pipeline: GitLab

#545445891

    ......@@ -237,7 +237,11 @@ export default {
    <div
    class="gl-display-flex gl-downstream-pipeline-job-width gl-flex-direction-column gl-line-height-normal"
    >
    <span class="gl-text-truncate" data-testid="downstream-title">
    <span
    class="gl-text-truncate"
    data-testid="downstream-title"
    data-qa-selector="downstream_title_content"
    >
    {{ downstreamTitle }}
    </span>
    <div class="gl-text-truncate">
    ......
    ......@@ -24,6 +24,7 @@ class Show < QA::Page::Base
    view 'app/assets/javascripts/pipelines/components/graph/linked_pipeline.vue' do
    element :expand_linked_pipeline_button
    element :linked_pipeline_container
    element :downstream_title_content
    end
    view 'app/assets/javascripts/reports/components/report_section.vue' do
    ......@@ -73,6 +74,18 @@ def has_tag?(tag_name)
    end
    end
    def linked_pipelines
    all_elements(:linked_pipeline_container, minimum: 1)
    end
    def find_linked_pipeline_by_title(title)
    linked_pipelines.find do |pipeline|
    within(pipeline) do
    find_element(:downstream_title_content).text.include?(title)
    end
    end
    end
    def has_linked_pipeline?(title: nil)
    # If the pipeline page has loaded linked pipelines should appear, but it can take a little while,
    # especially on busier environments.
    ......@@ -89,21 +102,6 @@ def has_no_linked_pipeline?
    alias_method :has_no_child_pipeline?, :has_no_linked_pipeline?
    def click_job(job_name)
    # Retry due to transient bug https://gitlab.com/gitlab-org/gitlab/-/issues/347126
    QA::Support::Retrier.retry_on_exception do
    click_element(:job_link, Project::Job::Show, text: job_name)
    end
    end
    def linked_pipelines
    all_elements(:linked_pipeline_container, minimum: 1)
    end
    def find_linked_pipeline_by_title(title)
    linked_pipelines.find { |pipeline| pipeline[:title].include?(title) }
    end
    def expand_linked_pipeline(title: nil)
    linked_pipeline = title ? find_linked_pipeline_by_title(title) : linked_pipelines.first
    ......@@ -124,6 +122,13 @@ def click_on_first_job
    first('.js-pipeline-graph-job-link', wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME).click
    end
    def click_job(job_name)
    # Retry due to transient bug https://gitlab.com/gitlab-org/gitlab/-/issues/347126
    QA::Support::Retrier.retry_on_exception do
    click_element(:job_link, Project::Job::Show, text: job_name)
    end
    end
    def click_job_action(job_name)
    wait_for_requests
    ......
    ......@@ -14,94 +14,64 @@ module QA
    before do
    add_ci_file(downstream1_project, [downstream1_ci_file])
    add_ci_file(upstream_project, [upstream_ci_file, upstream_child1_ci_file, upstream_child2_ci_file])
    start_pipeline_via_api_with_variable
    Support::Waiter.wait_until(max_duration: 180, sleep_interval: 5) do
    upstream_pipeline.status == 'success'
    end
    Support::Waiter.wait_until(max_duration: 180, sleep_interval: 5) do
    downstream1_pipeline.pipeline_variables && child1_pipeline.pipeline_variables
    end
    end
    it(
    'is determined based on forward:pipeline_variables condition',
    :aggregate_failures,
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/360745',
    quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361400', type: :investigating }
    :transient,
    issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361400',
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/360745'
    ) do
    # Is inheritable when true
    expect(child1_pipeline).to have_variable(key: key, value: value),
    "Expected to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{child1_pipeline.pipeline_variables}"
    # Is not inheritable when false
    expect(child2_pipeline).not_to have_variable(key: key, value: value),
    "Did not expect to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{child2_pipeline.pipeline_variables}"
    # Is not inheritable by default
    expect(downstream1_pipeline).not_to have_variable(key: key, value: value),
    "Did not expect to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{downstream1_pipeline.pipeline_variables}"
    end
    def start_pipeline_via_api_with_variable
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.variables = [{ key: key, value: value, variable_type: 'env_var' }]
    end
    Support::Waiter.wait_until { upstream_project.pipelines.size > 1 }
    end
    def upstream_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_project.pipelines.first[:id]
    # Due to long runtime, using 5 times trials instead of default 10 times
    5.times do |i|
    QA::Runtime::Logger.info("API pipeline variable inheritance transient bug test - Trial #{i + 1}")
    start_pipeline_via_api_with_variable(i + 1)
    wait_for_pipelines
    # Is inheritable when true
    expect(child1_pipeline).to have_variable(key: key, value: value),
    "Expected to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{child1_pipeline.pipeline_variables}"
    # Is not inheritable when false
    expect(child2_pipeline).not_to have_variable(key: key, value: value),
    "Did not expect to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{child2_pipeline.pipeline_variables}"
    # Is not inheritable by default
    expect(downstream1_pipeline).not_to have_variable(key: key, value: value),
    "Did not expect to find `{key: 'TEST_VAR', value: 'This is great!'}`" \
    " but got #{downstream1_pipeline.pipeline_variables}"
    end
    end
    def child1_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'child1_trigger')
    def start_pipeline_via_api_with_variable(expected_size)
    # Wait for 1st or previous pipeline to finish
    Support::Waiter.wait_until do
    upstream_project.pipelines.size == expected_size && upstream_pipeline.status == 'success'
    end
    end
    def child2_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'child2_trigger')
    pipeline.variables = [{ key: key, value: value, variable_type: 'env_var' }]
    end
    end
    def downstream1_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = downstream1_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'downstream1_trigger')
    end
    # Wait for this pipeline to be created
    Support::Waiter.wait_until { upstream_project.pipelines.size > expected_size }
    end
    def upstream_ci_file
    {
    file_path: '.gitlab-ci.yml',
    content: <<~YAML
    stages:
    - test
    - deploy
    child1_trigger:
    stage: test
    trigger:
    include: .child1-ci.yml
    forward:
    pipeline_variables: true
    child2_trigger:
    stage: test
    trigger:
    include: .child2-ci.yml
    forward:
    ......@@ -109,7 +79,6 @@ def upstream_ci_file
    # default behavior
    downstream1_trigger:
    stage: deploy
    trigger:
    project: #{downstream1_project.full_path}
    YAML
    ......
    ......@@ -16,16 +16,13 @@ module QA
    add_ci_file(upstream_project, [upstream_ci_file, upstream_child1_ci_file])
    start_pipeline_with_variable
    Page::Project::Pipeline::Show.perform do |show|
    Support::Waiter.wait_until { show.passed? }
    end
    wait_for_pipelines
    end
    it(
    'is inheritable when forward:pipeline_variables is true',
    :aggregate_failures,
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358197',
    quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361338', type: :investigating }
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358197'
    ) do
    visit_job_page('child1', 'child1_job')
    verify_job_log_shows_variable_value
    ......@@ -40,19 +37,13 @@ def upstream_ci_file
    {
    file_path: '.gitlab-ci.yml',
    content: <<~YAML
    stages:
    - test
    - deploy
    child1_trigger:
    stage: test
    trigger:
    include: .child1-ci.yml
    forward:
    pipeline_variables: true
    downstream1_trigger:
    stage: deploy
    trigger:
    project: #{downstream1_project.full_path}
    forward:
    ......
    ......@@ -17,16 +17,13 @@ module QA
    add_ci_file(upstream_project, [upstream_ci_file, upstream_child1_ci_file, upstream_child2_ci_file])
    start_pipeline_with_variable
    Page::Project::Pipeline::Show.perform do |show|
    Support::Waiter.wait_until { show.passed? }
    end
    wait_for_pipelines
    end
    it(
    'is not inheritable when forward:pipeline_variables is false',
    :aggregate_failures,
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358199',
    quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361339', type: :investigating }
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358199'
    ) do
    visit_job_page('child1', 'child1_job')
    verify_job_log_does_not_show_variable_value
    ......@@ -40,8 +37,7 @@ module QA
    it(
    'is not inheritable by default',
    :aggregate_failures,
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358200',
    quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361339', type: :investigating }
    testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358200'
    ) do
    visit_job_page('child2', 'child2_job')
    verify_job_log_does_not_show_variable_value
    ......@@ -56,12 +52,7 @@ def upstream_ci_file
    {
    file_path: '.gitlab-ci.yml',
    content: <<~YAML
    stages:
    - test
    - deploy
    child1_trigger:
    stage: test
    trigger:
    include: .child1-ci.yml
    forward:
    ......@@ -69,12 +60,10 @@ def upstream_ci_file
    # default behavior
    child2_trigger:
    stage: test
    trigger:
    include: .child2-ci.yml
    downstream1_trigger:
    stage: deploy
    trigger:
    project: #{downstream1_project.full_path}
    forward:
    ......@@ -82,7 +71,6 @@ def upstream_ci_file
    # default behavior
    downstream2_trigger:
    stage: deploy
    trigger:
    project: #{downstream2_project.full_path}
    YAML
    ......
    ......@@ -31,7 +31,7 @@ module QA
    project.remove_via_api!
    end
    it 'creates 2 trigger jobs and passes corresponding matrix variables', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348000', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/361346', type: :investigating } do
    it 'creates 2 trigger jobs and passes corresponding matrix variables', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348000' do
    Page::Project::Pipeline::Show.perform do |parent_pipeline|
    trigger_title1 = 'deploy: [ovh, monitoring]'
    trigger_title2 = 'deploy: [ovh, app]'
    ......
    ......@@ -64,6 +64,12 @@ def start_pipeline_with_variable
    end
    end
    def wait_for_pipelines
    Support::Waiter.wait_until(max_duration: 300, sleep_interval: 10) do
    upstream_pipeline.status == 'success' && downstream1_pipeline.status == 'success'
    end
    end
    def add_ci_file(project, files)
    Resource::Repository::Commit.fabricate_via_api! do |commit|
    commit.project = project
    ......@@ -93,6 +99,41 @@ def verify_job_log_does_not_show_variable_value
    end
    end
    def upstream_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_project.pipelines.first[:id]
    end
    end
    def child1_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'child1_trigger')
    end
    end
    def child2_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = upstream_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'child2_trigger')
    end
    end
    def downstream1_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = downstream1_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'downstream1_trigger')
    end
    end
    def downstream2_pipeline
    Resource::Pipeline.fabricate_via_api! do |pipeline|
    pipeline.project = downstream2_project
    pipeline.id = upstream_pipeline.downstream_pipeline_id(bridge_name: 'downstream2_trigger')
    end
    end
    def upstream_child1_ci_file
    {
    file_path: '.child1-ci.yml',
    ......
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment