cephfs admin: make fsConnect utility function more flexible

The fsConnect function is used by the tests to support getting a
data-path cephfs connection, in order to support those fs admin tests
that need to make changes in the file system directly. The new second
argument to the call allows for the cephfs connection to be made with a
non-default configuration.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2021-07-08 09:49:10 -04:00 committed by mergify[bot]
parent df3c6dae2e
commit e56f10f3b4
1 changed files with 9 additions and 4 deletions

View File

@ -19,13 +19,18 @@ import (
var snapDir = ".snapshots"
func fsConnect(t *testing.T) *cephfs.MountInfo {
func fsConnect(t *testing.T, configFile string) *cephfs.MountInfo {
mount, err := cephfs.CreateMount()
require.NoError(t, err)
require.NotNil(t, mount)
err = mount.ReadDefaultConfigFile()
require.NoError(t, err)
if configFile == "" {
err = mount.ReadDefaultConfigFile()
require.NoError(t, err)
} else {
err = mount.ReadConfigFile(configFile)
require.NoError(t, err)
}
err = mount.SetConfigOption("client_snapdir", snapDir)
require.NoError(t, err)
@ -114,7 +119,7 @@ func TestWorkflow(t *testing.T) {
require.NotEqual(t, "", subPath)
// connect to volume, cd to path (?)
mount := fsConnect(t)
mount := fsConnect(t, "")
defer func(mount *cephfs.MountInfo) {
assert.NoError(t, mount.Unmount())
assert.NoError(t, mount.Release())