ceph-csi/e2e
Madhu Rajanna 8ab04d4160 e2e: add backend image validation for rbd
validate backend rbd images count in each
E2E test cases. This helps a lot to catch
the issues in each test case.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
(cherry picked from commit d5c19954c1)
2020-08-24 09:24:09 +00:00
..
cephfs.go e2e: add backend validation for pvc restore and clone 2020-08-11 16:21:29 +00:00
deploy-vault.go doc: make sure configmap object referred or documented correctly 2020-06-10 11:33:10 +00:00
e2e_test.go cephfs: add upgrade testing 2020-07-26 03:41:53 +00:00
log.go cleanup: fix golint warnings in util, e2e 2020-05-20 13:18:41 +00:00
rbd.go e2e: add backend image validation for rbd 2020-08-24 09:24:09 +00:00
README.md doc: update e2e README for snapshot operation 2020-08-12 16:27:49 +00:00
resize.go cleanup: use wrapped static errors instead of dynamic 2020-07-21 08:36:24 +00:00
snapshot.go e2e: introduce createCephFSSnapshotClass creation 2020-08-08 00:11:35 +00:00
staticpvc.go e2e: Add e2e test cases for rbd rados namespace 2020-08-12 16:22:58 +05:30
upgrade-cephfs.go cephfs: add upgrade testing 2020-07-26 03:41:53 +00:00
upgrade-rbd.go rbd: add upgrade testing 2020-07-26 03:41:53 +00:00
upgrade.go cephfs: add upgrade testing 2020-07-26 03:41:53 +00:00
utils.go e2e: Add e2e test cases for rbd rados namespace 2020-08-12 16:22:58 +05:30

End-to-End Testing

Introduction

End-to-end (e2e) in cephcsi provides a mechanism to test the end-to-end behavior of the system, These tests will interact with live instances of ceph cluster just like how a user would.

The primary objectives of the e2e tests are to ensure a consistent and reliable behavior of the cephcsi code base and to catch hard-to-test bugs before users do when unit and integration tests are insufficient.

The Test framework is designed to install Rook, run cephcsi tests, and uninstall Rook.

The e2e test are built on top of Ginkgo and Gomega

Install Kubernetes

The cephcsi also provides a script for starting Kubernetes using minikube so users can quickly spin up a Kubernetes cluster.

the following parameters are available to configure kubernetes cluster

flag description
up Starts a local kubernetes cluster and prepare a disk for rook
down Stops a running local kubernetes cluster
clean Deletes a local kubernetes cluster
ssh Log into or run a command on a minikube machine with SSH
deploy-rook Deploy rook to minikube
create-block-pool Creates a rook block pool (named $ROOK_BLOCK_POOL_NAME)
delete-block-pool Deletes a rook block pool (named $ROOK_BLOCK_POOL_NAME)
clean-rook Deletes a rook from minikube
cephcsi Copy built docker images to kubernetes cluster
k8s-sidecar Copy kubernetes sidecar docker images to kubernetes cluster

following environment variables can be exported to customize kubernetes deployment

ENV Description Default
MINIKUBE_VERSION minikube version to install latest
KUBE_VERSION kubernetes version to install v1.14.10
MEMORY Amount of RAM allocated to the minikube VM in MB 3000
VM_DRIVER VM driver to create virtual machine virtualbox
CEPHCSI_IMAGE_REPO Repo URL to pull cephcsi images quay.io/cephcsi
K8S_IMAGE_REPO Repo URL to pull kubernetes sidecar images quay.io/k8scsi
K8S_FEATURE_GATES Feature gates to enable on kubernetes cluster BlockVolume=true,CSIBlockVolume=true,VolumeSnapshotDataSource=true
ROOK_BLOCK_POOL_NAME Block pool name to create in the rook instance newrbdpool
  • creating kubernetes cluster
$./minikube.sh up
  • Teardown kubernetes cluster
$./minikube.sh clean

Test parameters

In addition to standard go tests parameters, the following custom parameters are available while running tests:

flag description
deploy-timeout Timeout to wait for created kubernetes resources (default: 10 minutes)
deploy-cephfs Deploy cephfs csi driver as part of E2E (default: true)
deploy-rbd Deploy rbd csi driver as part of E2E (default: true)
test-cephfs Test cephfs csi driver as part of E2E (default: true)
upgrade-testing Perform upgrade testing (default: false)
upgrade-version Target version for upgrade testing (default: "v2.1.2")
test-rbd Test rbd csi driver as part of E2E (default: true)
cephcsi-namespace The namespace in which cephcsi driver will be created (default: "default")
rook-namespace The namespace in which rook operator is installed (default: "rook-ceph")
kubeconfig Path to kubeconfig containing embedded authinfo (default: $HOME/.kube/config)
timeout Panic test binary after duration d (default 0, timeout disabled)
v Verbose: print additional output

E2E for snapshot

After the support for snapshot/clone has been added to ceph-csi, you need to follow these steps before running e2e. Please note that the snapshot operation works only if the Kubernetes version is greater than or equal to 1.17.0.

  • Delete Alpha snapshot CRD created by ceph-csi in rook.

    • Check if you have any v1alpha1 CRD created in our Kubernetes cluster

      [$]kubectl get crd volumesnapshotclasses.snapshot.storage.k8s.io -o yaml |grep v1alpha1
        - name: v1alpha1
        - v1alpha1
      [$]kubectl get crd volumesnapshotcontents.snapshot.storage.k8s.io -o yaml |grep v1alpha1
        - name: v1alpha1
        - v1alpha1
      [$]kubectl get crd volumesnapshots.snapshot.storage.k8s.io -o yaml |grep v1alpha1
        - name: v1alpha1
        - v1alpha1
      
    • If you have Alpha CRD, delete it as from Kubernetes 1.17.0+ the snapshot should be v1beta1

      $./install-snapshot.sh delete-crd
      
  • Install snapshot controller and Beta snapshot CRD

    $./install-snapshot.sh install
    

Once you are done running e2e please perform the cleanup by running following:

    $./install-snapshot.sh cleanup

Running E2E

Note:- Prior to running the tests, you may need to copy the kubernetes configuration file to$HOME/.kube/configwhich is required to communicate with kubernetes cluster or you can passkubeconfigflag while running tests.

Functional tests are run by the go test command.

$go test ./e2e/ -timeout=20m -v -mod=vendor

Functional tests can be invoked by make command

$make func-test TESTOPTIONS="--deploy-timeout=10  -timeout=30m -v"