gitlab-qa 5.12.0 → 5.13.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/docs/what_tests_can_be_run.md +55 -54
  3. data/lib/gitlab/qa.rb +4 -0
  4. data/lib/gitlab/qa/component/base.rb +131 -0
  5. data/lib/gitlab/qa/component/elasticsearch.rb +5 -33
  6. data/lib/gitlab/qa/component/gitlab.rb +16 -78
  7. data/lib/gitlab/qa/component/internet_tunnel.rb +6 -29
  8. data/lib/gitlab/qa/component/jira.rb +5 -44
  9. data/lib/gitlab/qa/component/ldap.rb +8 -51
  10. data/lib/gitlab/qa/component/mail_hog.rb +5 -44
  11. data/lib/gitlab/qa/component/minio.rb +9 -34
  12. data/lib/gitlab/qa/component/postgresql.rb +4 -36
  13. data/lib/gitlab/qa/component/release.rb +13 -0
  14. data/lib/gitlab/qa/component/saml.rb +5 -54
  15. data/lib/gitlab/qa/component/specs.rb +0 -11
  16. data/lib/gitlab/qa/component/staging.rb +2 -2
  17. data/lib/gitlab/qa/docker/engine.rb +8 -0
  18. data/lib/gitlab/qa/release.rb +25 -0
  19. data/lib/gitlab/qa/runtime/env.rb +29 -1
  20. data/lib/gitlab/qa/runtime/scenario.rb +36 -0
  21. data/lib/gitlab/qa/scenario/test/instance/any.rb +1 -1
  22. data/lib/gitlab/qa/scenario/test/instance/deployment_base.rb +1 -1
  23. data/lib/gitlab/qa/scenario/test/instance/geo.rb +1 -1
  24. data/lib/gitlab/qa/scenario/test/instance/release.rb +18 -0
  25. data/lib/gitlab/qa/scenario/test/instance/repository_storage.rb +1 -1
  26. data/lib/gitlab/qa/scenario/test/instance/smoke.rb +1 -1
  27. data/lib/gitlab/qa/scenario/test/integration/elasticsearch.rb +1 -1
  28. data/lib/gitlab/qa/scenario/test/integration/geo.rb +1 -1
  29. data/lib/gitlab/qa/scenario/test/integration/gitaly_ha.rb +5 -5
  30. data/lib/gitlab/qa/scenario/test/integration/jira.rb +1 -1
  31. data/lib/gitlab/qa/scenario/test/integration/packages.rb +1 -1
  32. data/lib/gitlab/qa/scenario/test/integration/praefect.rb +2 -2
  33. data/lib/gitlab/qa/scenario/test/integration/saml.rb +1 -1
  34. data/lib/gitlab/qa/scenario/test/integration/smtp.rb +1 -1
  35. data/lib/gitlab/qa/scenario/test/omnibus/update.rb +2 -2
  36. data/lib/gitlab/qa/scenario/test/omnibus/upgrade.rb +1 -1
  37. data/lib/gitlab/qa/scenario/test/sanity/version.rb +1 -1
  38. data/lib/gitlab/qa/version.rb +1 -1
  39. metadata +6 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ca0c9bc180dabbb9cba4984c2f19381d16ae57631e7ca308e38a3649d8d72dbf
4
- data.tar.gz: '018c552b3d04932d581872c7ddb3d3199545a868884530e58d57ff0842528134'
3
+ metadata.gz: 03d6616c7add937d18759fbccacdd71b5c988986b786b118702534e69148eaf4
4
+ data.tar.gz: 2c586c2bd61b1562b10b538fb15f5a7d3e3443657a7270bc65381e6af37b2ea3
5
5
  SHA512:
