#225 CI/CD: Split functional tests
Merged by lholecek. Opened by rayson.
rayson/waiverdb cicd-split-function-test  into  master

Download 225.patch

This PR splits the functional test stage into a separated OpenShift Pipeline.

Typically, integration tests should be rerun
- when a new container image of WaiverDB is built
- when any service that WaiverDB depends on is updated to a new version
- to ensure an image is mature enough for promotion

Hence, splitting the functional test stage makes it possible to run integration
tests individually. It can also be a step of a larger pipeline.

Installation

To install this OpenShift pipeline:

oc process --local -f ./waiverdb-integration-test-template.yml \
   -p NAME=waiverdb-integration-test \
  | oc apply -f -

Additional installations with default parameters for dev, stage, and prod environments:

# for dev
oc process --local -f ./waiverdb-integration-test-template.yml \
   -p NAME=waiverdb-dev-integration-test \
   -p IMAGE="quay.io/factory2/waiverdb:latest" \
  | oc apply -f -
# for stage
oc process --local -f ./waiverdb-integration-test-template.yml \
   -p NAME=waiverdb-stage-integration-test \
   -p IMAGE="quay.io/factory2/waiverdb:stage" \
  | oc apply -f -
# for prod
oc process --local -f ./waiverdb-integration-test-template.yml \
   -p NAME=waiverdb-prod-integration-test \
   -p IMAGE="quay.io/factory2/waiverdb:prod" \
  | oc apply -f -

Usage

To trigger a pipeline build for each environment, run:

# for dev
oc start-build waiverdb-dev-integration-test
# for stage
oc start-build waiverdb-stage-integration-test
# for prod
oc start-build waiverdb-prod-integration-test

To trigger a custom integration test, start a new pipeline build with the image reference you want to test against and the Git repository and commit ID/branch name
where the functional test suite is used:

oc start-build waiverdb-integration-test \
  -e IMAGE="quay.io/factory2/waiverdb:test" \
  -e WAIVERDB_GIT_REPO=https://pagure.io/forks/<username>/waiverdb.git \
  -e WAIVERDB_GIT_REF=my-branch # master branch is default

NOTE

The stage of reporting test results to ResultsDB has not been implemented.

Example of test runs:
https://paas.upshift.redhat.com/console/project/waiverdb-test/browse/pipelines/waiverdb-integration-test?tab=history
https://jenkins-waiverdb-test.cloud.paas.upshift.redhat.com/job/waiverdb-test/job/waiverdb-test-waiverdb-integration-test/

rebased onto 2f3c9400f7f4a76d7dc972c59eb5161926482936

Why is this needed?

@csomh Well, this is actually copied from the Jenkins slave pod definition of dev pipeline.

By default the user ID in a pod is assigned with a "random" number by OpenShift. That user ID isn't associated with a user name. Programs that expects the current user must have a name will fail.
Those environment variables are used to set up NSS Wrapper for providing a user name at runtime. The background is NSS Wrapper is pre-installed in rad-jenkins-slave image and I just continue to this approach.

The dev pipeline would fail if the running user didn't have a user name. I haven't try removing this block for this pipeline buildconfig.

@csomh That part is removed since it is not needed in this kind of jobs.

rebased onto c02bc3fbb11433044c6dc4fd9b7303f462e3806e

Thanks @rayson! Would it be possible to move the Jenkins pipeline into its own file?

These groovy-yaml mixes make reading and editing a little bit difficult - the pipeline code is long enough to deserve its own file ;)

Yeah, i am also thinking how to move some parts of the template to
seperated files, but currently have no ideas about the best approach. See
my reply under the pr of image promotion.

Hunor Csomort=C3=A1ni pagure@pagure.io=E4=BA=8E2018=E5=B9=B48=E6=9C=8818=
=E6=97=A5 =E5=91=A8=E5=85=AD=E4=B8=8A=E5=8D=8812:02=E5=86=99=E9=81=93=EF=BC=
=9A

csomh commented on the pull-request: CI/CD: Split functional tests that
you are following:
``
Thanks @rayson! Would it be possible to move the Jenkins pipeline into it=
s
own file?

These groovy-yaml mixes make reading and editing a little bit difficult -
the pipeline code is long enough to deserve its own file ;)
``

To reply, visit the link below or just reply to this email
https://pagure.io/waiverdb/pull-request/225

@csomh Jenkinsfile is moved to a separated file.
Both template and Jenkinsfile are moved to openshift/pipelines/templates in favor of discussions in https://pagure.io/waiverdb/pull-request/227

rebased onto 3091670c43e6202234c00613c0b4f981ecea3ec3

rebased onto a3fd53b2507f2938e23240ed7dd673d517f2035f

Should be pipelines/templates/waiverdb-integration-test-template.yaml now.

@lholecek Thanks. I've updated the README.md. Instructions for other kinds of jobs will be also updated accordingly when after their templates are migrated.

rebased onto d8f34788f622029b73e2bf1e9b61a901add18a90

rebased onto c1f4a125d0df22d232d6c54c97898ae319d65f00

rebased onto cf9adbc099680af95b0c2f0d2a216df5653b9d77

Note: This PR depends on #227.

Commit f5770004 fixes this pull-request

Pull-Request has been merged by lholecek

Pull-Request has been merged by lholecek

Metadata