Skip to content

Latest commit

 

History

History
122 lines (84 loc) · 4.77 KB

File metadata and controls

122 lines (84 loc) · 4.77 KB

Building and testing the Operator

Requirements

You need to install a number of software packages on your system to satisfy the build dependencies for building the Operator and/or to run its automated tests.

CentOS

Run the following commands to install the required components:

sudo yum -y install epel-release https://repo.percona.com/yum/percona-release-latest.noarch.rpm
sudo yum -y install coreutils sed jq curl docker percona-xtrabackup-24
sudo curl -s -L https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 -o /usr/bin/yq
sudo chmod a+x /usr/bin/yq
curl -s -L https://github.com/openshift/origin/releases/download/v3.11.0/openshift-origin-client-tools-v3.11.0-0cbc58b-linux-64bit.tar.gz \
    | tar -C /usr/bin --strip-components 1 --wildcards -zxvpf - '*/oc' '*/kubectl'
curl -s https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz \
    | tar -C /usr/bin --strip-components 1 -zxvpf - '*/helm'
curl https://sdk.cloud.google.com | bash

MacOS

Install Docker, and run the following commands for the other required components:

brew install coreutils gnu-sed jq kubernetes-cli openshift-cli kubernetes-helm
brew install yq@3
brew link yq@3
curl https://sdk.cloud.google.com | bash

Runtime requirements

Also, you need a Kubernetes platform of supported version, available via EKS, GKE, OpenShift or minikube to run the Operator.

Note: there is no need to build an image if you are going to test some already-released version.

Building and testing the Operator

There are scripts which build the image and run tests. Both building and testing needs some repository for the newly created docker images. If nothing is specified, scripts use Percona's experimental repository perconalab/percona-server-mongodb-operator, which requires decent access rights to make a push.

To specify your own repository for the Percona Server for MongoDB Operator docker image, you can use IMAGE environment variable:

export IMAGE=bob/my_repository_for_test_images:K8SPSMDB-372-fix-feature-X

Use the following script to build the image:

./e2e-tests/build

You can also build the image and run your cluster in one command:

./e2e-tests/build-and-run

Running all tests at once can be done with the following command:

./e2e-tests/run

(see how to configure the testing infrastructure here).

Tests can also be run one-by-one using the appropriate scripts (their names should be self-explanatory):

./e2e-tests/init-deploy/run
./e2e-tests/arbiter/run
./e2e-tests/limits/run
./e2e-tests/scaling/run
./e2e-tests/demand-backup/run
./e2e-tests/scheduled-backup/run
./e2e-tests/storage/run
./e2e-tests/self-healing/run
./e2e-tests/operator-self-healing/run
....

Using environment variables to customize the testing process

Re-declaring default image names

You can use environment variables to re-declare all default images used for testing. The full list of variables is the following one:

  • IMAGE - Percona Server for MongoDB Operator, perconalab/percona-server-mongodb-operator:main by default,
  • IMAGE_MONGOD - mongod, perconalab/percona-server-mongodb-operator:main-mongod4.4 by default,
  • IMAGE_PMM - Percona Monitoring and Management (PMM) client, perconalab/pmm-client:dev-latest by default,
  • IMAGE_BACKUP - backup, perconalab/percona-server-mongodb-operator:main-backup by default,

Using automatic clean-up after testing

By default, each test creates its own namespace and does not clean up objects in case of failure.

To avoid manual deletion of such leftovers, you can run tests on a separate cluster and use the following environment variable to make the ultimate clean-up:

export CLEAN_NAMESPACE=1

Note: this will cause deleting all namespaces except default and system ones!

Skipping backup tests on S3-compatible storage

Making backups on S3-compatible storage needs creating Secrets to have the access to the S3 buckets. There is an environment variable enabled by default, which skips all tests requiring such Secrets:

SKIP_BACKUPS_TO_AWS_GCP=1

The backups tests will use only MinIO if this variable is declared, which is enough for local testing.