6
- metadata.gz: 2c1be4f5eab6dbefb4685dc03f7f12140cc442766f4ec86006a927aa95ae787be6065f762f0ff1b3d6f79ea3158464e9a5e33ac5c7790b75bc31ac3ed005ac19
7
- data.tar.gz: abbff15cf25737e634429c22e3a704ec3f933656546243a92b408c6c55baa8056439a2f3a0c0ca1901a2e54f3e166ff16df307d61d6db109e35ed566c914b4dd
6
+ metadata.gz: bae9f63159c042699b10d8bd0d61abb4254846af3d427d958ca31dd1b0e8fc3e5eef60e735e737814fb8612f5177921cf856f56bd0e4e447dbca09027c621637
7
+ data.tar.gz: ad061dc8fdfb338710e5286918084303e2eb5c3d2da087b0e79029ed26d913eb65e4deb1711e0025e7b2edb34d188d29bceb44a176b46c9b0f5e0e6a8fafd91d
@@ -28,60 +28,56 @@ For more details on the internals, please read the
28
28
 
29
29
  ## Supported GitLab environment variables
30
30
 
31
- * `GITLAB_USERNAME` - username to use when signing into GitLab
32
- * `GITLAB_PASSWORD` - password to use when signing into GitLab
33
- * `GITLAB_FORKER_USERNAME` - username to use for forking a project
34
- * `GITLAB_FORKER_PASSWORD` - password to use for forking a project
35
- * `GITLAB_QA_USERNAME_1` - username available in environments where signup is disabled
36
- * `GITLAB_QA_PASSWORD_1` - password for `GITLAB_QA_USERNAME_1` available in environments where signup is disabled (e.g. staging.gitlab.com)
37
- * `GITLAB_QA_USERNAME_2` - another username available in environments where signup is disabled
38
- * `GITLAB_QA_PASSWORD_2` - password for `GITLAB_QA_USERNAME_2` available in environments where signup is disabled (e.g. staging.gitlab.com)
39
- * `GITLAB_QA_USERNAME_3` - another username available in environments where signup is disabled
40
- * `GITLAB_QA_PASSWORD_3` - password for `GITLAB_QA_USERNAME_3` available in environments where signup is disabled (e.g. staging.gitlab.com)
41
- * `GITLAB_QA_USERNAME_4` - another username available in environments where signup is disabled
42
- * `GITLAB_QA_PASSWORD_4` - password for `GITLAB_QA_USERNAME_4` available in environments where signup is disabled (e.g. staging.gitlab.com)
43
- * `GITLAB_QA_USERNAME_5` - another username available in environments where signup is disabled
44
- * `GITLAB_QA_PASSWORD_5` - password for `GITLAB_QA_USERNAME_5` available in environments where signup is disabled (e.g. staging.gitlab.com)
45
- * `GITLAB_QA_USERNAME_6` - another username available in environments where signup is disabled
46
- * `GITLAB_QA_PASSWORD_6` - password for `GITLAB_QA_USERNAME_6` available in environments where signup is disabled (e.g. staging.gitlab.com)
47
- * `GITLAB_LDAP_USERNAME` - LDAP username to use when signing into GitLab
48
- * `GITLAB_LDAP_PASSWORD` - LDAP password to use when signing into GitLab
49
- * `GITLAB_ADMIN_USERNAME` - Admin username to use when adding a license
50
- * `GITLAB_ADMIN_PASSWORD` - Admin password to use when adding a license
51
- * `GITLAB_SANDBOX_NAME` - The sandbox group name the test suite is going to use (default: `gitlab-qa-sandbox`)
52
- * `GITLAB_QA_ACCESS_TOKEN` - A valid personal access token with the `api` scope.
53
- This is used for API access during tests, and is used in the
54
- [`Test::Instance::Staging`](#testinstancestaging) scenario to retrieve the
55
- version that staging is currently running. An existing token that is valid on
56
- staging can be found in the shared 1Password vault.
57
- * `GITLAB_QA_ADMIN_ACCESS_TOKEN` - A valid personal access token with the `api` scope
58
- from a user with admin access. Used for API access as an admin during tests.
59
- * `EE_LICENSE` - Enterprise Edition license
60
- * `QA_ARTIFACTS_DIR` - Path to a directory where artifacts (logs and screenshots)
61
- for failing tests will be saved (default: `/tmp/gitlab-qa`)
62
- * `DOCKER_HOST` - Docker host to run tests against (default: `http://localhost`)
63
- * `CHROME_HEADLESS` - when running locally, set to `false` to allow Chrome tests to be visible - watch your tests being run
64
- * `QA_ADDITIONAL_REPOSITORY_STORAGE` - the name of additional, non-default storage to be used with tests tagged `repository_storage`, run via the `Test::Instance::RepositoryStorage` scenario
65
- * `QA_PRAEFECT_REPOSITORY_STORAGE` - the name of repository storage using Praefect.
66
- * `QA_COOKIES` - optionally set to "cookie1=value;cookie2=value" in order to add a cookie to every request. This can be used to set the canary cookie by setting it to "gitlab_canary=true"
67
- * `QA_DEBUG` - set to `true` to verbosely log page object actions. Note: if enabled be aware that sensitive data might be logged. If an input element has a QA selector with `password` in the name, data entered into the input element will be masked. If the element doesn't have `password` in its name it won't be masked.
68
- * `QA_LOG_PATH` - path to output debug logging to. If not set logging will be output to STDOUT
69
- * `QA_CAN_TEST_GIT_PROTOCOL_V2` - set to `false` to skip tests that require Git protocol v2 if your environment doesn't support it.
70
- * `QA_CAN_TEST_ADMIN_FEATURES` - set to `false` to skip tests that require admin access.
71
- * `QA_CAN_TEST_PRAEFECT` - set to `false` to skip tests that require Praefect to be running.
72
- * `QA_DISABLE_RSPEC_RETRY` - set to `true` to turn off retrying tests on failure.
73
- * `QA_SIMULATE_SLOW_CONNECTION` - set to `true` to configure Chrome's network settings to simulate a slow connection.
74
- * `QA_SLOW_CONNECTION_LATENCY_MS` - the additional latency (in ms) of the simulated slow connection (default 2000 ms).
75
- * `QA_SLOW_CONNECTION_THROUGHPUT_KBPS` - the maximum throughput (in kbps) of the simulated slow connection (default 32 kbps).
76
- * `QA_SKIP_PULL` - set to `true` to skip pulling docker images (e.g., to use one you built locally).
77
- * `GITHUB_USERNAME` - Username for authenticating with GitHub.
78
- * `GITHUB_PASSWORD` - Password for authenticating with GitHub.
79
- * `GITLAB_QA_LOOP_RUNNER_MINUTES` - Minutes to run and repeat a spec while using the '--loop' option; default value is 1 minute.
80
- * `CI_SERVER_PERSONAL_ACCESS_TOKEN` - Personal access token of the server that is running the CI pipeline. This is used for pulling CI_RUNNER information in certain tests.
81
- * `GEO_MAX_FILE_REPLICATION_TIME` - maximum time that a test will wait for a replicated file to appear on a Geo secondary node (default 120 seconds)
82
- * `GEO_MAX_DB_REPLICATION_TIME` - maximum time that a test will wait for database data to appear on a Geo secondary node (default 120 seconds)
83
- * `JIRA_ADMIN_USERNAME` - Username for authenticating with Jira server as admin.
84
- * `JIRA_ADMIN_PASSWORD` - Password for authenticating with Jira server as admin.
31
+ | Variable | Default | Description | Required |
32
+ |-----------------------|-----------|-----------------------|----------|
33
+ | `GITLAB_USERNAME` | `root` | Username to use when signing into GitLab. | Yes|
34
+ | `GITLAB_PASSWORD` | `5iveL!fe` | Password to use when signing into GitLab. | Yes|
35
+ | `GITLAB_FORKER_USERNAME`|- | Username to use for forking a project. | Yes|
36
+ | `GITLAB_FORKER_PASSWORD`|- | Password to use for forking a project. | Yes|
37
+ | `GITLAB_QA_USERNAME_1` |- | Username available in environments where signup is disabled. | No|
38
+ | `GITLAB_QA_PASSWORD_1` |- | Password for `GITLAB_QA_USERNAME_1` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
39
+ | `GITLAB_QA_USERNAME_2` |- | Another username available in environments where signup is disabled. | No|
40
+ | `GITLAB_QA_PASSWORD_2` |- | Password for `GITLAB_QA_USERNAME_2` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
41
+ | `GITLAB_QA_USERNAME_3` |- | Another username available in environments where signup is disabled. | No|
42
+ | `GITLAB_QA_PASSWORD_3` |- | Password for `GITLAB_QA_USERNAME_3` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
43
+ | `GITLAB_QA_USERNAME_4` |- | Another username available in environments where signup is disabled. | No|
44
+ | `GITLAB_QA_PASSWORD_4` |- | Password for `GITLAB_QA_USERNAME_4` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
45
+ | `GITLAB_QA_USERNAME_5` |- | Another username available in environments where signup is disabled. | No|
46
+ | `GITLAB_QA_PASSWORD_5` |- | Password for `GITLAB_QA_USERNAME_5` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
47
+ | `GITLAB_QA_USERNAME_6` |- | Another username available in environments where signup is disabled. | No|
48
+ | `GITLAB_QA_PASSWORD_6` |- | Password for `GITLAB_QA_USERNAME_6` available in environments where signup is disabled (e.g. staging.gitlab.com). | No|
49
+ | `GITLAB_LDAP_USERNAME` |- | LDAP username to use when signing into GitLab. | No|
50
+ | `GITLAB_LDAP_PASSWORD` |- | LDAP password to use when signing into GitLab. | No|
51
+ | `GITLAB_ADMIN_USERNAME` |- | Admin username to use when adding a license. | No|
52
+ | `GITLAB_ADMIN_PASSWORD` |- | Admin password to use when adding a license. | No|
53
+ | `GITLAB_SANDBOX_NAME` | `gitlab-qa-sandbox` | The sandbox group name the test suite is going to use. | No|
54
+ | `GITLAB_QA_ACCESS_TOKEN`|- | A valid personal access token with the `api` scope. This is used for API access during tests, and is used in the version that staging is currently running. An existing token that is valid on [`Test::Instance::Staging`](#testinstancestaging) scenario to retrieve the staging can be found in the shared 1Password vault. |No|
55
+ | `GITLAB_QA_ADMIN_ACCESS_TOKEN` |- | A valid personal access token with the `api` scope from a user with admin access. Used for API access as an admin during tests. | No|
56
+ | `EE_LICESEN` |- | Enterprise Edition license. | No|
57
+ | `QA_ARTIFACTS_DIR` |`/tmp/gitlab-qa`| Path to a directory where artifacts (logs and screenshots) for failing tests will be saved. | No|
58
+ | `DOCKER_HOST` |`http://localhost`| Docker host to run tests against. | No|
59
+ | `CHROME_HEADLESS` |- | When running locally, set to `false` to allow Chrome tests to be visible - watch your tests being run. | No|
60
+ | `QA_ADDITIONAL_REPOSITORY_STORAGE` |- | The name of additional, non-default storage to be used with tests tagged `repository_storage`, run via the `Test::Instance::RepositoryStorage` scenario. | No|
61
+ | `QA_PRAEFECT_REPOSITORY_STORAGE` |- | The name of repository storage using Praefect. | No|
62
+ | `QA_COOKIES` |- | Optionally set to "cookie1=value;cookie2=value" in order to add a cookie to every request. This can be used to set the canary cookie by setting it to "gitlab_canary=true". | No|
63
+ | `QA_DEBUG` |- | Set to `true` to verbosely log page object actions. Note: if enabled be aware that sensitive data might be logged. If an input element has a QA selector with `password` in the name, data entered into the input element will be masked. If the element doesn't have `password` in its name it won't be masked. | No|
64
+ | `QA_LOG_PATH` |- | Path to output debug logging to. If not set logging will be output to STDOUT. | No|
65
+ | `QA_CAN_TEST_GIT_PROTOCOL_V2` |- | Set to `false` to skip tests that require Git protocol v2 if your environment doesn't support it. | No|
66
+ | `QA_CAN_TEST_ADMIN_FEATURES` |- | Set to `false` to skip tests that require admin access. | No|
67
+ | `QA_CAN_TEST_PRAEFECT` |- | Set to `false` to skip tests that require Praefect to be running. | No|
68
+ | `QA_DISABLE_RSPEC_RETRY` |- | Set to `true` to turn off retrying tests on failure. | No|
69
+ | `QA_SIMULATE_SLOW_CONNECTION` |- | Set to `true` to configure Chrome's network settings to simulate a slow connection. | No|
70
+ | `QA_SLOW_CONNECTION_LATENCY_MS` | `2000` | The additional latency (in ms) of the simulated slow connection. | No|
71
+ | `QA_SLOW_CONNECTION_THROUGHPUT_KBPS` | `32` | The maximum throughput (in kbps) of the simulated slow connection. | No|
72
+ | `QA_SKIP_PULL` | `false` | Set to `true` to skip pulling docker images (e.g., to use one you built locally). | No|
73
+ | `GITHUB_USERNAME` |- | Username for authenticating with GitHub. | No|
74
+ | `GITHUB_PASSWORD` |- | Password for authenticating with GitHub. | No|
75
+ | `GITLAB_QA_LOOP_RUNNER_MINUTES` | `1` | Minutes to run and repeat a spec while using the '--loop' option; default value is 1 minute. | No|
76
+ | `CI_SERVER_PERSONAL_ACCESS_TOKEN` |- | Personal access token of the server that is running the CI pipeline. This is used for pulling CI_RUNNER information in certain tests. | No|
77
+ | `GEO_MAX_FILE_REPLICATION_TIME` | `120` | Maximum time that a test will wait for a replicated file to appear on a Geo secondary node. | No|
78
+ | `GEO_MAX_DB_REPLICATION_TIME` | `120` | Maximum time that a test will wait for database data to appear on a Geo secondary node. | No|
79
+ | `JIRA_ADMIN_USERNAME` |- | Username for authenticating with Jira server as admin. | No|
80
+ | `JIRA_ADMIN_PASSWORD` |- | Password for authenticating with Jira server as admin. | No|
85
81
 
86
82
  ## [Supported Remote Grid environment variables](./running_against_remote_grid.md)
87
83
 
@@ -582,6 +578,11 @@ but will run tests against [`pre.gitlab.com`](https://pre.gitlab.com).
582
578
  Note that [`pre.gitlab.com`](https://pre.gitlab.com) is used as an Interim
583
579
  Performance Testbed and [will be replaced with the actual testbed in the future](https://gitlab.com/groups/gitlab-com/gl-infra/-/epics/60).
584
580
 
581
+ ### `Test::Instance::Release`
582
+
583
+ This scenario functions the same as `Test::Instance::Staging`
584
+ but will run tests against [`release.gitlab.net`](https://release.gitlab.net).
585
+
585
586
  ### `Test::Instance::Smoke`
586
587
 
587
588
  This scenario will run a limited amount of tests selected from the test suite tagged by `:smoke`.
@@ -6,6 +6,7 @@ module Gitlab
6
6
 
7
7
  module Runtime
8
8
  autoload :Env, 'gitlab/qa/runtime/env'
9
+ autoload :Scenario, 'gitlab/qa/runtime/scenario'
9
10
  autoload :TokenFinder, 'gitlab/qa/runtime/token_finder'
10
11
  end
11
12
 
@@ -25,6 +26,7 @@ module Gitlab
25
26
  autoload :Production, 'gitlab/qa/scenario/test/instance/production'
26
27
  autoload :Smoke, 'gitlab/qa/scenario/test/instance/smoke'
27
28
  autoload :Preprod, 'gitlab/qa/scenario/test/instance/preprod'
29
+ autoload :Release, 'gitlab/qa/scenario/test/instance/release'
28
30
  autoload :Geo, 'gitlab/qa/scenario/test/instance/geo'
29
31
  autoload :StagingGeo, 'gitlab/qa/scenario/test/instance/staging_geo'
30
32
  end
@@ -62,6 +64,7 @@ module Gitlab
62
64
  end
63
65
 
64
66
  module Component
67
+ autoload :Base, 'gitlab/qa/component/base'
65
68
  autoload :Gitlab, 'gitlab/qa/component/gitlab'
66
69
  autoload :InternetTunnel, 'gitlab/qa/component/internet_tunnel'
67
70
  autoload :LDAP, 'gitlab/qa/component/ldap'
@@ -71,6 +74,7 @@ module Gitlab
71
74
  autoload :Production, 'gitlab/qa/component/production'
72
75
  autoload :Minio, 'gitlab/qa/component/minio'
73
76
  autoload :Preprod, 'gitlab/qa/component/preprod'
77
+ autoload :Release, 'gitlab/qa/component/release'
74
78
  autoload :Elasticsearch, 'gitlab/qa/component/elasticsearch'
75
79
  autoload :MailHog, 'gitlab/qa/component/mail_hog'
76
80
  autoload :Jira, 'gitlab/qa/component/jira'
@@ -0,0 +1,131 @@
1
+ module Gitlab
2
+ module QA
3
+ module Component
4
+ class Base
5
+ include Scenario::Actable
6
+
7
+ attr_reader :docker
8
+ attr_accessor :volumes, :network, :environment
9
+ attr_writer :name, :exec_commands
10
+
11
+ def initialize
12
+ @docker = Docker::Engine.new
13
+ @environment = {}
14
+ @volumes = {}
15
+ @network_aliases = []
16
+
17
+ self.exec_commands = []
18
+ end
19
+
20
+ def add_network_alias(name)
21
+ @network_aliases.push(name)
22
+ end
23
+
24
+ def name
25
+ raise NotImplementedError, "#{self.class.name} must specify a default name"
26
+ end
27
+
28
+ def hostname
29
+ "#{name}.#{network}"
30
+ end
31
+
32
+ def image
33
+ return self.class.const_get('DOCKER_IMAGE') if self.class.const_defined?('DOCKER_IMAGE')
34
+
35
+ raise NotImplementedError, "#{self.class.name} must specify a docker image as DOCKER_IMAGE"
36
+ end
37
+
38
+ def tag
39
+ return self.class.const_get('DOCKER_IMAGE_TAG') if self.class.const_defined?('DOCKER_IMAGE_TAG')
40
+
41
+ raise NotImplementedError, "#{self.class.name} must specify a docker image tag as DOCKER_IMAGE_TAG"
42
+ end
43
+
44
+ def instance
45
+ prepare
46
+ start
47
+ reconfigure
48
+ wait_until_ready
49
+ process_exec_commands
50
+
51
+ yield self if block_given?
52
+ ensure
53
+ teardown
54
+ end
55
+
56
+ alias_method :launch_and_teardown_instance, :instance
57
+
58
+ def prepare
59
+ prepare_docker_image
60
+ prepare_network
61
+ end
62
+
63
+ def prepare_docker_image
64
+ return if Runtime::Env.skip_pull?
65
+
66
+ pull
67
+ end
68
+
69
+ def prepare_network
70
+ return if docker.network_exists?(network)
71
+
72
+ docker.network_create(network)
73
+ end
74
+
75
+ def start # rubocop:disable Metrics/AbcSize
76
+ docker.run(image, tag) do |command|
77
+ command << "-d"
78
+ command << "--name #{name}"
79
+ command << "--net #{network}"
80
+ command << "--hostname #{hostname}"
81
+
82
+ @volumes.to_h.each do |to, from|
83
+ command.volume(to, from, 'Z')
84
+ end
85
+
86
+ command.volume(File.join(Runtime::Env.host_artifacts_dir, name, 'logs'), '/var/log/gitlab', 'Z')
87
+
88
+ @environment.to_h.each do |key, value|
89
+ command.env(key, value)
90
+ end
91
+
92
+ @network_aliases.to_a.each do |network_alias|
93
+ command << "--network-alias #{network_alias}"
94
+ end
95
+ end
96
+ end
97
+
98
+ def restart
99
+ assert_name!
100
+
101
+ docker.restart(name)
102
+ end
103
+
104
+ def teardown
105
+ assert_name!
106
+
107
+ return unless docker.running?(name)
108
+
109
+ docker.stop(name)
110
+ docker.remove(name)
111
+ end
112
+
113
+ def pull
114
+ docker.pull(image, tag)
115
+ end
116
+
117
+ def process_exec_commands
118
+ exec_commands.each { |command| docker.exec(name, command) }
119
+ end
120
+
121
+ private
122
+
123
+ attr_reader :exec_commands, :wait_until_ready, :reconfigure
124
+
125
+ def assert_name!
126
+ raise 'Invalid instance name!' unless name
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
@@ -1,42 +1,19 @@
1
1
  module Gitlab
2
2
  module QA
3
3
  module Component
4
- class Elasticsearch
5
- include Scenario::Actable
6
-
7
- ELASTIC_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'.freeze
8
- ELASTIC_IMAGE_TAG = '6.4.2'.freeze
9
-
10
- attr_reader :docker
11
- attr_accessor :environment, :network
12
- attr_writer :name
13
-
14
- def initialize
15
- @docker = Docker::Engine.new
16
- @environment = {}
17
- end
4
+ class Elasticsearch < Base
5
+ DOCKER_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'.freeze
18
6
 
19
7
  def name
20
8
  @name ||= "elastic68"
21
9
  end
22
10
 
23
- def instance
24
- prepare
25
- start
26
- yield self
27
- ensure
28
- teardown
29
- end
30
-
31
- def prepare
32
- @docker.pull(ELASTIC_IMAGE, ELASTIC_IMAGE_TAG)
33
- return if @docker.network_exists?(network)
34
-
35
- @docker.network_create(network)
11
+ def tag
12
+ Runtime::Env.elastic_version
36
13
  end
37
14
 
38
15
  def start
39
- @docker.run(ELASTIC_IMAGE, ELASTIC_IMAGE_TAG) do |command|
16
+ @docker.run(image, tag) do |command|
40
17
  command << "-d"
41
18
  command << "--name #{name}"
42
19
  command << "--net #{network}"
@@ -46,11 +23,6 @@ module Gitlab
46
23
  command.env("discovery.type", "single-node")
47
24
  end
48
25
  end
49
-
50
- def teardown
51
- @docker.stop(name)
52
- @docker.remove(name)
53
- end
54
26
  end
55
27
  end
56
28
  end
@@ -7,13 +7,12 @@ require 'openssl'
7
7
  module Gitlab
8
8
  module QA
9
9
  module Component
10
- class Gitlab
10
+ class Gitlab < Base
11
11
  extend Forwardable
12
- include Scenario::Actable
13
12
 
14
- attr_reader :release, :docker
15
- attr_accessor :volumes, :network, :environment, :tls, :disable_animations
16
- attr_writer :name, :relative_path, :exec_commands, :skip_check
13
+ attr_reader :release
14
+ attr_accessor :tls, :disable_animations, :skip_availability_check
15
+ attr_writer :name, :relative_path
17
16
 
18
17
  def_delegators :release, :tag, :image, :edition
19
18
 
@@ -21,17 +20,14 @@ module Gitlab
21
20
  SSL_PATH = '/etc/gitlab/ssl'.freeze
22
21
 
23
22
  def initialize
24
- @docker = Docker::Engine.new
25
- @environment = {}
26
- @volumes = {}
27
- @network_aliases = []
23
+ super
24
+
28
25
  @disable_animations = true
29
- @skip_check = false
26
+ @skip_availability_check = false
30
27
 
31
28
  @volumes[CERTIFICATES_PATH] = SSL_PATH
32
29
 
33
30
  self.release = 'CE'
34
- self.exec_commands = []
35
31
  end
36
32
 
37
33
  def omnibus_config=(config)
@@ -48,12 +44,8 @@ module Gitlab
48
44
  @environment['ELASTIC_URL'] = url
49
45
  end
50
46
 
51
- def add_network_alias(name)
52
- @network_aliases.push(name)
53
- end
54
-
55
47
  def release=(release)
56
- @release = Release.new(release)
48
+ @release = QA::Release.new(release)
57
49
  end
58
50
 
59
51
  def name
@@ -72,10 +64,6 @@ module Gitlab
72
64
  tls ? '443' : '80'
73
65
  end
74
66
 
75
- def hostname
76
- "#{name}.#{network}"
77
- end
78
-
79
67
  def relative_path
80
68
  @relative_path ||= ''
81
69
  end
@@ -84,24 +72,16 @@ module Gitlab
84
72
  Runtime::Env.accept_insecure_certs = 'true'
85
73
  end
86
74
 
87
- def instance
88
- prepare
89
- start
90
- reconfigure
91
- wait unless @skip_check
92
- process_exec_commands
75
+ def prepare
76
+ prepare_gitlab_omnibus_config
93
77
 
94
- yield self if block_given?
95
- ensure
96
- teardown
78
+ super
97
79
  end
98
80
 
99
- alias_method :launch_and_teardown_instance, :instance
81
+ def pull
82
+ docker.login(**release.login_params) if release.login_params
100
83
 
101
- def prepare
102
- prepare_gitlab_omnibus_config
103
- prepare_docker_image
104
- prepare_network
84
+ super
105
85
  end
106
86
 
107
87
  def prepare_gitlab_omnibus_config
@@ -109,18 +89,6 @@ module Gitlab
109
89
  set_formless_login_token
110
90
  end
111
91
 
112
- def prepare_docker_image
113
- return if Runtime::Env.skip_pull?
114
-
115
- @docker.pull(image, tag)
116
- end
117
-
118
- def prepare_network
119
- return if @docker.network_exists?(network)
120
-
121
- @docker.network_create(network)
122
- end
123
-
124
92
  def setup_disable_animations
125
93
  @environment['GITLAB_OMNIBUS_CONFIG'] = "gitlab_rails['gitlab_disable_animations'] = true; #{@environment['GITLAB_OMNIBUS_CONFIG'] || ''}"
126
94
  end
@@ -128,17 +96,6 @@ module Gitlab
128
96
  def start # rubocop:disable Metrics/AbcSize
129
97
  ensure_configured!
130
98
 
131
- if release.dev_gitlab_org?
132
- Docker::Command.execute(
133
- [
134
- 'login',
135
- '--username gitlab-qa-bot',
136
- %(--password "#{Runtime::Env.dev_access_token_variable}"),
137
- Release::DEV_REGISTRY
138
- ]
139
- )
140
- end
141
-
142
99
  docker.run(image, tag) do |command|
143
100
  command << "-d -p #{port}"
144
101
  command << "--name #{name}"
@@ -170,18 +127,9 @@ module Gitlab
170
127
  end
171
128
  end
172
129
 
173
- def restart
174
- @docker.restart(name)
175
- end
176
-
177
- def teardown
178
- raise 'Invalid instance name!' unless name
179
-
180
- @docker.stop(name)
181
- @docker.remove(name)
182
- end
183
-
184
130
  def wait
131
+ return if skip_availability_check
132
+
185
133
  if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
186
134
  sleep 12 # TODO, handle that better
187
135
  puts ' -> GitLab is available.'
@@ -190,10 +138,6 @@ module Gitlab
190
138
  end
191
139
  end
192
140
 
193
- def pull
194
- @docker.pull(@release.image, @release.tag)
195
- end
196
-
197
141
  def sha_version
198
142
  json = @docker.read_file(
199
143
  @release.image, @release.tag,
@@ -204,14 +148,8 @@ module Gitlab
204
148
  manifest['software']['gitlab-rails']['locked_version']
205
149
  end
206
150
 
207
- def process_exec_commands
208
- exec_commands.each { |command| @docker.exec(name, command) }
209
- end
210
-
211
151
  private
212
152
 
213
- attr_reader :exec_commands
214
-
215
153
  def ensure_configured!
216
154
  raise 'Please configure an instance first!' unless [name, release, network].all?
217
155
  end