mirror of
https://github.com/ceph/go-ceph
synced 2024-12-19 21:02:12 +00:00
ce64ef536a
Start organizing some of the cephfs functionality into functions grouped by files by moving the MDS command functions into a new file. Move the tests dedicated to those functions into a new matching file too. Signed-off-by: John Mulligan <jmulligan@redhat.com>
42 lines
942 B
Go
42 lines
942 B
Go
package cephfs
|
|
|
|
import (
|
|
"encoding/json"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestMdsCommand(t *testing.T) {
|
|
mount := fsConnect(t)
|
|
defer fsDisconnect(t, mount)
|
|
|
|
cmd := []byte(`{"prefix": "client ls"}`)
|
|
buf, info, err := mount.MdsCommand(
|
|
testMdsName,
|
|
[][]byte{cmd})
|
|
assert.NoError(t, err)
|
|
assert.NotEqual(t, "", string(buf))
|
|
assert.Equal(t, "", string(info))
|
|
assert.Contains(t, string(buf), "ceph_version")
|
|
// response should also be valid json
|
|
var j []interface{}
|
|
err = json.Unmarshal(buf, &j)
|
|
assert.NoError(t, err)
|
|
assert.GreaterOrEqual(t, len(j), 1)
|
|
}
|
|
|
|
func TestMdsCommandError(t *testing.T) {
|
|
mount := fsConnect(t)
|
|
defer fsDisconnect(t, mount)
|
|
|
|
cmd := []byte("iAMinValId~~~")
|
|
buf, info, err := mount.MdsCommand(
|
|
testMdsName,
|
|
[][]byte{cmd})
|
|
assert.Error(t, err)
|
|
assert.Equal(t, "", string(buf))
|
|
assert.NotEqual(t, "", string(info))
|
|
assert.Contains(t, string(info), "unparseable JSON")
|
|
}
|