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