Commit 2fc77624 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'qa-testcase-184' into 'master'

Add E2E test for database delete replication for Geo

See merge request gitlab-org/gitlab!17836
parents b3b08019 d2af416e
......@@ -32,7 +32,7 @@
- explore_groups_button_label = _('Explore groups')
- explore_groups_button_link = explore_groups_path
.js-projects-list-holder
.js-projects-list-holder{ data: { qa_selector: 'projects_list' } }
- if any_projects?(projects)
- load_pipeline_status(projects) if pipeline_status
%ul.projects-list{ class: css_classes }
......
......@@ -5,11 +5,45 @@ module QA
module Page
module Dashboard
module Projects
def self.prepended(page)
page.module_eval do
view 'app/views/shared/projects/_list.html.haml' do
element :projects_list
end
end
end
def wait_for_project_replication(project_name)
wait(max: Runtime::Geo.max_db_replication_time) do
filter_by_name(project_name)
page.has_text?(project_name)
within_element(:projects_list) do
has_text?(project_name)
end
end
end
def projects_list
find_element(:projects_list)
end
def project_created?(project_name)
fill_element(:project_filter_form, project_name)
wait(max: Runtime::Geo.max_db_replication_time) do
within_element(:projects_list) do
has_text?(project_name)
end
end
end
def project_deleted?(project_name)
fill_element(:project_filter_form, project_name)
wait(max: Runtime::Geo.max_db_replication_time) do
within_element(:projects_list) do
has_no_text?(project_name)
end
end
end
end
......
......@@ -18,6 +18,10 @@ module QA
'/'
end
def clear_project_filter
fill_element(:project_filter_form, "")
end
private
def filter_by_name(name)
......
# frozen_string_literal: true
module QA
context 'Geo', :orchestrated, :geo do
describe 'GitLab Geo project deletion replication' do
deleted_project_name = nil
deleted_project_id = nil
# Log out so subsequent tests can start unauthenticated
after do
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects)
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
end
before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials)
project_to_delete = Resource::Project.fabricate_via_api! do |project|
project.name = 'delete-this-project'
project.description = 'Geo project to be deleted'
end
deleted_project_name = project_to_delete.name
deleted_project_id = project_to_delete.id
end
end
it 'replicates deletion of a project to secondary node' do
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
# Confirm replication of project to secondary node
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
expect(dashboard.project_created?(deleted_project_name)).to be_truthy
end
Page::Dashboard::Projects.perform(&:clear_project_filter)
# Delete project from primary node via API
delete_response = delete_project_on_primary(deleted_project_id)
expect(delete_response).to have_content('202 Accepted')
# Confirm deletion is replicated to secondary node
Page::Dashboard::Projects.perform do |dashboard|
expect(dashboard.project_deleted?(deleted_project_name)).to be_truthy
end
end
def delete_project_on_primary(project_id)
api_client = Runtime::API::Client.new(:geo_primary)
delete Runtime::API::Request.new(api_client, "/projects/#{project_id}").url
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