Commit eb7390ed authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 801ced25
......@@ -47,11 +47,11 @@ module LabelsHelper
end
end
def render_label(label, tooltip: true, link: nil, css: nil)
def render_label(label, tooltip: true, link: nil, css: nil, dataset: nil)
# if scoped label is used then EE wraps label tag with scoped label
# doc link
html = render_colored_label(label, tooltip: tooltip)
html = link_to(html, link, class: css) if link
html = link_to(html, link, class: css, data: dataset) if link
html
end
......
......@@ -26,6 +26,7 @@ module Analytics
alias_attribute :custom_stage?, :custom
scope :default_stages, -> { where(custom: false) }
scope :ordered, -> { order(:relative_position, :id) }
scope :for_list, -> { includes(:start_event_label, :end_event_label).ordered }
end
def parent=(_)
......
......@@ -30,10 +30,10 @@
= render_if_exists 'shared/issuable/sidebar_item_epic', issuable_sidebar: issuable_sidebar
- milestone = issuable_sidebar[:milestone] || {}
.block.milestone
.block.milestone{ data: { qa_selector: 'milestone_block' } }
.sidebar-collapsed-icon.has-tooltip{ title: sidebar_milestone_tooltip_label(milestone), data: { container: 'body', html: 'true', placement: 'left', boundary: 'viewport' } }
= icon('clock-o', 'aria-hidden': 'true')
%span.milestone-title.collapse-truncated-title
%span.milestone-title.collapse-truncated-title{ data: { qa_selector: 'milestone_title' } }
- if milestone.present?
= milestone[:title]
- else
......@@ -107,10 +107,10 @@
= icon('spinner spin', class: 'hidden block-loading', 'aria-hidden': 'true')
- if can_edit_issuable
= link_to _('Edit'), '#', class: 'js-sidebar-dropdown-toggle edit-link qa-edit-link-labels float-right', data: { track_label: "right_sidebar", track_property: "labels", track_event: "click_edit_button", track_value: "" }
.value.issuable-show-labels.dont-hide.hide-collapsed.qa-labels-block{ class: ("has-labels" if selected_labels.any?) }
.value.issuable-show-labels.dont-hide.hide-collapsed{ class: ("has-labels" if selected_labels.any?), data: { qa_selector: 'labels_block' } }
- if selected_labels.any?
- selected_labels.each do |label_hash|
= render_label(label_from_hash(label_hash).present(issuable_subject: nil), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title]))
= render_label(label_from_hash(label_hash).present(issuable_subject: nil), link: sidebar_label_filter_path(issuable_sidebar[:project_issuables_path], label_hash[:title]), dataset: { qa_selector: 'label', qa_label_name: label_hash[:title] })
- else
%span.no-value
= _('None')
......
......@@ -17,11 +17,11 @@
= render "snippets/actions"
.snippet-header.limited-header-width
%h2.snippet-title.prepend-top-0.mb-3.qa-snippet-title
%h2.snippet-title.prepend-top-0.mb-3{ data: { qa_selector: 'snippet_title' } }
= markdown_field(@snippet, :title)
- if @snippet.description.present?
.description.qa-snippet-description
.description{ data: { qa_selector: 'snippet_description' } }
.md
= markdown_field(@snippet, :description)
%textarea.hidden.js-task-list-field
......
---
title: Try longer to clean up after using a gpg-keychain and raise exption if the
cleanup fails
merge_request: 20718
author:
type: fixed
# frozen_string_literal: true
class ChangeLabelIdIndexToIncludeActionOnLabelEvents < ActiveRecord::Migration[5.2]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
add_concurrent_index(:resource_label_events, %I[label_id action])
remove_concurrent_index(:resource_label_events, :label_id)
end
def down
add_concurrent_index(:resource_label_events, :label_id)
remove_concurrent_index(:resource_label_events, %I[label_id action])
end
end
......@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_11_19_023952) do
ActiveRecord::Schema.define(version: 2019_11_24_150431) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm"
......@@ -3477,7 +3477,7 @@ ActiveRecord::Schema.define(version: 2019_11_19_023952) do
t.text "reference_html"
t.index ["epic_id"], name: "index_resource_label_events_on_epic_id"
t.index ["issue_id"], name: "index_resource_label_events_on_issue_id"
t.index ["label_id"], name: "index_resource_label_events_on_label_id"
t.index ["label_id", "action"], name: "index_resource_label_events_on_label_id_and_action"
t.index ["merge_request_id"], name: "index_resource_label_events_on_merge_request_id"
t.index ["user_id"], name: "index_resource_label_events_on_user_id"
end
......
......@@ -8,6 +8,8 @@ module Gitlab
class StageEvent
include Gitlab::CycleAnalytics::MetricsTables
delegate :label_based?, to: :class
def initialize(params)
@params = params
end
......@@ -35,7 +37,7 @@ module Gitlab
query
end
def label_based?
def self.label_based?
false
end
......
......@@ -5,7 +5,7 @@ module Gitlab
extend self
CleanupError = Class.new(StandardError)
BG_CLEANUP_RUNTIME_S = 2
BG_CLEANUP_RUNTIME_S = 10
FG_CLEANUP_RUNTIME_S = 0.5
MUTEX = Mutex.new
......@@ -107,19 +107,18 @@ module Gitlab
begin
cleanup_tmp_dir(tmp_dir)
rescue CleanupError => e
folder_contents = Dir.children(tmp_dir)
# This means we left a GPG-agent process hanging. Logging the problem in
# sentry will make this more visible.
Gitlab::Sentry.track_exception(e,
issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918',
extra: { tmp_dir: tmp_dir })
extra: { tmp_dir: tmp_dir, contents: folder_contents })
end
tmp_keychains_removed.increment unless File.exist?(tmp_dir)
end
def cleanup_tmp_dir(tmp_dir)
return FileUtils.remove_entry(tmp_dir, true) if Feature.disabled?(:gpg_cleanup_retries)
# Retry when removing the tmp directory failed, as we may run into a
# race condition:
# The `gpg-agent` agent process may clean up some files as well while
......
......@@ -6,8 +6,8 @@ module QA
module Snippet
class Show < Page::Base
view 'app/views/shared/snippets/_header.html.haml' do
element :snippet_title
element :snippet_description
element :snippet_title, required: true
element :snippet_description, required: true
element :embed_type
element :snippet_box
end
......@@ -21,15 +21,11 @@ module QA
end
def has_snippet_title?(snippet_title)
within_element(:snippet_title) do
has_text?(snippet_title)
end
has_element? :snippet_title, text: snippet_title
end
def has_snippet_description?(snippet_description)
within_element(:snippet_description) do
has_text?(snippet_description)
end
has_element? :snippet_description, text: snippet_description
end
def has_embed_type?(embed_type)
......
......@@ -5,19 +5,20 @@ module QA
module Issuable
class Sidebar < Page::Base
view 'app/views/shared/issuable/_sidebar.html.haml' do
element :labels_block, ".issuable-show-labels" # rubocop:disable QA/ElementWithPattern
element :milestones_block, '.block.milestone' # rubocop:disable QA/ElementWithPattern
element :labels_block
element :milestone_block
element :milestone_title
end
def has_label?(label)
page.within('.issuable-show-labels') do
!!find('span', text: label)
within_element(:labels_block) do
has_element?(:label, label_name: label)
end
end
def has_milestone?(milestone)
page.within('.block.milestone') do
!!find("[href*='/milestones/']", text: milestone)
within_element(:milestone_block) do
has_element?(:milestone_title, text: milestone)
end
end
end
......
......@@ -122,9 +122,8 @@ module QA
end
def has_label?(label)
page.within(element_selector_css(:labels_block)) do
element = find('span', text: label)
!element.nil?
within_element(:labels_block) do
!!has_element?(:label, label_name: label)
end
end
......
......@@ -177,6 +177,25 @@ describe Gitlab::Gpg do
end.not_to raise_error
end
it 'tracks an exception when cleaning up the tmp dir fails' do
expected_exception = described_class::CleanupError.new('cleanup failed')
expected_tmp_dir = nil
expect(described_class).to receive(:cleanup_tmp_dir).and_raise(expected_exception)
allow(Gitlab::Sentry).to receive(:track_exception)
described_class.using_tmp_keychain do
expected_tmp_dir = described_class.current_home_dir
FileUtils.touch(File.join(expected_tmp_dir, 'dummy.file'))
end
expect(Gitlab::Sentry).to have_received(:track_exception).with(
expected_exception,
issue_url: 'https://gitlab.com/gitlab-org/gitlab/issues/20918',
extra: { tmp_dir: expected_tmp_dir, contents: ['dummy.file'] }
)
end
shared_examples 'multiple deletion attempts of the tmp-dir' do |seconds|
let(:tmp_dir) do
tmp_dir = Dir.mktmpdir
......@@ -211,15 +230,6 @@ describe Gitlab::Gpg do
expect(File.exist?(tmp_dir)).to be false
end
it 'does not retry when the feature flag is disabled' do
stub_feature_flags(gpg_cleanup_retries: false)
expect(FileUtils).to receive(:remove_entry).with(tmp_dir, true).and_call_original
expect(Retriable).not_to receive(:retriable)
described_class.using_tmp_keychain {}
end
end
it_behaves_like 'multiple deletion attempts of the tmp-dir', described_class::FG_CLEANUP_RUNTIME_S
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment