mirror of https://github.com/ceph/go-ceph
cephfs: test creating a cephfs mount from a rados Conn
Verify the cephfs CreateFromRados function. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
9929f63b13
commit
296c551613
|
@ -7,6 +7,8 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
@ -192,3 +194,30 @@ func TestCephFSError(t *testing.T) {
|
|||
assert.Error(t, err)
|
||||
assert.Equal(t, err.Error(), "cephfs: ret=345")
|
||||
}
|
||||
|
||||
func radosConnect(t *testing.T) *rados.Conn {
|
||||
conn, err := rados.NewConn()
|
||||
require.NoError(t, err)
|
||||
err = conn.ReadDefaultConfigFile()
|
||||
require.NoError(t, err)
|
||||
|
||||
timeout := time.After(time.Second * 5)
|
||||
ch := make(chan error)
|
||||
go func(conn *rados.Conn) {
|
||||
ch <- conn.Connect()
|
||||
}(conn)
|
||||
select {
|
||||
case err = <-ch:
|
||||
case <-timeout:
|
||||
err = fmt.Errorf("timed out waiting for connect")
|
||||
}
|
||||
require.NoError(t, err)
|
||||
return conn
|
||||
}
|
||||
|
||||
func TestCreateFromRados(t *testing.T) {
|
||||
conn := radosConnect(t)
|
||||
mount, err := CreateFromRados(conn)
|
||||
assert.NoError(t, err)
|
||||
assert.NotNil(t, mount)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue