From 861747663b3a28c4ac1ec196ee327c2c8b7b8f64 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 20 May 2020 14:13:26 -0400 Subject: [PATCH] rados: test functions for MonCommandTarget Signed-off-by: John Mulligan --- rados/command_test.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/rados/command_test.go b/rados/command_test.go index f04f70b..223b890 100644 --- a/rados/command_test.go +++ b/rados/command_test.go @@ -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) +}