mirror of https://github.com/ceph/go-ceph
cephfs admin: in the test setup code, delay a bit to fetch mgr map
When the ceph client code has not yet (asynchronously) gotten the mgr map, it can return -EACCES when we run the MgrCommand function. We before continuing with the test function to get the fsadmin we delay a bit so that we are more likely to have the mgr map before continuing. This change also fixes the caching of the fs admin. Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
f9e1ec5d2a
commit
c1ff3a6b18
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
@ -58,12 +59,19 @@ func getFSAdmin(t *testing.T) *FSAdmin {
|
|||
if cachedFSAdmin != nil {
|
||||
return cachedFSAdmin
|
||||
}
|
||||
cachedFSAdmin, err := New()
|
||||
fsa, err := New()
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, cachedFSAdmin)
|
||||
require.NotNil(t, fsa)
|
||||
// We steal the connection set up by the New() method and wrap it in an
|
||||
// optional tracer.
|
||||
c := fsa.conn
|
||||
if debugTrace {
|
||||
cachedFSAdmin = NewFromConn(tracer(cachedFSAdmin.conn))
|
||||
c = tracer(c)
|
||||
}
|
||||
cachedFSAdmin = NewFromConn(c)
|
||||
// We sleep briefly before returning in order to ensure we have a mgr map
|
||||
// before we start executing the tests.
|
||||
time.Sleep(50 * time.Millisecond)
|
||||
return cachedFSAdmin
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue