Class: Gitlab::QA::Scenario::Test::Integration::GitalyCluster

Inherits:
Gitlab::QA::Scenario::Template show all
Defined in:
lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb

Direct Known Subclasses

Praefect

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Gitlab::QA::Scenario::Template

perform

Constructor Details

#initializeGitalyCluster

Returns a new instance of GitalyCluster.



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb', line 9

def initialize
  @gitlab_name = 'gitlab-gitaly-cluster'
  @primary_node_name = 'gitaly1'
  @secondary_node_name = 'gitaly2'
  @tertiary_node_name = 'gitaly3'
  @praefect_node_name = 'praefect'
  @database = 'postgres'
  @spec_suite = 'Test::Instance::All'
  @network = 'test'
  @env = {}
  @tag = 'gitaly_cluster'
end

Instance Attribute Details

#gitlab_nameObject (readonly)

Returns the value of attribute gitlab_name.



7
8
9
# File 'lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb', line 7

def gitlab_name
  @gitlab_name
end

#spec_suiteObject (readonly)

Returns the value of attribute spec_suite.



7
8
9
# File 'lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb', line 7

def spec_suite
  @spec_suite
end

Instance Method Details

#perform(release, *rspec_args) ⇒ Object

rubocop:disable Metrics/AbcSize



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
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb', line 23

def perform(release, *rspec_args)
  gitaly_primary_node = gitaly(@primary_node_name, release)
  gitaly_secondary_node = gitaly(@secondary_node_name, release)
  gitaly_tertiary_node = gitaly(@tertiary_node_name, release)

  sql_node = Component::PostgreSQL.new.tap do |sql|
    sql.name = @database
    sql.network = @network
    sql.instance(skip_teardown: true) do
      sql.run_psql '-d template1 -c "CREATE DATABASE praefect_production OWNER postgres"'
    end
  end

  praefect_node = Component::Gitlab.new.tap do |praefect|
    praefect.release = QA::Release.new(release)
    praefect.name = @praefect_node_name
    praefect.network = @network
    praefect.skip_availability_check = true

    praefect.omnibus_config = praefect_omnibus_configuration

    praefect.instance(skip_teardown: true)
  end

  Component::Gitlab.perform do |gitlab|
    gitlab.release = QA::Release.new(release)
    gitlab.name = gitlab_name
    gitlab.network = @network

    gitlab.omnibus_config = gitlab_omnibus_configuration
    gitlab.instance do
      puts "Running Gitaly Cluster specs!"

      if @tag
        rspec_args << "--" unless rspec_args.include?('--')
        rspec_args << "--tag" << @tag
      end

      Component::Specs.perform do |specs|
        specs.suite = spec_suite
        specs.release = gitlab.release
        specs.network = gitlab.network
        specs.args = [gitlab.address, *rspec_args]
        specs.env = @env
      end
    end
  end
ensure
  praefect_node&.teardown
  sql_node&.teardown
  gitaly_primary_node&.teardown
  gitaly_secondary_node&.teardown
  gitaly_tertiary_node&.teardown
end