package
2.4.0-rc1+incompatible
Repository: https://github.com/kubernetes-csi/csi-test.git
Documentation: pkg.go.dev

# README

CSI Driver Sanity Tester

This library provides a simple way to ensure that a CSI driver conforms to the CSI specification. There are two ways to leverage this testing framework. For CSI drivers written in Golang, the framework provides a simple API function to call to test the driver. Another way to run the test suite is to use the command line program csi-sanity.

For Golang CSI Drivers

This framework leverages the Ginkgo BDD testing framework to deliver a descriptive test suite for your driver. To test your driver, simply call the API in one of your Golang TestXXX functions. For example:

func TestMyDriver(t *testing.T) {
	// Setup the full driver and its environment
	... setup driver ...
	config := &sanity.Config{
		TargetPath:     ...
		StagingPath:    ...
		Address:        endpoint,
	}


	// Now call the test suite
	sanity.Test(t, config)
}

Only one such test function is supported because under the hood a Ginkgo test suite gets constructed and executed by the call.

Alternatively, the tests can also be embedded inside a Ginkgo test suite. In that case it is possible to define multiple tests with different configurations:

var _ = Describe("MyCSIDriver", func () {
	Context("Config A", func () {
		var config &sanity.Config

		BeforeEach(func() {
			//... setup driver and config...
		})

		AfterEach(func() {
			//...tear down driver...
		})

		Describe("CSI sanity", func() {
			sanity.GinkgoTest(config)
		})
	})

	Context("Config B", func () {
		// other configs
	})
})

Command line program

Please see csi-sanity

# Functions

ControllerUnpublishAndDeleteVolume controller unpublishes and deletes a volume, given volume ID and node ID.
CreateAndControllerPublishVolume creates and controller publishes a volume given a volume name and node ID.
DescribeSanity must be used instead of the usual Ginkgo Describe to register a test block.
GinkoTest is another entry point for sanity testing: instead of directly running tests like Test does, it merely registers the tests.
MakeControllerPublishVolumeReq creates and returns a ControllerPublishVolumeRequest.
MakeControllerUnpublishVolumeReq creates and returns a ControllerUnpublishVolumeRequest.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
PseudoUUID returns a unique string generated from random bytes, empty string in case of error.
Test will test the CSI driver at the specified address by setting up a Ginkgo suite and running it.
No description provided by the author
No description provided by the author
UniqueString returns a unique string by appending a random number.

# Constants

DefTestVolumeExpand defines the size increment for volume expansion.
DefTestVolumeSize defines the base size of dynamically provisioned volumes.
No description provided by the author

# Structs

Cleanup keeps track of resources, in particular volumes, which need to be freed when testing is done.
Config provides the configuration for the sanity tests.
CSISecrets consists of secrets used in CSI credentials.
No description provided by the author
SanityContext holds the variables that each test can depend on.
VolumeInfo keeps track of the information needed to delete a volume.

# Interfaces

IDGenerator generates valid and invalid Volume and Node IDs to be used in tests.