mirror of https://github.com/ceph/go-ceph
rbd: add a test helper to get a conn for a given cluster by config
This function can be used to connect to a non-default ceph cluster, in a simple, convenient way similar to the function we have for connecting to the default cluster. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
f84140356a
commit
de9505f862
|
@ -37,8 +37,22 @@ func radosConnect(t *testing.T) *rados.Conn {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
err = conn.ReadDefaultConfigFile()
|
err = conn.ReadDefaultConfigFile()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
waitForRadosConn(t, conn)
|
||||||
|
return conn
|
||||||
|
}
|
||||||
|
|
||||||
timeout := time.After(time.Second * 5)
|
func radosConnectConfig(t *testing.T, p string) *rados.Conn {
|
||||||
|
conn, err := rados.NewConn()
|
||||||
|
require.NoError(t, err)
|
||||||
|
err = conn.ReadConfigFile(p)
|
||||||
|
require.NoError(t, err)
|
||||||
|
waitForRadosConn(t, conn)
|
||||||
|
return conn
|
||||||
|
}
|
||||||
|
|
||||||
|
func waitForRadosConn(t *testing.T, conn *rados.Conn) {
|
||||||
|
var err error
|
||||||
|
timeout := time.After(time.Second * 15)
|
||||||
ch := make(chan error)
|
ch := make(chan error)
|
||||||
go func(conn *rados.Conn) {
|
go func(conn *rados.Conn) {
|
||||||
ch <- conn.Connect()
|
ch <- conn.Connect()
|
||||||
|
@ -49,7 +63,6 @@ func radosConnect(t *testing.T) *rados.Conn {
|
||||||
err = fmt.Errorf("timed out waiting for connect")
|
err = fmt.Errorf("timed out waiting for connect")
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
return conn
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestImageCreate(t *testing.T) {
|
func TestImageCreate(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue