gitlab-qa 5.13.3 → 5.14.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
  SHA256:
3
- metadata.gz: eee3720392a340a5c044a75f4c171c69a206454bb5a55f912af79292c051e31f
4
- data.tar.gz: 7655dfd19f4a18c9db558ed70b5f0321d89c2aa3556b3ab025d4dc495afd4ac5
3
+ metadata.gz: 50cde662fbba863a232e44eacbb2aa7535762949816bd6281e5e0ce4fd916337
4
+ data.tar.gz: 67a222363326b5ab0767db8e894d56c351dd10a1e5c63aefd84991b009973a9e
5
5
  SHA512:
6
- metadata.gz: 73394e3956b9d62e290c605f10694c102da38681741593bd521d76fc513ca8b45ba919f669c64341db36f9a671e62764ea50f48b8eaf91bc7fe52a586f7b052e
7
- data.tar.gz: 3e325da83b7efd3084c8db5172cc03f5eda6fbccd5fe6e457c2fac1441773c22b18c54fcafe0eb37b00ad8ab57fef7e9d4d587cb8da89d2e28d2589adad1cec8
6
+ metadata.gz: dcd1486c1b47346d82c1bb5be090ec24ee25e0bd620232b8bbeef32e556cd6a7b8ebad3c5f05132de5ceb90636a78d10f4d5c6d4dd451784eac2d79b69429509
7
+ data.tar.gz: '0418804183dce1d3e5072381bb0ac6eef32c9eb7c0d98231a8e5ea94cc63255d43e14f94e61a91a6f47a1b3aa8ad44bf628ac7ce77544d80ccb6b13c6f8cccc5'
@@ -42,6 +42,9 @@ make a few changes to your `gdk/gitlab/config/gitlab.yml` file.
42
42
  $ exe/gitlab-qa Test::Instance::Any gitlab/gitlab-ce:your-custom-tag http://192.168.0.12:3000 -- qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb
43
43
  ```
44
44
 
45
+ **Note:** The hostname of the URL provided to `gitlab-qa` must match the hostname configured for GDK.
46
+ If they do not match, a test will be signed out when it visits a page directly because the hostname of the URL visited will be different from the hostname that was used when signing in.
47
+
45
48
  ### Running EE tests
46
49
 
47
50
  When running EE tests you'll need to have a license available. GitLab engineers can [request a license](https://about.gitlab.com/handbook/developer-onboarding/#working-on-gitlab-ee).
@@ -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. Note: Admin access is required to change repository storage. | No|
61
+ | `QA_PRAEFECT_REPOSITORY_STORAGE` |- | The name of repository storage using Praefect. Note: Admin access is required to change repository storage. | 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` | `true` | 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` | `true` | Set to `false` to skip tests that require admin access. | No|
67
+ | `QA_CAN_TEST_PRAEFECT` | `true` | 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
 
@@ -622,6 +618,21 @@ $ export QA_ADDITIONAL_REPOSITORY_STORAGE=secondary
622
618
  $ gitlab-qa Test::Instance::RepositoryStorage
623
619
  ```
624
620
 
621
+ ### `Test::Instance::Airgapped`
622
+
623
+ This scenario will run tests from the test suite against an airgapped instance.
624
+ The airgapped instance is set up by using `iptables` in the GitLab container to block network traffic other than testable ports, and by using runners
625
+ in a shared internal network.
626
+
627
+ Example:
628
+
629
+ ```
630
+ # For EE
631
+ $ export EE_LICENSE=$(cat /path/to/gitlab_license)
632
+
633
+ $ gitlab-qa Test::Instance::Airgapped EE -- --tag smoke
634
+ ```
635
+
625
636
  ----
626
637
 
627
638
  [Back to README.md](../README.md)
@@ -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
 
@@ -28,6 +29,7 @@ module Gitlab
28
29
  autoload :Release, 'gitlab/qa/scenario/test/instance/release'
29
30
  autoload :Geo, 'gitlab/qa/scenario/test/instance/geo'
30
31
  autoload :StagingGeo, 'gitlab/qa/scenario/test/instance/staging_geo'
32
+ autoload :Airgapped, 'gitlab/qa/scenario/test/instance/airgapped'
31
33
  end
32
34
 
33
35
  module Omnibus
@@ -63,6 +65,7 @@ module Gitlab
63
65
  end
64
66
 
65
67
  module Component
68
+ autoload :Base, 'gitlab/qa/component/base'
66
69
  autoload :Gitlab, 'gitlab/qa/component/gitlab'
67
70
  autoload :InternetTunnel, 'gitlab/qa/component/internet_tunnel'
68
71
  autoload :LDAP, 'gitlab/qa/component/ldap'
