2015-05-01 19:35:40 +00:00
|
|
|
package cephfs_test
|
|
|
|
|
|
|
|
import "testing"
|
2015-08-31 14:34:42 +00:00
|
|
|
import "github.com/ceph/go-ceph/cephfs"
|
2015-05-01 19:35:40 +00:00
|
|
|
import "github.com/stretchr/testify/assert"
|
|
|
|
|
|
|
|
func TestCreateMount(t *testing.T) {
|
2015-07-08 08:34:54 +00:00
|
|
|
mount, err := cephfs.CreateMount()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, mount)
|
2015-05-01 19:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestMountRoot(t *testing.T) {
|
2015-07-08 08:34:54 +00:00
|
|
|
mount, err := cephfs.CreateMount()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, mount)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.ReadDefaultConfigFile()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.Mount()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestSyncFs(t *testing.T) {
|
2015-07-08 08:34:54 +00:00
|
|
|
mount, err := cephfs.CreateMount()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, mount)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.ReadDefaultConfigFile()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.Mount()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.SyncFs()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestChangeDir(t *testing.T) {
|
2015-07-08 08:34:54 +00:00
|
|
|
mount, err := cephfs.CreateMount()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, mount)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.ReadDefaultConfigFile()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.Mount()
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
dir1 := mount.CurrentDir()
|
|
|
|
assert.NotNil(t, dir1)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.MakeDir("/asdf", 0755)
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
err = mount.ChangeDir("/asdf")
|
|
|
|
assert.NoError(t, err)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
dir2 := mount.CurrentDir()
|
|
|
|
assert.NotNil(t, dir2)
|
2015-05-01 19:35:40 +00:00
|
|
|
|
2015-07-08 08:34:54 +00:00
|
|
|
assert.NotEqual(t, dir1, dir2)
|
|
|
|
assert.Equal(t, dir1, "/")
|
|
|
|
assert.Equal(t, dir2, "/asdf")
|
2015-05-01 19:35:40 +00:00
|
|
|
}
|