Skip to content

Commit

Permalink
Update functional-testing.md
Browse files Browse the repository at this point in the history
  • Loading branch information
mathu97 authored May 10, 2019
1 parent 075dadb commit 2d2a898
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions book/src/functional-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ Currently, [csi-sanity](https://github.com/kubernetes-csi/csi-test/tree/master/c
* [Kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/#install-kubectl)

There are two ways to run end-to-end tests for your CSI Plugin
1) use [Kubernetes E2E Tests](https://github.com/kubernetes/kubernetes/tree/e84271ed8ad04c94ce3c0a6fecd9f8dff834e861/test/e2e/storage/external), by providing a DriverDefinition YAML file via a parameter.
* **Note**: In some cases you would not be able to use this method, in running e2e tests by just providing a YAML file defining your CSI plugin. For example the [NFS CSI plugin](https://github.com/kubernetes-csi/csi-driver-nfs/tree/2c5c9bcd62595bd3b7f4976539f3bf3dcf3bbbc6) currently does not support dynamic provisoning, so we would want to skip those and run only pre-provisioned tests. For such cases, you would need to write your own testdriver, which is discussed below.
1) use [Kubernetes E2E Tests](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/storage/external), by providing a DriverDefinition YAML file via a parameter.
* **Note**: In some cases you would not be able to use this method, in running e2e tests by just providing a YAML file defining your CSI plugin. For example the [NFS CSI plugin](https://github.com/kubernetes-csi/csi-driver-nfs) currently does not support dynamic provisoning, so we would want to skip those and run only pre-provisioned tests. For such cases, you would need to write your own testdriver, which is discussed below.

2) import the in-tree storage tests and run them using `go test`.

This doc will cover how to run the E2E tests using the second method.

## Importing the E2E test suite as a library

In-tree storage e2e tests could be used to test CSI storage plugins. Your repo should be setup similar to how the [NFS CSI plugin](https://github.com/kubernetes-csi/csi-driver-nfs/tree/2c5c9bcd62595bd3b7f4976539f3bf3dcf3bbbc6) is setup, where the testfiles are in a `test` directory and the main test file is in the `cmd` directory.
In-tree storage e2e tests could be used to test CSI storage plugins. Your repo should be setup similar to how the [NFS CSI plugin](https://github.com/kubernetes-csi/csi-driver-nfs) is setup, where the testfiles are in a `test` directory and the main test file is in the `cmd` directory.

To be able to import Kubernetes in-tree storage tests, the CSI plugin would need to use **Kubernetes v1.14+** (add to plugin's GoPkg.toml, since pluggable E2E tests become available in v1.14). CSI plugin authors would also be required to implement a [testdriver](https://github.com/kubernetes/kubernetes/blob/6644db9914379a4a7b3d3487b41b2010f226e4dc/test/e2e/storage/testsuites/testdriver.go#L31) for their CSI plugin. The testdriver provides required functionality that would help setup testcases for a particular plugin.

Expand Down Expand Up @@ -73,7 +73,7 @@ You would define something similar for your CSI plugin.

Depending on your plugin's specs, you would implement other interaces defined [here](https://github.com/kubernetes/kubernetes/blob/6644db9914379a4a7b3d3487b41b2010f226e4dc/test/e2e/storage/testsuites/testdriver.go#L61). For example the [NFS testdriver](https://github.com/kubernetes-csi/csi-driver-nfs/blob/193faa0f2aa92a3be0855764a1126ff3cdcd3e77/test/nfs-testdriver.go#L66) also implements PreprovisionedVolumeTestDriver and PreprovisionedPVTestDriver interfaces, to enable pre-provisoned tests.

After implementing the testdriver for your CSI plugin, you would create a `csi-volumes.go` file, where the implemented testdriver is used to run in-tree storage testsuites, [similar to how the NFS CSI plugin does so](https://github.com/kubernetes-csi/csi-driver-nfs/blob/193faa0f2aa92a3be0855764a1126ff3cdcd3e77/test/csi-volumes.go#L37). This is where you would define which testsuites you would want to run for your plugin. All available in-tree testsuites can be found [here](https://github.com/kubernetes/kubernetes/tree/6644db9914379a4a7b3d3487b41b2010f226e4dc/test/e2e/storage/testsuites).
After implementing the testdriver for your CSI plugin, you would create a `csi-volumes.go` file, where the implemented testdriver is used to run in-tree storage testsuites, [similar to how the NFS CSI plugin does so](https://github.com/kubernetes-csi/csi-driver-nfs/blob/193faa0f2aa92a3be0855764a1126ff3cdcd3e77/test/csi-volumes.go#L37). This is where you would define which testsuites you would want to run for your plugin. All available in-tree testsuites can be found [here](https://github.com/kubernetes/kubernetes/tree/master/test/e2e/storage/testsuites).

Finally, importing the `test` package into your [main test file](https://github.com/kubernetes-csi/csi-driver-nfs/blob/193faa0f2aa92a3be0855764a1126ff3cdcd3e77/cmd/tests/nfs-e2e.go#L18) will [initialize the testsuites to run the E2E tests](https://github.com/kubernetes-csi/csi-driver-nfs/blob/193faa0f2aa92a3be0855764a1126ff3cdcd3e77/test/csi-volumes.go#L37).

Expand Down

0 comments on commit 2d2a898

Please sign in to comment.