Use ginkgo test suite to test all mounters
This commit is contained in:
parent
0bd6f9b7cc
commit
093c5bf500
3 changed files with 122 additions and 36 deletions
|
@ -78,7 +78,7 @@ func (cs *controllerServer) CreateVolume(ctx context.Context, req *csi.CreateVol
|
|||
return &csi.CreateVolumeResponse{
|
||||
Volume: &csi.Volume{
|
||||
Id: volumeID,
|
||||
CapacityBytes: 0,
|
||||
CapacityBytes: 1,
|
||||
Attributes: req.GetParameters(),
|
||||
},
|
||||
}, nil
|
||||
|
|
116
pkg/s3/s3-driver_suite_test.go
Normal file
116
pkg/s3/s3-driver_suite_test.go
Normal file
|
@ -0,0 +1,116 @@
|
|||
package s3_test
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/ctrox/csi-s3-driver/pkg/s3"
|
||||
"github.com/kubernetes-csi/csi-test/pkg/sanity"
|
||||
)
|
||||
|
||||
const ()
|
||||
|
||||
var _ = Describe("S3Driver", func() {
|
||||
mntDir, err := ioutil.TempDir("", "mnt")
|
||||
if err != nil {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
AfterSuite(func() {
|
||||
os.RemoveAll(mntDir)
|
||||
})
|
||||
|
||||
Context("goofys", func() {
|
||||
socket := "/tmp/csi-goofys.sock"
|
||||
csiEndpoint := "unix://" + socket
|
||||
cfg := &s3.Config{
|
||||
AccessKeyID: "FJDSJ",
|
||||
SecretAccessKey: "DSG643HGDS",
|
||||
Endpoint: "http://127.0.0.1:9000",
|
||||
Mounter: "goofys",
|
||||
}
|
||||
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
driver, err := s3.NewS3("test-node", csiEndpoint, cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go driver.Run()
|
||||
|
||||
Describe("CSI sanity", func() {
|
||||
sanityCfg := &sanity.Config{
|
||||
TargetPath: mntDir,
|
||||
Address: csiEndpoint,
|
||||
TestVolumeSize: 1,
|
||||
}
|
||||
sanity.GinkgoTest(sanityCfg)
|
||||
})
|
||||
})
|
||||
|
||||
Context("s3fs", func() {
|
||||
socket := "/tmp/csi-s3fs.sock"
|
||||
csiEndpoint := "unix://" + socket
|
||||
cfg := &s3.Config{
|
||||
AccessKeyID: "FJDSJ",
|
||||
SecretAccessKey: "DSG643HGDS",
|
||||
Endpoint: "http://127.0.0.1:9000",
|
||||
Mounter: "s3fs",
|
||||
}
|
||||
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
driver, err := s3.NewS3("test-node", csiEndpoint, cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go driver.Run()
|
||||
|
||||
defer os.RemoveAll(mntDir)
|
||||
|
||||
Describe("CSI sanity", func() {
|
||||
sanityCfg := &sanity.Config{
|
||||
TargetPath: mntDir,
|
||||
Address: csiEndpoint,
|
||||
TestVolumeSize: 1,
|
||||
}
|
||||
sanity.GinkgoTest(sanityCfg)
|
||||
})
|
||||
})
|
||||
|
||||
Context("s3ql", func() {
|
||||
socket := "/tmp/csi-s3ql.sock"
|
||||
csiEndpoint := "unix://" + socket
|
||||
|
||||
cfg := &s3.Config{
|
||||
AccessKeyID: "FJDSJ",
|
||||
SecretAccessKey: "DSG643HGDS",
|
||||
Endpoint: "http://127.0.0.1:9000",
|
||||
Mounter: "s3ql",
|
||||
}
|
||||
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
}
|
||||
driver, err := s3.NewS3("test-node", csiEndpoint, cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go driver.Run()
|
||||
|
||||
defer os.RemoveAll(mntDir)
|
||||
|
||||
Describe("CSI sanity", func() {
|
||||
sanityCfg := &sanity.Config{
|
||||
TargetPath: mntDir,
|
||||
Address: csiEndpoint,
|
||||
TestVolumeSize: 1,
|
||||
}
|
||||
sanity.GinkgoTest(sanityCfg)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
|
@ -17,43 +17,13 @@ limitations under the License.
|
|||
package s3
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/kubernetes-csi/csi-test/pkg/sanity"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestDriver(t *testing.T) {
|
||||
socket := "/tmp/csi.sock"
|
||||
endpoint := "unix://" + socket
|
||||
|
||||
if err := os.Remove(socket); err != nil && !os.IsNotExist(err) {
|
||||
t.Fatalf("failed to remove unix domain socket file %s, error: %s", socket, err)
|
||||
}
|
||||
cfg := &Config{
|
||||
AccessKeyID: "FJDSJ",
|
||||
SecretAccessKey: "DSG643HGDS",
|
||||
Endpoint: "http://127.0.0.1:9000",
|
||||
EncryptionKey: "IskEwCuEg6drywi",
|
||||
}
|
||||
driver, err := NewS3("test-node", endpoint, cfg)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
go driver.Run()
|
||||
|
||||
mntDir, err := ioutil.TempDir("", "mnt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(mntDir)
|
||||
|
||||
sanityCfg := &sanity.Config{
|
||||
TargetPath: mntDir,
|
||||
Address: endpoint,
|
||||
}
|
||||
|
||||
sanity.Test(t, sanityCfg)
|
||||
func TestS3Driver(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "S3Driver")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue