rados: test functions for MonCommandTarget
@@ -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)
+}
