debian-mirror-gitlab/doc/development/testing_guide/end_to_end/index.md

184 lines
8.7 KiB
Markdown
Raw Normal View History

2019-02-15 15:39:39 +05:30
# End-to-end Testing
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
## What is end-to-end testing?
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
End-to-end testing is a strategy used to check whether your application works
as expected across the entire software stack and architecture, including
integration of all micro-services and components that are supposed to work
2018-03-17 18:26:18 +05:30
together.
## How do we test GitLab?
We use [Omnibus GitLab][omnibus-gitlab] to build GitLab packages and then we
2019-02-15 15:39:39 +05:30
test these packages using the [GitLab QA orchestrator][gitlab-qa] tool, which is
a black-box testing framework for the API and the UI.
2018-03-17 18:26:18 +05:30
### Testing nightly builds
2020-03-13 15:44:24 +05:30
We run scheduled pipelines each night to test nightly builds created by Omnibus.
2019-12-21 20:55:43 +05:30
You can find these nightly pipelines at `https://gitlab.com/gitlab-org/quality/nightly/pipelines`
(need Developer access permissions). Results are reported in the `#qa-nightly` Slack channel.
2019-02-15 15:39:39 +05:30
### Testing staging
2020-03-13 15:44:24 +05:30
We run scheduled pipelines each night to test staging.
2019-12-21 20:55:43 +05:30
You can find these nightly pipelines at `https://gitlab.com/gitlab-org/quality/staging/pipelines`
2020-03-13 15:44:24 +05:30
(need Developer access permissions). Results are reported in the `#qa-staging` Slack channel.
2018-03-17 18:26:18 +05:30
### Testing code in merge requests
2020-03-13 15:44:24 +05:30
#### Using the `package-and-qa` job
2019-07-07 11:18:12 +05:30
It is possible to run end-to-end tests for a merge request, eventually being run in
a pipeline in the [`gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/) project,
2020-03-13 15:44:24 +05:30
by triggering the `package-and-qa` manual action in the `test` stage (not
2019-07-07 11:18:12 +05:30
available for forks).
2020-03-13 15:44:24 +05:30
**This runs end-to-end tests against a custom CE and EE (with an Ultimate license)
Omnibus package built from your merge request's changes.**
2018-03-17 18:26:18 +05:30
Manual action that starts end-to-end tests is also available in merge requests
2019-02-15 15:39:39 +05:30
in [Omnibus GitLab][omnibus-gitlab].
2018-03-17 18:26:18 +05:30
Below you can read more about how to use it and how does it work.
#### How does it work?
Currently, we are using _multi-project pipeline_-like approach to run QA
pipelines.
2019-09-30 21:07:59 +05:30
```mermaid
2019-07-07 11:18:12 +05:30
graph LR
A1 -.->|1. Triggers an omnibus-gitlab pipeline and wait for it to be done| A2
2019-09-30 21:07:59 +05:30
B2[`Trigger-qa` stage<br>`Trigger:qa-test` job] -.->|2. Triggers a gitlab-qa pipeline and wait for it to be done| A3
2019-07-07 11:18:12 +05:30
2019-12-21 20:55:43 +05:30
subgraph "gitlab-foss/gitlab pipeline"
2020-03-13 15:44:24 +05:30
A1[`test` stage<br>`package-and-qa` job]
2019-07-07 11:18:12 +05:30
end
2019-09-30 21:07:59 +05:30
subgraph "omnibus-gitlab pipeline"
A2[`Trigger-docker` stage<br>`Trigger:gitlab-docker` job] -->|once done| B2
2019-07-07 11:18:12 +05:30
end
2019-09-30 21:07:59 +05:30
subgraph "gitlab-qa pipeline"
2020-03-13 15:44:24 +05:30
A3>QA jobs run] -.->|3. Reports back the pipeline result to the `package-and-qa` job<br>and post the result on the original commit tested| A1
2019-07-07 11:18:12 +05:30
end
2019-09-30 21:07:59 +05:30
```
2019-02-15 15:39:39 +05:30
1. Developer triggers a manual action, that can be found in CE / EE merge
2019-07-07 11:18:12 +05:30
requests. This starts a chain of pipelines in multiple projects.
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
1. The script being executed triggers a pipeline in [Omnibus GitLab][omnibus-gitlab]
2019-07-07 11:18:12 +05:30
and waits for the resulting status. We call this a _status attribution_.
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
1. GitLab packages are being built in the [Omnibus GitLab][omnibus-gitlab]
2019-07-07 11:18:12 +05:30
pipeline. Packages are then pushed to its Container Registry.
2018-03-17 18:26:18 +05:30
1. When packages are ready, and available in the registry, a final step in the
2019-07-07 11:18:12 +05:30
[Omnibus GitLab][omnibus-gitlab] pipeline, triggers a new
2019-07-31 22:56:46 +05:30
GitLab QA pipeline (those with access can view them at `https://gitlab.com/gitlab-org/gitlab-qa/pipelines`). It also waits for a resulting status.
2018-03-17 18:26:18 +05:30
1. GitLab QA pulls images from the registry, spins-up containers and runs tests
2019-07-07 11:18:12 +05:30
against a test environment that has been just orchestrated by the `gitlab-qa`
tool.
2018-03-17 18:26:18 +05:30
2019-07-31 22:56:46 +05:30
1. The result of the GitLab QA pipeline is being
2019-07-07 11:18:12 +05:30
propagated upstream, through Omnibus, back to the CE / EE merge request.
2020-03-13 15:44:24 +05:30
Please note, we plan to [add more specific information](https://gitlab.com/gitlab-org/quality/team-tasks/issues/156)
about the tests included in each job/scenario that runs in `gitlab-qa`.
##### Running custom tests
The [existing scenarios](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md)
that run in the downstream `gitlab-qa` pipeline include many tests, but there are times when you might want to run a
test or a group of tests that are different than the groups in any of the existing scenarios.
For example, when we [dequarantine](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests)
a flaky test we first want to make sure that it's no longer flaky.
We can do that using the `ce:custom-parallel` and `ee:custom-parallel` jobs.
Both are manual jobs that you can configure using custom variables.
When you click the name (not the play icon) of one of the parallel jobs,
you'll be prompted to enter variables. You can use any of [the variables
that can be used with `gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables)
as well as these:
| Variable | Description |
|-|-|
| `QA_SCENARIO` | The scenario to run (default `Test::Instance::Image`) |
| `QA_TESTS` | The test(s) to run (no default, which means run all the tests in the scenario). Use file paths as you would when running tests via RSpec, e.g., `qa/specs/features/ee/browser_ui` would include all the `EE` UI tests. |
| `QA_RSPEC_TAGS` | The RSpec tags to add (no default) |
For now [manual jobs with custom variables will not use the same variable
when retried](https://gitlab.com/gitlab-org/gitlab/issues/31367), so if you want to run the same test(s) multiple times,
specify the same variables in each `custom-parallel` job (up to as
many of the 10 available jobs that you want to run).
2019-07-07 11:18:12 +05:30
#### Using the `review-qa-all` jobs
On every pipeline during the `test` stage, the `review-qa-smoke` job is
automatically started: it runs the QA smoke suite against the
[Review App][review-apps].
You can also manually start the `review-qa-all`: it runs the full QA suite
against the [Review App][review-apps].
**This runs end-to-end tests against a Review App based on [the official GitLab
Helm chart][helm-chart], itself deployed with custom
[Cloud Native components][cng] built from your merge request's changes.**
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
See [Review Apps][review-apps] for more details about Review Apps.
2019-12-04 20:38:33 +05:30
[helm-chart]: https://gitlab.com/gitlab-org/charts/gitlab/
2019-07-07 11:18:12 +05:30
[cng]: https://gitlab.com/gitlab-org/build/CNG
2019-09-30 21:07:59 +05:30
## How do I run the tests?
2020-03-13 15:44:24 +05:30
If you are not [testing code in a merge request](#testing-code-in-merge-requests),
there are two main options for running the tests. If you simply want to run
the existing tests against a live GitLab instance or against a pre-built docker image
2019-09-30 21:07:59 +05:30
you can use the [GitLab QA orchestrator][gitlab-qa-readme]. See also [examples
of the test scenarios you can run via the orchestrator](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#examples).
On the other hand, if you would like to run against a local development GitLab
environment, you can use the [GitLab Development Kit (GDK)](https://gitlab.com/gitlab-org/gitlab-development-kit/).
2019-12-04 20:38:33 +05:30
Please refer to the instructions in the [QA README](https://gitlab.com/gitlab-org/gitlab/tree/master/qa/README.md#how-can-i-use-it)
2019-09-30 21:07:59 +05:30
and the section below.
2019-07-07 11:18:12 +05:30
## How do I write tests?
2018-03-17 18:26:18 +05:30
In order to write new tests, you first need to learn more about GitLab QA
2019-02-15 15:39:39 +05:30
architecture. See the [documentation about it][gitlab-qa-architecture].
2018-03-17 18:26:18 +05:30
2019-02-15 15:39:39 +05:30
Once you decided where to put [test environment orchestration scenarios] and
[instance-level scenarios], take a look at the [GitLab QA README][instance-qa-readme],
the [GitLab QA orchestrator README][gitlab-qa-readme], and [the already existing
instance-level scenarios][instance-level scenarios].
2018-03-17 18:26:18 +05:30
2019-09-30 21:07:59 +05:30
Continued reading:
2019-09-04 21:01:54 +05:30
- [Quick Start Guide](quick_start_guide.md)
- [Style Guide](style_guide.md)
- [Best Practices](best_practices.md)
2019-12-26 22:10:19 +05:30
- [Testing with feature flags](feature_flags.md)
- [Flows](flows.md)
2019-09-04 21:01:54 +05:30
2018-03-17 18:26:18 +05:30
## Where can I ask for help?
2018-10-15 14:42:47 +05:30
You can ask question in the `#quality` channel on Slack (GitLab internal) or
you can find an issue you would like to work on in
2019-12-21 20:55:43 +05:30
[the `gitlab` issue tracker][gitlab-issues], or
2019-02-15 15:39:39 +05:30
[the `gitlab-qa` issue tracker][gitlab-qa-issues].
2018-03-17 18:26:18 +05:30
[omnibus-gitlab]: https://gitlab.com/gitlab-org/omnibus-gitlab
[gitlab-qa]: https://gitlab.com/gitlab-org/gitlab-qa
2019-07-07 11:18:12 +05:30
[gitlab-qa-readme]: https://gitlab.com/gitlab-org/gitlab-qa/tree/master/README.md
2019-09-04 21:01:54 +05:30
[review-apps]: ../review_apps.md
2018-03-17 18:26:18 +05:30
[gitlab-qa-architecture]: https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/architecture.md
2019-02-15 15:39:39 +05:30
[gitlab-qa-issues]: https://gitlab.com/gitlab-org/gitlab-qa/issues?label_name%5B%5D=new+scenario
2019-12-21 20:55:43 +05:30
[gitlab-issues]: https://gitlab.com/gitlab-org/gitlab/issues?label_name[]=QA&label_name[]=test
2019-02-15 15:39:39 +05:30
[test environment orchestration scenarios]: https://gitlab.com/gitlab-org/gitlab-qa/tree/master/lib/gitlab/qa/scenario
2019-12-04 20:38:33 +05:30
[instance-level scenarios]: https://gitlab.com/gitlab-org/gitlab-foss/tree/master/qa/qa/specs/features
[instance-qa-readme]: https://gitlab.com/gitlab-org/gitlab/tree/master/qa/README.md
[instance-qa-examples]: https://gitlab.com/gitlab-org/gitlab-foss/tree/master/qa/qa