Commit 01c27ab5 authored by Mark Lapierre's avatar Mark Lapierre

Merge branch 'fix-geo-wiki-http-secondary-spec' into 'master'

Add initial wiki HTTP push to primary node

Closes #35706

See merge request gitlab-org/gitlab!20253
parents b83380f3 c52c1ea7
......@@ -2,101 +2,111 @@
module QA
# https://gitlab.com/gitlab-org/gitlab/issues/35706
context 'Geo', :orchestrated, :geo, :quarantine do
context 'Geo', :orchestrated, :geo do
describe 'GitLab Geo Wiki HTTP push secondary' do
let(:wiki_content) { 'This tests wiki pushes via HTTP to secondary.' }
let(:push_content) { 'This is from the Geo wiki push to secondary!' }
let(:push_content_primary) { 'This is from the Geo wiki push to primary!' }
let(:push_content_secondary) { 'This is from the Geo wiki push to secondary!' }
let(:project_name) { "geo-wiki-project-#{SecureRandom.hex(8)}" }
let(:git_push_http_path_prefix) { '/-/push_from_secondary' }
wiki = nil
after do
Runtime::Browser.visit(:geo_secondary, QA::Page::Dashboard::Projects) do
Page::Main::Menu.perform do |menu|
menu.sign_out if menu.has_personal_area?(wait: 0)
end
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
context 'wiki commit' do
it 'is redirected to the primary and ultimately replicated to the secondary' do
wiki = nil
before do
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
Runtime::Browser.visit(:geo_primary, QA::Page::Main::Login) do
# Visit the primary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
# Create a new project and wiki
project = Resource::Project.fabricate_via_api! do |project|
project.name = project_name
project.description = 'Geo test project'
end
# Create a new project and wiki
project = Resource::Project.fabricate_via_api! do |project|
project.name = project_name
project.description = 'Geo test project'
end
wiki = Resource::Wiki.fabricate! do |wiki|
wiki.project = project
wiki.title = 'Geo wiki'
wiki.content = wiki_content
wiki.message = 'First wiki commit'
end
wiki = Resource::Wiki.fabricate! do |wiki|
wiki.project = project
wiki.title = 'Geo wiki'
wiki.content = wiki_content
wiki.message = 'First wiki commit'
end
expect(wiki).to have_content(wiki_content)
expect(wiki).to have_content(wiki_content)
# Perform a git push over HTTP directly to the primary
# This push is required to ensure we have the primary credentials
# written out to the .netrc
Resource::Repository::WikiPush.fabricate! do |push|
push.wiki = wiki
push.file_name = 'Readme.md'
push.file_content = push_content_primary
push.commit_message = 'Update Readme.md'
end
end
end
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
# Visit the secondary node and login
Page::Main::Login.perform(&:sign_in_using_credentials)
it 'is redirected to the primary and ultimately replicated to the secondary' do
Runtime::Browser.visit(:geo_secondary, QA::Page::Main::Login) do
Page::Main::Login.perform(&:sign_in_using_credentials)
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project_name)
dashboard.go_to_project(project_name)
end
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(project_name)
dashboard.go_to_project(project_name)
end
Page::Project::Menu.perform(&:click_wiki)
Page::Project::Menu.perform(&:click_wiki)
# Grab the HTTP URI for the secondary node and store as 'secondary_location'
Page::Project::Wiki::Show.perform do |show|
show.wait_for_repository_replication
show.click_clone_repository
end
# Grab the HTTP URI for the secondary node and store as 'secondary_location'
Page::Project::Wiki::Show.perform do |show|
show.wait_for_repository_replication
show.click_clone_repository
end
secondary_location = Page::Project::Wiki::GitAccess.perform do |git_access|
git_access.choose_repository_clone_http
git_access.repository_location
end
secondary_location = Page::Project::Wiki::GitAccess.perform do |git_access|
git_access.choose_repository_clone_http
git_access.repository_location
end
# Perform a git push over HTTP to the secondary node
push = Resource::Repository::WikiPush.fabricate! do |push|
push.wiki = wiki
push.repository_http_uri = secondary_location.uri
push.file_name = 'Home.md'
push.file_content = push_content
push.commit_message = 'Update Home.md'
end
# Perform a git push over HTTP to the secondary node
push = Resource::Repository::WikiPush.fabricate! do |push|
push.wiki = wiki
push.repository_http_uri = secondary_location.uri
push.file_name = 'Home.md'
push.file_content = push_content_secondary
push.commit_message = 'Update Home.md'
end
# Check that the git cli produces the 'warning: redirecting to..(primary node)' output
primary_uri = wiki.repository_http_location.uri
# Check that the git cli produces the 'warning: redirecting to..(primary node)' output
primary_uri = wiki.repository_http_location.uri
primary_uri.user = nil
# The secondary inserts a special path prefix.
# See `Gitlab::Geo::GitPushHttp::PATH_PREFIX`.
path = File.join(git_push_http_path_prefix, '\d+', primary_uri.path)
absolute_path = primary_uri.to_s.sub(primary_uri.path, path)
# The secondary inserts a special path prefix.
# See `Gitlab::Geo::GitPushHttp::PATH_PREFIX`.
path = File.join(git_push_http_path_prefix, '\d+', primary_uri.path)
absolute_path = primary_uri.to_s.sub(primary_uri.path, path)
expect(push.output).to match(/warning: redirecting to #{absolute_path}/)
expect(push.output).to match(/warning: redirecting to #{absolute_path}/)
# Validate git push worked and new content is visible
Page::Project::Menu.perform(&:click_wiki)
# Validate git push worked and new content is visible
Page::Project::Menu.perform(&:click_wiki)
Page::Project::Wiki::Show.perform do |show|
show.wait_for_repository_replication_with(push_content)
show.refresh
Page::Project::Wiki::Show.perform do |show|
show.wait_for_repository_replication_with(push_content_secondary)
show.refresh
expect(show).to have_content(push_content)
end
expect(show).to have_content(push_content_secondary)
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