From c1ff3a6b18d089bdd5adface32874de4840c073c Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Thu, 6 Aug 2020 09:27:47 -0400 Subject: [PATCH] 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 --- cephfs/admin/fsadmin_test.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cephfs/admin/fsadmin_test.go b/cephfs/admin/fsadmin_test.go index 3507f70..369ddfc 100644 --- a/cephfs/admin/fsadmin_test.go +++ b/cephfs/admin/fsadmin_test.go @@ -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 }