gitlab-qa 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d83b347ec8981ab144775468b910e228caa43412
4
- data.tar.gz: 7934fdefcdf098dd3191d3b5d18a235821d20211
3
+ metadata.gz: 32ba2e013021db66a5aa650661b9b84853494bb4
4
+ data.tar.gz: e46916c8c07a846e132713918c7cb27aaf0688dc
5
5
  SHA512:
6
- metadata.gz: 56c3cff94ff316d86c7ad90005596cde353ba858d006640bd5a7b340790bd3a815c94067c3fd4db7c3ff1a2c4f9143636c8a1d7a1e865facd5a33a3e9590b678
7
- data.tar.gz: 1691de3953e20cbb89b8d168e435fed51c23c69dd1c2d9430ab90863d8e20d4add63138f9f67286d791593bdbea0a7704d35c792414a23aaa3bf3225d8a7d43d
6
+ metadata.gz: c5c3a6a1b4eeffd67ef375c288217e2501371ae8c36f5bba98902f16e02893b5befc1b94fea238b34e2aeefd94411198c10481202df78c2cb7fd3f4a66365e8e
7
+ data.tar.gz: 69d51e22a352ed08f05ca2bd99adcc3ec59ccc3b32fde0c5cddd22f9b29ab19cf6ebe88d8eaea69bed34a02a420efbc5c98bc79c6b04fe7b2449b6eb557f3419
@@ -3,8 +3,8 @@ services:
3
3
 
4
4
  stages:
5
5
  - check
6
+ - sanity
6
7
  - test
7
- - notify
8
8
 
9
9
  variables:
10
10
  TEST_IMAGE: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa
@@ -33,6 +33,24 @@ check:rspec:
33
33
  tags:
34
34
  - docker
35
35
 
36
+ .sanity: &sanity
37
+ stage: sanity
38
+ image: $TEST_IMAGE
39
+ except:
40
+ - triggers
41
+ tags:
42
+ - docker
43
+
44
+ ce:version:
45
+ script: bin/qa Test::Sanity::Version CE
46
+ allow_failure: true
47
+ <<: *sanity
48
+
49
+ ee:version:
50
+ script: bin/qa Test::Sanity::Version EE
51
+ allow_failure: true
52
+ <<: *sanity
53
+
36
54
  .test: &test
37
55
  stage: test
38
56
  image: $TEST_IMAGE
@@ -76,14 +94,11 @@ ee:mattermost:
76
94
  script: bin/qa Test::Integration::Mattermost EE
77
95
  <<: *test
78
96
 
79
- notify:slack:
80
- before_script:
81
- - apk update && apk add git curl bash
82
- image: alpine
83
- stage: notify
84
- script:
85
- - bin/slack "#development" "Pipeline on \`$CI_BUILD_REF_NAME\` failed! Commit \`$(git log -1 --oneline | sed 's|\"|\\\\\"|g')\` See <https://gitlab.com/gitlab-org/gitlab-qa/commit/"$CI_BUILD_REF"/pipelines>"
86
- when: on_failure
87
- only:
88
- - master
89
- - tags@gitlab-org/gitlab-qa
97
+ ee:geo:
98
+ script: bin/qa Test::Integration::Geo EE
99
+ <<: *test
100
+ allow_failure: true
101
+ tags:
102
+ - docker
103
+ - 7gb
104
+ - triggered-packages
@@ -1,3 +1,6 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.3
3
+
1
4
  Style/Documentation:
2
5
  Enabled: false
3
6
 
@@ -13,5 +16,11 @@ Lint/ShadowingOuterLocalVariable:
13
16
  Metrics/BlockLength:
14
17
  Enabled: false
15
18
 
16
- Style/PredicateName:
19
+ Style/FrozenStringLiteralComment:
17
20
  Enabled: false
21
+
22
+ Metrics/MethodLength:
23
+ Max: 20
24
+
25
+ Metrics/AbcSize:
26
+ Max: 18
@@ -1,46 +1,12 @@
1
- ## Contributing
1
+ ## Developer Certificate of Origin + License
2
2
 
