mirror of
https://github.com/ceph/go-ceph
synced 2024-12-18 20:35:33 +00:00
863d71caa5
These apis are now stable as per the stability plan. Signed-off-by: John Mulligan <jmulligan@redhat.com>
46 lines
1012 B
Go
46 lines
1012 B
Go
package rados
|
|
|
|
import (
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func (suite *RadosTestSuite) TestReadOpAssertVersion() {
|
|
suite.SetupConnection()
|
|
ta := assert.New(suite.T())
|
|
|
|
var (
|
|
oid = "TestReadOpAssertVersion"
|
|
err error
|
|
)
|
|
|
|
// Create an object.
|
|
op1 := CreateWriteOp()
|
|
defer op1.Release()
|
|
op1.Create(CreateIdempotent)
|
|
err = op1.Operate(suite.ioctx, oid, OperationNoFlag)
|
|
ta.NoError(err)
|
|
|
|
// Retrieve last object version after writing.
|
|
ver1, err := suite.ioctx.GetLastVersion()
|
|
ta.NoError(err)
|
|
|
|
// Read with version assert. It should succeed.
|
|
op2 := CreateReadOp()
|
|
defer op2.Release()
|
|
op2.AssertVersion(ver1)
|
|
err = op2.Operate(suite.ioctx, oid, OperationNoFlag)
|
|
ta.NoError(err)
|
|
|
|
// Refresh the version.
|
|
ver2, err := suite.ioctx.GetLastVersion()
|
|
ta.NoError(err)
|
|
|
|
// Read with version assert, but modify the version first.
|
|
// It should fail.
|
|
op3 := CreateReadOp()
|
|
defer op3.Release()
|
|
op3.AssertVersion(ver2 + 1)
|
|
err = op3.Operate(suite.ioctx, oid, OperationNoFlag)
|
|
ta.Error(err)
|
|
}
|