Document for running Velero end-to-end test suite.
The E2E tests are validating end-to-end behavior of Velero including install, backup and restore operations. These tests take longer to complete and is not expected to be part of day-to-day developer workflow. It is for this reason that they are disabled when running unit tests. This is accomplished by running unit tests in
short mode using the
-short flag to
If you previously ran unit tests using the
go test ./... command or any of its variations, then you will now run the same command with the
-short flag to
go test to accomplish the same behavior. Alternatively, you can use the
make test command to run unit tests.
Running the E2E tests expects:
- A running kubernetes cluster:
- With DNS and CNI installed.
- Compatible with Velero- running Kubernetes v1.10 or later.
- With necessary storage drivers/provisioners installed.
These are the current set of limitations with the E2E tests.
- E2E tests only accepts credentials only for a single provider and for that reason, only tests for a single provider can be run at a time.
- Each E2E test suite installs an instance of Velero to run tests and uninstalls it after test completion. It is possible that a test suite may be installing Velero while another may be uninstalling Velero. This race condition can lead to tests being flaky and cause false negatives. The options for resolving this are:
- Make each test suite setup wait for Velero to be uninstalled before attempting to install as part of its setup.
- Make each test suite install Velero in a different namespace.
Configuration for E2E tests
Below is a list of the configuration used by E2E tests. These configuration parameters are expected as values to the following command line flags:
-credentials-file: File containing credentials for backup and volume provider. Required.
-bucket: Name of the object storage bucket where backups from e2e tests should be stored. Required.
-cloud-provider: The cloud the tests will be run in. Appropriate plug-ins will be installed except for kind which requires the object-store-provider to be specified.
-object-store-provider: Object store provider to use. Required when kind is the cloud provider.
-velerocli: Path to the velero application to use. Optional, by default uses
-velero-image: Image for the velero server to be tested. Optional, by default uses
-bsl-config: Configuration to use for the backup storage location. Format is key1=value1,key2=value2. Optional.
-prefix: Prefix in the
bucket, under which all Velero data should be stored within the bucket. Optional.
-vsl-config: Configuration to use for the volume snapshot location. Format is key1=value1,key2=value2. Optional.
-velero-namespace: Namespace to install velero in. Optional, defaults to "velero".
-install-velero: Specifies whether to install/uninstall velero for the tests. Optional, defaults to "true".
-additional-bsl-object-store-provider: Provider of object store plugin for additional backup storage location. Required if testing multiple credentials support.
-additional-bsl-bucket: Name of the object storage bucket for additional backup storage location. Required if testing multiple credentials support.
-additional-bsl-prefix: Prefix in the
additional-bsl-bucket, under which all Velero data should be stored. Optional.
-additional-bsl-config: Configuration to use for the additional backup storage location. Format is key1=value1,key2=value2. Optional.
-additional-bsl-credentials-file: File containing credentials for the additional backup storage location. Required if testing multiple credentials support.
These configurations or parameters are used to generate install options for Velero for each test suite.
Tests can be run with the Kubernetes cluster hosted in various cloud providers or in a kind cluster with storage in a specified object store type. Currently supported cloud provider types are aws, azure, vsphere and kind.
Running tests locally
E2E tests can be run from the Velero repository root by running
make test-e2e. While running E2E tests using
make the E2E test configuration values are passed using
Below is a mapping between
make variables to E2E configuration flags.
-object-store-provider. Required when kind is the cloud provider.
For example, E2E tests can be run from Velero repository roots using the commands below:
- Run Velero tests in a kind cluster with AWS (or Minio) as the storage provider:
BSL_PREFIX=<PREFIX_UNDER_BUCKET> BSL_BUCKET=<BUCKET_FOR_E2E_TEST_BACKUP> CREDS_FILE=/path/to/aws-creds CLOUD_PROVIDER=kind OBJECT_STORE_PROVIDER=aws make test-e2e
- Run Velero tests in an AWS cluster:
BSL_PREFIX=<PREFIX_UNDER_BUCKET> BSL_BUCKET=<BUCKET_FOR_E2E_TEST_BACKUP> CREDS_FILE=/path/to/aws-creds CLOUD_PROVIDER=aws make test-e2e
- Run Velero tests in a Microsoft Azure cluster:
BSL_CONFIG="resourceGroup=$AZURE_BACKUP_RESOURCE_GROUP,storageAccount=$AZURE_STORAGE_ACCOUNT_ID,subscriptionId=$AZURE_BACKUP_SUBSCRIPTION_ID" BSL_BUCKET=<BUCKET_FOR_E2E_TEST_BACKUP> CREDS_FILE=/path/to/azure-creds CLOUD_PROVIDER=azure make test-e2e
- Run Ginko-focused Restore Multi-API Groups tests using Minio as the backup storage location:
BSL_CONFIG="region=minio,s3ForcePathStyle=\"true\",s3Url=<ip address>:9000" BSL_PREFIX=<prefix> BSL_BUCKET=<bucket> CREDS_FILE=<absolute path to minio credentials file> CLOUD_PROVIDER=kind OBJECT_STORE_PROVIDER=aws VELERO_NAMESPACE="velero" GINKGO_FOCUS="API group versions" make test-e2e
- Run Velero tests in a kind cluster with AWS (or Minio) as the storage provider and use Microsoft Azure as the storage provider for an additional Backup Storage Location:
make test-e2e \ CLOUD_PROVIDER=kind OBJECT_STORE_PROVIDER=aws BSL_BUCKET=<BUCKET_FOR_E2E_TEST_BACKUP> BSL_PREFIX=<PREFIX_UNDER_BUCKET> CREDS_FILE=/path/to/aws-creds \ ADDITIONAL_OBJECT_STORE_PROVIDER=azure ADDITIONAL_BSL_BUCKET=<BUCKET_FOR_AZURE_BSL> ADDITIONAL_BSL_PREFIX=<PREFIX_UNDER_BUCKET> ADDITIONAL_BSL_CONFIG=<CONFIG_FOR_AZURE_BUCKET> ADDITIONAL_CREDS_FILE=/path/to/azure-creds
-focus flag is passed to ginkgo using the
GINKGO_FOCUS make variable. This can be used to focus on specific tests.
When adding a test, aim to instantiate an API client only once at the beginning of the test. There is a constructor
newTestClient that facilitates the configuration and instantiation of clients. Also, please use the
kubebuilder runtime controller client for any new test, as we will phase out usage of
client-go API clients.
Look for the ⛵ emoji printed at the end of each install and uninstall log. There should not be two install/unintall in a row, and there should be tests between an install and an uninstall.
There is no documentation for this package.