Commit 05ad0ff0 authored by Dan Davison's avatar Dan Davison

Merge branch 'garbage-collection-test' into 'master'

Test garbage collection test in pipeline

See merge request gitlab-org/gitlab!62683
parents d1d25346 d9df159d
......@@ -23,7 +23,7 @@
display_path: true,
extra_group: namespace_id),
{},
{ class: 'select2 js-select-namespace qa-project-namespace-select block-truncated', data: { track_label: "#{track_label}", track_event: "activate_form_input", track_property: "project_path", track_value: "" }})
{ class: 'select2 js-select-namespace qa-project-namespace-select block-truncated', data: { track_label: "#{track_label}", track_event: "activate_form_input", track_property: "project_path", track_value: "", qa_selector: "select_namespace_dropdown" }})
- else
.input-group-prepend.static-namespace.flex-shrink-0.has-tooltip{ title: user_url(current_user.username) + '/' }
......
......@@ -17,7 +17,7 @@
- else
.form-group
= f.label :default_branch, "Default branch", class: 'label-bold'
= f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide'})
= f.select(:default_branch, @project.repository.branch_names, {}, {class: 'select2 select-wide', data: { qa_selector: 'default_branch_dropdown' }})
.form-group
.form-check
......@@ -28,4 +28,4 @@
= _("When merge requests and commits in the default branch close, any issues they reference also close.")
= link_to sprite_icon('question-o'), help_page_path('user/project/issues/managing_issues.md', anchor: 'disabling-automatic-issue-closing'), target: '_blank'
= f.submit _('Save changes'), class: "gl-button btn btn-confirm"
= f.submit _('Save changes'), class: "gl-button btn btn-confirm", data: { qa_selector: 'save_changes_button' }
......@@ -79,6 +79,7 @@ module QA
autoload :GroupLabel, 'qa/resource/group_label'
autoload :MergeRequest, 'qa/resource/merge_request'
autoload :ProjectImportedFromGithub, 'qa/resource/project_imported_from_github'
autoload :ProjectImportedFromURL, 'qa/resource/project_imported_from_url'
autoload :MergeRequestFromFork, 'qa/resource/merge_request_from_fork'
autoload :DeployKey, 'qa/resource/deploy_key'
autoload :DeployToken, 'qa/resource/deploy_token'
......@@ -290,6 +291,7 @@ module QA
module Import
autoload :Github, 'qa/page/project/import/github'
autoload :RepoByURL, 'qa/page/project/import/repo_by_url'
end
module Pipeline
......@@ -337,6 +339,7 @@ module QA
autoload :MergeRequest, 'qa/page/project/settings/merge_request'
autoload :MirroringRepositories, 'qa/page/project/settings/mirroring_repositories'
autoload :ProtectedTags, 'qa/page/project/settings/protected_tags'
autoload :DefaultBranch, 'qa/page/project/settings/default_branch'
autoload :VisibilityFeaturesPermissions, 'qa/page/project/settings/visibility_features_permissions'
autoload :AccessTokens, 'qa/page/project/settings/access_tokens'
......
# frozen_string_literal: true
module QA
module Page
module Project
module Import
class RepoByURL < Page::Base
include Page::Component::Select2
view 'app/views/projects/_new_project_fields.html.haml' do
element :select_namespace_dropdown
end
def import!(gitlab_repo_path, name)
fill_git_repository_url_link(gitlab_repo_path)
fill_project_name(name)
choose_test_namespace
click_create_button
wait_for_success
go_to_project(name)
end
private
def fill_git_repository_url_link(gitlab_repo_path)
fill_in 'project_import_url', with: gitlab_repo_path
end
def fill_project_name(name)
fill_in 'project_name', with: name
end
def choose_test_namespace
find('.js-select-namespace').click
search_and_select(Runtime::Namespace.path)
end
def click_create_button
find('.btn-confirm').click
end
def wait_for_success
wait_until(max_duration: 60, sleep_interval: 5.0, reload: true, skip_finished_loading_check_on_refresh: true) do
page.has_no_content?('Import in progress', wait: 3.0)
end
end
def go_to_project(name)
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.go_to_project(name)
end
end
end
end
end
end
end
......@@ -79,6 +79,10 @@ module QA
click_link 'GitHub'
end
def click_repo_by_url_link
click_button 'Repo by URL'
end
def enable_initialize_with_readme
check_element(:initialize_with_readme_checkbox)
end
......
# frozen_string_literal: true
module QA
module Page
module Project
module Settings
class DefaultBranch < Page::Base
include Page::Component::Select2
view 'app/views/projects/default_branch/_show.html.haml' do
element :save_changes_button
element :default_branch_dropdown
end
def set_default_branch(branch)
find('.select2-chosen').click
search_and_select(branch)
end
def click_save_changes_button
find('.btn-confirm').click
end
end
end
end
end
end
QA::Page::Project::Settings::DefaultBranch.prepend_mod_with('Page::Project::Settings::DefaultBranch', namespace: QA)
......@@ -56,6 +56,14 @@ module QA
ProtectedTags.perform(&block)
end
end
def expand_default_branch(&block)
within('#default-branch-settings') do
find('.btn-default').click do
DefaultBranch.perform(&block)
end
end
end
end
end
end
......
# frozen_string_literal: true
require 'securerandom'
module QA
module Resource
class ProjectImportedFromURL < Resource::Project
def fabricate!
self.import = true
super
group.visit!
Page::Group::Show.perform(&:go_to_new_project)
Page::Project::New.perform do |project_page|
project_page.click_import_project
project_page.click_repo_by_url_link
end
Page::Project::Import::RepoByURL.perform do |import_page|
import_page.import!(@gitlab_repository_path, @name)
end
end
end
end
end
# frozen_string_literal: true
module QA
RSpec.describe 'Package' do
describe 'Container Registry Online Garbage Collection', :registry_gc, only: { subdomain: %i[pre] } do
let(:group) { Resource::Group.fabricate_via_api! }
let(:imported_project) do
Resource::ProjectImportedFromURL.fabricate_via_browser_ui! do |project|
project.name = 'container-registry'
project.group = group
project.gitlab_repository_path = 'https://gitlab.com/gitlab-org/container-registry.git'
end
end
let!(:gitlab_ci_yaml) do
<<~YAML
variables:
GOPATH: $CI_PROJECT_DIR/.go
BUILD_CACHE: $CI_PROJECT_DIR/.online-gc-tester
STAGE_ONE_VALIDATION_DELAY: "6m"
STAGE_TWO_VALIDATION_DELAY: "12m"
STAGE_THREE_VALIDATION_DELAY: "6m"
STAGE_FOUR_VALIDATION_DELAY: "12m"
STAGE_FIVE_VALIDATION_DELAY: "12m"
stages:
- generate
- build
- test
.base: &base
image: docker:19
services:
- docker:19-dind
variables:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_TLS_VERIFY: 1
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
before_script:
- until docker info; do sleep 1; done
- mkdir -p $GOPATH
- mkdir -p $BUILD_CACHE
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
test:
stage: generate
extends: .base
script:
- apk add go make git
- make binaries
- ./bin/online-gc-tester generate --base-dir=$BUILD_CACHE
- ./bin/online-gc-tester build --base-dir=$BUILD_CACHE
- ./bin/online-gc-tester push --base-dir=$BUILD_CACHE
- ./bin/online-gc-tester pull --base-dir=$BUILD_CACHE
- ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=1 --delay=$STAGE_ONE_VALIDATION_DELAY
- ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=2 --delay=$STAGE_TWO_VALIDATION_DELAY
- ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=3 --delay=$STAGE_THREE_VALIDATION_DELAY
- ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=4 --delay=$STAGE_FOUR_VALIDATION_DELAY
- ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=5 --delay=$STAGE_FIVE_VALIDATION_DELAY
timeout: 1h 30m
YAML
end
before do
Flow::Login.sign_in
imported_project
Page::Project::Menu.perform(&:go_to_repository_settings)
Page::Project::Settings::Repository.perform do |setting|
setting.expand_default_branch
end
Page::Project::Settings::DefaultBranch.perform do |setting|
setting.set_default_branch('online-gc-test-builder-poc')
setting.click_save_changes_button
end
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = imported_project
commit.branch = 'online-gc-test-builder-poc'
commit.commit_message = 'Update .gitlab-ci.yml'
commit.update_files([{
file_path: '.gitlab-ci.yml',
content: gitlab_ci_yaml
}])
end
end
it 'runs the online garbage collector tool', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1854' do
imported_project.visit!
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('test')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 3900)
end
end
end
end
end
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