rbd: add simple test for Image.GetCreateTimestamp()

Signed-off-by: Niels de Vos <ndevos@redhat.com>
This commit is contained in:
Niels de Vos 2020-06-17 16:17:32 +02:00 committed by John Mulligan
parent 5b45db6803
commit 8ef910e0c5
1 changed files with 67 additions and 0 deletions

67
rbd/rbd_nautilus_test.go Normal file
View File

@ -0,0 +1,67 @@
// +build !luminous,!mimic
package rbd
import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestImagePropertiesNautilus(t *testing.T) {
conn := radosConnect(t)
defer conn.Shutdown()
poolname := GetUUID()
err := conn.MakePool(poolname)
require.NoError(t, err)
defer func() { assert.NoError(t, conn.DeletePool(poolname)) }()
ioctx, err := conn.OpenIOContext(poolname)
require.NoError(t, err)
defer ioctx.Destroy()
name := GetUUID()
err = quickCreate(ioctx, name, testImageSize, testImageOrder)
require.NoError(t, err)
img, err := OpenImage(ioctx, name, NoSnapshot)
require.NoError(t, err)
defer func() { assert.NoError(t, img.Remove()) }()
defer func() { assert.NoError(t, img.Close()) }()
_, err = img.GetCreateTimestamp()
assert.NoError(t, err)
}
func TestClosedImageNautilus(t *testing.T) {
conn := radosConnect(t)
defer conn.Shutdown()
poolname := GetUUID()
err := conn.MakePool(poolname)
assert.NoError(t, err)
defer func() { assert.NoError(t, conn.DeletePool(poolname)) }()
ioctx, err := conn.OpenIOContext(poolname)
require.NoError(t, err)
defer ioctx.Destroy()
name := GetUUID()
err = quickCreate(ioctx, name, testImageSize, testImageOrder)
assert.NoError(t, err)
image, err := OpenImage(ioctx, name, NoSnapshot)
assert.NoError(t, err)
defer func() { assert.NoError(t, image.Remove()) }()
// close the image
err = image.Close()
assert.NoError(t, err)
// functions should now fail with an RBDError
_, err = image.GetCreateTimestamp()
assert.Error(t, err)
}