gitlab-qa 5.16.0 → 6.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -2
- data/docs/what_tests_can_be_run.md +106 -5
- data/lib/gitlab/qa.rb +3 -0
- data/lib/gitlab/qa/component/base.rb +12 -12
- data/lib/gitlab/qa/component/specs.rb +35 -11
- data/lib/gitlab/qa/report/json_test_results.rb +21 -0
- data/lib/gitlab/qa/report/junit_test_results.rb +21 -0
- data/lib/gitlab/qa/report/results_in_issues.rb +31 -16
- data/lib/gitlab/qa/report/test_result.rb +64 -0
- data/lib/gitlab/qa/runtime/env.rb +4 -1
- data/lib/gitlab/qa/scenario/test/instance/geo.rb +0 -3
- data/lib/gitlab/qa/scenario/test/integration/gitaly_cluster.rb +9 -6
- data/lib/gitlab/qa/scenario/test/integration/praefect.rb +2 -1
- data/lib/gitlab/qa/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ae53aaf2bbb205e8b04452a569bf5eac0c6743f55455f0f7897e36f0aa5e69f
|
4
|
+
data.tar.gz: 0b0a56d2d6e5afde89ba9f0f76db8dd1b8c0fb288d727fa6343423d4d9d33a73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd2a3ef1881f63da084930753c9d093c50c130c1ffa6923c5b91e2c9c98cbac48c84e825d350ed35b2d75f92704311eef249ee87cbff0d80c3ecdd3a9b426144
|
7
|
+
data.tar.gz: '0678f05968f62afb7f1266aec93824f746010a2155c2ee50a11588f5d4e3e07ae6b88dea59b5bb67c85e722a67cc543ee49faf7e433feba6dedd2dc55dd16b24'
|
data/.gitlab-ci.yml
CHANGED
@@ -94,7 +94,7 @@ release:
|
|
94
94
|
- exe/gitlab-qa ${QA_SCENARIO:=Test::Instance::Image} ${RELEASE:=$DEFAULT_RELEASE} -- $QA_TESTS $QA_RSPEC_TAGS $RSPEC_REPORT_OPTS || test_run_exit_code=$?
|
95
95
|
- exe/gitlab-qa-report --update-screenshot-path "gitlab-qa-run-*/**/rspec-*.xml"
|
96
96
|
- export GITLAB_QA_ACCESS_TOKEN="$GITLAB_QA_PRODUCTION_ACCESS_TOKEN"
|
97
|
-
- if [ "$TOP_UPSTREAM_SOURCE_REF" == "master" ]; then exe/gitlab-qa-report --report-in-issues "gitlab-qa-run-*/**/rspec-*.xml" --project "$QA_TESTCASES_REPORTING_PROJECT"; fi
|
97
|
+
- if [ "$TOP_UPSTREAM_SOURCE_REF" == "master" ]; then exe/gitlab-qa-report --report-in-issues "gitlab-qa-run-*/**/rspec-*.xml" --project "$QA_TESTCASES_REPORTING_PROJECT" || true; fi
|
98
98
|
- exit $test_run_exit_code
|
99
99
|
|
100
100
|
.ce-qa:
|
@@ -143,7 +143,7 @@ release:
|
|
143
143
|
.rspec-report-opts:
|
144
144
|
variables:
|
145
145
|
FILE_SAFE_JOB_NAME: $(echo $CI_JOB_NAME | sed 's/[ /]/_/g')
|
146
|
-
RSPEC_REPORT_OPTS: "--format RspecJunitFormatter --out \"tmp/rspec-${CI_JOB_ID}.xml\" --format html --out \"tmp/rspec-${FILE_SAFE_JOB_NAME}.htm\" --color --format documentation"
|
146
|
+
RSPEC_REPORT_OPTS: "--format QA::Support::JsonFormatter --out \"tmp/rspec-${CI_JOB_ID}.json\" --format RspecJunitFormatter --out \"tmp/rspec-${CI_JOB_ID}.xml\" --format html --out \"tmp/rspec-${FILE_SAFE_JOB_NAME}.htm\" --color --format documentation"
|
147
147
|
|
148
148
|
.quarantine:
|
149
149
|
allow_failure: true
|
@@ -1,5 +1,6 @@
|
|
1
|
-
# What tests can be run?
|
2
1
|
|
2
|
+
# What tests can be run?
|
3
|
+
[[_TOC_]]
|
3
4
|
## The two types of QA tests
|
4
5
|
|
5
6
|
First of all, the first thing to choose is whether you want to run orchestrated
|
@@ -28,6 +29,8 @@ For more details on the internals, please read the
|
|
28
29
|
|
29
30
|
## Supported GitLab environment variables
|
30
31
|
|
32
|
+
All environment variables used by GitLab QA should be defined in [`lib/gitlab/qa/runtime/env.rb`](https://gitlab.com/gitlab-org/gitlab-qa/-/blob/master/lib/gitlab/qa/runtime/env.rb).
|
33
|
+
|
31
34
|
| Variable | Default | Description | Required |
|
32
35
|
|-----------------------|-----------|-----------------------|----------|
|
33
36
|
| `GITLAB_USERNAME` | `root` | Username to use when signing into GitLab. | Yes|
|
@@ -53,7 +56,8 @@ For more details on the internals, please read the
|
|
53
56
|
| `GITLAB_SANDBOX_NAME` | `gitlab-qa-sandbox` | The sandbox group name the test suite is going to use. | No|
|
54
57
|
| `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
58
|
| `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
|
-
| `
|
59
|
+
| `GITLAB_QA_CONTAINER_REGISTRY_ACCESS_TOKEN` | - | A valid personal access token with the `read_registry` scope. Used to [access the container registry on `registry.gitlab.com` when tests run in a CI job that _is not_ triggered via another pipeline](https://gitlab.com/gitlab-org/gitlab-qa/-/blob/364addb83e7b136ff0f9d8719ca9553d290aa9ab/lib/gitlab/qa/release.rb#L152). For example, if you manually run a [new Staging pipeline](https://ops.gitlab.net/gitlab-org/quality/staging/-/pipelines/new), this token will be used. | No |
|
60
|
+
| `EE_LICENSE` |- | Enterprise Edition license. | No|
|
57
61
|
| `QA_ARTIFACTS_DIR` |`/tmp/gitlab-qa`| Path to a directory where artifacts (logs and screenshots) for failing tests will be saved. | No|
|
58
62
|
| `DOCKER_HOST` |`http://localhost`| Docker host to run tests against. | No|
|
59
63
|
| `CHROME_HEADLESS` |- | When running locally, set to `false` to allow Chrome tests to be visible - watch your tests being run. | No|
|
@@ -78,13 +82,33 @@ For more details on the internals, please read the
|
|
78
82
|
| `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
83
|
| `JIRA_ADMIN_USERNAME` |- | Username for authenticating with Jira server as admin. | No|
|
80
84
|
| `JIRA_ADMIN_PASSWORD` |- | Password for authenticating with Jira server as admin. | No|
|
85
|
+
| `CACHE_NAMESPACE_NAME` | `true` | Cache namespace name for groups. | No|
|
81
86
|
|
82
87
|
## [Supported Remote Grid environment variables](./running_against_remote_grid.md)
|
83
88
|
|
84
89
|
## Running tests with a feature flag enabled
|
85
90
|
|
86
|
-
It is possible to enable a feature flag before running tests.
|
87
|
-
|
91
|
+
It is possible to enable or disable a feature flag before running tests.
|
92
|
+
To test a Gitlab image with a feature flag enabled, run this command:
|
93
|
+
```
|
94
|
+
$ gitlab-qa Test::Instance::Image gitlab/gitlab-ee:12.4.0-ee.0 --enable-feature feature_flag_name
|
95
|
+
```
|
96
|
+
|
97
|
+
To run a test with feature flag disabled, run this command:
|
98
|
+
```
|
99
|
+
$ gitlab-qa Test::Instance::Image gitlab/gitlab-ee:12.4.0-ee.0 --disable-feature feature_flag_name
|
100
|
+
```
|
101
|
+
|
102
|
+
You an also test a GitLab image multiple times with different feature flag settings:
|
103
|
+
```
|
104
|
+
$ gitlab-qa Test::Instance::Image gitlab/gitlab-ee:12.4.0-ee.0 --disable-feature feature_flag_name --enable-feature feature_flag_name
|
105
|
+
```
|
106
|
+
This will first disable `feature_flag_name` flag and run the tests and then enable it and run the tests again.
|
107
|
+
|
108
|
+
You can pass any number of feature flag settings. The tests will run once for each setting.
|
109
|
+
|
110
|
+
See the [QA framework documentation](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/qa/README.md#running-tests-with-a-feature-flag-enabled)
|
111
|
+
for information on running the tests with different feature flag settings from the QA framework.
|
88
112
|
|
89
113
|
## Specifying the GitLab version
|
90
114
|
|
@@ -112,6 +136,10 @@ For example, the following command would use the image named `gitlab/gitlab-ee:n
|
|
112
136
|
$ gitlab-qa Test::Instance::Image EE
|
113
137
|
```
|
114
138
|
|
139
|
+
To run EE tests, the `EE_LICENSE` environment variable needs to be set:
|
140
|
+
|
141
|
+
`$ export EE_LICENSE=$(cat /path/to/GitLab.gitlab_license)`
|
142
|
+
|
115
143
|
## Examples
|
116
144
|
|
117
145
|
### `Test::Instance::Image CE|EE|<full image address>`
|
@@ -217,6 +245,25 @@ $ gitlab-qa Test::Integration::Geo EE
|
|
217
245
|
|
218
246
|
[test-geo]: https://gitlab.com/gitlab-org/gitlab-ee/blob/master/qa/qa/ee/scenario/test/geo.rb
|
219
247
|
|
248
|
+
### `Test::Integration::GitalyCluster CE|EE|<full image address>`
|
249
|
+
|
250
|
+
This tests [Gitaly Cluster](https://docs.gitlab.com/ee/administration/gitaly/praefect.html),
|
251
|
+
a clustered configuration of the Gitaly repository storage service.
|
252
|
+
|
253
|
+
The scenario configures and starts several docker containers to
|
254
|
+
represent the [recommended minimum configuration](https://docs.gitlab.com/ee/administration/gitaly/praefect.html#requirements-for-configuring-a-gitaly-cluster)
|
255
|
+
of a Gitaly Cluster.
|
256
|
+
|
257
|
+
To run tests against the GitLab container, a GitLab QA (`gitlab/gitlab-qa`)
|
258
|
+
container is spun up and tests are run from it by running the
|
259
|
+
`Test::Instance::All` scenario with the `:gitaly_cluster` tag.
|
260
|
+
|
261
|
+
Example:
|
262
|
+
|
263
|
+
```
|
264
|
+
$ gitlab-qa Test::Integration::GitalyCluster EE
|
265
|
+
```
|
266
|
+
|
220
267
|
### `Test::Integration::LDAPNoTLS CE|EE|<full image address>`
|
221
268
|
|
222
269
|
This tests that a GitLab instance works as expected with an external
|
@@ -545,7 +592,7 @@ in the GitLab CE project).
|
|
545
592
|
|
546
593
|
- `GITLAB_QA_DEV_ACCESS_TOKEN`: A valid personal access token for the
|
547
594
|
`gitlab-qa-bot` on `dev.gitlab.org` with the `registry` scope.
|
548
|
-
This is used to pull the QA Docker from the Omnibus GitLab `dev` Container Registry.
|
595
|
+
This is used to pull the QA Docker image from the Omnibus GitLab `dev` Container Registry.
|
549
596
|
If the variable isn't present, the QA image from Docker Hub will be used.
|
550
597
|
This can be found in the shared 1Password vault.
|
551
598
|
|
@@ -560,6 +607,41 @@ $ export GITLAB_PASSWORD="$GITLAB_QA_PASSWORD"
|
|
560
607
|
$ gitlab-qa Test::Instance::Staging
|
561
608
|
```
|
562
609
|
|
610
|
+
### `Test::Instance::StagingGeo`
|
611
|
+
|
612
|
+
This scenario tests that the Geo staging deployment (with [`staging.gitlab.com`](https://staging.gitlab.com) as the primary site and [`geo.staging.gitlab.com`](https://geo.staging.gitlab.com) as the secondary site) works as expected by running tests tagged `:geo` against it. This is done by spinning up a GitLab QA (`gitlab/gitlab-qa`) container and running the `QA::EE::Scenario::Test::Geo` scenario. Note that the Geo setup steps in the `QA::EE::Scenario::Test::Geo` scenario are skipped when testing a live Geo deployment.
|
613
|
+
|
614
|
+
**Required user properties:**
|
615
|
+
|
616
|
+
- The user must provide OAuth authorization on the secondary site before running Geo tests. This can be done via the authorization modal that appears after logging into the secondary node for the first time.
|
617
|
+
|
618
|
+
- Some Geo tests require the user to have Admin access level (for example, the Geo Nodes API tests)
|
619
|
+
|
620
|
+
**Required environment variables:**
|
621
|
+
|
622
|
+
- `GITLAB_QA_ACCESS_TOKEN`: A valid personal access token with the `api` scope.
|
623
|
+
This is used to retrieve the version that staging is currently running.
|
624
|
+
This can be found in the shared 1Password vault.
|
625
|
+
|
626
|
+
**Optional environment variables:**
|
627
|
+
|
628
|
+
- `GITLAB_QA_DEV_ACCESS_TOKEN`: A valid personal access token for the
|
629
|
+
`gitlab-qa-bot` on `dev.gitlab.org` with the `registry` scope.
|
630
|
+
This is used to pull the QA Docker image from the Omnibus GitLab `dev` Container Registry.
|
631
|
+
If the variable isn't present, the QA image from Docker Hub will be used.
|
632
|
+
This can be found in the shared 1Password vault.
|
633
|
+
|
634
|
+
Example:
|
635
|
+
|
636
|
+
```
|
637
|
+
$ export GITLAB_QA_ACCESS_TOKEN=your_api_access_token
|
638
|
+
$ export GITLAB_QA_DEV_ACCESS_TOKEN=your_dev_registry_access_token
|
639
|
+
$ export GITLAB_USERNAME="gitlab-qa"
|
640
|
+
$ export GITLAB_PASSWORD="$GITLAB_QA_PASSWORD"
|
641
|
+
|
642
|
+
$ gitlab-qa Test::Instance::StagingGeo
|
643
|
+
```
|
644
|
+
|
563
645
|
### `Test::Instance::Production`
|
564
646
|
|
565
647
|
This scenario functions the same as `Test::Instance::Staging`
|
@@ -633,6 +715,25 @@ $ export EE_LICENSE=$(cat /path/to/gitlab_license)
|
|
633
715
|
$ gitlab-qa Test::Instance::Airgapped EE -- --tag smoke
|
634
716
|
```
|
635
717
|
|
718
|
+
### `Test::Instance::Geo EE|<full image address>:nightly|latest|any_tag http://geo-primary.gitlab http://geo-secondary.gitlab`
|
719
|
+
|
720
|
+
This scenario will run tests tagged `:geo` against a live Geo deployment, by spinning up a GitLab QA (`gitlab/gitlab-qa`)
|
721
|
+
container and running the `QA::EE::Scenario::Test::Geo` scenario. Note that the Geo setup steps in the `QA::EE::Scenario::Test::Geo` scenario are skipped when testing a live Geo deployment. The URLs for the primary site and secondary site of the live Geo deployment must be provided as command line arguments.
|
722
|
+
|
723
|
+
**Required user properties:**
|
724
|
+
|
725
|
+
- The user must provide OAuth authorization on the secondary site before running Geo tests. This can be done via the authorization modal that appears after signing into the secondary node for the first time.
|
726
|
+
|
727
|
+
- Some Geo tests require the user to have Admin access level (for example, the Geo Nodes API tests)
|
728
|
+
|
729
|
+
Example:
|
730
|
+
|
731
|
+
```
|
732
|
+
$ export GITLAB_USERNAME="gitlab-qa"
|
733
|
+
$ export GITLAB_PASSWORD="$GITLAB_QA_PASSWORD"
|
734
|
+
|
735
|
+
$ gitlab-qa Test::Instance::Geo EE https://primary.gitlab.com https://secondary.gitlab.com
|
736
|
+
```
|
636
737
|
----
|
637
738
|
|
638
739
|
[Back to README.md](../README.md)
|
data/lib/gitlab/qa.rb
CHANGED
@@ -97,9 +97,12 @@ module Gitlab
|
|
97
97
|
end
|
98
98
|
|
99
99
|
module Report
|
100
|
+
autoload :JsonTestResults, 'gitlab/qa/report/json_test_results'
|
101
|
+
autoload :JUnitTestResults, 'gitlab/qa/report/junit_test_results'
|
100
102
|
autoload :PrepareStageReports, 'gitlab/qa/report/prepare_stage_reports'
|
101
103
|
autoload :ResultsInIssues, 'gitlab/qa/report/results_in_issues'
|
102
104
|
autoload :SummaryTable, 'gitlab/qa/report/summary_table'
|
105
|
+
autoload :TestResult, 'gitlab/qa/report/test_result'
|
103
106
|
autoload :UpdateScreenshotPath, 'gitlab/qa/report/update_screenshot_path'
|
104
107
|
end
|
105
108
|
|
@@ -41,26 +41,16 @@ module Gitlab
|
|
41
41
|
raise NotImplementedError, "#{self.class.name} must specify a docker image tag as DOCKER_IMAGE_TAG"
|
42
42
|
end
|
43
43
|
|
44
|
-
def instance
|
44
|
+
def instance(skip_teardown: false)
|
45
45
|
instance_no_teardown do
|
46
46
|
yield self if block_given?
|
47
47
|
end
|
48
48
|
ensure
|
49
|
-
teardown
|
49
|
+
teardown unless skip_teardown
|
50
50
|
end
|
51
51
|
|
52
52
|
alias_method :launch_and_teardown_instance, :instance
|
53
53
|
|
54
|
-
def instance_no_teardown
|
55
|
-
prepare
|
56
|
-
start
|
57
|
-
reconfigure
|
58
|
-
wait_until_ready
|
59
|
-
process_exec_commands
|
60
|
-
|
61
|
-
yield self if block_given?
|
62
|
-
end
|
63
|
-
|
64
54
|
def prepare
|
65
55
|
prepare_docker_image
|
66
56
|
prepare_network
|
@@ -147,6 +137,16 @@ module Gitlab
|
|
147
137
|
raise 'Invalid instance name!' unless name
|
148
138
|
end
|
149
139
|
|
140
|
+
def instance_no_teardown
|
141
|
+
prepare
|
142
|
+
start
|
143
|
+
reconfigure
|
144
|
+
wait_until_ready
|
145
|
+
process_exec_commands
|
146
|
+
|
147
|
+
yield self if block_given?
|
148
|
+
end
|
149
|
+
|
150
150
|
def teardown?
|
151
151
|
!Runtime::Scenario.attributes.include?(:teardown) || Runtime::Scenario.teardown
|
152
152
|
end
|
@@ -27,26 +27,50 @@ module Gitlab
|
|
27
27
|
|
28
28
|
name = "#{release.project_name}-qa-#{SecureRandom.hex(4)}"
|
29
29
|
|
30
|
-
|
31
|
-
command << "-t --rm --net=#{network || 'bridge'}"
|
30
|
+
feature_flag_sets = []
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# When `args` includes `[..., "--disable-feature", "a", "--enable-feature", "b", ...]`
|
33
|
+
# `feature_flag_sets` will be set to `[["--disable-feature", "a"], ["--enable-feature", "b"]]`
|
34
|
+
# This will result in tests running twice, once with each feature.
|
35
|
+
while (index = args&.index { |x| x =~ /--.*-feature/ })
|
36
|
+
feature_flag_sets << args.slice!(index, 2)
|
37
|
+
end
|
36
38
|
|
37
|
-
|
38
|
-
|
39
|
+
# When `args` do not have either "--disable-feature" or "--enable-feature", we
|
40
|
+
# add [] so that test is run exactly once.
|
41
|
+
feature_flag_sets << [] unless feature_flag_sets.any?
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
feature_flag_sets.each do |feature_flag_set|
|
44
|
+
@docker.run(release.qa_image, release.qa_tag, suite, *args_with_flags(args, feature_flag_set)) do |command|
|
45
|
+
command << "-t --rm --net=#{network || 'bridge'}"
|
46
|
+
|
47
|
+
env.merge(Runtime::Env.variables).each do |key, value|
|
48
|
+
command.env(key, value)
|
49
|
+
end
|
50
|
+
|
51
|
+
command.volume('/var/run/docker.sock', '/var/run/docker.sock')
|
52
|
+
command.volume(File.join(Runtime::Env.host_artifacts_dir, name), File.join(Docker::Volumes::QA_CONTAINER_WORKDIR, 'tmp'))
|
53
|
+
|
54
|
+
@volumes.to_h.each do |to, from|
|
55
|
+
command.volume(to, from)
|
56
|
+
end
|
43
57
|
|
44
|
-
|
58
|
+
command.name(name)
|
59
|
+
end
|
45
60
|
end
|
46
61
|
end
|
47
62
|
|
48
63
|
private
|
49
64
|
|
65
|
+
def args_with_flags(args, feature_flag_set)
|
66
|
+
return args if feature_flag_set.empty?
|
67
|
+
|
68
|
+
puts "Running with feature flag: #{feature_flag_set.join(' ')}"
|
69
|
+
|
70
|
+
args_with_f = args.dup
|
71
|
+
args_with_f.insert(1, *feature_flag_set)
|
72
|
+
end
|
73
|
+
|
50
74
|
def skip_tests?
|
51
75
|
Runtime::Scenario.attributes.include?(:run_tests) && !Runtime::Scenario.run_tests
|
52
76
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Gitlab
|
6
|
+
module QA
|
7
|
+
module Report
|
8
|
+
class JsonTestResults
|
9
|
+
include Enumerable
|
10
|
+
|
11
|
+
def initialize(file)
|
12
|
+
@testcases = JSON.parse(File.read(file))['examples'].map { |test| TestResult.from_json(test) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def each(&block)
|
16
|
+
@testcases.each(&block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'nokogiri'
|
4
|
+
|
5
|
+
module Gitlab
|
6
|
+
module QA
|
7
|
+
module Report
|
8
|
+
class JUnitTestResults
|
9
|
+
include Enumerable
|
10
|
+
|
11
|
+
def initialize(file)
|
12
|
+
@testcases = Nokogiri::XML(File.read(file)).xpath('//testcase').map { |test| TestResult.from_junit(test) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def each(&block)
|
16
|
+
@testcases.each(&block)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -46,7 +46,18 @@ module Gitlab
|
|
46
46
|
|
47
47
|
Dir.glob(files).each do |file|
|
48
48
|
puts "Reporting tests in #{file}"
|
49
|
-
|
49
|
+
extension = File.extname(file)
|
50
|
+
|
51
|
+
case extension
|
52
|
+
when '.json'
|
53
|
+
test_results = Report::JsonTestResults.new(file)
|
54
|
+
when '.xml'
|
55
|
+
test_results = Report::JUnitTestResults.new(file)
|
56
|
+
else
|
57
|
+
raise "Unknown extension #{extension}"
|
58
|
+
end
|
59
|
+
|
60
|
+
test_results.each do |test|
|
50
61
|
report_test(test)
|
51
62
|
end
|
52
63
|
end
|
@@ -99,9 +110,9 @@ module Gitlab
|
|
99
110
|
end
|
100
111
|
|
101
112
|
def report_test(test)
|
102
|
-
return if test.
|
113
|
+
return if test.skipped
|
103
114
|
|
104
|
-
puts "Reporting test: #{test
|
115
|
+
puts "Reporting test: #{test.file} | #{test.name}"
|
105
116
|
|
106
117
|
issue = find_issue(test)
|
107
118
|
if issue
|
@@ -124,29 +135,37 @@ module Gitlab
|
|
124
135
|
Gitlab.create_issue(
|
125
136
|
project,
|
126
137
|
title_from_test(test),
|
127
|
-
{ description: "### Full description\n\n#{search_safe(test
|
138
|
+
{ description: "### Full description\n\n#{search_safe(test.name)}\n\n### File path\n\n#{test.file}", labels: 'status::automated' }
|
128
139
|
)
|
129
140
|
end
|
130
141
|
end
|
131
142
|
|
143
|
+
# rubocop:disable Metrics/AbcSize
|
132
144
|
def find_issue(test)
|
133
145
|
handle_gitlab_client_exceptions do
|
146
|
+
return Gitlab.issue(project, id_from_status_issue_url(test.status_issue)) if test.status_issue
|
147
|
+
|
134
148
|
issues = Gitlab.issues(project, { search: search_term(test) })
|
135
149
|
.auto_paginate
|
136
150
|
.select { |issue| issue.state == 'opened' && issue.title.strip == title_from_test(test) }
|
137
151
|
|
138
|
-
warn(%(Too many issues found with the file path "#{test
|
152
|
+
warn(%(Too many issues found with the file path "#{test.file}" and name "#{test.name}")) if issues.many?
|
139
153
|
|
140
154
|
issues.first
|
141
155
|
end
|
142
156
|
end
|
157
|
+
# rubocop:enable Metrics/AbcSize
|
158
|
+
|
159
|
+
def id_from_status_issue_url(url)
|
160
|
+
url.split('/').last.to_i
|
161
|
+
end
|
143
162
|
|
144
163
|
def search_term(test)
|
145
|
-
%("#{test
|
164
|
+
%("#{test.file}" "#{search_safe(test.name)}")
|
146
165
|
end
|
147
166
|
|
148
167
|
def title_from_test(test)
|
149
|
-
title = "#{partial_file_path(test
|
168
|
+
title = "#{partial_file_path(test.file)} | #{search_safe(test.name)}".strip
|
150
169
|
|
151
170
|
return title unless title.length > MAX_TITLE_LENGTH
|
152
171
|
|
@@ -162,7 +181,7 @@ module Gitlab
|
|
162
181
|
end
|
163
182
|
|
164
183
|
def note_status(issue, test)
|
165
|
-
return if
|
184
|
+
return if test.failures.empty?
|
166
185
|
|
167
186
|
note = note_content(test)
|
168
187
|
|
@@ -176,7 +195,7 @@ module Gitlab
|
|
176
195
|
end
|
177
196
|
|
178
197
|
def note_content(test)
|
179
|
-
errors =
|
198
|
+
errors = test.failures.each_with_object([]) do |failure, text|
|
180
199
|
text << <<~TEXT
|
181
200
|
Error:
|
182
201
|
```
|
@@ -185,7 +204,7 @@ module Gitlab
|
|
185
204
|
|
186
205
|
Stacktrace:
|
187
206
|
```
|
188
|
-
#{failure
|
207
|
+
#{failure['stacktrace']}
|
189
208
|
```
|
190
209
|
TEXT
|
191
210
|
end.join("\n\n")
|
@@ -231,7 +250,7 @@ module Gitlab
|
|
231
250
|
def update_labels(issue, test)
|
232
251
|
labels = issue.labels
|
233
252
|
labels.delete_if { |label| label.start_with?("#{pipeline}::") }
|
234
|
-
labels << (
|
253
|
+
labels << (test.failures.empty? ? "#{pipeline}::passed" : "#{pipeline}::failed")
|
235
254
|
labels << "Enterprise Edition" if ee_test?(test)
|
236
255
|
quarantine_job? ? labels << "quarantine" : labels.delete("quarantine")
|
237
256
|
|
@@ -242,11 +261,7 @@ module Gitlab
|
|
242
261
|
# rubocop:enable Metrics/AbcSize
|
243
262
|
|
244
263
|
def ee_test?(test)
|
245
|
-
test
|
246
|
-
end
|
247
|
-
|
248
|
-
def failures(test)
|
249
|
-
test.search('failure')
|
264
|
+
test.file =~ %r{features/ee/(api|browser_ui)}
|
250
265
|
end
|
251
266
|
|
252
267
|
def pipeline
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Gitlab
|
4
|
+
module QA
|
5
|
+
module Report
|
6
|
+
class TestResult
|
7
|
+
attr_accessor :name, :file, :skipped, :failures, :status_issue
|
8
|
+
|
9
|
+
def self.from_json(test)
|
10
|
+
new.tap do |test_result|
|
11
|
+
test_result.name = test['full_description']
|
12
|
+
test_result.file = test['file_path']
|
13
|
+
test_result.skipped = test['status'] == 'pending'
|
14
|
+
test_result.failures = failures_from_json_exceptions(test)
|
15
|
+
test_result.status_issue = test['status_issue']
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.from_junit(test)
|
20
|
+
new.tap do |test_result|
|
21
|
+
test_result.name = test['name']
|
22
|
+
test_result.file = test['file']
|
23
|
+
test_result.skipped = test.search('skipped').any?
|
24
|
+
test_result.failures = failures_from_junit_exceptions(test)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.failures_from_json_exceptions(test)
|
29
|
+
return [] unless test.key?('exceptions')
|
30
|
+
|
31
|
+
test['exceptions'].map do |exception|
|
32
|
+
spec_file_first_index = exception['backtrace'].rindex do |line|
|
33
|
+
line.include?(File.basename(test['file_path']))
|
34
|
+
end
|
35
|
+
|
36
|
+
{
|
37
|
+
'message' => "#{exception['class']}: #{exception['message']}",
|
38
|
+
'stacktrace' => exception['backtrace'].slice(0..spec_file_first_index).join("\n")
|
39
|
+
}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
private_class_method :failures_from_json_exceptions
|
43
|
+
|
44
|
+
def self.failures_from_junit_exceptions(test)
|
45
|
+
failures = test.search('failure')
|
46
|
+
return [] if failures.empty?
|
47
|
+
|
48
|
+
failures.map do |exception|
|
49
|
+
trace = exception.content.split("\n").map(&:strip)
|
50
|
+
spec_file_first_index = trace.rindex do |line|
|
51
|
+
line.include?(File.basename(test['file']))
|
52
|
+
end
|
53
|
+
|
54
|
+
{
|
55
|
+
'message' => "#{exception['type']}: #{exception['message']}",
|
56
|
+
'stacktrace' => trace.slice(0..spec_file_first_index).join("\n")
|
57
|
+
}
|
58
|
+
end
|
59
|
+
end
|
60
|
+
private_class_method :failures_from_junit_exceptions
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -6,6 +6,8 @@ module Gitlab
|
|
6
6
|
module Env
|
7
7
|
extend self
|
8
8
|
|
9
|
+
# Variables that are used in tests and are passed through to the docker container that executes the tests.
|
10
|
+
# These variables should be listed in /docs/what_tests_can_be_run.md#supported-gitlab-environment-variables
|
9
11
|
ENV_VARIABLES = {
|
10
12
|
'QA_REMOTE_GRID' => :remote_grid,
|
11
13
|
'QA_REMOTE_GRID_USERNAME' => :remote_grid_username,
|
@@ -78,7 +80,8 @@ module Gitlab
|
|
78
80
|
'GEO_MAX_DB_REPLICATION_TIME' => :geo_max_db_replication_time,
|
79
81
|
'JIRA_HOSTNAME' => :jira_hostname,
|
80
82
|
'JIRA_ADMIN_USERNAME' => :jira_admin_username,
|
81
|
-
'JIRA_ADMIN_PASSWORD' => :jira_admin_password
|
83
|
+
'JIRA_ADMIN_PASSWORD' => :jira_admin_password,
|
84
|
+
'CACHE_NAMESPACE_NAME' => :cache_namespace_name
|
82
85
|
}.freeze
|
83
86
|
|
84
87
|
ENV_VARIABLES.each_value do |accessor|
|
@@ -8,9 +8,6 @@ module Gitlab
|
|
8
8
|
|
9
9
|
class Geo < Scenario::Template
|
10
10
|
def perform(release, primary_address, secondary_address, *rspec_args)
|
11
|
-
# Geo requires an EE license
|
12
|
-
Runtime::Env.require_license!
|
13
|
-
|
14
11
|
Component::Specs.perform do |specs|
|
15
12
|
specs.suite = 'QA::EE::Scenario::Test::Geo'
|
16
13
|
specs.release = QA::Release.new(release)
|
@@ -7,13 +7,13 @@ module Gitlab
|
|
7
7
|
attr_reader :gitlab_name, :spec_suite
|
8
8
|
|
9
9
|
def initialize
|
10
|
-
@gitlab_name = 'gitlab-gitaly-
|
10
|
+
@gitlab_name = 'gitlab-gitaly-cluster'
|
11
11
|
@primary_node_name = 'gitaly1'
|
12
12
|
@secondary_node_name = 'gitaly2'
|
13
13
|
@tertiary_node_name = 'gitaly3'
|
14
14
|
@praefect_node_name = 'praefect'
|
15
15
|
@database = 'postgres'
|
16
|
-
@spec_suite = 'Test::
|
16
|
+
@spec_suite = 'Test::Instance::All'
|
17
17
|
@network = 'test'
|
18
18
|
end
|
19
19
|
|
@@ -26,7 +26,7 @@ module Gitlab
|
|
26
26
|
sql_node = Component::PostgreSQL.new.tap do |sql|
|
27
27
|
sql.name = @database
|
28
28
|
sql.network = @network
|
29
|
-
sql.
|
29
|
+
sql.instance(skip_teardown: true) do
|
30
30
|
sql.run_psql '-d template1 -c "CREATE DATABASE praefect_production OWNER postgres"'
|
31
31
|
end
|
32
32
|
end
|
@@ -39,7 +39,7 @@ module Gitlab
|
|
39
39
|
|
40
40
|
praefect.omnibus_config = praefect_omnibus_configuration
|
41
41
|
|
42
|
-
praefect.
|
42
|
+
praefect.instance(skip_teardown: true)
|
43
43
|
end
|
44
44
|
|
45
45
|
Component::Gitlab.perform do |gitlab|
|
@@ -49,7 +49,10 @@ module Gitlab
|
|
49
49
|
|
50
50
|
gitlab.omnibus_config = gitlab_omnibus_configuration
|
51
51
|
gitlab.instance do
|
52
|
-
puts "Running Gitaly
|
52
|
+
puts "Running Gitaly Cluster specs!"
|
53
|
+
|
54
|
+
rspec_args << "--" unless rspec_args.include?('--')
|
55
|
+
rspec_args << %w[--tag gitaly_cluster]
|
53
56
|
|
54
57
|
Component::Specs.perform do |specs|
|
55
58
|
specs.suite = spec_suite
|
@@ -190,7 +193,7 @@ module Gitlab
|
|
190
193
|
gitaly.network = @network
|
191
194
|
gitaly.skip_availability_check = true
|
192
195
|
gitaly.omnibus_config = gitaly_omnibus_configuration
|
193
|
-
gitaly.
|
196
|
+
gitaly.instance(skip_teardown: true)
|
194
197
|
end
|
195
198
|
end
|
196
199
|
end
|
@@ -65,6 +65,7 @@ module Gitlab
|
|
65
65
|
def omnibus_config_with_praefect
|
66
66
|
<<~OMNIBUS
|
67
67
|
gitaly['enable'] = true;
|
68
|
+
gitaly['listen_addr'] = '0.0.0.0:8075';
|
68
69
|
gitaly['auth_token'] = 'secret-token';
|
69
70
|
gitaly['storage'] = [
|
70
71
|
{
|
@@ -82,7 +83,7 @@ module Gitlab
|
|
82
83
|
praefect['virtual_storages'] = {
|
83
84
|
'default' => {
|
84
85
|
'praefect-gitaly-0' => {
|
85
|
-
'address' => '
|
86
|
+
'address' => 'tcp://localhost:8075',
|
86
87
|
'token' => 'secret-token',
|
87
88
|
'primary' => true
|
88
89
|
}
|
data/lib/gitlab/qa/version.rb
CHANGED
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:
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Bizon
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: climate_control
|
@@ -257,9 +257,12 @@ files:
|
|
257
257
|
- lib/gitlab/qa/docker/shellout.rb
|
258
258
|
- lib/gitlab/qa/docker/volumes.rb
|
259
259
|
- lib/gitlab/qa/release.rb
|
260
|
+
- lib/gitlab/qa/report/json_test_results.rb
|
261
|
+
- lib/gitlab/qa/report/junit_test_results.rb
|
260
262
|
- lib/gitlab/qa/report/prepare_stage_reports.rb
|
261
263
|
- lib/gitlab/qa/report/results_in_issues.rb
|
262
264
|
- lib/gitlab/qa/report/summary_table.rb
|
265
|
+
- lib/gitlab/qa/report/test_result.rb
|
263
266
|
- lib/gitlab/qa/report/update_screenshot_path.rb
|
264
267
|
- lib/gitlab/qa/reporter.rb
|
265
268
|
- lib/gitlab/qa/runner.rb
|