mirror of
https://github.com/ceph/go-ceph
synced 2025-03-03 01:49:15 +00:00
rgw/admin: Add a test for API.GetInfo
Co-authored-by: Anoop C S <anoopcs@cryptolab.net> Signed-off-by: Sébastien Han <seb@redhat.com> Signed-off-by: Anoop C S <anoopcs@cryptolab.net>
This commit is contained in:
parent
936fc2deb1
commit
0ba56a3142
10
micro-osd.sh
10
micro-osd.sh
@ -164,6 +164,10 @@ launch_radosgw() {
|
||||
radosgw-admin user create --uid admin --display-name "Admin User" --caps "buckets=*;users=*;usage=read;metadata=read" --access-key="$S3_ACCESS_KEY" --secret-key="$S3_SECRET_KEY"
|
||||
}
|
||||
|
||||
launch_radosgw2() {
|
||||
radosgw-admin caps add --uid=admin --caps="info=read"
|
||||
}
|
||||
|
||||
selftest() {
|
||||
ceph --version
|
||||
ceph status
|
||||
@ -183,9 +187,12 @@ if [ -z "$FEATURESET" ] ; then
|
||||
nautilus|octopus)
|
||||
FEATURESET="mon osd mgr mds rbd-mirror rgw selftest"
|
||||
;;
|
||||
*)
|
||||
pacific)
|
||||
FEATURESET="mon osd mgr mds mds2 rbd-mirror cephfs-mirror rgw selftest"
|
||||
;;
|
||||
*)
|
||||
FEATURESET="mon osd mgr mds mds2 rbd-mirror cephfs-mirror rgw rgw2 selftest"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
@ -200,6 +207,7 @@ for fname in ${FEATURESET} ; do
|
||||
rbd-mirror) launch_rbd_mirror ;;
|
||||
cephfs-mirror) launch_cephfs_mirror ;;
|
||||
rgw|radosgw) launch_radosgw ;;
|
||||
rgw2|radosgw2) launch_radosgw2 ;;
|
||||
selftest) selftest ;;
|
||||
*)
|
||||
echo "Invalid feature: ${fname}"
|
||||
|
57
rgw/admin/info_test.go
Normal file
57
rgw/admin/info_test.go
Normal file
@ -0,0 +1,57 @@
|
||||
//go:build !(nautilus || octopus || pacific) && ceph_preview
|
||||
// +build !nautilus,!octopus,!pacific,ceph_preview
|
||||
|
||||
package admin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/ceph/go-ceph/rados"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func radosConnect(t *testing.T) *rados.Conn {
|
||||
conn, err := rados.NewConn()
|
||||
require.NoError(t, err)
|
||||
err = conn.ReadDefaultConfigFile()
|
||||
require.NoError(t, err)
|
||||
waitForRadosConn(t, conn)
|
||||
return conn
|
||||
}
|
||||
|
||||
func waitForRadosConn(t *testing.T, conn *rados.Conn) {
|
||||
var err error
|
||||
timeout := time.After(time.Second * 15)
|
||||
ch := make(chan error)
|
||||
go func(conn *rados.Conn) {
|
||||
ch <- conn.Connect()
|
||||
}(conn)
|
||||
select {
|
||||
case err = <-ch:
|
||||
case <-timeout:
|
||||
err = fmt.Errorf("timed out waiting for connect")
|
||||
}
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
func (suite *RadosGWTestSuite) TestGetInfo() {
|
||||
suite.SetupConnection()
|
||||
co, err := New(suite.endpoint, suite.accessKey, suite.secretKey, newDebugHTTPClient(http.DefaultClient))
|
||||
assert.NoError(suite.T(), err)
|
||||
|
||||
suite.T().Run("test get rgw cluster/endpoint information", func(t *testing.T) {
|
||||
info, err := co.GetInfo(context.Background())
|
||||
assert.NoError(suite.T(), err)
|
||||
assert.Equal(suite.T(), "rados", info.InfoSpec.StorageBackends[0].Name)
|
||||
conn := radosConnect(suite.T())
|
||||
fsid, err := conn.GetFSID()
|
||||
assert.NoError(suite.T(), err)
|
||||
assert.Equal(suite.T(), fsid, info.InfoSpec.StorageBackends[0].ClusterID)
|
||||
conn.Shutdown()
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user