Skip to content

Commit

Permalink
ceph: fix probable cause of intermittent fails in the manager test
Browse files Browse the repository at this point in the history
Explicitly set the length of the string parameter in json.Unmarshal method

fixes: #8669

Signed-off-by: Juan Miguel Olmo Martínez <jolmomar@redhat.com>
  • Loading branch information
jmolmo authored and mergify-bot committed Sep 20, 2021
1 parent a357db9 commit 5c75139
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions tests/integration/ceph_mgr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ func (s *CephMgrSuite) waitForOrchestrationModule() {

// Get status information
bytes := []byte(output)
logBytesInfo(bytes)

var status orchStatus
err := json.Unmarshal(bytes, &status)
err := json.Unmarshal(bytes[:len(output)], &status)
if err != nil {
logger.Error("Error getting ceph orch status")
continue
Expand Down Expand Up @@ -222,6 +224,14 @@ func (s *CephMgrSuite) TestStatus() {
assert.Equal(s.T(), status, "Backend: rook\nAvailable: Yes")
}

func logBytesInfo(bytesSlice []byte){
logger.Infof("---- bytes slice info ---")
logger.Infof("bytes: %v\n", bytesSlice)
logger.Infof("length: %d\n", len(bytesSlice))
logger.Infof("string: -->%s<--\n", string(bytesSlice))
logger.Infof("-------------------------")
}

func (s *CephMgrSuite) TestHostLs() {
logger.Info("Testing .... <ceph orch host ls>")

Expand All @@ -231,9 +241,10 @@ func (s *CephMgrSuite) TestHostLs() {
logger.Infof("output = %s", output)

hosts := []byte(output)
var hostsList []host
logBytesInfo(hosts)

err = json.Unmarshal(hosts, &hostsList)
var hostsList []host
err = json.Unmarshal(hosts[:len(output)], &hostsList)
if err != nil {
assert.Nil(s.T(), err)
}
Expand Down Expand Up @@ -265,9 +276,10 @@ func (s *CephMgrSuite) TestServiceLs() {
logger.Infof("output = %s", output)

services := []byte(output)
var servicesList []service
logBytesInfo(services)

err = json.Unmarshal(services, &servicesList)
var servicesList []service
err = json.Unmarshal(services[:len(output)], &servicesList)
assert.Nil(s.T(), err)

labelFilter := ""
Expand Down

0 comments on commit 5c75139

Please sign in to comment.