mirror of
https://github.com/ceph/go-ceph
synced 2024-12-23 14:45:42 +00:00
rbd: convert uses of RbdImageOptionX to ImageOptionX
Signed-off-by: John Mulligan <jmulligan@redhat.com>
This commit is contained in:
parent
6d77dc97dc
commit
51827ead4e
@ -25,12 +25,12 @@ func TestGetFeatures(t *testing.T) {
|
||||
name := GetUUID()
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
err = options.SetUint64(RbdImageOptionFeatures, FeatureLayering|FeatureStripingV2)
|
||||
err = options.SetUint64(ImageOptionFeatures, FeatureLayering|FeatureStripingV2)
|
||||
require.NoError(t, err)
|
||||
// FeatureStripingV2 only works with additional arguments
|
||||
err = options.SetUint64(RbdImageOptionStripeUnit, 1024*1024)
|
||||
err = options.SetUint64(ImageOptionStripeUnit, 1024*1024)
|
||||
require.NoError(t, err)
|
||||
err = options.SetUint64(RbdImageOptionStripeCount, 4)
|
||||
err = options.SetUint64(ImageOptionStripeCount, 4)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = CreateImage(ioctx, name, 16*1024*1024, options)
|
||||
@ -90,7 +90,7 @@ func TestUpdateFeatures(t *testing.T) {
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
// test with FeatureExclusiveLock as that is mutable
|
||||
err = options.SetUint64(RbdImageOptionFeatures, FeatureExclusiveLock)
|
||||
err = options.SetUint64(ImageOptionFeatures, FeatureExclusiveLock)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = CreateImage(ioctx, name, 16*1024*1024, options)
|
||||
|
@ -13,169 +13,169 @@ func TestRbdOptions(t *testing.T) {
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
|
||||
err = options.SetUint64(RbdImageOptionFormat, 1)
|
||||
err = options.SetUint64(ImageOptionFormat, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionFormat, "string not allowed")
|
||||
err = options.SetString(ImageOptionFormat, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionFormat)
|
||||
i, err = options.GetUint64(ImageOptionFormat)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionFormat)
|
||||
_, err = options.GetString(ImageOptionFormat)
|
||||
assert.Error(t, err)
|
||||
set, err := options.IsSet(RbdImageOptionFormat)
|
||||
set, err := options.IsSet(ImageOptionFormat)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionFormat)
|
||||
err = options.Unset(ImageOptionFormat)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionFeatures, 1)
|
||||
err = options.SetUint64(ImageOptionFeatures, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionFeatures, "string not allowed")
|
||||
err = options.SetString(ImageOptionFeatures, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionFeatures)
|
||||
i, err = options.GetUint64(ImageOptionFeatures)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionFeatures)
|
||||
_, err = options.GetString(ImageOptionFeatures)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionFeatures)
|
||||
set, err = options.IsSet(ImageOptionFeatures)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionFeatures)
|
||||
err = options.Unset(ImageOptionFeatures)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionOrder, 1)
|
||||
err = options.SetUint64(ImageOptionOrder, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionOrder, "string not allowed")
|
||||
err = options.SetString(ImageOptionOrder, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionOrder)
|
||||
i, err = options.GetUint64(ImageOptionOrder)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionOrder)
|
||||
_, err = options.GetString(ImageOptionOrder)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionOrder)
|
||||
set, err = options.IsSet(ImageOptionOrder)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionOrder)
|
||||
err = options.Unset(ImageOptionOrder)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionStripeUnit, 1)
|
||||
err = options.SetUint64(ImageOptionStripeUnit, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionStripeUnit, "string not allowed")
|
||||
err = options.SetString(ImageOptionStripeUnit, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionStripeUnit)
|
||||
i, err = options.GetUint64(ImageOptionStripeUnit)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionStripeUnit)
|
||||
_, err = options.GetString(ImageOptionStripeUnit)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionStripeUnit)
|
||||
set, err = options.IsSet(ImageOptionStripeUnit)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionStripeUnit)
|
||||
err = options.Unset(ImageOptionStripeUnit)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionStripeCount, 1)
|
||||
err = options.SetUint64(ImageOptionStripeCount, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionStripeCount, "string not allowed")
|
||||
err = options.SetString(ImageOptionStripeCount, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionStripeCount)
|
||||
i, err = options.GetUint64(ImageOptionStripeCount)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionStripeCount)
|
||||
_, err = options.GetString(ImageOptionStripeCount)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionStripeCount)
|
||||
set, err = options.IsSet(ImageOptionStripeCount)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionStripeCount)
|
||||
err = options.Unset(ImageOptionStripeCount)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionJournalOrder, 1)
|
||||
err = options.SetUint64(ImageOptionJournalOrder, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionJournalOrder, "string not allowed")
|
||||
err = options.SetString(ImageOptionJournalOrder, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionJournalOrder)
|
||||
i, err = options.GetUint64(ImageOptionJournalOrder)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionJournalOrder)
|
||||
_, err = options.GetString(ImageOptionJournalOrder)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionJournalOrder)
|
||||
set, err = options.IsSet(ImageOptionJournalOrder)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionJournalOrder)
|
||||
err = options.Unset(ImageOptionJournalOrder)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionJournalSplayWidth, 1)
|
||||
err = options.SetUint64(ImageOptionJournalSplayWidth, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionJournalSplayWidth, "string not allowed")
|
||||
err = options.SetString(ImageOptionJournalSplayWidth, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionJournalSplayWidth)
|
||||
i, err = options.GetUint64(ImageOptionJournalSplayWidth)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionJournalSplayWidth)
|
||||
_, err = options.GetString(ImageOptionJournalSplayWidth)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionJournalSplayWidth)
|
||||
set, err = options.IsSet(ImageOptionJournalSplayWidth)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionJournalSplayWidth)
|
||||
err = options.Unset(ImageOptionJournalSplayWidth)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionJournalPool, 1)
|
||||
err = options.SetUint64(ImageOptionJournalPool, 1)
|
||||
assert.Error(t, err)
|
||||
err = options.SetString(RbdImageOptionJournalPool, "journal")
|
||||
err = options.SetString(ImageOptionJournalPool, "journal")
|
||||
assert.NoError(t, err)
|
||||
_, err = options.GetUint64(RbdImageOptionJournalPool)
|
||||
_, err = options.GetUint64(ImageOptionJournalPool)
|
||||
assert.Error(t, err)
|
||||
s, err = options.GetString(RbdImageOptionJournalPool)
|
||||
s, err = options.GetString(ImageOptionJournalPool)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, s == "journal")
|
||||
set, err = options.IsSet(RbdImageOptionJournalPool)
|
||||
set, err = options.IsSet(ImageOptionJournalPool)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionJournalPool)
|
||||
err = options.Unset(ImageOptionJournalPool)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionFeaturesSet, 1)
|
||||
err = options.SetUint64(ImageOptionFeaturesSet, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionFeaturesSet, "string not allowed")
|
||||
err = options.SetString(ImageOptionFeaturesSet, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionFeaturesSet)
|
||||
i, err = options.GetUint64(ImageOptionFeaturesSet)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionFeaturesSet)
|
||||
_, err = options.GetString(ImageOptionFeaturesSet)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionFeaturesSet)
|
||||
set, err = options.IsSet(ImageOptionFeaturesSet)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionFeaturesSet)
|
||||
err = options.Unset(ImageOptionFeaturesSet)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionFeaturesClear, 1)
|
||||
err = options.SetUint64(ImageOptionFeaturesClear, 1)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionFeaturesClear, "string not allowed")
|
||||
err = options.SetString(ImageOptionFeaturesClear, "string not allowed")
|
||||
assert.Error(t, err)
|
||||
i, err = options.GetUint64(RbdImageOptionFeaturesClear)
|
||||
i, err = options.GetUint64(ImageOptionFeaturesClear)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, i == 1)
|
||||
_, err = options.GetString(RbdImageOptionFeaturesClear)
|
||||
_, err = options.GetString(ImageOptionFeaturesClear)
|
||||
assert.Error(t, err)
|
||||
set, err = options.IsSet(RbdImageOptionFeaturesClear)
|
||||
set, err = options.IsSet(ImageOptionFeaturesClear)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionFeaturesClear)
|
||||
err = options.Unset(ImageOptionFeaturesClear)
|
||||
assert.NoError(t, err)
|
||||
|
||||
err = options.SetUint64(RbdImageOptionDataPool, 1)
|
||||
err = options.SetUint64(ImageOptionDataPool, 1)
|
||||
assert.Error(t, err)
|
||||
err = options.SetString(RbdImageOptionDataPool, "data")
|
||||
err = options.SetString(ImageOptionDataPool, "data")
|
||||
assert.NoError(t, err)
|
||||
_, err = options.GetUint64(RbdImageOptionDataPool)
|
||||
_, err = options.GetUint64(ImageOptionDataPool)
|
||||
assert.Error(t, err)
|
||||
s, err = options.GetString(RbdImageOptionDataPool)
|
||||
s, err = options.GetString(ImageOptionDataPool)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, s == "data")
|
||||
set, err = options.IsSet(RbdImageOptionDataPool)
|
||||
set, err = options.IsSet(ImageOptionDataPool)
|
||||
assert.NoError(t, err)
|
||||
assert.True(t, set)
|
||||
err = options.Unset(RbdImageOptionDataPool)
|
||||
err = options.Unset(ImageOptionDataPool)
|
||||
assert.NoError(t, err)
|
||||
|
||||
/* introduced with Ceph Mimic, can not be tested on Luminous
|
||||
@ -200,7 +200,7 @@ func TestRbdOptionsClear(t *testing.T) {
|
||||
options := NewRbdImageOptions()
|
||||
|
||||
// set at least one option
|
||||
err := options.SetUint64(RbdImageOptionFormat, 1)
|
||||
err := options.SetUint64(ImageOptionFormat, 1)
|
||||
assert.NoError(t, err)
|
||||
|
||||
empty := options.IsEmpty()
|
||||
|
@ -178,7 +178,7 @@ func TestCreateImageWithOptions(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// create image with RbdImageOptionOrder
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
name = GetUUID()
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
@ -191,7 +191,7 @@ func TestCreateImageWithOptions(t *testing.T) {
|
||||
datapool := GetUUID()
|
||||
err = conn.MakePool(datapool)
|
||||
assert.NoError(t, err)
|
||||
err = options.SetString(RbdImageOptionDataPool, datapool)
|
||||
err = options.SetString(ImageOptionDataPool, datapool)
|
||||
assert.NoError(t, err)
|
||||
name = GetUUID()
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
@ -635,7 +635,7 @@ func TestReadAt(t *testing.T) {
|
||||
name := GetUUID()
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
require.NoError(t, err)
|
||||
@ -714,7 +714,7 @@ func TestImageCopy(t *testing.T) {
|
||||
name := GetUUID()
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
require.NoError(t, err)
|
||||
@ -748,7 +748,7 @@ func TestImageCopy(t *testing.T) {
|
||||
name := GetUUID()
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
require.NoError(t, err)
|
||||
@ -784,7 +784,7 @@ func TestImageCopy(t *testing.T) {
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
require.NoError(t, err)
|
||||
@ -806,7 +806,7 @@ func TestImageCopy(t *testing.T) {
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
require.NoError(t, err)
|
||||
@ -1338,9 +1338,9 @@ func TestCloneImage(t *testing.T) {
|
||||
cloneName := "clone1"
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder))
|
||||
err = options.SetUint64(ImageOptionOrder, uint64(testImageOrder))
|
||||
assert.NoError(t, err)
|
||||
err = options.SetUint64(RbdImageOptionFeatures, 1)
|
||||
err = options.SetUint64(ImageOptionFeatures, 1)
|
||||
assert.NoError(t, err)
|
||||
err = CreateImage(ioctx, imageName, testImageSize, options)
|
||||
assert.NoError(t, err)
|
||||
@ -1361,7 +1361,7 @@ func TestCloneImage(t *testing.T) {
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionFormat, uint64(2))
|
||||
err = options.SetUint64(ImageOptionFormat, uint64(2))
|
||||
assert.NoError(t, err)
|
||||
err = CloneImage(ioctx, imageName, snapName, ioctx, cloneName, options)
|
||||
assert.NoError(t, err)
|
||||
@ -1383,7 +1383,7 @@ func TestCloneImage(t *testing.T) {
|
||||
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionFormat, uint64(2))
|
||||
err = options.SetUint64(ImageOptionFormat, uint64(2))
|
||||
assert.NoError(t, err)
|
||||
err = CloneFromImage(image, snapName, ioctx, cloneName, options)
|
||||
assert.NoError(t, err)
|
||||
@ -1400,7 +1400,7 @@ func TestCloneImage(t *testing.T) {
|
||||
t.Run("cloneFromImageInvalidCtx", func(t *testing.T) {
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err = options.SetUint64(RbdImageOptionFormat, uint64(2))
|
||||
err = options.SetUint64(ImageOptionFormat, uint64(2))
|
||||
assert.NoError(t, err)
|
||||
badImage := GetImage(nil, image.name)
|
||||
err = CloneFromImage(badImage, snapName, ioctx, cloneName, options)
|
||||
@ -1435,7 +1435,7 @@ func TestCloneImage(t *testing.T) {
|
||||
func quickCreate(ioctx *rados.IOContext, name string, size uint64, order int) error {
|
||||
options := NewRbdImageOptions()
|
||||
defer options.Destroy()
|
||||
err := options.SetUint64(RbdImageOptionOrder, uint64(order))
|
||||
err := options.SetUint64(ImageOptionOrder, uint64(order))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1455,7 +1455,7 @@ func TestGetId(t *testing.T) {
|
||||
name := GetUUID()
|
||||
options := NewRbdImageOptions()
|
||||
assert.NoError(t,
|
||||
options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder)))
|
||||
options.SetUint64(ImageOptionOrder, uint64(testImageOrder)))
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
assert.NoError(t, err)
|
||||
|
||||
@ -1493,7 +1493,7 @@ func TestOpenImageById(t *testing.T) {
|
||||
name := GetUUID()
|
||||
options := NewRbdImageOptions()
|
||||
assert.NoError(t,
|
||||
options.SetUint64(RbdImageOptionOrder, uint64(testImageOrder)))
|
||||
options.SetUint64(ImageOptionOrder, uint64(testImageOrder)))
|
||||
err = CreateImage(ioctx, name, testImageSize, options)
|
||||
assert.NoError(t, err)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user