cephfs: release fs resources in remaining test cases

In a previous commit we added fsDisconnect to match with fsConnect.  For
tests that do not use fsConnect but still acquire resources we need to
free up those resources with direct calls to the appropriate functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-03-23 16:58:15 -04:00 committed by John Mulligan
parent 1842ad248d
commit 36196c5e60
2 changed files with 6 additions and 0 deletions

View File

@ -164,9 +164,11 @@ func TestUnmountMount(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, mount)
assert.False(t, mount.IsMounted())
assert.NoError(t, mount.Release())
})
t.Run("mountUnmount", func(t *testing.T) {
mount := fsConnect(t)
defer func() { assert.NoError(t, mount.Release()) }()
assert.True(t, mount.IsMounted())
err := mount.Unmount()
@ -292,12 +294,14 @@ func TestCreateMountWithId(t *testing.T) {
mount, err := CreateMountWithId("bobolink")
assert.NoError(t, err)
assert.NotNil(t, mount)
defer func() { assert.NoError(t, mount.Release()) }()
err = mount.ReadDefaultConfigFile()
assert.NoError(t, err)
err = mount.Mount()
assert.NoError(t, err)
defer func() { assert.NoError(t, mount.Unmount()) }()
// verify the custom entity_id is visible in the 'session ls' output
// of mds.
@ -400,6 +404,7 @@ func TestGetSetConfigOption(t *testing.T) {
mount, err := CreateMount()
require.NoError(t, err)
require.NotNil(t, mount)
defer func() { assert.NoError(t, mount.Release()) }()
err = mount.SetConfigOption("__dne__", "value")
assert.Error(t, err)

View File

@ -12,6 +12,7 @@ import (
func TestGetFsCid(t *testing.T) {
t.Run("unmounted", func(t *testing.T) {
mount, err := CreateMount()
defer func() { assert.NoError(t, mount.Release()) }()
require.NoError(t, err)
require.NotNil(t, mount)