summaryrefslogtreecommitdiff
path: root/qa/qa/specs/features/browser_ui/3_create/gitaly/high_availability_spec.rb
blob: 3bb03f68d51e83001d3c246c13b78396ccf8bd52 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# frozen_string_literal: true

module QA
  context 'Create' do
    context 'Gitaly' do
      describe 'High Availability', :orchestrated, :gitaly_ha do
        let(:project) do
          Resource::Project.fabricate! do |project|
            project.name = 'gitaly_high_availability'
          end
        end
        let(:initial_file) { 'pushed_to_primary.txt' }
        let(:final_file) { 'pushed_to_secondary.txt' }

        before do
          @praefect_manager = Service::PraefectManager.new
          Flow::Login.sign_in
        end

        after do
          @praefect_manager.reset
        end

        it 'makes sure that automatic failover is happening' do
          Resource::Repository::ProjectPush.fabricate! do |push|
            push.project = project
            push.commit_message = 'pushed to primary gitaly node'
            push.new_branch = true
            push.file_name = initial_file
            push.file_content = "This should exist on both nodes"
          end

          @praefect_manager.stop_primary_node

          project.visit!

          Page::Project::Show.perform do |show|
            show.wait_until do
              show.has_name?(project.name)
            end
            expect(show).to have_file(initial_file)
          end

          Resource::Repository::Commit.fabricate_via_api! do |commit|
            commit.project = project
            commit.add_files([
              {
                file_path: 'committed_to_primary.txt',
                content: 'This should exist on both nodes too'
              }
            ])
          end

          project.visit!

          Page::Project::Show.perform do |show|
            expect(show).to have_file(final_file)
          end
        end
      end
    end
  end
end