gitlab-qa 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.dockerignore +1 -0
- data/.gitignore +9 -0
- data/.gitlab-ci.yml +80 -0
- data/.rspec +3 -0
- data/.rubocop.yml +17 -0
- data/.travis.yml +5 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/README.md +12 -0
- data/Rakefile +13 -0
- data/bin/console +7 -0
- data/bin/qa +8 -0
- data/bin/setup +8 -0
- data/bin/slack +13 -0
- data/exe/gitlab-qa +7 -0
- data/gitlab-qa.gemspec +27 -0
- data/lib/gitlab/qa.rb +29 -0
- data/lib/gitlab/qa/docker/command.rb +46 -0
- data/lib/gitlab/qa/docker/engine.rb +52 -0
- data/lib/gitlab/qa/docker/gitlab.rb +126 -0
- data/lib/gitlab/qa/docker/specs.rb +33 -0
- data/lib/gitlab/qa/scenario/actable.rb +25 -0
- data/lib/gitlab/qa/scenario/template.rb +18 -0
- data/lib/gitlab/qa/scenario/test/instance/any.rb +21 -0
- data/lib/gitlab/qa/scenario/test/instance/image.rb +42 -0
- data/lib/gitlab/qa/scenario/test/omnibus/image.rb +24 -0
- data/lib/gitlab/qa/scenario/test/omnibus/upgrade.rb +38 -0
- data/lib/gitlab/qa/version.rb +5 -0
- metadata +143 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 55a7f55cf9ae0ed256e9471c8f0339891efd0ff8
|
|
4
|
+
data.tar.gz: 7d0a29fc73eebbfd0664a682bfc964429fe3c25c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 83348ec223aed07efecbf57e30bb9a7987a13dcb1cc317e426c7dd0ecba303a24388e6885409d8753ff4871e21ab8a62018684035ff6c2c9f04e768209dfd66f
|
|
7
|
+
data.tar.gz: c4b4bcdfb0c9521cae38da8a594e664e6f8d77169fe9408346c178951fe1afb0e15e4244a5a71f9204e0b6818af8c440c7396b8497a47fc3e06daaa904c39652
|
data/.dockerignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
./tmp
|
data/.gitignore
ADDED
data/.gitlab-ci.yml
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
services:
|
|
2
|
+
- docker:1.13-dind
|
|
3
|
+
|
|
4
|
+
stages:
|
|
5
|
+
- check
|
|
6
|
+
- test
|
|
7
|
+
- notify
|
|
8
|
+
|
|
9
|
+
variables:
|
|
10
|
+
TEST_IMAGE: registry.gitlab.com/gitlab-org/gitlab-build-images:gitlab-qa
|
|
11
|
+
DOCKER_DRIVER: overlay
|
|
12
|
+
DOCKER_HOST: tcp://docker:2375
|
|
13
|
+
|
|
14
|
+
before_script:
|
|
15
|
+
- bundle install
|
|
16
|
+
|
|
17
|
+
check:rubocop:
|
|
18
|
+
stage: check
|
|
19
|
+
image: $TEST_IMAGE
|
|
20
|
+
script: bundle exec rubocop
|
|
21
|
+
except:
|
|
22
|
+
- triggers
|
|
23
|
+
tags:
|
|
24
|
+
- docker
|
|
25
|
+
|
|
26
|
+
check:rspec:
|
|
27
|
+
stage: check
|
|
28
|
+
image: $TEST_IMAGE
|
|
29
|
+
script: bundle exec rspec
|
|
30
|
+
except:
|
|
31
|
+
- triggers
|
|
32
|
+
tags:
|
|
33
|
+
- docker
|
|
34
|
+
|
|
35
|
+
.test: &test
|
|
36
|
+
stage: test
|
|
37
|
+
image: $TEST_IMAGE
|
|
38
|
+
tags:
|
|
39
|
+
- docker
|
|
40
|
+
artifacts:
|
|
41
|
+
when: on_failure
|
|
42
|
+
expire_in: 30d
|
|
43
|
+
paths:
|
|
44
|
+
- tmp/*.png
|
|
45
|
+
|
|
46
|
+
ce:instance:
|
|
47
|
+
script: bin/qa Test::Instance::Image CE
|
|
48
|
+
<<: *test
|
|
49
|
+
|
|
50
|
+
ee:instance:
|
|
51
|
+
script: bin/qa Test::Instance::Image EE
|
|
52
|
+
<<: *test
|
|
53
|
+
|
|
54
|
+
ce:image:
|
|
55
|
+
script: bin/qa Test::Omnibus::Image CE
|
|
56
|
+
<<: *test
|
|
57
|
+
|
|
58
|
+
ee:image:
|
|
59
|
+
script: bin/qa Test::Omnibus::Image EE
|
|
60
|
+
<<: *test
|
|
61
|
+
|
|
62
|
+
ce:upgrade:
|
|
63
|
+
script: bin/qa Test::Omnibus::Upgrade CE
|
|
64
|
+
<<: *test
|
|
65
|
+
|
|
66
|
+
ee:upgrade:
|
|
67
|
+
script: bin/qa Test::Omnibus::Upgrade EE
|
|
68
|
+
<<: *test
|
|
69
|
+
|
|
70
|
+
notify:slack:
|
|
71
|
+
before_script:
|
|
72
|
+
- apk update && apk add git curl bash
|
|
73
|
+
image: alpine
|
|
74
|
+
stage: notify
|
|
75
|
+
script:
|
|
76
|
+
- bin/slack "#omnibus-builds" "(╯°□°)╯︵┻━┻ 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>"
|
|
77
|
+
when: on_failure
|
|
78
|
+
only:
|
|
79
|
+
- master
|
|
80
|
+
- tags@gitlab-org/gitlab-qa
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Style/Documentation:
|
|
2
|
+
Enabled: false
|
|
3
|
+
|
|
4
|
+
Style/ModuleFunction:
|
|
5
|
+
Enabled: false
|
|
6
|
+
|
|
7
|
+
Style/SignalException:
|
|
8
|
+
Enabled: false
|
|
9
|
+
|
|
10
|
+
Lint/ShadowingOuterLocalVariable:
|
|
11
|
+
Enabled: false
|
|
12
|
+
|
|
13
|
+
Metrics/BlockLength:
|
|
14
|
+
Enabled: false
|
|
15
|
+
|
|
16
|
+
Style/PredicateName:
|
|
17
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016-2017 GitLab Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
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.
|
data/README.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# GitLab end-to-end tests
|
|
2
|
+
|
|
3
|
+
End-to-end test suite that verifies GitLab as a whole.
|
|
4
|
+
|
|
5
|
+
GitLab consists of multiple pieces configured and packaged by
|
|
6
|
+
[GitLab Omnibus](https://gitlab.com/gitlab-org/omnibus-gitlab).
|
|
7
|
+
|
|
8
|
+
The purpose of this test suite is to verify that all pieces do integrate well together.
|
|
9
|
+
|
|
10
|
+
## How we use it
|
|
11
|
+
|
|
12
|
+
Currently we trigger test suite against GitLab Docker images created by Omnibus nightly.
|
data/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require 'bundler/gem_tasks'
|
|
2
|
+
require 'rspec/core/rake_task'
|
|
3
|
+
require 'rubocop/rake_task'
|
|
4
|
+
|
|
5
|
+
RSpec::Core::RakeTask.new('spec')
|
|
6
|
+
RuboCop::RakeTask.new
|
|
7
|
+
|
|
8
|
+
task :test do
|
|
9
|
+
Rake::Task['rubocop'].invoke
|
|
10
|
+
Rake::Task['spec'].invoke
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
task default: :test
|
data/bin/console
ADDED
data/bin/qa
ADDED
data/bin/setup
ADDED
data/bin/slack
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
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
|
data/exe/gitlab-qa
ADDED
data/gitlab-qa.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'gitlab/qa/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'gitlab-qa'
|
|
8
|
+
spec.version = Gitlab::QA::VERSION
|
|
9
|
+
spec.authors = ['Grzegorz Bizon']
|
|
10
|
+
spec.email = ['grzesiek.bizon@gmail.com']
|
|
11
|
+
|
|
12
|
+
spec.summary = 'Integration tests for GitLab'
|
|
13
|
+
spec.homepage = 'http://about.gitlab.com'
|
|
14
|
+
spec.license = 'MIT'
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`
|
|
17
|
+
.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
|
18
|
+
spec.bindir = 'exe'
|
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
20
|
+
spec.require_paths = ['lib']
|
|
21
|
+
|
|
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'
|
|
27
|
+
end
|
data/lib/gitlab/qa.rb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
|
|
2
|
+
|
|
3
|
+
module Gitlab
|
|
4
|
+
module QA
|
|
5
|
+
module Scenario
|
|
6
|
+
autoload :Actable, 'qa/scenario/actable'
|
|
7
|
+
autoload :Template, 'qa/scenario/template'
|
|
8
|
+
|
|
9
|
+
module Test
|
|
10
|
+
module Instance
|
|
11
|
+
autoload :Image, 'qa/scenario/test/instance/image'
|
|
12
|
+
autoload :Any, 'qa/scenario/test/instance/any'
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
module Omnibus
|
|
16
|
+
autoload :Image, 'qa/scenario/test/omnibus/image'
|
|
17
|
+
autoload :Upgrade, 'qa/scenario/test/omnibus/upgrade'
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
module Docker
|
|
23
|
+
autoload :Engine, 'qa/docker/engine'
|
|
24
|
+
autoload :Command, 'qa/docker/command'
|
|
25
|
+
autoload :Gitlab, 'qa/docker/gitlab'
|
|
26
|
+
autoload :Specs, 'qa/docker/specs'
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
module Gitlab
|
|
4
|
+
module QA
|
|
5
|
+
module Docker
|
|
6
|
+
class Command
|
|
7
|
+
class StatusError < StandardError; end
|
|
8
|
+
|
|
9
|
+
attr_reader :args
|
|
10
|
+
|
|
11
|
+
def self.execute(cmd, &block)
|
|
12
|
+
new(cmd).execute!(&block)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def initialize(cmd = nil)
|
|
16
|
+
@args = Array(cmd)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def <<(*args)
|
|
20
|
+
tap { @args.concat(args) }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def execute!(&block)
|
|
24
|
+
engine("docker #{@args.join(' ')}", &block)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def engine(cmd)
|
|
30
|
+
puts "Running shell command: `#{cmd}`"
|
|
31
|
+
|
|
32
|
+
Open3.popen2e(cmd) do |_in, out, wait|
|
|
33
|
+
out.each do |line|
|
|
34
|
+
puts line
|
|
35
|
+
yield line, wait if block_given?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
if wait.value.exited? && wait.value.exitstatus.nonzero?
|
|
39
|
+
raise StatusError, "Docker command `#{cmd}` failed!"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Docker
|
|
4
|
+
class Engine
|
|
5
|
+
DOCKER_HOST = ENV['DOCKER_HOST'] || 'http://localhost'
|
|
6
|
+
|
|
7
|
+
def hostname
|
|
8
|
+
URI(DOCKER_HOST).host
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def pull(image, tag)
|
|
12
|
+
Docker::Command.execute("pull #{image}:#{tag}")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def run(image, tag, *args)
|
|
16
|
+
Docker::Command.new('run').tap do |command|
|
|
17
|
+
yield command
|
|
18
|
+
|
|
19
|
+
command << "#{image}:#{tag}"
|
|
20
|
+
command << args if args.any?
|
|
21
|
+
|
|
22
|
+
command.execute!
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def attach(name, &block)
|
|
27
|
+
Docker::Command.execute("attach --sig-proxy=false #{name}", &block)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def stop(name)
|
|
31
|
+
Docker::Command.execute("stop #{name}")
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def remove(name)
|
|
35
|
+
Docker::Command.execute("rm -f #{name}")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def network_exists?(name)
|
|
39
|
+
Docker::Command.execute("network inspect #{name}")
|
|
40
|
+
rescue Docker::Command::StatusError
|
|
41
|
+
false
|
|
42
|
+
else
|
|
43
|
+
true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def network_create(name)
|
|
47
|
+
Docker::Command.execute("network create #{name}")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
require 'securerandom'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
5
|
+
module Gitlab
|
|
6
|
+
module QA
|
|
7
|
+
module Docker
|
|
8
|
+
class Gitlab
|
|
9
|
+
include Scenario::Actable
|
|
10
|
+
|
|
11
|
+
# rubocop:disable Style/Semicolon
|
|
12
|
+
|
|
13
|
+
attr_accessor :release, :image, :tag, :volumes, :network
|
|
14
|
+
attr_reader :name
|
|
15
|
+
|
|
16
|
+
def initialize
|
|
17
|
+
@docker = Docker::Engine.new
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def name=(name)
|
|
21
|
+
@name = "#{name}-#{SecureRandom.hex(4)}"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def ee?
|
|
25
|
+
@release == :ee
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def address
|
|
29
|
+
"http://#{hostname}"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def hostname
|
|
33
|
+
"#{@name}.#{@network}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def instance
|
|
37
|
+
raise 'Please provide a block!' unless block_given?
|
|
38
|
+
|
|
39
|
+
prepare; start; reconfigure; wait
|
|
40
|
+
|
|
41
|
+
yield self
|
|
42
|
+
|
|
43
|
+
teardown
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def prepare
|
|
47
|
+
@docker.pull(@image, @tag)
|
|
48
|
+
|
|
49
|
+
return if @docker.network_exists?(@network)
|
|
50
|
+
@docker.network_create(@network)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def start
|
|
54
|
+
unless [@name, @image, @tag, @network].all?
|
|
55
|
+
raise 'Please configure an instance first!'
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
@docker.run(@image, @tag) do |command|
|
|
59
|
+
command << "-d --name #{@name} -p 80:80"
|
|
60
|
+
command << "--net #{@network} --hostname #{hostname}"
|
|
61
|
+
|
|
62
|
+
@volumes.to_h.each do |to, from|
|
|
63
|
+
command << "--volume #{to}:#{from}:Z"
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def reconfigure
|
|
69
|
+
@docker.attach(@name) do |line, wait|
|
|
70
|
+
# TODO, workaround which allows to detach from the container
|
|
71
|
+
#
|
|
72
|
+
Process.kill('INT', wait.pid) if line =~ /gitlab Reconfigured!/
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def teardown
|
|
77
|
+
raise 'Invalid instance name!' unless @name
|
|
78
|
+
|
|
79
|
+
@docker.stop(@name)
|
|
80
|
+
@docker.remove(@name)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def wait
|
|
84
|
+
puts "GitLab URL: #{address}"
|
|
85
|
+
print 'Waiting for GitLab to become available '
|
|
86
|
+
|
|
87
|
+
if Availability.new("http://#{@docker.hostname}").check(180)
|
|
88
|
+
sleep 12 # TODO, handle that better
|
|
89
|
+
puts ' -> GitLab is available.'
|
|
90
|
+
else
|
|
91
|
+
abort ' -> GitLab unavailable!'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
class Availability
|
|
96
|
+
def initialize(address)
|
|
97
|
+
@uri = URI.join(address, '/help')
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
def check(retries)
|
|
101
|
+
retries.times do
|
|
102
|
+
return true if service_available?
|
|
103
|
+
|
|
104
|
+
print '.'
|
|
105
|
+
sleep 1
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
false
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
private
|
|
112
|
+
|
|
113
|
+
def service_available?
|
|
114
|
+
response = Net::HTTP.start(@uri.host, @uri.port) do |http|
|
|
115
|
+
http.head2(@uri.request_uri)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
response.code.to_i == 200
|
|
119
|
+
rescue Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError
|
|
120
|
+
false
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Docker
|
|
4
|
+
class Specs
|
|
5
|
+
include Scenario::Actable
|
|
6
|
+
|
|
7
|
+
IMAGE_NAME = 'gitlab/gitlab-qa'.freeze
|
|
8
|
+
|
|
9
|
+
attr_accessor :env
|
|
10
|
+
|
|
11
|
+
def initialize
|
|
12
|
+
@docker = Docker::Engine.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# rubocop:disable Metrics/AbcSize
|
|
16
|
+
#
|
|
17
|
+
def test(gitlab)
|
|
18
|
+
tag = "#{gitlab.release}-#{gitlab.tag}"
|
|
19
|
+
args = ['Test::Instance', gitlab.address]
|
|
20
|
+
|
|
21
|
+
puts 'Running instance test scenarios for Gitlab ' \
|
|
22
|
+
"#{gitlab.release.upcase} at #{gitlab.address}"
|
|
23
|
+
|
|
24
|
+
@docker.run(IMAGE_NAME, tag, *args) do |command|
|
|
25
|
+
command << "-t --rm --net #{gitlab.network}"
|
|
26
|
+
command << %(-e #{env}="$#{env}") if env
|
|
27
|
+
command << "--name #{gitlab.name}-specs"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Scenario
|
|
4
|
+
module Actable
|
|
5
|
+
def act(*args, &block)
|
|
6
|
+
instance_exec(*args, &block)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.included(base)
|
|
10
|
+
base.extend(ClassMethods)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module ClassMethods
|
|
14
|
+
def perform
|
|
15
|
+
yield new if block_given?
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def act(*args, &block)
|
|
19
|
+
new.act(*args, &block)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Scenario
|
|
4
|
+
class Template
|
|
5
|
+
def self.perform(*args)
|
|
6
|
+
new.tap do |scenario|
|
|
7
|
+
yield scenario if block_given?
|
|
8
|
+
return scenario.perform(*args)
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def perform(*_args)
|
|
13
|
+
raise NotImplementedError
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Scenario
|
|
4
|
+
module Test
|
|
5
|
+
module Instance
|
|
6
|
+
##
|
|
7
|
+
# Run test suite against any GitLab instance,
|
|
8
|
+
# including staging and on-premises installation.
|
|
9
|
+
#
|
|
10
|
+
class Any < Scenario::Template
|
|
11
|
+
def perform(address)
|
|
12
|
+
Spec::Image.perform do |specs|
|
|
13
|
+
specs.test(address)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Scenario
|
|
4
|
+
module Test
|
|
5
|
+
module Instance
|
|
6
|
+
class Image < Scenario::Template
|
|
7
|
+
attr_writer :tag, :volumes
|
|
8
|
+
|
|
9
|
+
def initialize
|
|
10
|
+
@tag = 'nightly'
|
|
11
|
+
@volumes = {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# rubocop:disable Metrics/MethodLength
|
|
15
|
+
#
|
|
16
|
+
def perform(version)
|
|
17
|
+
unless %w(CE EE).include?(version)
|
|
18
|
+
raise 'Unknown GitLab release type specified!'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Docker::Gitlab.perform do |gitlab|
|
|
22
|
+
gitlab.release = version.downcase.to_sym
|
|
23
|
+
gitlab.name = "gitlab-qa-#{gitlab.release}"
|
|
24
|
+
gitlab.image = "gitlab/gitlab-#{gitlab.release}"
|
|
25
|
+
gitlab.tag = @tag
|
|
26
|
+
gitlab.volumes = @volumes
|
|
27
|
+
gitlab.network = 'test'
|
|
28
|
+
|
|
29
|
+
gitlab.instance do
|
|
30
|
+
Docker::Specs.perform do |instance|
|
|
31
|
+
instance.env = 'EE_LICENSE' if gitlab.ee?
|
|
32
|
+
instance.test(gitlab)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Gitlab
|
|
2
|
+
module QA
|
|
3
|
+
module Scenario
|
|
4
|
+
module Test
|
|
5
|
+
module Omnibus
|
|
6
|
+
class Image < Scenario::Template
|
|
7
|
+
# rubocop:disable Style/Semicolon
|
|
8
|
+
|
|
9
|
+
def perform(version)
|
|
10
|
+
Docker::Gitlab.perform do |instance|
|
|
11
|
+
instance.name = "gitlab-qa-#{version.downcase}"
|
|
12
|
+
instance.image = "gitlab/gitlab-#{version.downcase}"
|
|
13
|
+
instance.tag = 'nightly'
|
|
14
|
+
instance.network = 'bridge'
|
|
15
|
+
|
|
16
|
+
instance.act { prepare; start; reconfigure; teardown }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'tmpdir'
|
|
2
|
+
require 'fileutils'
|
|
3
|
+
|
|
4
|
+
module Gitlab
|
|
5
|
+
module QA
|
|
6
|
+
module Scenario
|
|
7
|
+
module Test
|
|
8
|
+
module Omnibus
|
|
9
|
+
class Upgrade < Scenario::Template
|
|
10
|
+
VOLUMES = { 'config' => '/etc/gitlab',
|
|
11
|
+
'logs' => '/var/log/gitlab',
|
|
12
|
+
'data' => '/var/opt/gitlab' }.freeze
|
|
13
|
+
|
|
14
|
+
def perform(version)
|
|
15
|
+
with_temporary_volumes do |volumes|
|
|
16
|
+
Scenario::Test::Instance::Image.perform(version) do |scenario|
|
|
17
|
+
scenario.tag = 'latest'
|
|
18
|
+
scenario.volumes = volumes
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
Scenario::Test::Instance::Image.perform(version) do |scenario|
|
|
22
|
+
scenario.tag = 'nightly'
|
|
23
|
+
scenario.volumes = volumes
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def with_temporary_volumes
|
|
29
|
+
Dir.mktmpdir('gitlab-qa-').tap do |dir|
|
|
30
|
+
yield Hash[VOLUMES.map { |k, v| ["#{dir}/#{k}", v] }]
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gitlab-qa
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Grzegorz Bizon
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-03-15 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.12'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.12'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: rubocop
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 0.47.1
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - "~>"
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 0.47.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 0.10.4
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 0.10.4
|
|
83
|
+
description:
|
|
84
|
+
email:
|
|
85
|
+
- grzesiek.bizon@gmail.com
|
|
86
|
+
executables:
|
|
87
|
+
- gitlab-qa
|
|
88
|
+
extensions: []
|
|
89
|
+
extra_rdoc_files: []
|
|
90
|
+
files:
|
|
91
|
+
- ".dockerignore"
|
|
92
|
+
- ".gitignore"
|
|
93
|
+
- ".gitlab-ci.yml"
|
|
94
|
+
- ".rspec"
|
|
95
|
+
- ".rubocop.yml"
|
|
96
|
+
- ".travis.yml"
|
|
97
|
+
- Gemfile
|
|
98
|
+
- LICENSE
|
|
99
|
+
- README.md
|
|
100
|
+
- Rakefile
|
|
101
|
+
- bin/console
|
|
102
|
+
- bin/qa
|
|
103
|
+
- bin/setup
|
|
104
|
+
- bin/slack
|
|
105
|
+
- exe/gitlab-qa
|
|
106
|
+
- gitlab-qa.gemspec
|
|
107
|
+
- lib/gitlab/qa.rb
|
|
108
|
+
- lib/gitlab/qa/docker/command.rb
|
|
109
|
+
- lib/gitlab/qa/docker/engine.rb
|
|
110
|
+
- lib/gitlab/qa/docker/gitlab.rb
|
|
111
|
+
- lib/gitlab/qa/docker/specs.rb
|
|
112
|
+
- lib/gitlab/qa/scenario/actable.rb
|
|
113
|
+
- lib/gitlab/qa/scenario/template.rb
|
|
114
|
+
- lib/gitlab/qa/scenario/test/instance/any.rb
|
|
115
|
+
- lib/gitlab/qa/scenario/test/instance/image.rb
|
|
116
|
+
- lib/gitlab/qa/scenario/test/omnibus/image.rb
|
|
117
|
+
- lib/gitlab/qa/scenario/test/omnibus/upgrade.rb
|
|
118
|
+
- lib/gitlab/qa/version.rb
|
|
119
|
+
homepage: http://about.gitlab.com
|
|
120
|
+
licenses:
|
|
121
|
+
- MIT
|
|
122
|
+
metadata: {}
|
|
123
|
+
post_install_message:
|
|
124
|
+
rdoc_options: []
|
|
125
|
+
require_paths:
|
|
126
|
+
- lib
|
|
127
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
128
|
+
requirements:
|
|
129
|
+
- - ">="
|
|
130
|
+
- !ruby/object:Gem::Version
|
|
131
|
+
version: '0'
|
|
132
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
|
+
requirements:
|
|
134
|
+
- - ">="
|
|
135
|
+
- !ruby/object:Gem::Version
|
|
136
|
+
version: '0'
|
|
137
|
+
requirements: []
|
|
138
|
+
rubyforge_project:
|
|
139
|
+
rubygems_version: 2.5.1
|
|
140
|
+
signing_key:
|
|
141
|
+
specification_version: 4
|
|
142
|
+
summary: Integration tests for GitLab
|
|
143
|
+
test_files: []
|