Skip to content

Commit 4924ade

Browse files
authored
[4.0.0 backport] CBG-4916 use standard rosmar SourceID when not using go test (#7813)
1 parent 4cfe78d commit 4924ade

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

base/bucket.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -540,21 +540,25 @@ func RequireNoBucketTTL(ctx context.Context, b Bucket) error {
540540

541541
// GetSourceID returns the source ID for a bucket.
542542
func GetSourceID(ctx context.Context, bucket Bucket) (string, error) {
543-
// for rosmar bucket and testing, use the bucket name as the source ID to make it easier to identify the source
543+
bucketUUID, err := bucket.UUID()
544+
if err != nil {
545+
return "", err
546+
}
544547
gocbBucket, err := AsGocbV2Bucket(bucket)
545548
if err != nil {
546-
return bucket.GetName(), nil
549+
// for rosmar bucket and testing, use the bucket name as the source ID to make it easier to identify the source
550+
if underGoTest() {
551+
return bucket.GetName(), nil
552+
}
553+
serverUUID := ""
554+
return CreateEncodedSourceID(bucketUUID, serverUUID)
547555
}
548556

549557
// If not overwriting the source ID, for rosmar, serverUUID would be ""
550558
serverUUID, err := GetServerUUID(ctx, gocbBucket)
551559
if err != nil {
552560
return "", err
553561
}
554-
bucketUUID, err := bucket.UUID()
555-
if err != nil {
556-
return "", err
557-
}
558562
return CreateEncodedSourceID(bucketUUID, serverUUID)
559563
}
560564

base/util_testing.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,3 +1013,8 @@ func RequireXattrNotFound(t testing.TB, dataStore sgbucket.DataStore, docID stri
10131013
require.Error(t, err, fmt.Sprintf("Expected xattr %q to not be found on document %q but has contents %s", xattrName, docID, xattrs[xattrName]))
10141014
RequireXattrNotFoundError(t, err)
10151015
}
1016+
1017+
// underGoTest returns true if the tests are being run via 'go test'
1018+
func underGoTest() bool {
1019+
return testing.Testing()
1020+
}

0 commit comments

Comments
 (0)