# End-to-end Testing > 原文:[https://docs.gitlab.com/ee/development/testing_guide/end_to_end/](https://docs.gitlab.com/ee/development/testing_guide/end_to_end/) * [What is end-to-end testing?](#what-is-end-to-end-testing) * [How do we test GitLab?](#how-do-we-test-gitlab) * [Testing nightly builds](#testing-nightly-builds) * [Testing staging](#testing-staging) * [Testing code in merge requests](#testing-code-in-merge-requests) * [Using the `package-and-qa` job](#using-the-package-and-qa-job) * [How does it work?](#how-does-it-work) * [With Pipeline for Merged Results](#with-pipeline-for-merged-results) * [Running custom tests](#running-custom-tests) * [Using the `review-qa-all` jobs](#using-the-review-qa-all-jobs) * [How do I run the tests?](#how-do-i-run-the-tests) * [Running tests that require special setup](#running-tests-that-require-special-setup) * [How do I write tests?](#how-do-i-write-tests) * [Where can I ask for help?](#where-can-i-ask-for-help) # End-to-end Testing[](#end-to-end-testing "Permalink") ## What is end-to-end testing?[](#what-is-end-to-end-testing "Permalink") 端到端测试是一种策略,用于检查您的应用程序在整个软件堆栈和体系结构中是否按预期工作,包括应该协同工作的所有微服务和组件的集成. ## How do we test GitLab?[](#how-do-we-test-gitlab "Permalink") 我们使用[Omnibus GitLab](https://gitlab.com/gitlab-org/omnibus-gitlab)构建 GitLab 程序包,然后使用[GitLab QA 协调器](https://gitlab.com/gitlab-org/gitlab-qa)工具测试这些程序包,该工具是 API 和 UI 的黑盒测试框架. ### Testing nightly builds[](#testing-nightly-builds "Permalink") 我们每天晚上运行预定的管道,以测试 Omnibus 创建的每晚构建. 您可以在`https://gitlab.com/gitlab-org/quality/nightly/pipelines` (需要开发人员访问权限)中找到这些夜间管道. 结果在`#qa-nightly` Slack 频道中报告. ### Testing staging[](#testing-staging "Permalink") 我们每天晚上运行预定的管道以测试阶段. 您可以在`https://gitlab.com/gitlab-org/quality/staging/pipelines` (需要开发人员访问权限)中找到这些夜间管道. 结果在`#qa-staging` Slack 频道中报告. ### Testing code in merge requests[](#testing-code-in-merge-requests "Permalink") #### Using the `package-and-qa` job[](#using-the-package-and-qa-job "Permalink") 通过在`test`阶段触发`package-and-qa`手动操作,可以对合并请求运行端到端测试,最终在[`gitlab-qa-mirror`](https://gitlab.com/gitlab-org/gitlab-qa-mirror/)项目的管道中运行(不适用于 fork) ). **这将针对根据合并请求的更改构建的自定义 CE 和 EE(具有终极许可证)Omnibus 程序包进行端到端测试.** [Omnibus GitLab](https://gitlab.com/gitlab-org/omnibus-gitlab)中的合并请求中也提供了启动端到端测试的手动操作. 您可以在下面阅读有关如何使用它以及如何工作的更多信息. #### How does it work?[](#how-does-it-work "Permalink") 当前,我们正在使用类似*多项目管道*的方法来运行质量检查管道. 图 LR A1 -.-> | 1\. 触发 omnibus-gitlab-mirror 管道并等待它完成| A2 B2 [`Trigger-qa`阶段 `Trigger:qa-test`工作] -.-> | 2\. 触发 gitlab-qa-mirror 管道并等待它完成| A3 子图" gitlab-foss / gitlab 管道" A1 [`test`阶段 "打包和质量检查"工作]结束子图" omnibus-gitlab 管道" A2 [`Trigger-docker`阶段 `Trigger:gitlab-docker`作业]-> |一旦完成| B2 结束子图" gitlab-qa-镜像管道" A3> QA 作业运行] -.-> | 3\. 将管道结果报告给"打包和质量检查"作业 并将结果发布到经过测试的原始提交| A1 端 1. 开发人员触发手动操作,可以在 GitLab 合并请求中找到该操作. 这将启动多个项目中的一系列管道. 2. 正在执行的脚本触发[Omnibus GitLab Mirror 中](https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror)的管道,并等待结果状态. 我们将此称为*状态归因* . 3. 在[Omnibus GitLab Mirror](https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror)管道中正在构建 GitLab 软件包. 然后将程序包推送到其容器注册表. 4. 当软件包准备就绪并在注册表中可用时, [Omnibus GitLab Mirror](https://gitlab.com/gitlab-org/build/omnibus-gitlab-mirror)管道的最后一步将触发新的 GitLab QA 管道(具有访问权限的人可以在`https://gitlab.com/gitlab-org/gitlab-qa-mirror/pipelines`查看它们) `https://gitlab.com/gitlab-org/gitlab-qa-mirror/pipelines` ). 它还等待结果状态. 5. GitLab QA 从注册表中提取图像,旋转容器,并针对刚刚由`gitlab-qa`工具精心策划的测试环境运行测试. 6. GitLab QA 管道的结果正在通过 Omnibus 上游传播回 GitLab 合并请求. 请注意,我们计划[添加](https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/156)有关`gitlab-qa-mirror`中运行的每个作业/场景中包含的测试的[更多特定信息](https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/156) . #### With Pipeline for Merged Results[](#with-pipeline-for-merged-results "Permalink") 在"合并结果的管道"中,管道在包含源分支和目标分支的合并结果的新引用上运行. 但是,此参考不适用于`gitlab-qa-mirror`管道. 因此,在"合并结果"管道上的端到端测试将使用合并请求源分支的头部. graph LR A["a1b1c1 - branch HEAD (CI_MERGE_REQUEST_SOURCE_BRANCH_SHA)"] B["x1y1z1 - master HEAD"] C["d1e1f1 - merged results (CI_COMMIT_SHA)"] A --> C B --> C A --> E["E2E tests"] C --> D["Pipeline for merged results"] ##### Running custom tests[](#running-custom-tests "Permalink") 在下游`gitlab-qa-mirror`管道中运行的[现有场景](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md)包括许多测试,但是有时您可能想要运行一个测试或一组与任何现有场景中的组不同的测试. 例如,当我们[对](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests)一个薄片状测试进行[隔离](https://about.gitlab.com/handbook/engineering/quality/guidelines/debugging-qa-test-failures/#dequarantining-tests)时,我们首先要确保它不再是薄片状的. 我们可以使用`ce:custom-parallel`和`ee:custom-parallel`作业来做到这一点. 两者都是手动作业,您可以使用自定义变量进行配置. 单击并行作业之一的名称(而不是播放图标)时,系统将提示您输入变量. 您可以使用[`gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables)可以使用的任何[变量](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables)以及这些[变量](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#supported-gitlab-environment-variables) : | Variable | Description | | --- | --- | | `QA_SCENARIO` | 要运行的方案(默认`Test::Instance::Image` ) | | `QA_TESTS` | 要运行的测试(没有默认设置,这意味着运行方案中的所有测试). 通过 RSpec 运行测试时,请使用文件路径,例如, `qa/specs/features/ee/browser_ui`将包括所有`EE` UI 测试. | | `QA_RSPEC_TAGS` | 要添加的 RSpec 标记(无默认值) | 现在, [具有自定义变量的手动作业在重试时将不会使用相同的变量](https://gitlab.com/gitlab-org/gitlab/-/issues/31367) ,因此,如果要多次运行相同的测试,请在每个`custom-parallel`作业中指定相同的变量(最多可使用 10 个变量)您要运行的作业). #### Using the `review-qa-all` jobs[](#using-the-review-qa-all-jobs "Permalink") 在`test`阶段的每个管道上,都会自动启动`review-qa-smoke`作业:它将针对[Review App](../review_apps.html)运行 QA 烟雾套件. 您还可以手动启动`review-qa-all` :它针对[Review App](../review_apps.html)运行完整的质量检查套件. **This runs end-to-end tests against a Review App based on [the official GitLab Helm chart](https://gitlab.com/gitlab-org/charts/gitlab/), itself deployed with custom [Cloud Native components](https://gitlab.com/gitlab-org/build/CNG) built from your merge request’s changes.** 有关[审阅应用程序](../review_apps.html)的更多详细信息,请参见[审阅应用](../review_apps.html)程序. ## How do I run the tests?[](#how-do-i-run-the-tests "Permalink") 如果您不是[在合并请求中测试代码](#testing-code-in-merge-requests) ,则有两个主要选项可用于运行测试. 如果您只想对一个实时的 GitLab 实例或一个预先构建的 Docker 映像运行现有测试,则可以使用[GitLab QA 协调器](https://gitlab.com/gitlab-org/gitlab-qa/tree/master/README.md) . 另请参见[可以通过 Orchestrator 运行的测试方案示例](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/what_tests_can_be_run.md#examples) . 另一方面,如果您想在本地开发的 GitLab 环境中运行,则可以使用[GitLab 开发工具包(GDK)](https://gitlab.com/gitlab-org/gitlab-development-kit/) . 请参考[质量检查自述文件](https://gitlab.com/gitlab-org/gitlab/tree/master/qa/README.md#how-can-i-use-it)和以下部分中的说明. ### Running tests that require special setup[](#running-tests-that-require-special-setup "Permalink") 了解如何执行[需要特殊设置或考虑才能在本地环境上运行的测试](running_tests_that_require_special_setup.html) . ## How do I write tests?[](#how-do-i-write-tests "Permalink") 为了编写新的测试,您首先需要了解有关 GitLab QA 体系结构的更多信息. 请参阅有关[文档](https://gitlab.com/gitlab-org/gitlab-qa/blob/master/docs/architecture.md) . 一旦决定了将[测试环境业务流程场景](https://gitlab.com/gitlab-org/gitlab-qa/tree/master/lib/gitlab/qa/scenario)和[实例级场景](https://gitlab.com/gitlab-org/gitlab-foss/tree/master/qa/qa/specs/features)放置在何处,请查看[GitLab QA 自述文件](https://gitlab.com/gitlab-org/gitlab/tree/master/qa/README.md) , [GitLab QA Orchestrator 自述文件](https://gitlab.com/gitlab-org/gitlab-qa/tree/master/README.md)和[已经存在的实例级场景](https://gitlab.com/gitlab-org/gitlab-foss/tree/master/qa/qa/specs/features) . 继续阅读: * [Beginner’s Guide](beginners_guide.html) * [Style Guide](style_guide.html) * [Best Practices](best_practices.html) * [Testing with feature flags](feature_flags.html) * [Flows](flows.html) * [RSpec metadata/tags](rspec_metadata_tests.html) ## Where can I ask for help?[](#where-can-i-ask-for-help "Permalink") 您可以在 Slack 上的`#quality`频道(GitLab 内部)上[`gitlab`](https://gitlab.com/gitlab-org/gitlab/-/issues?label_name[]=QA&label_name[]=test) ,或者[在`gitlab-qa`](https://gitlab.com/gitlab-org/gitlab-qa/-/issues?label_name[]=new+scenario) [问题跟踪器](https://gitlab.com/gitlab-org/gitlab/-/issues?label_name[]=QA&label_name[]=test)或[`gitlab-qa`问题跟踪器中](https://gitlab.com/gitlab-org/gitlab-qa/-/issues?label_name[]=new+scenario)找到您要[`gitlab-qa`问题](https://gitlab.com/gitlab-org/gitlab-qa/-/issues?label_name[]=new+scenario) .