Class: Gitlab::QA::Scenario::Test::Integration::MTLS

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

Instance Method Summary collapse

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

perform

Constructor Details

#initializeMTLS

Returns a new instance of MTLS.



9
10
11
12
13
14
15
16
# File 'lib/gitlab/qa/scenario/test/integration/mtls.rb', line 9

def initialize
  @gitlab_name = 'gitlab'
  @gitaly_name = 'gitaly'
  @spec_suite = 'Test::Instance::All'
  @network = 'test'
  @env = {}
  @tag = 'mtls'
end

Instance Method Details

#gitaly_omnibusObject



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/gitlab/qa/scenario/test/integration/mtls.rb', line 88

def gitaly_omnibus
  <<~OMNIBUS
    gitaly['configuration'] = {
      auth: {
        token: 'abc123secret',
      },
      tls_listen_addr: '0.0.0.0:9999',
      tls: {
        certificate_path: '/etc/gitlab/ssl/gitaly.test.crt',
        key_path: '/etc/gitlab/ssl/gitaly.test.key',
      },
      storage: [
        {
          name: 'default',
          path: '/var/opt/gitlab/git-data/repositories',
        },
        {
          name: 'storage1',
          path: '/mnt/gitlab/git-data/repositories',
        },
      ],
    };
    postgresql['enable'] = false;
    redis['enable'] = false;
    nginx['enable'] = false;
    puma['enable'] = false;
    sidekiq['enable'] = false;
    gitlab_workhorse['enable'] = false;
    gitlab_exporter['enable'] = false;
    alertmanager['enable'] = false;
    prometheus['enable'] = false;

    gitlab_rails['rake_cache_clear'] = false;
    gitlab_rails['auto_migrate'] = false;

    gitlab_shell['secret_token'] = 'shellsecret';

    gitlab_rails['internal_api_url'] = 'https://#{@gitlab_name}.#{@network}';

    git_data_dirs({
      'default' => { 'path' => '/var/opt/gitlab/git-data' },
      'storage1' => { 'path' => '/mnt/gitlab/git-data' },
    })
  OMNIBUS
end

#gitlab_omnibusObject



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/gitlab/qa/scenario/test/integration/mtls.rb', line 72

def gitlab_omnibus
  <<~OMNIBUS
    gitaly['enable'] = false;

    external_url 'https://#{@gitlab_name}.#{@network}';

    gitlab_rails['gitaly_token'] = 'abc123secret';
    gitlab_shell['secret_token'] = 'shellsecret';

    git_data_dirs({
      'default' => { 'gitaly_address' => 'tls://#{@gitaly_name}.#{@network}:9999' },
      'storage1' => { 'gitaly_address' => 'tls://#{@gitaly_name}.#{@network}:9999' },
    });
  OMNIBUS
end

#perform(release, *rspec_args) ⇒ Object



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
64
65
66
67
68
69
70
# File 'lib/gitlab/qa/scenario/test/integration/mtls.rb', line 18

def perform(release, *rspec_args)
  # You can create 2 networks with the same 'human friendly' name if you run network create in parallel
  # However this causes 'ambiguous network' errors, so lets just create network manually earlier
  # see https://github.com/moby/moby/issues/18864#issuecomment-167006094
  # and also api docs https://github.com/moby/moby/blob/master/docs/api/v1.42.yaml#L9932-L9941
  docker = Docker::Engine.new
  docker.network_create(@network) unless docker.network_exists?(@network)

  gitaly_thread = Thread.new do
    Thread.current.abort_on_exception = true
    @gitaly_node = Component::Gitlab.perform do |gitaly|
      gitaly.release = QA::Release.new(release)
      gitaly.name = @gitaly_name
      gitaly.network = @network
      gitaly.skip_availability_check = true
      gitaly.seed_admin_token = false

      gitaly.omnibus_configuration << gitaly_omnibus
      gitaly.gitaly_tls = true

      gitaly.instance(skip_teardown: true)
    end
  end

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

    gitlab.omnibus_configuration << gitlab_omnibus
    gitlab.tls = true

    gitlab.instance do
      gitaly_thread.join
      Runtime::Logger.info("Running mTLS 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
  @gitaly_node&.teardown
end