rados: update test setup code to avoid blocking forever

When working on the previous rbd change it was determined that the
connection setup code would block forever if the ceph config was missing
or bad when running the tests. Adjust the connection setup in the rados
pkg such that the tests will not block forever.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2019-12-18 17:23:44 -05:00 committed by Niels de Vos
parent 3ec0541977
commit d51628ca59
1 changed files with 14 additions and 2 deletions

View File

@ -31,9 +31,21 @@ func (suite *RadosTestSuite) SetupSuite() {
require.NoError(suite.T(), err)
defer conn.Shutdown()
conn.ReadDefaultConfigFile()
err = conn.ReadDefaultConfigFile()
require.NoError(suite.T(), err)
if err = conn.Connect(); assert.NoError(suite.T(), err) {
timeout := time.After(time.Second * 5)
ch := make(chan error)
go func(conn *Conn) {
ch <- conn.Connect()
}(conn)
select {
case err = <-ch:
case <-timeout:
err = fmt.Errorf("timed out waiting for connect")
}
if assert.NoError(suite.T(), err) {
pool := uuid.Must(uuid.NewV4()).String()
if err = conn.MakePool(pool); assert.NoError(suite.T(), err) {
suite.pool = pool