diff --git a/internal/util/util.go b/internal/util/util.go new file mode 100644 index 0000000..c1ad963 --- /dev/null +++ b/internal/util/util.go @@ -0,0 +1,37 @@ +package util + +import "os" + +// CephVersion type +type CephVersion int + +// Enum of known CephVersions +const ( + CephNautilus CephVersion = 14 + iota + CephOctopus + CephPacific + CephQuincy + CephUnknown +) + +// CurrentCephVersion is the current Ceph version +func CurrentCephVersion() CephVersion { + vname := os.Getenv("CEPH_VERSION") + return CephVersionOfString(vname) +} + +// CephVersionOfString converts a string to CephVersion +func CephVersionOfString(vname string) CephVersion { + switch vname { + case "nautilus": + return CephNautilus + case "octopus": + return CephOctopus + case "pacific": + return CephPacific + case "quincy": + return CephQuincy + default: + return CephUnknown + } +} diff --git a/rgw/admin/bucket_test.go b/rgw/admin/bucket_test.go index c709394..23b2f48 100644 --- a/rgw/admin/bucket_test.go +++ b/rgw/admin/bucket_test.go @@ -4,21 +4,13 @@ import ( "context" "errors" "net/http" - "os" "testing" + "github.com/ceph/go-ceph/internal/util" "github.com/stretchr/testify/assert" ) -func skipIfQuincy(t *testing.T) { - vname := os.Getenv("CEPH_VERSION") - if vname == "quincy" { - t.Skipf("disabled on ceph %s", vname) - } -} - func (suite *RadosGWTestSuite) TestBucket() { - skipIfQuincy(suite.T()) suite.SetupConnection() co, err := New(suite.endpoint, suite.accessKey, suite.secretKey, newDebugHTTPClient(http.DefaultClient)) assert.NoError(suite.T(), err) @@ -60,7 +52,10 @@ func (suite *RadosGWTestSuite) TestBucket() { suite.T().Run("remove non-existing bucket", func(t *testing.T) { err := co.RemoveBucket(context.Background(), Bucket{Bucket: "foo"}) assert.Error(suite.T(), err) - // TODO: report to rgw team, this should return NoSuchBucket? - assert.True(suite.T(), errors.Is(err, ErrNoSuchKey)) + if util.CurrentCephVersion() <= util.CephOctopus { + assert.True(suite.T(), errors.Is(err, ErrNoSuchKey)) + } else { + assert.True(suite.T(), errors.Is(err, ErrNoSuchBucket)) + } }) }