Skip to content

Commit

Permalink
Update santiy test to use ginkgo.
Browse files Browse the repository at this point in the history
This have several benefits that:
1. Using consistent testing framework as e2e test
2. Able to define multiple test configurations per:
https://github.com/kubernetes-csi/csi-test/tree/master/pkg/sanity
3. Test results will be print to stdout as test runs as opposes to stuck
for a while and dump all results at once in the old way
  • Loading branch information
Cheng Pan committed Sep 17, 2018
1 parent e182c6a commit 9d73de4
Showing 1 changed file with 30 additions and 15 deletions.
45 changes: 30 additions & 15 deletions tests/sanity/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,52 @@ import (
"os"
"testing"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/bertinatto/ebs-csi-driver/pkg/cloud"
"github.com/bertinatto/ebs-csi-driver/pkg/driver"
sanity "github.com/kubernetes-csi/csi-test/pkg/sanity"
)

func TestSanity(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "AWS EBS CSI Driver Sanity Tests")
}

var _ = Describe("AWS EBS CSI Driver", func() {
const (
mountPath = "/tmp/csi/mount"
stagePath = "/tmp/csi/stage"
socket = "/tmp/csi.sock"
endpoint = "unix://" + socket
)

if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
t.Fatalf("could not remove socket file %s: %v", socket, err)
}

ebsDriver := driver.NewDriver(cloud.NewFakeCloudProvider(), driver.NewFakeMounter(), endpoint)
defer ebsDriver.Stop()

go func() {
if err := ebsDriver.Run(); err != nil {
t.Fatalf("could not run CSI driver: %v", err)
}
}()

config := &sanity.Config{
Address: endpoint,
TargetPath: mountPath,
StagingPath: stagePath,
}

sanity.Test(t, config)
}
var ebsDriver *driver.Driver

BeforeEach(func() {
ebsDriver = driver.NewDriver(cloud.NewFakeCloudProvider(), driver.NewFakeMounter(), endpoint)
go func() {
err := ebsDriver.Run()
Expect(err).To(BeNil())
}()
})

AfterEach(func() {
ebsDriver.Stop()
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
Expect(err).To(BeNil())
}
})

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

})

0 comments on commit 9d73de4

Please sign in to comment.