@@ -0,0 +1,135 @@
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, :runner_network
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
+ if runner_network && !docker.network_exists?(runner_network)
71
+ docker.network_create("--driver=bridge --internal #{runner_network}")
72
+ end
73
+
74
+ return if docker.network_exists?(network)
75
+
76
+ docker.network_create(network)
77
+ end
78
+
79
+ def start # rubocop:disable Metrics/AbcSize
80
+ docker.run(image, tag) do |command|
81
+ command << "-d"
82
+ command << "--name #{name}"
83
+ command << "--net #{network}"
84
+ command << "--hostname #{hostname}"
85
+
86
+ @volumes.to_h.each do |to, from|
87
+ command.volume(to, from, 'Z')
88
+ end
89
+
90
+ command.volume(File.join(Runtime::Env.host_artifacts_dir, name, 'logs'), '/var/log/gitlab', 'Z')
91
+
92
+ @environment.to_h.each do |key, value|
93
+ command.env(key, value)
94
+ end
95
+
96
+ @network_aliases.to_a.each do |network_alias|
97
+ command << "--network-alias #{network_alias}"
98
+ end
99
+ end
100
+ end
101
+
102
+ def restart
103
+ assert_name!
104
+
105
+ docker.restart(name)
106
+ end
107
+
108
+ def teardown
109
+ assert_name!
110
+
111
+ return unless docker.running?(name)
112
+
113
+ docker.stop(name)
114
+ docker.remove(name)
115
+ end
116
+
117
+ def pull
118
+ docker.pull(image, tag)
119
+ end
120
+
121
+ def process_exec_commands
122
+ exec_commands.each { |command| docker.exec(name, command) }
123
+ end
124
+
125
+ private
126
+
127
+ attr_reader :exec_commands, :wait_until_ready, :reconfigure
128
+
129
+ def assert_name!
130
+ raise 'Invalid instance name!' unless name
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
@@ -1,41 +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
-
9
- attr_reader :docker
10
- attr_accessor :environment, :network
11
- attr_writer :name
12
-
13
- def initialize
14
- @docker = Docker::Engine.new
15
- @environment = {}
16
- end
4
+ class Elasticsearch < Base
5
+ DOCKER_IMAGE = 'docker.elastic.co/elasticsearch/elasticsearch'.freeze
17
6
 
18
7
  def name
19
8
  @name ||= "elastic68"
20
9
  end
21
10
 
22
- def instance
23
- prepare
24
- start
25
- yield self
26
- ensure
27
- teardown
28
- end
29
-
30
- def prepare
31
- @docker.pull(ELASTIC_IMAGE, Runtime::Env.elastic_version)
32
- return if @docker.network_exists?(network)
33
-
34
- @docker.network_create(network)
11
+ def tag
12
+ Runtime::Env.elastic_version
35
13
  end
36
14
 
37
15
  def start
38
- @docker.run(ELASTIC_IMAGE, Runtime::Env.elastic_version) do |command|
16
+ @docker.run(image, tag) do |command|
39
17
  command << "-d"
40
18
  command << "--name #{name}"
41
19
  command << "--net #{network}"
@@ -45,11 +23,6 @@ module Gitlab
45
23
  command.env("discovery.type", "single-node")
46
24
  end
47
25
  end
48
-
49
- def teardown
50
- @docker.stop(name)
51
- @docker.remove(name)
52
- end
53
26
  end
54
27
  end
55
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, :runner_network
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,10 +44,6 @@ 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
48
  @release = QA::Release.new(release)
57
49
  end
@@ -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,28 +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
- QA::Release::DEV_REGISTRY
138
- ]
139
- )
140
- elsif release.omnibus_mirror?
141
- bot_token = ENV['GITLAB_BOT_MULTI_PROJECT_PIPELINE_POLLING_TOKEN']
142
-
143
- Docker::Command.execute(
144
- [
145
- 'login',
146
- '--username gitlab-bot',
147
- %(--password "#{bot_token}"),
148
- QA::Release::COM_REGISTRY
149
- ]
150
- )
151
- end
152
-
153
99
  docker.run(image, tag) do |command|
154
100
  command << "-d -p #{port}"
155
101
  command << "--name #{name}"
@@ -170,6 +116,7 @@ module Gitlab
170
116
  command << "--network-alias #{network_alias}"
171
117
  end
172
118
  end
119
+ Docker::Command.execute("network connect --alias #{name}.#{network} --alias #{name}.#{runner_network} #{runner_network} #{name}") if runner_network
173
120
  end
174
121
 
175
122
  def reconfigure
@@ -181,18 +128,9 @@ module Gitlab
181
128
  end
182
129
  end
183
130
 
184
- def restart
185
- @docker.restart(name)
186
- end
187
-
188
- def teardown
189
- raise 'Invalid instance name!' unless name
190
-
191
- @docker.stop(name)
192
- @docker.remove(name)
193
- end
194
-
195
131
  def wait
132
+ return if skip_availability_check
133
+
196
134
  if Availability.new(name, relative_path: relative_path, scheme: scheme, protocol_port: port.to_i).check(180)
197
135
  sleep 12 # TODO, handle that better
198
136
  puts ' -> GitLab is available.'
@@ -201,10 +139,6 @@ module Gitlab
201
139
  end
202
140
  end
203
141
 
204
- def pull
205
- @docker.pull(@release.image, @release.tag)
206
- end
207
-
208
142
  def sha_version
209
143
  json = @docker.read_file(
210
144
  @release.image, @release.tag,
@@ -215,14 +149,8 @@ module Gitlab
215
149
  manifest['software']['gitlab-rails']['locked_version']
216
150
  end
217
151
 
218
- def process_exec_commands
219
- exec_commands.each { |command| @docker.exec(name, command) }
220
- end
221
-
222
152
  private
223
153
 
224
- attr_reader :exec_commands
225
-
226
154
  def ensure_configured!
227
155
  raise 'Please configure an instance first!' unless [name, release, network].all?
228
156
  end