rbd: add exclusive-lock and journaling image features for rbd image

Current rbd plugin only supports the layering feature
for rbd image. Add exclusive-lock and journaling image
features for the rbd.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
Signed-off-by: woohhan <woohyung_han@tmax.co.kr>
This commit is contained in:
Madhu Rajanna
2021-03-11 11:58:48 +05:30
committed by mergify[bot]
parent 2f6fca0862
commit d8f7b38d3d
5 changed files with 170 additions and 38 deletions

View File

@ -21,6 +21,7 @@ import (
"testing"
librbd "github.com/ceph/go-ceph/rbd"
"github.com/stretchr/testify/assert"
)
func TestHasSnapshotFeature(t *testing.T) {
@ -42,3 +43,86 @@ func TestHasSnapshotFeature(t *testing.T) {
}
}
}
func TestValidateImageFeatures(t *testing.T) {
tests := []struct {
imageFeatures string
rbdVol *rbdVolume
isErr bool
errMsg string
}{
{
"layering",
&rbdVolume{
Mounter: rbdDefaultMounter,
},
false,
"",
},
{
"layering",
&rbdVolume{
Mounter: rbdNbdMounter,
},
false,
"",
},
{
"layering,exclusive-lock,journaling",
&rbdVolume{
Mounter: rbdNbdMounter,
},
false,
"",
},
{
"layering,journaling",
&rbdVolume{
Mounter: rbdNbdMounter,
},
true,
"feature journaling requires exclusive-lock to be set",
},
{
"layering,exclusive-lock,journaling",
&rbdVolume{
Mounter: rbdDefaultMounter,
},
true,
"feature exclusive-lock requires rbd-nbd for mounter",
},
{
"layering,exclusive-lock,journaling",
&rbdVolume{
Mounter: rbdDefaultMounter,
},
true,
"feature exclusive-lock requires rbd-nbd for mounter",
},
{
"layering,exclusive-loc,journaling",
&rbdVolume{
Mounter: rbdNbdMounter,
},
true,
"invalid feature exclusive-loc",
},
{
"ayering",
&rbdVolume{
Mounter: rbdDefaultMounter,
},
true,
"invalid feature ayering",
},
}
for _, test := range tests {
err := test.rbdVol.validateImageFeatures(test.imageFeatures)
if test.isErr {
assert.EqualError(t, err, test.errMsg)
continue
}
assert.Nil(t, err)
}
}