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.



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

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.



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

def gitlab_name
  @gitlab_name
end

#spec_suiteObject (readonly)

Returns the value of attribute spec_suite.



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

def spec_suite
  @spec_suite
end

Instance Method Details

#perform(release, *rspec_args) ⇒ Object



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
# File 'lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb', line 24

def perform(release, *rspec_args)
  # The postgres container starts in seconds so not essential to parallelize it
  # This also ensure that the docker network is created here, avoiding any potential race conditions later
  #  if the gitaly-cluster and GitLab containers attempt to create a network in parallel
  @sql_node = postgres

  gitaly_cluster = Thread.new do
    Thread.current.abort_on_exception = true
    start_gitaly_cluster(release)
  end

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

    gitlab.omnibus_configuration << gitlab_omnibus_configuration
    gitlab.instance do
      # Wait for gitaly cluster to finish booting, before attempting to run specs
      gitaly_cluster.join
      Runtime::Logger.info('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