End-to-end test pipelines
e2e:test-on-omnibus child pipeline
The e2e:test-on-omnibus
child pipeline is the main executor of E2E testing for the GitLab platform. The pipeline definition has several dynamic
components to reduce the number of tests being executed in merge request pipelines.
Setup
Pipeline setup consists of:
- The
e2e-test-pipeline-generate
job in theprepare
stage of the main GitLab pipeline. - The
e2e:test-on-omnibus
job in theqa
stage, which triggers the child pipeline that is responsible for building theomnibus
package and running E2E tests.
e2e-test-pipeline-generate
This job consists of two components that implement selective test execution:
- The
detect_changes
Rake task determines which e2e specs should be executed in a particular merge request pipeline. This task analyzes changes in a particular merge request and determines which specs must be executed. Based on that, adry-run
of every scenario executes and determines if a scenario contains any executable tests. Selective test execution uses these criteria to determine which specific tests to execute. -
generate-e2e-pipeline
is executed, which generates a child pipeline YAML definition file with appropriate environment variables.
e2e:test-on-omnibus execution pipeline
E2E test execution pipeline consists of several stages which all support execution of E2E tests.
.pre
This stage is responsible for the following tasks:
- Fetching
knapsack
reports that support parallel test execution. - Triggering downstream pipeline which builds the
omnibus-gitlab
Docker image.
test
This stage runs e2e tests against different types of GitLab configurations. The number of jobs executed is determined dynamically by
e2e-test-pipeline-generate
job.
report
This stage is responsible for allure test report generation.
Adding new jobs
Selective test execution depends on a set of rules present in every job definition. A typical job contains the following attributes:
variables:
QA_SCENARIO: Test::Integration::MyNewJob
rules:
- !reference [.rules:test:qa, rules]
- if: $QA_SUITES =~ /Test::Integration::MyNewJob/
- !reference [.rules:test:manual, rules]
In this example:
-
QA_SCENARIO: Test::Integration::MyNewJob
: name of the scenario class that is passed to thegitlab-qa
executor. -
!reference [.rules:test:qa, rules]
: main rule definition that is matched for pipelines that should execute all tests. For example, when changes toqa
framework are present. -
if: $QA_SUITES =~ /Test::Integration::MyNewJob/
: main rule responsible for selective test execution.QA_SUITE
is the name of the scenario abstraction located inqa framework
.QA_SUITE
is not the same asQA_SCENARIO
, which is passed to thegitlab-qa
executor. For consistency, it usually has the same name.QA_SUITE
abstraction class usually contains information on what tags to run and optionally some additional setup steps. -
!reference [.rules:test:manual, rules]
: final rule that is always matched and sets the job tomanual
so it can still be executed on demand, even if not set to execute by selective test execution.
Considering example above, perform the following steps to create a new job:
-
Create new scenario type
my_new_job.rb
in theintegration
directory of thegitlab-qa
project and release new version so it's generally available. -
Create new scenario
my_new_job.rb
inintegration
directory of theqa
framework. In the most simple case, this scenario would define RSpec tags that should be executed:module QA module Scenario module Test module Integration class MyNewJob < Test::Instance::All tags :some_special_tag end end end end end
-
Add new job definition in the
main.gitlab-ci.yml
pipeline definition:ee:my-new-job: extends: .qa variables: QA_SCENARIO: Test::Integration::MyNewJob rules: - !reference [.rules:test:qa, rules] - if: $QA_SUITES =~ /Test::Integration::MyNewJob/ - !reference [.rules:test:manual, rules]
Parallel jobs
For selective execution to work correctly with job types that require running multiple parallel jobs, a job definition typically must be split into parallel and selective variants. Splitting is necessary so that when selective execution executes only a single spec, multiple unnecessary jobs are not spawned. For example:
ee:my-new-job-selective:
extends: .qa
variables:
QA_SCENARIO: Test::Integration::MyNewJob
rules:
- !reference [.rules:test:qa-selective, rules]
- if: $QA_SUITES =~ /Test::Integration::MyNewJob/
ee:my-new-job:
extends:
- .parallel
- ee:my-new-job-selective
rules:
- !reference [.rules:test:qa-parallel, rules]
- if: $QA_SUITES =~ /Test::Integration::MyNewJob/
e2e:test-on-gdk
The e2e:test-on-gdk
child pipeline supports development of the GitLab platform by providing feedback to engineers on
end-to-end test execution faster than via e2e:test-on-omnibus
.
This is achieved by running tests against the GitLab Development Kit (GDK), which can be built and installed in less time than when testing against Omnibus GitLab. The trade-off is that Omnibus GitLab can be used to deploy a production installation, whereas the GDK is a development environment. Tests that run against the GDK might not catch bugs that depend on part of the process of preparing GitLab to run in a production environment, including pre-compiling assets, assigning configuration defaults as part of an official installation package, deploying GitLab services to multiple servers, and more. On the other hand, engineers who use the GDK day-to-day can benefit from automated tests catching bugs that only appear on the GDK.
Setup
The pipeline setup consists of several jobs in the main GitLab pipeline:
- The
e2e-test-pipeline-generate
job in theprepare
stage. This is the same job as in thee2e:test-on-omnibus
pipeline. - The
build-gdk-image
job in thebuild-images
stage. - The
e2e:test-on-gdk
trigger job in theqa
stage, which triggers the child pipeline that runs E2E tests.
build-gdk-image
This job uses the code from the merge request to build a Docker image that can be used in test jobs to launch a GDK instance in a container. The image is pushed to the container registry.
The job also runs in pipelines on the default branch to build a base image that includes the GDK and GitLab components. This avoids building the entire image from scratch in merge requests. However, if the merge request includes changes to certain GitLab components or code the job will rebuild the base image before building the image that will be used in the test jobs.
e2e:test-on-gdk
child pipeline
Like the e2e:test-on-omnibus
pipeline, the e2e:test-on-gdk
pipeline consists of several stages that support
execution of E2E tests.
.pre
This stage is responsible for fetching knapsack
reports that support parallel test execution.
test
This stage runs e2e tests against different types of GitLab configurations. The number of jobs executed is determined dynamically by the
e2e-test-pipeline-generate
job.
Each job starts a container from the GDK Docker image created in the build-gdk-image
job, and then executes the end-to-end
tests against the GDK instance running in the container.
report
This stage is responsible for allure test report generation.
e2e:test-on-cng
The e2e:test-on-cng
child pipeline runs tests against Cloud Native GitLab installation.
Unlike review-apps
, this pipeline uses local kind Kubernetes cluster.
Deployment is managed by the cng
orchestrator tool, which you can also use to locally recreate CI/CD deployments.
This pipeline is executed in merge requests and is part of pre-merge validation lifecycle. If any test is failing, this will prevent ability to merge introduced code changes.
Setup
The pipeline setup consists of several jobs in the main GitLab pipeline:
-
compile-production-assets
andbuild-assets-image
jobs are responsible for compiling frontend assets which are required by CNG build pipeline. -
e2e-test-pipeline-generate
job is responsible for generatinge2e:test-on-cng
child pipeline
e2e:test-on-cng
child pipeline
Child pipeline consists of several stages that support E2E test execution.
.pre
-
build-cng-env
job is responsible for setting up all environment variables for CNG downstream pipeline -
build-cng
job triggersCNG
downstream pipeline which is responsible for building all necessary images
test
Jobs in test
stage perform following actions:
- local k8s cluster setup using
kind
- GitLab installation using official
helm
chart - E2E test execution against performed deployment
report
This stage is responsible for allure test report generation as well as test metrics upload.
Debugging
To help with debugging:
- Each test job prints a list of arguments that you can pass to the
cng
orchestrator to exactly recreate the same deployment for local debugging. - Cluster events log and all pod logs are saved in E2E test job artifacts.
-
cng
orchestrator will automatically output all cluster events with errors in case of failed deployment