rados: test functions for MonCommandTarget

Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
John Mulligan 2020-05-20 14:13:26 -04:00 committed by John Mulligan
parent 665611d054
commit 861747663b

View File

@ -10,6 +10,7 @@ import (
var (
osdNumber = 0
monName = "a"
)
func (suite *RadosTestSuite) TestMonCommand() {
@ -175,3 +176,45 @@ func (suite *RadosTestSuite) TestOsdCommandMalformedCommand() {
assert.NotEqual(suite.T(), info, "")
assert.Len(suite.T(), buf, 0)
}
func (suite *RadosTestSuite) TestMonCommandTargetDescriptions() {
suite.SetupConnection()
command, err := json.Marshal(
map[string]string{"prefix": "get_command_descriptions", "format": "json"})
assert.NoError(suite.T(), err)
buf, info, err := suite.conn.MonCommandTarget(monName, [][]byte{command})
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), info, "")
var message map[string]interface{}
err = json.Unmarshal(buf, &message)
assert.NoError(suite.T(), err)
}
func (suite *RadosTestSuite) TestMonCommandTarget() {
suite.SetupConnection()
command, err := json.Marshal(
map[string]string{"prefix": "mon_status"})
assert.NoError(suite.T(), err)
buf, info, err := suite.conn.MonCommandTarget(monName, [][]byte{command})
assert.NoError(suite.T(), err)
assert.Equal(suite.T(), info, "")
var message map[string]interface{}
err = json.Unmarshal(buf, &message)
assert.NoError(suite.T(), err)
}
func (suite *RadosTestSuite) TestMonCommandTargetMalformedCommand() {
suite.SetupConnection()
command := []byte("JUNK!")
buf, info, err := suite.conn.MonCommandTarget(monName, [][]byte{command})
assert.Error(suite.T(), err)
assert.NotEqual(suite.T(), info, "")
assert.Len(suite.T(), buf, 0)
}