Skip to content

Commit

Permalink
Merge pull request kubernetes-csi#90 from pohly/ginkgo-integration
Browse files Browse the repository at this point in the history
pkg/sanity: support sanity testing in another Ginkgo suite
  • Loading branch information
lpabon authored Jul 10, 2018
2 parents 508354d + ab42b9a commit 3b71fd3
Show file tree
Hide file tree
Showing 6 changed files with 305 additions and 197 deletions.
45 changes: 41 additions & 4 deletions pkg/sanity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,50 @@ Golang `TestXXX` functions. For example:

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

// Now call the test suite
sanity.Test(t, driverEndpointAddress, "/mnt")

// 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:

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

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

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

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

Context("Config B", func () {
...
})
})
```

## Command line program
Please see [csi-sanity](https://github.com/kubernetes-csi/csi-test/tree/master/cmd/csi-sanity)
Loading

0 comments on commit 3b71fd3

Please sign in to comment.