3
- Thank you for your interest in contributing to this GitLab project! We welcome
4
- all contributions. By participating in this project, you agree to abide by the
5
- [code of conduct](#code-of-conduct).
3
+ By contributing to GitLab B.V., You accept and agree to the following terms and
4
+ conditions for Your present and future Contributions submitted to GitLab B.V.
5
+ Except for the license granted herein to GitLab B.V. and recipients of software
6
+ distributed by GitLab B.V., You reserve all right, title, and interest in and to
7
+ Your Contributions. All Contributions are subject to the following DCO + License
8
+ terms.
6
9
 
7
- ## Contributor license agreement
10
+ [DCO + License](https://gitlab.com/gitlab-org/dco/blob/master/README.md)
8
11
 
9
- By submitting code as an individual you agree to the [individual contributor
10
- license agreement][individual-agreement].
11
-
12
- By submitting code as an entity you agree to the [corporate contributor license
13
- agreement][corporate-agreement].
14
-
15
- ## Code of conduct
16
-
17
- As contributors and maintainers of this project, we pledge to respect all people
18
- who contribute through reporting issues, posting feature requests, updating
19
- documentation, submitting pull requests or patches, and other activities.
20
-
21
- We are committed to making participation in this project a harassment-free
22
- experience for everyone, regardless of level of experience, gender, gender
23
- identity and expression, sexual orientation, disability, personal appearance,
24
- body size, race, ethnicity, age, or religion.
25
-
26
- Examples of unacceptable behavior by participants include the use of sexual
27
- language or imagery, derogatory comments or personal attacks, trolling, public
28
- or private harassment, insults, or other unprofessional conduct.
29
-
30
- Project maintainers have the right and responsibility to remove, edit, or reject
31
- comments, commits, code, wiki edits, issues, and other contributions that are
32
- not aligned to this Code of Conduct. Project maintainers who do not follow the
33
- Code of Conduct may be removed from the project team.
34
-
35
- This code of conduct applies both within project spaces and in public spaces
36
- when an individual is representing the project or its community.
37
-
38
- Instances of abusive, harassing, or otherwise unacceptable behavior can be
39
- reported by emailing contact@gitlab.com.
40
-
41
- This Code of Conduct is adapted from the [Contributor Covenant][contributor-covenant], version 1.1.0,
42
- available at [http://contributor-covenant.org/version/1/1/0/](http://contributor-covenant.org/version/1/1/0/).
43
-
44
- [contributor-covenant]: http://contributor-covenant.org
45
- [individual-agreement]: https://docs.gitlab.com/ee/legal/individual_contributor_license_agreement.html
46
- [corporate-agreement]: https://docs.gitlab.com/ee/legal/corporate_contributor_license_agreement.html
12
+ _This notice should stay as the first item in the CONTRIBUTING.md file._
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
- The MIT License
1
+ Copyright (c) 2011-2017 GitLab B.V.
2
2
 
3
- Copyright (c) 2016-2017 GitLab Inc.
3
+ With regard to the GitLab Software:
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -9,13 +9,17 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
9
  copies of the Software, and to permit persons to whom the Software is
10
10
  furnished to do so, subject to the following conditions:
11
11
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
14
 
15
15
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
16
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
17
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
23
+ For all third party components incorporated into the GitLab Software, those
24
+ components are licensed under the original license provided by the owner of the
25
+ applicable component.
data/README.md CHANGED
@@ -10,6 +10,10 @@ GitLab consists of multiple pieces configured and packaged by
10
10
 
11
11
  The purpose of this test suite is to verify that all pieces do integrate well together.
12
12
 
13
+ ## Architecture
14
+
15
+ See the [GitLab QA architecture](/docs/architecture.md).
16
+
13
17
  ## How do we use it
14
18
 
15
19
  Currently we trigger test suite against GitLab Docker images created by Omnibus nightly.
@@ -37,6 +41,10 @@ command in your system.
37
41
 
38
42
  `gitlab-qa Test::Instance::Any CE|EE nightly|latest http://your.instance.gitlab`
39
43
 
44
+ For instance, to run it against https://staging.gitlab.com:
45
+
46
+ `GITLAB_USERNAME=your_username GITLAB_PASSWORD=your_password gitlab-qa Test::Instance::Any EE latest https://staging.gitlab.com`
47
+
40
48
  ## How does it work?
41
49
 
42
50
  GitLab QA handles a few scenarios:
@@ -0,0 +1,5 @@
1
+ # GitLab QA architecture
2
+
3
+ <img src="https://docs.google.com/drawings/d/e/2PACX-1vTBlBcIBFFnQOd9xGQ7-2rij96mP2-ajNd9sQILhSI2D7x-q_8oMuO_GFG8-BWRoQZkVHWdQZTdXF8c/pub?w=855&amp;h=2426">
4
+
5
+ _[edit diagram (for GitLab team members only)](https://docs.google.com/drawings/d/12mTCF7BU-xaxxS9MmIjkSYnf31RN4wgkkHcXTmS0NoA/edit)_
@@ -1,4 +1,3 @@
1
- # coding: utf-8
2
1
  lib = File.expand_path('../lib', __FILE__)
3
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
3
  require 'gitlab/qa/version'
@@ -19,9 +18,9 @@ Gem::Specification.new do |spec|
19
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ['lib']
21
20
 
22
- spec.add_development_dependency 'bundler', '~> 1.12'
23
- spec.add_development_dependency 'rake', '~> 10.0'
24
- spec.add_development_dependency 'rspec', '~> 3.0'
25
- spec.add_development_dependency 'rubocop', '~> 0.47.1'
26
- spec.add_development_dependency 'pry', '~> 0.10.4'
21
+ spec.add_development_dependency 'bundler', '~> 1.16'
22
+ spec.add_development_dependency 'pry', '~> 0.11'
23
+ spec.add_development_dependency 'rake', '~> 12.2'
24
+ spec.add_development_dependency 'rspec', '~> 3.7'
25
+ spec.add_development_dependency 'rubocop', '~> 0.51'
27
26
  end
@@ -1,4 +1,4 @@
1
- $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
1
+ $LOAD_PATH << File.expand_path(__dir__)
2
2
 
3
3
  module Gitlab
4
4
  module QA
@@ -25,6 +25,11 @@ module Gitlab
25
25
 
26
26
  module Integration
27
27
  autoload :Mattermost, 'qa/scenario/test/integration/mattermost'
28
+ autoload :Geo, 'qa/scenario/test/integration/geo'
29
+ end
30
+
31
+ module Sanity
32
+ autoload :Version, 'qa/scenario/test/sanity/version'
28
33
  end
29
34
  end
30
35
  end
@@ -2,7 +2,6 @@ require 'securerandom'
2
2
  require 'net/http'
3
3
  require 'uri'
4
4
  require 'forwardable'
5
- require 'shellwords'
6
5
 
7
6
  module Gitlab
8
7
  module QA
@@ -14,7 +13,8 @@ module Gitlab
14
13
  # rubocop:disable Style/Semicolon
15
14
 
16
15
  attr_reader :release, :docker
17
- attr_accessor :volumes, :network, :environment, :network_aliases
16
+ attr_accessor :volumes, :network, :environment
17
+ attr_writer :name
18
18
 
19
19
  def_delegators :release, :tag, :image, :edition
20
20
 
@@ -28,7 +28,11 @@ module Gitlab
28
28
  end
29
29
 
30
30
  def omnibus_config=(config)
31
- @environment['GITLAB_OMNIBUS_CONFIG'] = config
31
+ @environment['GITLAB_OMNIBUS_CONFIG'] = config.tr("\n", ' ')
32
+ end
33
+
34
+ def add_network_alias(name)
35
+ @network_aliases.push(name)
32
36
  end
33
37
 
34
38
  def release=(release)
@@ -64,13 +68,12 @@ module Gitlab
64
68
  @docker.network_create(network)
65
69
  end
66
70
 
67
- # rubocop:disable Metrics/MethodLength
68
71
  # rubocop:disable Metrics/AbcSize
69
72
  def start
70
73
  ensure_configured!
71
74
 
72
75
  docker.run(image, tag) do |command|
73
- command << '-d -p 80:80'
76
+ command << '-d -p 80'
74
77
  command << "--name #{name}"
75
78
  command << "--net #{network}"
76
79
  command << "--hostname #{hostname}"
@@ -80,8 +83,7 @@ module Gitlab
80
83
  end
81
84
 
82
85
  @environment.to_h.each do |key, value|
83
- escaped_value = Shellwords.escape(value)
84
- command << "--env #{key}=#{escaped_value}"
86
+ command << %(--env #{key}="#{value}")
85
87
  end
86
88
 
87
89
  @network_aliases.to_a.each do |network_alias|
@@ -92,6 +94,7 @@ module Gitlab
92
94
 
93
95
  def reconfigure
94
96
  @docker.attach(name) do |line, wait|
97
+ puts line
95
98
  # TODO, workaround which allows to detach from the container
96
99
  #
97
100
  Process.kill('INT', wait.pid) if line =~ /gitlab Reconfigured!/
@@ -110,10 +113,7 @@ module Gitlab
110
113
  end
111
114
 
112
115
  def wait
113
- puts "GitLab URL: #{address}"
114
- print 'Waiting for GitLab to become available '
115
-
116
- if Availability.new("http://#{@docker.hostname}").check(180)
116
+ if Availability.new(name).check(180)
117
117
  sleep 12 # TODO, handle that better
118
118
  puts ' -> GitLab is available.'
119
119
  else
@@ -121,6 +121,20 @@ module Gitlab
121
121
  end
122
122
  end
123
123
 
124
+ def pull
125
+ @docker.pull(@release.image, @release.tag)
126
+ end
127
+
128
+ def sha_version
129
+ json = @docker.read_file(
130
+ @release.image, @release.tag,
131
+ '/opt/gitlab/version-manifest.json'
132
+ )
133
+
134
+ manifest = JSON.parse(json)
135
+ manifest['software']['gitlab-rails']['locked_version']
136
+ end
137
+
124
138
  private
125
139
 
126
140
  # rubocop:disable Style/GuardClause
@@ -131,11 +145,18 @@ module Gitlab
131
145
  end
132
146
 
133
147
  class Availability
134
- def initialize(address)
135
- @uri = URI.join(address, '/help')
148
+ def initialize(name)
149
+ @docker = Docker::Engine.new
150
+
151
+ host = @docker.hostname
152
+ port = @docker.port(name, 80).split(':').last
153
+
154
+ @uri = URI.join("http://#{host}:#{port}", '/help')
136
155
  end
137
156
 
138
157
  def check(retries)
158
+ print "Waiting for GitLab at `#{@uri}` to become available "
159
+
139
160
  retries.times do
140
161
  return true if service_available?
141
162
 
@@ -5,53 +5,31 @@ module Gitlab
5
5
  # This class represents GitLab QA specs image that is implemented in
6
6
  # the `qa/` directory located in GitLab CE / EE repositories.
7
7
  #
8
- # TODO, it needs some refactoring.
9
- #
10
- class Specs
11
- include Scenario::Actable
8
+ class Specs < Scenario::Template
9
+ IMAGE = 'gitlab/gitlab-qa'.freeze
12
10
 
13
- IMAGE_NAME = 'gitlab/gitlab-qa'.freeze
11
+ attr_accessor :suite, :release, :network, :args
14
12
 
15
13
  def initialize
16
14
  @docker = Docker::Engine.new
17
15
  end
18
16
 
19
- def test(gitlab:, suite: 'Test::Instance', extra_args: [])
20
- test_address(
21
- release: gitlab.release,
22
- address: gitlab.address,
23
- name: "#{gitlab.name}-specs",
24
- network: gitlab.network,
25
- suite: suite,
26
- extra_args: extra_args
27
- )
28
- end
17
+ def perform # rubocop:disable Metrics/AbcSize
18
+ raise ArgumentError unless [suite, release].all?
29
19
 
30
- # rubocop:disable Metrics/ParameterLists
31
- def test_address(release:, address:, name: nil, network: nil,
32
- suite: 'Test::Instance', extra_args: [])
33
- puts "Running instance suite #{suite} for Gitlab " \
34
- "#{release.edition.upcase} at #{address}"
20
+ puts "Running test suite `#{suite}` for #{release.project_name}"
35
21
 
36
- args = [suite, address] + extra_args
22
+ @docker.run(IMAGE, release.edition_tag, suite, *args) do |command|
23
+ command << "-t --rm --net=#{network || 'bridge'}"
37
24
 
38
- @docker.run(IMAGE_NAME, release.edition_tag, *args) do |command|
39
- build_command(command, name, network)
40
- end
41
- end
25
+ Runtime::Env.delegated.each do |env|
26
+ command.env(env, "$#{env}")
27
+ end
42
28
 
43
- private
44
-
45
- def build_command(command, name, network)
46
- command << "-t --rm --net=#{network || 'bridge'}"
47
-
48
- Runtime::Env.delegated.each do |env|
49
- command.env(env, "$#{env}")
29
+ command.volume('/var/run/docker.sock', '/var/run/docker.sock')
30
+ command.volume(Runtime::Env.screenshots_dir, '/home/qa/tmp')
31
+ command.name("gitlab-specs-#{Time.now.to_i}")
50
32
  end
51
-
52
- command.volume('/var/run/docker.sock', '/var/run/docker.sock')
53
- command.volume(Runtime::Env.screenshots_dir, '/home/qa/tmp')
54
- command.name(name || "gitlab-specs-#{Time.now.to_i}")
55
33
  end
56
34
  end
57
35
  end
@@ -28,8 +28,12 @@ module Gitlab
28
28
  "docker #{@args.join(' ')}"
29
29
  end
30
30
 
31
+ def ==(other)
32
+ to_s == other.to_s
33
+ end
34
+
31
35
  def execute!(&block)
32
- Docker::Shellout.execute!(self, &block)
36
+ Docker::Shellout.new(self).execute!(&block)
33
37
  end
34
38
 
35
39
  def self.execute(cmd, &block)
@@ -14,7 +14,7 @@ module Gitlab
14
14
 
15
15
  def run(image, tag, *args)
16
16
  Docker::Command.new('run').tap do |command|
17
- yield command
17
+ yield command if block_given?
18
18
 
19
19
  command << "#{image}:#{tag}"
20
20
  command << args if args.any?
@@ -23,6 +23,11 @@ module Gitlab
23
23
  end
24
24
  end
25
25
 
26
+ def read_file(image, tag, path, &block)
27
+ cat_file = "run --rm --entrypoint /bin/cat #{image}:#{tag} #{path}"
28
+ Docker::Command.execute(cat_file, &block)
29
+ end
30
+
26
31
  def attach(name, &block)
27
32
  Docker::Command.execute("attach --sig-proxy=false #{name}", &block)
28
33
  end
@@ -50,6 +55,10 @@ module Gitlab
50
55
  def network_create(name)
51
56
  Docker::Command.execute("network create #{name}")
52
57
  end
58
+
59
+ def port(name, port)
60
+ Docker::Command.execute("port #{name} #{port}/tcp")
61
+ end
53
62
  end
54
63
  end
55
64
  end
@@ -6,20 +6,33 @@ module Gitlab
6
6
  class Shellout
7
7
  class StatusError < StandardError; end
8
8
 
9
- def self.execute!(command)
10
- puts "Running shell command: `#{command}`"
9
+ def initialize(command)
10
+ @command = command
11
+ @output = []
11
12
 
12
- Open3.popen2e(command.to_s) do |_in, out, wait|
13
+ puts "Docker shell command: `#{@command}`"
14
+ end
15
+
16
+ def execute!
17
+ raise StatusError, 'Command already executed' if @output.any?
18
+
19
+ Open3.popen2e(@command.to_s) do |_in, out, wait|
13
20
  out.each do |line|
14
- puts line
21
+ @output.push(line)
15
22
 
16
- yield line, wait if block_given?
23
+ if block_given?
24
+ yield line, wait
25
+ else
26
+ puts line
27
+ end
17
28
  end
18
29
 
19
30
  if wait.value.exited? && wait.value.exitstatus.nonzero?
20
- raise StatusError, "Docker command `#{command}` failed!"
31
+ raise StatusError, "Docker command `#{@command}` failed!"
21
32
  end
22
33
  end
34
+
35
+ @output.join.chomp
23
36
  end
24
37
  end
25
38
  end
@@ -1,14 +1,15 @@
1
1
  module Gitlab
2
2
  module QA
3
3
  class Release
4
- CUSTOM_GITLAB_IMAGE_REGEX = %r{/gitlab-([ce]e):(.+)\z}
4
+ CANONICAL_REGEX = /\A(?<edition>ce|ee):?(?<tag>.+)?/i
5
+ CUSTOM_GITLAB_IMAGE_REGEX = %r{/gitlab-(?<edition>[ce]e):(?<tag>.+)\z}
5
6
  DEFAULT_TAG = 'nightly'.freeze
6
7
 
7
8
  attr_reader :release
8
9
  attr_writer :tag
9
10
 
10
11
  def initialize(release)
11
- @release = release.to_s
12
+ @release = release.to_s.downcase
12
13
  end
13
14
 
14
15
  def to_s
@@ -24,9 +25,9 @@ module Gitlab
24
25
  def edition
25
26
  @edition ||=
26
27
  if canonical?
27
- release.downcase.to_sym
28
+ release.match(CANONICAL_REGEX)[:edition].to_sym
28
29
  else
29
- release.match(CUSTOM_GITLAB_IMAGE_REGEX)[1].to_sym
30
+ release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition].to_sym
30
31
  end
31
32
  end
32
33
 
@@ -39,16 +40,16 @@ module Gitlab
39
40
  end
40
41
  end
41
42
 
42
- def canonical_image
43
- @canonical_image ||= "gitlab/gitlab-#{edition}"
43
+ def project_name
44
+ @project_name ||= image.sub(%r{^gitlab\/}, '')
44
45
  end
45
46
 
46
47
  def tag
47
48
  @tag ||=
48
49
  if canonical?
49
- DEFAULT_TAG
50
+ release.match(CANONICAL_REGEX)[:tag] || DEFAULT_TAG
50
51
  else
51
- release.match(CUSTOM_GITLAB_IMAGE_REGEX)[2]
52
+ release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:tag]
52
53
  end
53
54
  end
54
55
 
@@ -59,7 +60,11 @@ module Gitlab
59
60
  private
60
61
 
61
62
  def canonical?
62
- %w(ce ee).include?(release.downcase)
63
+ release =~ CANONICAL_REGEX
64
+ end
65
+
66
+ def canonical_image
67
+ @canonical_image ||= "gitlab/gitlab-#{edition}"
63
68
  end
64
69
  end
65
70
  end
@@ -4,10 +4,10 @@ module Gitlab
4
4
  module Env
5
5
  extend self
6
6
 
7
- VARIABLES = %w(GITLAB_USERNAME
7
+ VARIABLES = %w[GITLAB_USERNAME
8
8
  GITLAB_PASSWORD
9
9
  GITLAB_URL
10
- EE_LICENSE).freeze
10
+ EE_LICENSE].freeze
11
11
 
12
12
  def screenshots_dir
13
13
  ENV['QA_SCREENSHOTS_DIR'] || '/tmp/gitlab-qa-screenshots'
@@ -13,8 +13,10 @@ module Gitlab
13
13
  r.tag = tag
14
14
  end
15
15
 
16
- Component::Specs.perform do |instance|
17
- instance.test_address(release: release, address: address)
16
+ Component::Specs.perform do |specs|
17
+ specs.suite = 'Test::Instance'
18
+ specs.release = release
19
+ specs.args = [address]
18
20
  end
19
21
  end
20
22
  end
@@ -17,8 +17,11 @@ module Gitlab
17
17
  gitlab.network = 'test'
18
18
 
19
19
  gitlab.instance do
20
- Component::Specs.perform do |instance|
21
- instance.test(gitlab: gitlab)
20
+ Component::Specs.perform do |specs|
21
+ specs.suite = 'Test::Instance'
22
+ specs.release = gitlab.release
23
+ specs.network = gitlab.network
24
+ specs.args = [gitlab.address]
22
25
  end
23
26
  end
24
27
  end
@@ -0,0 +1,74 @@
1
+ module Gitlab
2
+ module QA
3
+ module Scenario
4
+ module Test
5
+ module Integration
6
+ class Geo < Scenario::Template
7
+ ##
8
+ # rubocop:disable Metrics/MethodLength
9
+ # rubocop:disable Metrics/AbcSize
10
+ #
11
+ def perform(release)
12
+ release = Release.new(release)
13
+
14
+ unless release.edition == :ee
15
+ raise ArgumentError, 'Geo is EE only!'
16
+ end
17
+
18
+ Component::Gitlab.perform do |primary|
19
+ primary.release = release
20
+ primary.name = 'gitlab-primary'
21
+ primary.network = 'geo'
22
+ primary.omnibus_config = <<~OMNIBUS
23
+ geo_primary_role['enable'] = true;
24
+ postgresql['listen_address'] = '0.0.0.0';
25
+ postgresql['trust_auth_cidr_addresses'] = ['0.0.0.0/0','0.0.0.0/0'];
26
+ postgresql['md5_auth_cidr_addresses'] = ['0.0.0.0/0'];
27
+ postgresql['max_replication_slots'] = 1;
28
+ gitlab_rails['db_key_base'] = '4dd58204865eb41bca93bd38131d51cc';
29
+ OMNIBUS
30
+
31
+ primary.instance do
32
+ Component::Gitlab.perform do |secondary|
33
+ secondary.release = release
34
+ secondary.name = 'gitlab-secondary'
35
+ secondary.network = 'geo'
36
+ secondary.omnibus_config = <<~OMNIBUS
37
+ geo_secondary_role['enable'] = true;
38
+ gitlab_rails['db_key_base'] = '4dd58204865eb41bca93bd38131d51cc';
39
+ OMNIBUS
40
+
41
+ secondary.act do
42
+ # TODO, we do not wait for secondary to start because of
43
+ # https://gitlab.com/gitlab-org/gitlab-ee/issues/3999
44
+ #
45
+ # rubocop:disable Style/Semicolon
46
+ prepare; start; reconfigure
47
+
48
+ # shellout to instance specs
49
+ puts 'Running Geo primary / secondary specs!'
50
+
51
+ Component::Specs.perform do |specs|
52
+ specs.suite = 'QA::EE::Scenario::Test::Geo'
53
+ specs.release = release
54
+ specs.network = 'geo'
55
+ specs.args = [
56
+ '--primary-address', primary.address,
57
+ '--primary-name', primary.name,
58
+ '--secondary-address', secondary.address,
59
+ '--secondary-name', secondary.name
60
+ ]
61
+ end
62
+
63
+ teardown
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
@@ -4,7 +4,6 @@ module Gitlab
4
4
  module Test
5
5
  module Integration
6
6
  class Mattermost < Scenario::Template
7
- # rubocop:disable Metrics/MethodLength
8
7
  def perform(release)
9
8
  Component::Gitlab.perform do |gitlab|
10
9
  gitlab.release = release
@@ -12,17 +11,18 @@ module Gitlab
12
11
 
13
12
  mattermost_hostname = "mattermost.#{gitlab.network}"
14
13
  mattermost_external_url = "http://#{mattermost_hostname}"
15
- gitlab.omnibus_config =
16
- "mattermost_external_url '#{mattermost_external_url}'"
17
- gitlab.network_aliases = [mattermost_hostname]
14
+
15
+ gitlab.add_network_alias(mattermost_hostname)
16
+ gitlab.omnibus_config = <<~OMNIBUS
17
+ mattermost_external_url '#{mattermost_external_url}'
18
+ OMNIBUS
18
19
 
19
20
  gitlab.instance do
20
- Component::Specs.perform do |instance|
21
- instance.test(
22
- gitlab: gitlab,
23
- suite: 'Test::Integration::Mattermost',
24
- extra_args: [mattermost_external_url]
25
- )
21
+ Component::Specs.perform do |specs|
22
+ specs.suite = 'Test::Integration::Mattermost'
23
+ specs.release = gitlab.release
24
+ specs.network = gitlab.network
25
+ specs.args = [gitlab.address, mattermost_external_url]
26
26
  end
27
27
  end
28
28
  end
@@ -11,8 +11,6 @@ module Gitlab
11
11
  'logs' => '/var/log/gitlab',
12
12
  'data' => '/var/opt/gitlab' }.freeze
13
13
 
14
- # rubocop:disable Metrics/MethodLength
15
- #
16
14
  def perform(next_release)
17
15
  next_release = Release.new(next_release)
18
16
 
@@ -0,0 +1,52 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'cgi'
4
+
5
+ module Gitlab
6
+ module QA
7
+ module Scenario
8
+ module Test
9
+ module Sanity
10
+ # This test checks that the sha_version of a GitLab was authored in
11
+ # the window defined by `HOURS_AGO`. We perform a single API call,
12
+ # so `COMMITS` needs to be a large enough value that we expect all
13
+ # the commits in the time window will fit.
14
+ class Version < Scenario::Template
15
+ HOURS_AGO = 24
16
+ COMMITS = 10_000
17
+
18
+ # rubocop:disable Style/Semicolon
19
+ def perform(release)
20
+ version = Component::Gitlab.perform do |gitlab|
21
+ gitlab.release = release
22
+ gitlab.act { pull; sha_version }
23
+ end
24
+
25
+ project = "gitlab-org/#{Release.new(release).project_name}"
26
+ commit = recent_commits(project).find { |c| c['id'] == version }
27
+
28
+ if commit
29
+ puts "Found commit #{version} in recent history of #{project}"
30
+ else
31
+ puts "Did not find #{version} in recent history of #{project}"
32
+ exit 1
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def recent_commits(project)
39
+ api = 'https://gitlab.com/api/v4'
40
+ url = "#{api}/projects/#{CGI.escape(project)}/repository/commits"
41
+ since = (Time.now - HOURS_AGO * 60 * 60).strftime('%FT%T')
42
+
43
+ uri = URI(url)
44
+ uri.query = URI.encode_www_form(since: since, per_page: COMMITS)
45
+ JSON.parse(Net::HTTP.get(uri))
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module QA
3
- VERSION = '0.3.0'.freeze
3
+ VERSION = '0.4.0'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-qa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Grzegorz Bizon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2017-11-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,70 +16,70 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.12'
19
+ version: '1.16'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.12'
26
+ version: '1.16'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: pry
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '0.11'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '0.11'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
42
+ name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.0'
47
+ version: '12.2'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.0'
54
+ version: '12.2'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rubocop
56
+ name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.47.1
61
+ version: '3.7'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.47.1
68
+ version: '3.7'
69
69
  - !ruby/object:Gem::Dependency
70
- name: pry
70
+ name: rubocop
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.10.4
75
+ version: '0.51'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.10.4
82
+ version: '0.51'
83
83
  description:
84
84
  email:
85
85
  - grzesiek.bizon@gmail.com
@@ -102,7 +102,7 @@ files:
102
102
  - bin/console
103
103
  - bin/qa
104
104
  - bin/setup
105
- - bin/slack
105
+ - docs/architecture.md
106
106
  - exe/gitlab-qa
107
107
  - gitlab-qa.gemspec
108
108
  - lib/gitlab/qa.rb
@@ -117,9 +117,11 @@ files:
117
117
  - lib/gitlab/qa/scenario/template.rb
118
118
  - lib/gitlab/qa/scenario/test/instance/any.rb
119
119
  - lib/gitlab/qa/scenario/test/instance/image.rb
120
+ - lib/gitlab/qa/scenario/test/integration/geo.rb
120
121
  - lib/gitlab/qa/scenario/test/integration/mattermost.rb
121
122
  - lib/gitlab/qa/scenario/test/omnibus/image.rb
122
123
  - lib/gitlab/qa/scenario/test/omnibus/upgrade.rb
124
+ - lib/gitlab/qa/scenario/test/sanity/version.rb
123
125
  - lib/gitlab/qa/version.rb
124
126
  homepage: http://about.gitlab.com
125
127
  licenses:
data/bin/slack DELETED
@@ -1,13 +0,0 @@
1
- #!/bin/bash
2
- # Sends Slack notification ERROR_MSG to CHANNEL
3
- # An env. variable CI_SLACK_WEBHOOK_URL needs to be set.
4
-
5
- CHANNEL=$1
6
- ERROR_MSG=$2
7
-
8
- if [ -z "$CHANNEL" ] || [ -z "$ERROR_MSG" ] || [ -z "$CI_SLACK_WEBHOOK_URL" ]; then
9
- echo "Missing argument(s) - Use: $0 channel message"
10
- echo "and set CI_SLACK_WEBHOOK_URL environment variable."
11
- else
12
- curl -X POST --data-urlencode 'payload={"channel": "'"$CHANNEL"'", "username": "GitLab-QA Builder", "text": "'"$ERROR_MSG"'"}' "$CI_SLACK_WEBHOOK_URL"
13
- fi