github.com/percona/percona-xtradb-cluster-operator@v1.14.0/e2e-tests/README.md (about)

     1  # Building and testing the Operator
     2  
     3  ## Requirements
     4  
     5  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.
     6  
     7  ### CentOS
     8  
     9  Run the following commands to install the required components:
    10  
    11  ```
    12  sudo yum -y install epel-release https://repo.percona.com/yum/percona-release-latest.noarch.rpm
    13  sudo yum -y install coreutils sed jq curl docker percona-xtrabackup-24
    14  sudo curl -s -L https://github.com/mikefarah/yq/releases/download/4.27.2/yq_linux_amd64 -o /usr/bin/yq
    15  sudo chmod a+x /usr/bin/yq
    16  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 \
    17      | tar -C /usr/bin --strip-components 1 --wildcards -zxvpf - '*/oc' '*/kubectl'
    18  curl -s https://get.helm.sh/helm-v3.2.4-linux-amd64.tar.gz \
    19      | tar -C /usr/bin --strip-components 1 -zxvpf - '*/helm'
    20  curl https://sdk.cloud.google.com | bash
    21  ```
    22  
    23  ### MacOS
    24  
    25  Install [Docker](https://docs.docker.com/docker-for-mac/install/), and run the following commands for the other required components:
    26  
    27  ```
    28  brew install coreutils gnu-sed jq yq kubernetes-cli openshift-cli kubernetes-helm percona-xtrabackup
    29  curl https://sdk.cloud.google.com | bash
    30  ```
    31  
    32  ### Runtime requirements
    33  
    34  Also, you need a Kubernetes platform of [supported version](https://www.percona.com/doc/kubernetes-operator-for-pxc/System-Requirements.html#officially-supported-platforms), available via [EKS](https://www.percona.com/doc/kubernetes-operator-for-pxc/eks.html), [GKE](https://www.percona.com/doc/kubernetes-operator-for-pxc/gke.html), [OpenShift](https://www.percona.com/doc/kubernetes-operator-for-pxc/openshift.html) or [minikube](https://www.percona.com/doc/kubernetes-operator-for-pxc/minikube.html) to run the Operator.
    35  
    36  **Note:** there is no need to build an image if you are going to test some already-released version.
    37  
    38  ## Building and testing the Operator
    39  
    40  There are scripts which build the image and run tests. Both building and testing
    41  needs some repository for the newly created docker images. If nothing is
    42  specified, scripts use Percona's experimental repository `perconalab/percona-xtradb-cluster-operator`, which
    43  requires decent access rights to make a push.
    44  
    45  To specify your own repository for the Operator docker image, you can use IMAGE environment variable:
    46  
    47  ```
    48  export IMAGE=bob/my_repository_for_test_images:K8SPXC-622-fix-feature-X
    49  ```
    50  We use linux/amd64 platform by default. To specify another platform, you can use DOCKER_DEFAULT_PLATFORM environment variable
    51  
    52  ```
    53  export DOCKER_DEFAULT_PLATFORM=linux/amd64
    54  ```
    55  
    56  Use the following script to build the image:
    57  
    58  ```
    59  ./e2e-tests/build
    60  ```
    61  
    62  You can also build the image and run your cluster in one command:
    63  
    64  ```
    65  ./e2e-tests/build-and-run
    66  ```
    67  
    68  Running all tests at once can be done with the following command:
    69  
    70  ```
    71  ./e2e-tests/run
    72  ```
    73  
    74  (see how to configure the testing infrastructure [here](#using-environment-variables-to-customize-the-testing-process)).
    75  
    76  Tests can also be run one-by-one using the appropriate scripts (their names should be self-explanatory):
    77  
    78  ```
    79  ./e2e-tests/init-deploy/run
    80  ./e2e-tests/recreate/run
    81  ./e2e-tests/limits/run
    82  ./e2e-tests/scaling/run
    83  ./e2e-tests/monitoring/run
    84  ./e2e-tests/affinity/run
    85  ./e2e-tests/demand-backup/run
    86  ./e2e-tests/scheduled-backup/run
    87  ./e2e-tests/storage/run
    88  ./e2e-tests/self-healing/run
    89  ./e2e-tests/operator-self-healing/run
    90  ....
    91  ```
    92  
    93  ## Using environment variables to customize the testing process
    94  
    95  ### Re-declaring default image names
    96  
    97  You can use environment variables to re-declare all default docker images used for testing. The
    98  full list of variables is the following one:
    99  
   100  * `IMAGE` - the Operator, `perconalab/percona-xtradb-cluster-operator:main` by default,
   101  * `IMAGE_PXC` - Percona XtraDB Cluster, `perconalab/percona-xtradb-cluster-operator:main-pxc8.0` by default,
   102  * `IMAGE_PMM_CLIENT` - Percona Monitoring and Management (PMM) client, `perconalab/pmm-client:dev-latest` by default,
   103  * `IMAGE_PROXY` - ProxySQL, `perconalab/percona-xtradb-cluster-operator:main-proxysql` by default,
   104  * `IMAGE_HAPROXY` - HA Proxy, `perconalab/percona-xtradb-cluster-operator:main-haproxy` by default,
   105  * `IMAGE_BACKUP` - backups, `perconalab/percona-xtradb-cluster-operator:main-pxc8.0-backup` by default,
   106  * `IMAGE_LOGCOLLECTOR` - Log Collector, `perconalab/percona-xtradb-cluster-operator:main-logcollector` by default,
   107  
   108  ### Running the Operator cluster-wide
   109  
   110  Also, you can run the Operator for the tests in a [cluster-wide mode](https://www.percona.com/doc/kubernetes-operator-for-pxc/cluster-wide.html) if needed. This feature is turned on if the following variable is declared:
   111  
   112  ```
   113  export OPERATOR_NS=pxc-operator
   114  ```
   115  
   116  ### Using automatic clean-up after testing
   117  
   118  By default, each test creates its own namespace and does not clean up objects in case of failure.
   119  
   120  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:
   121  
   122  ```
   123  export CLEAN_NAMESPACE=1
   124  ```
   125  
   126  **Note:** this will cause **deleting all namespaces** except default and system ones!
   127  
   128  ### Skipping backup tests on S3-compatible storage
   129  
   130  Making backups [on S3-compatible storage](https://www.percona.com/doc/kubernetes-operator-for-pxc/backups.html#making-scheduled-backups) 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:
   131  
   132  ```
   133  SKIP_REMOTE_BACKUPS=1
   134  ```
   135  
   136  The backups tests will use only [MinIO](https://min.io/) if this variable is declared,
   137  which is enough for local testing.