Merge pull request #31 from Vicente-Cheng/minor-fixed-rbd-go

rbd: the length of args on create_v3 should be 3 instead of 2
This commit is contained in:
Noah Watkins 2018-07-07 12:26:02 -07:00 committed by GitHub
commit e57e53d585
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 1 deletions

View File

@ -152,7 +152,7 @@ func Create(ioctx *rados.IOContext, name string, size uint64, order int,
defer C.free(unsafe.Pointer(c_name)) defer C.free(unsafe.Pointer(c_name))
switch len(args) { switch len(args) {
case 2: case 3:
ret = C.rbd_create3(C.rados_ioctx_t(ioctx.Pointer()), ret = C.rbd_create3(C.rados_ioctx_t(ioctx.Pointer()),
c_name, C.uint64_t(size), c_name, C.uint64_t(size),
C.uint64_t(args[0]), &c_order, C.uint64_t(args[0]), &c_order,

View File

@ -11,6 +11,10 @@ import (
"testing" "testing"
) )
//Rdb feature
var RbdFeatureLayering = uint64(1 << 0)
var RbdFeatureStripingV2 = uint64(1 << 1)
func GetUUID() string { func GetUUID() string {
out, _ := exec.Command("uuidgen").Output() out, _ := exec.Command("uuidgen").Output()
return string(out[:36]) return string(out[:36])
@ -23,6 +27,43 @@ func TestVersion(t *testing.T) {
assert.False(t, patch < 0 || patch > 1000, "invalid patch") assert.False(t, patch < 0 || patch > 1000, "invalid patch")
} }
func TestCreateImage(t *testing.T) {
conn, _ := rados.NewConn()
conn.ReadDefaultConfigFile()
conn.Connect()
poolname := GetUUID()
err := conn.MakePool(poolname)
assert.NoError(t, err)
ioctx, err := conn.OpenIOContext(poolname)
assert.NoError(t, err)
name := GetUUID()
image, err := rbd.Create(ioctx, name, 1<<22, 22)
assert.NoError(t, err)
err = image.Remove()
assert.NoError(t, err)
name = GetUUID()
image, err = rbd.Create(ioctx, name, 1<<22, 22,
RbdFeatureLayering|RbdFeatureStripingV2)
assert.NoError(t, err)
err = image.Remove()
assert.NoError(t, err)
name = GetUUID()
image, err = rbd.Create(ioctx, name, 1<<22, 22,
RbdFeatureLayering|RbdFeatureStripingV2, 4096, 2)
assert.NoError(t, err)
err = image.Remove()
assert.NoError(t, err)
ioctx.Destroy()
conn.DeletePool(poolname)
conn.Shutdown()
}
func TestGetImageNames(t *testing.T) { func TestGetImageNames(t *testing.T) {
conn, _ := rados.NewConn() conn, _ := rados.NewConn()
conn.ReadDefaultConfigFile() conn.ReadDefaultConfigFile()