Skip to content

Commit

Permalink
rbd: add a test helper to get a conn for a given cluster by config
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
phlogistonjohn authored and mergify[bot] committed Apr 13, 2021
1 parent f841403 commit de9505f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions rbd/rbd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,22 @@ func radosConnect(t *testing.T) *rados.Conn {
require.NoError(t, err)
err = conn.ReadDefaultConfigFile()
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)
go func(conn *rados.Conn) {
ch <- conn.Connect()
Expand All @@ -49,7 +63,6 @@ func radosConnect(t *testing.T) *rados.Conn {
err = fmt.Errorf("timed out waiting for connect")
}
require.NoError(t, err)
return conn
}

func TestImageCreate(t *testing.T) {
Expand Down

0 comments on commit de9505f

Please sign in to comment.