rados: add wrapper for the function rados_ioctx_get_id()

Implements GetPoolID() and test case around the same.

Signed-off-by: Mudit Agarwal <muagarwa@redhat.com>
This commit is contained in:
Mudit Agarwal 2020-07-21 12:08:05 +05:30 committed by John Mulligan
parent 2bb1b9bffc
commit 837777d3fc
2 changed files with 20 additions and 0 deletions

View File

@ -249,6 +249,15 @@ func (ioctx *IOContext) GetPoolStats() (stat PoolStat, err error) {
}, nil
}
// GetPoolID returns the pool ID associated with the I/O context.
//
// Implements:
// int64_t rados_ioctx_get_id(rados_ioctx_t io)
func (ioctx *IOContext) GetPoolID() int64 {
ret := C.rados_ioctx_get_id(ioctx.ioctx)
return int64(ret)
}
// GetPoolName returns the name of the pool associated with the I/O context.
func (ioctx *IOContext) GetPoolName() (name string, err error) {
var (

View File

@ -610,6 +610,17 @@ func (suite *RadosTestSuite) TestGetPoolStats() {
suite.T().Error("Pool stats aren't changing")
}
func (suite *RadosTestSuite) TestGetPoolID() {
suite.SetupConnection()
poolIDByName, err := suite.conn.GetPoolByName(suite.pool)
assert.NoError(suite.T(), err)
assert.NotEqual(suite.T(), int64(0), poolIDByName)
poolID := suite.ioctx.GetPoolID()
assert.Equal(suite.T(), poolIDByName, poolID)
}
func (suite *RadosTestSuite) TestGetPoolName() {
suite.SetupConnection()