Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip failing tests on Couchbase 7.6 #6731

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions base/bucket_gocb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,13 +1746,7 @@ func TestCouchbaseServerIncorrectLogin(t *testing.T) {
testBucket.BucketSpec.Server = strings.ReplaceAll(testBucket.BucketSpec.Server, "couchbase://", "couchbases://")
} else {
testBucket.BucketSpec.Server = strings.ReplaceAll(testBucket.BucketSpec.Server, "couchbases://", "couchbase://")
gocbBucket, err := AsGocbV2Bucket(testBucket)
require.NoError(t, err)
clusterCompatMajor, clusterCompatMinor, err := getClusterVersion(gocbBucket.cluster)
require.NoError(t, err)
if clusterCompatMajor == 7 && clusterCompatMinor == 6 {
t.Skip("Skipping test for Couchbase Server 7.6 due to GOCBC-1615")
}
SkipInvalidAuthForCouchbaseServer76(t)
}

// Attempt to open the bucket again using invalid creds. We should expect an error.
Expand Down
4 changes: 2 additions & 2 deletions base/main_test_bucket_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type TestBucketPool struct {

// readyBucketPool contains a buffered channel of buckets ready for use
readyBucketPool chan Bucket
cluster tbpCluster
cluster *tbpCluster
bucketReadierQueue chan tbpBucketName
bucketReadierWaitGroup *sync.WaitGroup
ctxCancelFunc context.CancelFunc
Expand Down Expand Up @@ -122,7 +122,7 @@ func NewTestBucketPoolWithOptions(ctx context.Context, bucketReadierFunc TBPBuck
useDefaultScope: options.UseDefaultScope,
}

tbp.cluster = newTestCluster(ctx, UnitTestUrl(), tbp.Logf)
tbp.cluster = newTestCluster(ctx, UnitTestUrl(), &tbp)

useCollections, err := tbp.canUseNamedCollections(ctx)
if err != nil {
Expand Down
84 changes: 33 additions & 51 deletions base/main_test_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,6 @@ import (
"github.com/couchbase/gocb/v2"
)

// tbpCluster defines the required test bucket pool cluster operations
type tbpCluster interface {
getBucketNames() ([]string, error)
insertBucket(ctx context.Context, name string, quotaMB int) error
removeBucket(name string) error
openTestBucket(ctx context.Context, name tbpBucketName, waitUntilReady time.Duration) (Bucket, error)
supportsCollections() (bool, error)
supportsMobileRBAC() (bool, error)
isServerEnterprise() (bool, error)
mobileXDCRCompatible(ctx context.Context) (bool, error)
close(context.Context) error
}

// firstServerVersionToSupportMobileXDCR this is the first server version to support Mobile XDCR feature
var firstServerVersionToSupportMobileXDCR = &ComparableBuildVersion{
epoch: 0,
Expand All @@ -40,30 +27,35 @@ var firstServerVersionToSupportMobileXDCR = &ComparableBuildVersion{

type clusterLogFunc func(ctx context.Context, format string, args ...interface{})

// newTestCluster returns a cluster based on the driver used by the defaultBucketSpec. Accepts a clusterLogFunc to support
// cluster logging within a test bucket pool context
func newTestCluster(ctx context.Context, server string, logger clusterLogFunc) tbpCluster {
return newTestClusterV2(ctx, server, logger)
}

// tbpClusterV2 implements the tbpCluster interface for a gocb v2 cluster
type tbpClusterV2 struct {
logger clusterLogFunc
server string // server address to connect to cluster
connstr string // connection string used to connect to the cluster
supportsHLV bool // Flag to indicate cluster supports Mobile XDCR
// tbpCluster represents a gocb v2 cluster
type tbpCluster struct {
logger clusterLogFunc
server string // server address to connect to cluster
connstr string // connection string used to connect to the cluster
supportsHLV bool // Flag to indicate cluster supports Mobile XDCR
majorVersion int
minorVersion int
version string
// cluster can be used to perform cluster-level operations (but not bucket-level operations)
cluster *gocb.Cluster
}

var _ tbpCluster = &tbpClusterV2{}

func newTestClusterV2(ctx context.Context, server string, logger clusterLogFunc) *tbpClusterV2 {
tbpCluster := &tbpClusterV2{
logger: logger,
// newTestCluster returns a cluster based on the driver used by the defaultBucketSpec.
func newTestCluster(ctx context.Context, server string, tbp *TestBucketPool) *tbpCluster {
tbpCluster := &tbpCluster{
logger: tbp.Logf,
server: server,
}
tbpCluster.cluster, tbpCluster.connstr = getGocbClusterForTest(ctx, server)
metadata, err := tbpCluster.cluster.Internal().GetNodesMetadata(&gocb.GetNodesMetadataOptions{})
if err != nil {
tbp.Fatalf(ctx, "Couldn't get cluster metadata: %v", err)
}
tbpCluster.version = metadata[0].Version
tbpCluster.majorVersion, tbpCluster.minorVersion, err = getClusterVersion(tbpCluster.cluster)
if err != nil {
tbp.Fatalf(ctx, "Couldn't get cluster version: %v", err)
}
return tbpCluster
}

Expand Down Expand Up @@ -113,19 +105,14 @@ func getGocbClusterForTest(ctx context.Context, server string) (*gocb.Cluster, s

// isServerEnterprise returns true if the connected returns true if the connected couchbase server
// instance is Enterprise edition And false for Community edition
func (c *tbpClusterV2) isServerEnterprise() (bool, error) {
metadata, err := c.cluster.Internal().GetNodesMetadata(&gocb.GetNodesMetadataOptions{})
if err != nil {
return false, err
}

if strings.Contains(metadata[0].Version, "enterprise") {
func (c *tbpCluster) isServerEnterprise() (bool, error) {
if strings.Contains(c.version, "enterprise") {
return true, nil
}
return false, nil
}

func (c *tbpClusterV2) getBucketNames() ([]string, error) {
func (c *tbpCluster) getBucketNames() ([]string, error) {

bucketSettings, err := c.cluster.Buckets().GetAllBuckets(nil)
if err != nil {
Expand All @@ -140,7 +127,7 @@ func (c *tbpClusterV2) getBucketNames() ([]string, error) {
return names, nil
}

func (c *tbpClusterV2) insertBucket(ctx context.Context, name string, quotaMB int) error {
func (c *tbpCluster) insertBucket(ctx context.Context, name string, quotaMB int) error {

settings := gocb.CreateBucketSettings{
BucketSettings: gocb.BucketSettings{
Expand All @@ -158,12 +145,12 @@ func (c *tbpClusterV2) insertBucket(ctx context.Context, name string, quotaMB in
return c.cluster.Buckets().CreateBucket(settings, options)
}

func (c *tbpClusterV2) removeBucket(name string) error {
func (c *tbpCluster) removeBucket(name string) error {
return c.cluster.Buckets().DropBucket(name, nil)
}

// openTestBucket opens the bucket of the given name for the gocb cluster in the given TestBucketPool.
func (c *tbpClusterV2) openTestBucket(ctx context.Context, testBucketName tbpBucketName, waitUntilReady time.Duration) (Bucket, error) {
func (c *tbpCluster) openTestBucket(ctx context.Context, testBucketName tbpBucketName, waitUntilReady time.Duration) (Bucket, error) {

bucketCluster, connstr := getGocbClusterForTest(ctx, c.server)

Expand All @@ -182,7 +169,7 @@ func (c *tbpClusterV2) openTestBucket(ctx context.Context, testBucketName tbpBuc
return bucketFromSpec, nil
}

func (c *tbpClusterV2) close(ctx context.Context) error {
func (c *tbpCluster) close(ctx context.Context) error {
// no close operations needed
if c.cluster != nil {
if err := c.cluster.Close(nil); err != nil {
Expand All @@ -193,7 +180,7 @@ func (c *tbpClusterV2) close(ctx context.Context) error {
return nil
}

func (c *tbpClusterV2) supportsCollections() (bool, error) {
func (c *tbpCluster) supportsCollections() (bool, error) {
major, _, err := getClusterVersion(c.cluster)
if err != nil {
return false, err
Expand All @@ -202,7 +189,7 @@ func (c *tbpClusterV2) supportsCollections() (bool, error) {
}

// supportsMobileRBAC is true if running couchbase server with all Sync Gateway roles
func (c *tbpClusterV2) supportsMobileRBAC() (bool, error) {
func (c *tbpCluster) supportsMobileRBAC() (bool, error) {
isEE, err := c.isServerEnterprise()
if err != nil {
return false, err
Expand All @@ -220,7 +207,7 @@ func (c *tbpClusterV2) supportsMobileRBAC() (bool, error) {
}

// mobileXDCRCompatible checks if a cluster is mobile XDCR compatible, a cluster must be enterprise edition AND > 7.6.1
func (c *tbpClusterV2) mobileXDCRCompatible(ctx context.Context) (bool, error) {
func (c *tbpCluster) mobileXDCRCompatible(ctx context.Context) (bool, error) {
enterprise, err := c.isServerEnterprise()
if err != nil {
return false, err
Expand All @@ -229,14 +216,9 @@ func (c *tbpClusterV2) mobileXDCRCompatible(ctx context.Context) (bool, error) {
return false, nil
}

metadata, err := c.cluster.Internal().GetNodesMetadata(&gocb.GetNodesMetadataOptions{})
if err != nil {
return false, err
}

// take server version, server version will be the first 5 character of version string
// in the form of x.x.x
vrs := metadata[0].Version[:5]
vrs := c.version[:5]

// convert the above string into a comparable string
version, err := NewComparableBuildVersionFromString(vrs)
Expand Down
10 changes: 10 additions & 0 deletions base/util_testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,16 @@ func SkipImportTestsIfNotEnabled(t *testing.T) {
}
}

// SkipInvalidAuthForCouchbaseServer76 temporarily skips test on Couchbase Server 7.6 until invalid credentials return ErrAuthenticationFailure.
func SkipInvalidAuthForCouchbaseServer76(t *testing.T) {
if UnitTestUrlIsWalrus() {
return
}
if GTestBucketPool.cluster.majorVersion == 7 && GTestBucketPool.cluster.minorVersion == 6 {
t.Skip("Skipping test for invalid credentials with Couchbase Server 7.6 due to GOCBC-1615")
}
}

// CreateBucketScopesAndCollections will create the given scopes and collections within the given BucketSpec.
func CreateBucketScopesAndCollections(ctx context.Context, bucketSpec BucketSpec, scopes map[string][]string) error {
atLeastOneScope := false
Expand Down
2 changes: 1 addition & 1 deletion rest/adminapitest/admin_api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3183,7 +3183,6 @@ func TestConfigsIncludeDefaults(t *testing.T) {

func TestLegacyCredentialInheritance(t *testing.T) {
rest.RequireBucketSpecificCredentials(t)

base.SetUpTestLogging(t, base.LevelInfo, base.KeyHTTP)

ctx := base.TestCtx(t)
Expand Down Expand Up @@ -3921,6 +3920,7 @@ func TestTombstoneCompactionPurgeInterval(t *testing.T) {
// Make sure per DB credentials override per bucket credentials
func TestPerDBCredsOverride(t *testing.T) {
rest.RequireBucketSpecificCredentials(t)
base.SkipInvalidAuthForCouchbaseServer76(t)

ctx := base.TestCtx(t)
// Get test bucket
Expand Down
Loading