Add latest changes from gitlab-org/gitlab@master

This commit is contained in:
GitLab Bot 2021-07-19 06:08:44 +00:00
parent fede4aa94d
commit 302202fe37
25 changed files with 141 additions and 97 deletions

View File

@ -123,6 +123,7 @@ Naming/FileName:
- 'ee/lib/generators/**/*'
- 'qa/qa/scenario/test/integration/ldap_no_tls.rb'
- 'qa/qa/scenario/test/integration/ldap_tls.rb'
- 'qa/tasks/*'
IgnoreExecutableScripts: true
AllowedAcronyms:

View File

@ -172,6 +172,7 @@ export default {
treeWidth,
diffFilesLength: 0,
virtualScrollCurrentIndex: -1,
disableVirtualScroller: false,
};
},
computed: {
@ -504,12 +505,17 @@ export default {
this.moveToNeighboringCommit({ direction: 'previous' }),
);
}
Mousetrap.bind(['ctrl+f', 'command+f'], () => {
this.disableVirtualScroller = true;
});
},
removeEventListeners() {
Mousetrap.unbind(keysFor(MR_PREVIOUS_FILE_IN_DIFF));
Mousetrap.unbind(keysFor(MR_NEXT_FILE_IN_DIFF));
Mousetrap.unbind(keysFor(MR_COMMITS_NEXT_COMMIT));
Mousetrap.unbind(keysFor(MR_COMMITS_PREVIOUS_COMMIT));
Mousetrap.unbind(['ctrl+f', 'command+f']);
},
jumpToFile(step) {
const targetIndex = this.currentDiffIndex + step;
@ -622,7 +628,7 @@ export default {
<div v-if="isBatchLoading" class="loading"><gl-loading-icon size="lg" /></div>
<template v-else-if="renderDiffFiles">
<dynamic-scroller
v-if="isVirtualScrollingEnabled"
v-if="!disableVirtualScroller && isVirtualScrollingEnabled"
ref="virtualScroller"
:items="diffs"
:min-item-size="70"

View File

@ -0,0 +1,18 @@
# frozen_string_literal: true
class AddDetectedAtToVulnerabilities < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
with_lock_retries do
add_column :vulnerabilities, :detected_at, :datetime_with_timezone
change_column_default :vulnerabilities, :detected_at, -> { 'NOW()' }
end
end
def down
with_lock_retries do
remove_column :vulnerabilities, :detected_at
end
end
end

View File

@ -0,0 +1 @@
de9167bc4f9e2b68b257a7ff81636d5dbb6d73ff81672fdf1c73adadf5707bea

View File

@ -19046,7 +19046,8 @@ CREATE TABLE vulnerabilities (
dismissed_at timestamp with time zone,
dismissed_by_id bigint,
resolved_on_default_branch boolean DEFAULT false NOT NULL,
present_on_default_branch boolean DEFAULT true NOT NULL
present_on_default_branch boolean DEFAULT true NOT NULL,
detected_at timestamp with time zone DEFAULT now()
);
CREATE SEQUENCE vulnerabilities_id_seq

View File

@ -4,11 +4,6 @@ LABEL maintainer="GitLab Quality Department <quality@gitlab.com>"
ENV DEBIAN_FRONTEND="noninteractive"
ENV DOCKER_VERSION="17.09.0-ce"
# https://s3.amazonaws.com/gitlab-google-chrome-stable
ENV CHROME_VERSION="91.0.4472.77-1"
ENV CHROME_DEB="google-chrome-stable_${CHROME_VERSION}_amd64.deb"
ENV CHROME_URL="https://s3.amazonaws.com/gitlab-google-chrome-stable/${CHROME_DEB}"
##
# Update APT sources and install dependencies
#
@ -22,15 +17,6 @@ RUN wget -q "https://download.docker.com/linux/static/stable/x86_64/docker-${DOC
tar -zxf "docker-${DOCKER_VERSION}.tgz" && mv docker/docker /usr/local/bin/docker && \
rm "docker-${DOCKER_VERSION}.tgz"
##
# Install Google Chrome version with headless support
# Download from our local S3 bucket, populated by https://gitlab.com/gitlab-org/gitlab-build-images/-/blob/master/scripts/cache-google-chrome
#
RUN curl --silent --show-error --fail -O "${CHROME_URL}" && \
dpkg -i "./${CHROME_DEB}" || true && \
apt-get install -f -y && \
rm -f "./${CHROME_DEB}"
##
# Install client certificate - Bug in Chrome Headless: https://gitlab.com/gitlab-org/gitlab/-/issues/331492
#
@ -60,9 +46,32 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \
apt-get update -y && apt-get install google-cloud-sdk kubectl -y
##
# Install Google Chrome version with headless support
# Download from our local S3 bucket, populated by https://gitlab.com/gitlab-org/gitlab-build-images/-/blob/master/scripts/cache-google-chrome
#
# https://s3.amazonaws.com/gitlab-google-chrome-stable
ENV CHROME_VERSION="91.0.4472.77-1"
ENV CHROME_DEB="google-chrome-stable_${CHROME_VERSION}_amd64.deb"
ENV CHROME_URL="https://s3.amazonaws.com/gitlab-google-chrome-stable/${CHROME_DEB}"
RUN curl --silent --show-error --fail -O "${CHROME_URL}" && \
dpkg -i "./${CHROME_DEB}" || true && \
apt-get install -f -y && \
rm -f "./${CHROME_DEB}"
WORKDIR /home/gitlab/qa
# Install qa dependencies or fetch from cache if unchanged
COPY ./qa/Gemfile* /home/gitlab/qa/
RUN bundle install --jobs=$(nproc) --retry=3 --without=development --quiet
##
# Fetch chromedriver based on version of chrome
# Copy rakefile first so that webdriver is not reinstalled on every code change
# https://github.com/titusfortner/webdrivers
COPY ./qa/tasks/webdrivers.rake /home/gitlab/qa/tasks/
RUN bundle exec rake -f tasks/webdrivers.rake webdrivers:chromedriver:update
COPY ./config/initializers/0_inject_enterprise_edition_module.rb /home/gitlab/config/initializers/
# Copy VERSION to ensure the COPY succeeds to copy at least one file since ee/app/models/license.rb isn't present in FOSS
# The [b] part makes ./ee/app/models/license.r[b] a pattern that is allowed to return no files (which is the case in FOSS)
@ -71,12 +80,6 @@ COPY ./lib/gitlab.rb /home/gitlab/lib/
COPY ./lib/gitlab/utils.rb /home/gitlab/lib/gitlab/
COPY ./INSTALLATION_TYPE ./VERSION /home/gitlab/
RUN bundle install --jobs=$(nproc) --retry=3 --without=development --quiet
COPY ./qa /home/gitlab/qa
# Fetch chromedriver version based on version of chrome
# https://github.com/titusfortner/webdrivers
RUN bundle exec rake webdrivers:chromedriver:update
ENTRYPOINT ["bin/test"]

View File

@ -22,7 +22,7 @@ gem 'rotp', '~> 3.1.0'
gem 'timecop', '~> 0.9.1'
gem 'parallel', '~> 1.19'
gem 'rspec-parameterized', '~> 0.4.2'
gem 'github_api', '~> 0.18.2'
gem "octokit", "~> 4.21"
gem "webdrivers", "~> 4.6"
gem 'chemlab', '~> 0.7'

View File

@ -56,31 +56,36 @@ GEM
adamantium (~> 0.2.0)
equalizer (~> 0.0.9)
concurrent-ruby (1.1.9)
descendants_tracker (0.0.4)
thread_safe (~> 0.3, >= 0.3.1)
diff-lcs (1.3)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
equalizer (0.0.11)
faker (1.9.3)
i18n (>= 0.7)
faraday (0.17.3)
faraday (1.5.1)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0.1)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.1)
faraday-patron (~> 1.0)
multipart-post (>= 1.2, < 3)
github_api (0.18.2)
addressable (~> 2.4)
descendants_tracker (~> 0.0.4)
faraday (~> 0.8)
hashie (~> 3.5, >= 3.5.2)
oauth2 (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
gitlab-qa (4.0.0)
hashie (3.6.0)
http-accept (1.7.0)
http-cookie (1.0.3)
domain_name (~> 0.5)
i18n (1.8.10)
concurrent-ruby (~> 1.0)
ice_nine (0.11.2)
jwt (2.2.2)
knapsack (1.17.1)
rake
launchy (2.4.3)
@ -96,19 +101,14 @@ GEM
mini_mime (1.0.2)
mini_portile2 (2.5.0)
minitest (5.14.4)
multi_json (1.15.0)
multi_xml (0.6.0)
multipart-post (2.1.1)
netrc (0.11.0)
nokogiri (1.11.1)
mini_portile2 (~> 2.5.0)
racc (~> 1.4)
oauth2 (1.4.4)
faraday (>= 0.8, < 2.0)
jwt (>= 1.0, < 3.0)
multi_json (~> 1.3)
multi_xml (~> 0.5)
rack (>= 1.2, < 3)
octokit (4.21.0)
faraday (>= 0.9)
sawyer (~> 0.8.0, >= 0.5.3)
oj (3.11.5)
parallel (1.19.2)
parallel_tests (2.29.0)
@ -166,7 +166,11 @@ GEM
rspec-core (>= 2, < 4, != 2.12.0)
ruby-debug-ide (0.7.2)
rake (>= 0.8.1)
ruby2_keywords (0.0.4)
rubyzip (2.3.2)
sawyer (0.8.2)
addressable (>= 2.3.5)
faraday (> 0.8, < 2.0)
selenium-webdriver (4.0.0.beta4)
childprocess (>= 0.5, < 5.0)
rexml (~> 3.2)
@ -212,10 +216,10 @@ DEPENDENCIES
chemlab (~> 0.7)
chemlab-library-www-gitlab-com (~> 0.1)
faker (~> 1.6, >= 1.6.6)
github_api (~> 0.18.2)
gitlab-qa
knapsack (~> 1.17)
nokogiri (~> 1.11.1)
octokit (~> 4.21)
parallel (~> 1.19)
parallel_tests (~> 2.29)
pry-byebug (~> 3.5.1)

View File

@ -1,8 +1,7 @@
# frozen_string_literal: true
# rubocop:disable Rails/RakeEnvironment
require 'webdrivers'
load 'webdrivers/Rakefile'
load 'tasks/webdrivers.rake'
require_relative 'qa/tools/revoke_all_personal_access_tokens'
require_relative 'qa/tools/delete_subgroups'

View File

@ -48,7 +48,7 @@ module QA
end
def mirror_direction=(value)
raise ArgumentError, "Mirror direction must be 'Push' or 'Pull'" unless %w(Push Pull).include? value
raise ArgumentError, "Mirror direction must be 'Push' or 'Pull'" unless %w[Push Pull].include?(value)
select_element(:mirror_direction, value)
@ -59,7 +59,9 @@ module QA
end
def authentication_method=(value)
raise ArgumentError, "Authentication method must be 'SSH public key', 'Password', or 'None'" unless %w(Password None SSH\ public\ key).include? value
unless %w[Password None SSH\ public\ key].include?(value)
raise ArgumentError, "Authentication method must be 'SSH public key', 'Password', or 'None'"
end
select_element(:authentication_method, value)
end
@ -129,4 +131,7 @@ module QA
end
end
QA::Page::Project::Settings::MirroringRepositories.prepend_mod_with('Page::Project::Settings::MirroringRepositories', namespace: QA)
QA::Page::Project::Settings::MirroringRepositories.prepend_mod_with( # rubocop:disable Cop/InjectEnterpriseEditionModule
'Page::Project::Settings::MirroringRepositories',
namespace: QA
)

View File

@ -1,14 +1,12 @@
# frozen_string_literal: true
require 'github_api'
require 'octokit'
module QA
module Resource
class ProjectImportedFromGithub < Resource::Project
attribute :github_repo_id do
github_repository_path.split('/').yield_self do |path|
github_client.repos.get(user: path[0], repo: path[1]).id
end
github_client.repository(github_repository_path).id
end
def fabricate!
@ -42,6 +40,10 @@ module QA
'/import/github'
end
def api_trigger_mirror_pull_path
"#{api_get_path}/mirror/pull"
end
def api_post_body
{
repo_id: github_repo_id,
@ -56,13 +58,24 @@ module QA
api_resource
end
def trigger_project_mirror
Runtime::Logger.info "Triggering pull mirror request"
Support::Retrier.retry_until(max_attempts: 6, sleep_interval: 10) do
response = post(request_url(api_trigger_mirror_pull_path), nil)
Runtime::Logger.info "Mirror pull request response: #{response}"
response.code == Support::Api::HTTP_STATUS_OK
end
end
private
# Github client
#
# @return [Github::Client]
# @return [Octokit::Client]
def github_client
@github_client ||= Github.new(oauth_token: github_personal_access_token)
@github_client ||= Octokit::Client.new(access_token: github_personal_access_token)
end
end
end

4
qa/tasks/webdrivers.rake Normal file
View File

@ -0,0 +1,4 @@
# frozen_string_literal: true
require 'webdrivers'
load 'webdrivers/Rakefile'

View File

@ -137,7 +137,7 @@ RSpec.describe 'Merge request > User sees pipelines', :js do
check_head_pipeline(expected_project: parent_project)
end
it 'does not create a pipeline in the parent project when user cancels the action' do
it 'does not create a pipeline in the parent project when user cancels the action', :clean_gitlab_redis_cache, :clean_gitlab_redis_shared_state do
visit project_merge_request_path(parent_project, merge_request)
create_merge_request_pipeline

View File

@ -138,7 +138,7 @@ RSpec.describe ProjectsHelper do
end
end
describe "#project_list_cache_key", :clean_gitlab_redis_shared_state do
describe "#project_list_cache_key", :clean_gitlab_redis_cache do
let(:project) { project_with_repo }
before do

View File

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Gitlab::RateLimitHelpers, :clean_gitlab_redis_shared_state do
RSpec.describe Gitlab::RateLimitHelpers, :clean_gitlab_redis_cache do
let(:limiter_class) do
Class.new do
include ::Gitlab::RateLimitHelpers

View File

@ -2,8 +2,8 @@
require 'spec_helper'
RSpec.describe Gitlab::SidekiqStatus do
describe '.set', :clean_gitlab_redis_shared_state do
RSpec.describe Gitlab::SidekiqStatus, :clean_gitlab_redis_queues, :clean_gitlab_redis_shared_state do
describe '.set' do
it 'stores the job ID' do
described_class.set('123')
@ -16,7 +16,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe '.unset', :clean_gitlab_redis_shared_state do
describe '.unset' do
it 'removes the job ID' do
described_class.set('123')
described_class.unset('123')
@ -29,7 +29,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe '.all_completed?', :clean_gitlab_redis_shared_state do
describe '.all_completed?' do
it 'returns true if all jobs have been completed' do
expect(described_class.all_completed?(%w(123))).to eq(true)
end
@ -41,7 +41,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe '.running?', :clean_gitlab_redis_shared_state do
describe '.running?' do
it 'returns true if job is running' do
described_class.set('123')
@ -53,7 +53,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe '.num_running', :clean_gitlab_redis_shared_state do
describe '.num_running' do
it 'returns 0 if all jobs have been completed' do
expect(described_class.num_running(%w(123))).to eq(0)
end
@ -66,7 +66,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe '.num_completed', :clean_gitlab_redis_shared_state do
describe '.num_completed' do
it 'returns 1 if all jobs have been completed' do
expect(described_class.num_completed(%w(123))).to eq(1)
end
@ -88,7 +88,7 @@ RSpec.describe Gitlab::SidekiqStatus do
end
end
describe 'completed', :clean_gitlab_redis_shared_state do
describe 'completed' do
it 'returns the completed job' do
expect(described_class.completed_jids(%w(123))).to eq(['123'])
end

View File

@ -75,7 +75,7 @@ RSpec.describe CacheMarkdownField, :clean_gitlab_redis_cache do
end
it 'returns false when the local version was bumped' do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
stub_application_setting(local_markdown_version: 2)
thing.cached_markdown_version = cache_version
is_expected.to be_falsy
@ -88,7 +88,7 @@ RSpec.describe CacheMarkdownField, :clean_gitlab_redis_cache do
end
it 'returns true when the cached version is just right' do
allow(Gitlab::CurrentSettings.current_application_settings).to receive(:local_markdown_version).and_return(2)
stub_application_setting(local_markdown_version: 2)
thing.cached_markdown_version = cache_version + 2
is_expected.to be_truthy

View File

@ -21,7 +21,7 @@ RSpec.describe API::Branches do
stub_feature_flags(branch_list_keyset_pagination: false)
end
describe "GET /projects/:id/repository/branches", :use_clean_rails_redis_caching do
describe "GET /projects/:id/repository/branches", :use_clean_rails_redis_caching, :clean_gitlab_redis_shared_state do
let(:route) { "/projects/#{project_id}/repository/branches" }
shared_examples_for 'repository branches' do

View File

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
RSpec.describe API::Ci::Runner, :clean_gitlab_redis_trace_chunks do
include StubGitlabCalls
include RedisHelpers
include WorkhorseHelpers
@ -142,7 +142,7 @@ RSpec.describe API::Ci::Runner, :clean_gitlab_redis_shared_state do
context 'when redis data are flushed' do
before do
redis_shared_state_cleanup!
redis_trace_chunks_cleanup!
end
it 'has empty trace' do

View File

@ -39,7 +39,7 @@ RSpec.describe DesignManagement::CopyDesignCollection::QueueService, :clean_gitl
expect { subject }.to change { target_issue.design_collection.copy_state }.from('ready').to('in_progress')
end
it 'queues a DesignManagement::CopyDesignCollectionWorker' do
it 'queues a DesignManagement::CopyDesignCollectionWorker', :clean_gitlab_redis_queues do
expect { subject }.to change(DesignManagement::CopyDesignCollectionWorker.jobs, :size).by(1)
end

View File

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe EventCreateService do
RSpec.describe EventCreateService, :clean_gitlab_redis_cache, :clean_gitlab_redis_shared_state do
let(:service) { described_class.new }
let_it_be(:user, reload: true) { create :user }
@ -50,7 +50,7 @@ RSpec.describe EventCreateService do
end
end
describe 'Merge Requests', :clean_gitlab_redis_shared_state do
describe 'Merge Requests' do
describe '#open_mr' do
subject(:open_mr) { service.open_mr(merge_request, merge_request.author) }
@ -194,7 +194,7 @@ RSpec.describe EventCreateService do
end
end
describe '#wiki_event', :clean_gitlab_redis_shared_state do
describe '#wiki_event' do
let_it_be(:user) { create(:user) }
let_it_be(:wiki_page) { create(:wiki_page) }
let_it_be(:meta) { create(:wiki_page_meta, :for_wiki_page, wiki_page: wiki_page) }
@ -247,7 +247,7 @@ RSpec.describe EventCreateService do
end
end
describe '#push', :clean_gitlab_redis_shared_state do
describe '#push' do
let(:push_data) do
{
commits: [
@ -272,7 +272,7 @@ RSpec.describe EventCreateService do
end
end
describe '#bulk_push', :clean_gitlab_redis_shared_state do
describe '#bulk_push' do
let(:push_data) do
{
action: :created,
@ -306,7 +306,7 @@ RSpec.describe EventCreateService do
end
end
describe 'design events', :clean_gitlab_redis_shared_state do
describe 'design events' do
let_it_be(:design) { create(:design, project: project) }
let_it_be(:author) { user }

View File

@ -554,24 +554,13 @@ RSpec.describe Git::BranchPushService, services: true do
end
end
describe "housekeeping" do
describe "housekeeping", :clean_gitlab_redis_cache, :clean_gitlab_redis_queues, :clean_gitlab_redis_shared_state do
let(:housekeeping) { Repositories::HousekeepingService.new(project) }
before do
# Flush any raw key-value data stored by the housekeeping code.
Gitlab::Redis::Cache.with { |conn| conn.flushall }
Gitlab::Redis::Queues.with { |conn| conn.flushall }
Gitlab::Redis::SharedState.with { |conn| conn.flushall }
allow(Repositories::HousekeepingService).to receive(:new).and_return(housekeeping)
end
after do
Gitlab::Redis::Cache.with { |conn| conn.flushall }
Gitlab::Redis::Queues.with { |conn| conn.flushall }
Gitlab::Redis::SharedState.with { |conn| conn.flushall }
end
it 'does not perform housekeeping when not needed' do
expect(housekeeping).not_to receive(:execute)

View File

@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe Members::CreateService, :aggregate_failures, :clean_gitlab_redis_shared_state, :sidekiq_inline do
RSpec.describe Members::CreateService, :aggregate_failures, :clean_gitlab_redis_cache, :clean_gitlab_redis_shared_state, :sidekiq_inline do
let_it_be(:source) { create(:project) }
let_it_be(:user) { create(:user) }
let_it_be(:member) { create(:user) }

View File

@ -5,21 +5,21 @@ module RedisHelpers
# Usage: performance enhancement
def redis_cache_cleanup!
Gitlab::Redis::Cache.with(&:flushall)
Gitlab::Redis::Cache.with(&:flushdb)
end
# Usage: SideKiq, Mailroom, CI Runner, Workhorse, push services
def redis_queues_cleanup!
Gitlab::Redis::Queues.with(&:flushall)
Gitlab::Redis::Queues.with(&:flushdb)
end
# Usage: session state, rate limiting
def redis_shared_state_cleanup!
Gitlab::Redis::SharedState.with(&:flushall)
Gitlab::Redis::SharedState.with(&:flushdb)
end
# Usage: CI trace chunks
def redis_trace_chunks_cleanup!
Gitlab::Redis::TraceChunks.with(&:flushall)
Gitlab::Redis::TraceChunks.with(&:flushdb)
end
end

View File

@ -5,9 +5,9 @@ RSpec.shared_context 'unique ips sign in limit' do
let(:request_context) { Gitlab::RequestContext.instance }
before do
Gitlab::Redis::Cache.with(&:flushall)
Gitlab::Redis::Queues.with(&:flushall)
Gitlab::Redis::SharedState.with(&:flushall)
redis_cache_cleanup!
redis_queues_cleanup!
redis_shared_state_cleanup!
end
before do