Skip to content

Commit 58c8eb1

Browse files
committed
CBG-5558 remove TestsUseXattrs code
1 parent 769dfca commit 58c8eb1

47 files changed

Lines changed: 175 additions & 915 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

base/bootstrap_test.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@ func TestBootstrapRefCounting(t *testing.T) {
5252
assert.Equal(c, int32(GTestBucketPool.numBuckets), GTestBucketPool.stats.TotalBucketInitCount.Load())
5353
}, 2*time.Minute, 5*time.Millisecond) // Wait for bucket pool to be initialized, since GetConfigBuckets requires equal buckets to TestBucketPool.numBuckets
5454

55+
bootstrapConfigInXattrs := true
5556
var perBucketCredentialsConfig map[string]*CredentialsConfig
56-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), perBucketCredentialsConfig, TestUseXattrs(), false, CachedClusterConnections)
57+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), perBucketCredentialsConfig, bootstrapConfigInXattrs, false, CachedClusterConnections)
5758
require.NoError(t, err)
5859
defer cluster.Close()
5960
require.NotNil(t, cluster)
@@ -145,7 +146,9 @@ func newTestBootstrapConnection(t *testing.T) BootstrapConnection {
145146
t.Cleanup(cluster.Close)
146147
return cluster
147148
}
148-
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, TestUseXattrs(), false, CachedClusterConnections)
149+
150+
bootstrapConfigInXattrs := true
151+
cluster, err := NewCouchbaseCluster(ctx, TestClusterSpec(t), nil, bootstrapConfigInXattrs, false, CachedClusterConnections)
149152
require.NoError(t, err)
150153
t.Cleanup(cluster.Close)
151154
return cluster

base/bucket_gocb_test.go

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -505,18 +505,8 @@ func TestTouchCASSemantics(t *testing.T) {
505505
require.NotEqual(t, getTouchCAS, clearTouchCAS, "Touch should bump CAS when clearing TTL")
506506
}
507507

508-
func SkipXattrTestsIfNotEnabled(t *testing.T) {
509-
510-
if !TestUseXattrs() {
511-
t.Skip("XATTR based tests not enabled. Enable via SG_TEST_USE_XATTRS=true environment variable")
512-
}
513-
}
514-
515508
// TestXattrWriteCasSimple. Validates basic write of document with xattr, and retrieval of the same doc w/ xattr.
516509
func TestXattrWriteCasSimple(t *testing.T) {
517-
518-
SkipXattrTestsIfNotEnabled(t)
519-
520510
ctx := TestCtx(t)
521511
bucket := GetTestBucket(t)
522512
defer bucket.Close(ctx)
@@ -582,9 +572,6 @@ func TestXattrWriteCasSimple(t *testing.T) {
582572

583573
// TestXattrWriteCasUpsert. Validates basic write of document with xattr, retrieval of the same doc w/ xattr, update of the doc w/ xattr, retrieval of the doc w/ xattr.
584574
func TestXattrWriteCasUpsert(t *testing.T) {
585-
586-
SkipXattrTestsIfNotEnabled(t)
587-
588575
ctx := TestCtx(t)
589576
bucket := GetTestBucket(t)
590577
defer bucket.Close(ctx)
@@ -647,9 +634,6 @@ func TestXattrWriteCasUpsert(t *testing.T) {
647634

648635
// TestXattrWriteCasWithXattrCasCheck. Validates cas check when using WriteCasWithXattr
649636
func TestXattrWriteCasWithXattrCasCheck(t *testing.T) {
650-
651-
SkipXattrTestsIfNotEnabled(t)
652-
653637
ctx := TestCtx(t)
654638
bucket := GetTestBucket(t)
655639
defer bucket.Close(ctx)
@@ -710,8 +694,6 @@ func TestXattrWriteCasWithXattrCasCheck(t *testing.T) {
710694
}
711695

712696
func TestMultiXattrRoundtrip(t *testing.T) {
713-
SkipXattrTestsIfNotEnabled(t)
714-
715697
ctx := TestCtx(t)
716698
bucket := GetTestBucket(t)
717699
defer bucket.Close(ctx)
@@ -737,9 +719,6 @@ func TestMultiXattrRoundtrip(t *testing.T) {
737719

738720
// TestWriteCasXATTRRaw. Validates basic write of document and xattr as raw bytes.
739721
func TestXattrWriteCasRaw(t *testing.T) {
740-
741-
SkipXattrTestsIfNotEnabled(t)
742-
743722
ctx := TestCtx(t)
744723
bucket := GetTestBucket(t)
745724
defer bucket.Close(ctx)
@@ -777,13 +756,10 @@ func TestXattrWriteCasRaw(t *testing.T) {
777756

778757
// TestWriteCasTombstoneResurrect. Verifies writing a new document body and xattr to a logically deleted document (xattr still exists)
779758
func TestXattrWriteCasTombstoneResurrect(t *testing.T) {
780-
781759
if UnitTestUrlIsWalrus() {
782760
t.Skip("Test requires Couchbase Server bucket when using xattrs")
783761
}
784762

785-
SkipXattrTestsIfNotEnabled(t)
786-
787763
ctx := TestCtx(t)
788764
bucket := GetTestBucket(t)
789765
defer bucket.Close(ctx)
@@ -847,11 +823,8 @@ func TestXattrWriteCasTombstoneResurrect(t *testing.T) {
847823

848824
// TestXattrWriteCasTombstoneUpdate. Validates update of xattr on logically deleted document.
849825
func TestXattrWriteCasTombstoneUpdate(t *testing.T) {
850-
851826
t.Skip("Test does not pass with errors: https://gist.github.com/tleyden/d261fe2b92bdaaa6e78f9f1c00fdfd58. Needs investigation")
852827

853-
SkipXattrTestsIfNotEnabled(t)
854-
855828
ctx := TestCtx(t)
856829
bucket := GetTestBucket(t)
857830
defer bucket.Close(ctx)
@@ -919,8 +892,6 @@ func TestXattrWriteCasTombstoneUpdate(t *testing.T) {
919892

920893
// TestXattrWriteUpdateXattr. Validates basic write of document with xattr, and retrieval of the same doc w/ xattr.
921894
func TestXattrWriteUpdateXattr(t *testing.T) {
922-
SkipXattrTestsIfNotEnabled(t)
923-
924895
ctx := TestCtx(t)
925896
bucket := GetTestBucket(t)
926897
defer bucket.Close(ctx)
@@ -1019,8 +990,6 @@ func TestXattrWriteUpdateXattr(t *testing.T) {
1019990
}
1020991

1021992
func TestWriteUpdateWithXattrUserXattr(t *testing.T) {
1022-
SkipXattrTestsIfNotEnabled(t)
1023-
1024993
ctx := TestCtx(t)
1025994
bucket := GetTestBucket(t)
1026995
defer bucket.Close(ctx)
@@ -1091,8 +1060,6 @@ func TestWriteUpdateWithXattrUserXattr(t *testing.T) {
10911060
}
10921061

10931062
func TestWriteUpdateDeleteXattr(t *testing.T) {
1094-
SkipXattrTestsIfNotEnabled(t)
1095-
10961063
ctx := TestCtx(t)
10971064
bucket := GetTestBucket(t)
10981065
defer bucket.Close(ctx)
@@ -1128,8 +1095,6 @@ func TestWriteUpdateDeleteXattr(t *testing.T) {
11281095
}
11291096

11301097
func TestWriteUpdateDeleteXattrTombstone(t *testing.T) {
1131-
SkipXattrTestsIfNotEnabled(t)
1132-
11331098
ctx := TestCtx(t)
11341099
bucket := GetTestBucket(t)
11351100
defer bucket.Close(ctx)
@@ -1156,9 +1121,6 @@ func TestWriteUpdateDeleteXattrTombstone(t *testing.T) {
11561121

11571122
// TestXattrDeleteDocument. Delete document that has a system xattr. System XATTR should be retained and retrievable.
11581123
func TestXattrDeleteDocument(t *testing.T) {
1159-
1160-
SkipXattrTestsIfNotEnabled(t)
1161-
11621124
ctx := TestCtx(t)
11631125
bucket := GetTestBucket(t)
11641126
defer bucket.Close(ctx)
@@ -1197,9 +1159,6 @@ func TestXattrDeleteDocument(t *testing.T) {
11971159

11981160
// TestXattrDeleteDocumentUpdate. Delete a document that has a system xattr along with an xattr update.
11991161
func TestXattrDeleteDocumentUpdate(t *testing.T) {
1200-
1201-
SkipXattrTestsIfNotEnabled(t)
1202-
12031162
ctx := TestCtx(t)
12041163
bucket := GetTestBucket(t)
12051164
defer bucket.Close(ctx)
@@ -1302,9 +1261,6 @@ func TestXattrDeleteDocumentAndUpdateXattr(t *testing.T) {
13021261

13031262
// Validates tombstone of doc + xattr in a matrix of various possible previous states of the document.
13041263
func TestXattrTombstoneDocAndUpdateXattr(t *testing.T) {
1305-
1306-
SkipXattrTestsIfNotEnabled(t)
1307-
13081264
SetUpTestLogging(t, LevelDebug, KeyCRUD)
13091265

13101266
ctx := TestCtx(t)
@@ -1411,9 +1367,6 @@ func TestXattrTombstoneDocAndUpdateXattr(t *testing.T) {
14111367

14121368
// Validates deletion of doc + xattr in a matrix of various possible previous states of the document.
14131369
func TestXattrDeleteDocAndXattr(t *testing.T) {
1414-
1415-
SkipXattrTestsIfNotEnabled(t)
1416-
14171370
SetUpTestLogging(t, LevelDebug, KeyCRUD)
14181371

14191372
ctx := TestCtx(t)
@@ -1487,11 +1440,9 @@ func TestXattrDeleteDocAndXattr(t *testing.T) {
14871440
// This simulates a race condition by calling deleteWithXattrInternal() and passing a custom
14881441
// callback function
14891442
func TestDeleteWithXattrWithSimulatedRaceResurrect(t *testing.T) {
1490-
14911443
if UnitTestUrlIsWalrus() {
14921444
t.Skip("Test requires CBS in order to use deleteWithXattrInternal callback")
14931445
}
1494-
SkipXattrTestsIfNotEnabled(t)
14951446

14961447
ctx := TestCtx(t)
14971448
bucket := GetTestBucket(t)
@@ -1533,9 +1484,6 @@ func TestDeleteWithXattrWithSimulatedRaceResurrect(t *testing.T) {
15331484

15341485
// TestXattrRetrieveDocumentAndXattr.
15351486
func TestXattrRetrieveDocumentAndXattr(t *testing.T) {
1536-
1537-
SkipXattrTestsIfNotEnabled(t)
1538-
15391487
ctx := TestCtx(t)
15401488
bucket := GetTestBucket(t)
15411489
defer bucket.Close(ctx)
@@ -1625,12 +1573,10 @@ func TestXattrRetrieveDocumentAndXattr(t *testing.T) {
16251573

16261574
// TestXattrMutateDocAndXattr. Validates mutation of doc + xattr in various possible previous states of the document.
16271575
func TestXattrMutateDocAndXattr(t *testing.T) {
1628-
16291576
// Skipping on non-Couchbase until CBG-3392 is fixed
16301577
if UnitTestUrlIsWalrus() {
16311578
t.Skip("Test requires Couchbase Server bucket when using xattrs")
16321579
}
1633-
SkipXattrTestsIfNotEnabled(t)
16341580

16351581
ctx := TestCtx(t)
16361582
bucket := GetTestBucket(t)
@@ -1750,8 +1696,6 @@ func TestXattrMutateDocAndXattr(t *testing.T) {
17501696
}
17511697

17521698
func TestGetXattr(t *testing.T) {
1753-
SkipXattrTestsIfNotEnabled(t)
1754-
17551699
ctx := TestCtx(t)
17561700
bucket := GetTestBucket(t)
17571701
defer bucket.Close(ctx)
@@ -1834,8 +1778,6 @@ func TestGetXattr(t *testing.T) {
18341778
}
18351779

18361780
func TestGetXattrAndBody(t *testing.T) {
1837-
SkipXattrTestsIfNotEnabled(t)
1838-
18391781
ctx := TestCtx(t)
18401782
bucket := GetTestBucket(t)
18411783
defer bucket.Close(ctx)
@@ -2244,7 +2186,6 @@ func verifyDocDeletedXattrExists(ctx context.Context, store sgbucket.XattrStore,
22442186
}
22452187

22462188
func TestUpdateXattrWithDeleteBodyAndIsDelete(t *testing.T) {
2247-
SkipXattrTestsIfNotEnabled(t)
22482189
SetUpTestLogging(t, LevelDebug, KeyCRUD)
22492190

22502191
ctx := TestCtx(t)
@@ -2290,7 +2231,6 @@ func TestUpdateXattrWithDeleteBodyAndIsDelete(t *testing.T) {
22902231
}
22912232

22922233
func TestUserXattrGetWithXattr(t *testing.T) {
2293-
SkipXattrTestsIfNotEnabled(t)
22942234
SetUpTestLogging(t, LevelDebug, KeyCRUD)
22952235

22962236
ctx := TestCtx(t)
@@ -2322,7 +2262,6 @@ func TestUserXattrGetWithXattr(t *testing.T) {
23222262
}
23232263

23242264
func TestUserXattrGetWithXattrNil(t *testing.T) {
2325-
SkipXattrTestsIfNotEnabled(t)
23262265
SetUpTestLogging(t, LevelDebug, KeyCRUD)
23272266

23282267
ctx := TestCtx(t)
@@ -2355,7 +2294,6 @@ func TestUserXattrGetWithXattrNil(t *testing.T) {
23552294
}
23562295

23572296
func TestInsertTombstoneWithXattr(t *testing.T) {
2358-
SkipXattrTestsIfNotEnabled(t)
23592297
SetUpTestLogging(t, LevelDebug, KeyCRUD)
23602298

23612299
ctx := TestCtx(t)
@@ -2709,7 +2647,6 @@ func requireXattrNotFoundError(t *testing.T, err error) {
27092647

27102648
func TestWriteUpdateWithXattrsDocumentTombstone(t *testing.T) {
27112649
ctx := TestCtx(t)
2712-
SkipXattrTestsIfNotEnabled(t)
27132650

27142651
bucket := GetTestBucket(t)
27152652
defer bucket.Close(ctx)
@@ -3243,7 +3180,6 @@ func TestMetadataStoreUpdateAfterMigrationComplete(t *testing.T) {
32433180
// Without the shortcut: callback would observe the actual primary body (because the wrapper
32443181
// would pass nil for previous and primary.WriteUpdateWithXattrs would re-read).
32453182
func TestMetadataStoreWriteUpdateWithXattrsCASShortcut(t *testing.T) {
3246-
SkipXattrTestsIfNotEnabled(t)
32473183
ctx := TestCtx(t)
32483184
bucket := GetTestBucket(t)
32493185
defer bucket.Close(ctx)
@@ -3309,7 +3245,6 @@ func TestMetadataStoreWriteUpdateWithXattrsCASShortcut(t *testing.T) {
33093245
// returned in UpdatedDoc.Xattrs land in primary; xattrs the callback marked for deletion are
33103246
// simply not migrated (which is equivalent to "deleted" since primary never held them).
33113247
func TestMetadataStoreWriteUpdateWithXattrsHonorsXattrsToDelete(t *testing.T) {
3312-
SkipXattrTestsIfNotEnabled(t)
33133248
ctx := TestCtx(t)
33143249
bucket := GetTestBucket(t)
33153250
defer bucket.Close(ctx)
@@ -3364,7 +3299,6 @@ func TestMetadataStoreWriteUpdateWithXattrsHonorsXattrsToDelete(t *testing.T) {
33643299
// that exists only in fallback, the wrapper writes the tombstone to fallback (the only store
33653300
// that ever held the doc). Subsequent reads through the wrapper must surface not-found.
33663301
func TestMetadataStoreWriteUpdateWithXattrsTombstoneFallbackOnly(t *testing.T) {
3367-
SkipXattrTestsIfNotEnabled(t)
33683302
ctx := TestCtx(t)
33693303
bucket := GetTestBucket(t)
33703304
defer bucket.Close(ctx)
@@ -3423,7 +3357,6 @@ func TestMetadataStoreWriteUpdateWithXattrsTombstoneFallbackOnly(t *testing.T) {
34233357
// of TestMetadataStoreUpdateMigratesFromFallback: the wrapper must surface the fallback body and
34243358
// xattrs to the callback and write the result to primary.
34253359
func TestMetadataStoreWriteUpdateWithXattrsMigratesFromFallback(t *testing.T) {
3426-
SkipXattrTestsIfNotEnabled(t)
34273360
ctx := TestCtx(t)
34283361
bucket := GetTestBucket(t)
34293362
defer bucket.Close(ctx)
@@ -3584,7 +3517,6 @@ func TestMetadataStoreUpdateConcurrentFallbackWriterShadowed(t *testing.T) {
35843517
// case the tombstone lives in fallback because the doc never made it to primary), and a
35853518
// subsequent WriteUpdateWithXattrs must resurrect it — landing the live doc in primary.
35863519
func TestMetadataStoreWriteUpdateWithXattrsResurrectsAfterFallbackTombstone(t *testing.T) {
3587-
SkipXattrTestsIfNotEnabled(t)
35883520
ctx := TestCtx(t)
35893521
bucket := GetTestBucket(t)
35903522
defer bucket.Close(ctx)

base/constants.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ const (
4646

4747
TestEnvUseExistingBucket = "SG_TEST_USE_EXISTING_BUCKET"
4848

49-
// Don't use Xattrs by default, but provide the test runner a way to specify Xattr usage
50-
TestEnvSyncGatewayUseXattrs = "SG_TEST_USE_XATTRS"
51-
TestEnvSyncGatewayTrue = "True"
52-
5349
// TestEnvDisableRevCache if set to true will disable the revision cache for tests
5450
TestEnvDisableRevCache = "SG_TEST_DISABLE_REV_CACHE"
5551

base/util_testing.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,6 @@ func rosmarUriFromPath(path string) string {
195195
return uri + strings.ReplaceAll(path, `\`, `/`)
196196
}
197197

198-
// Should Sync Gateway use XATTRS functionality when running unit tests?
199-
func TestUseXattrs() bool {
200-
useXattrs, isSet := os.LookupEnv(TestEnvSyncGatewayUseXattrs)
201-
if !isSet {
202-
return true
203-
}
204-
205-
val, err := strconv.ParseBool(useXattrs)
206-
if err != nil {
207-
panic(fmt.Sprintf("unable to parse %q value %q: %v", TestEnvSyncGatewayUseXattrs, useXattrs, err))
208-
}
209-
if !val {
210-
panic(fmt.Sprintf("sync gateway %s requires xattrs to be enabled, remove env var %s=%s", ProductVersion, TestEnvSyncGatewayUseXattrs, useXattrs))
211-
}
212-
213-
return val
214-
}
215-
216198
// Should Sync Gateway skip TLS verification. Default: DefaultTestTLSSkipVerify
217199
func TestTLSSkipVerify() bool {
218200
tlsSkipVerify, isSet := os.LookupEnv(TestEnvTLSSkipVerify)
@@ -279,22 +261,6 @@ func TestSupportsMobileXDCR() bool {
279261
return GTestBucketPool.cluster.isServerEnterprise()
280262
}
281263

282-
// Should tests try to drop GSI indexes before flushing buckets?
283-
// See SG #3422
284-
func TestsShouldDropIndexes() bool {
285-
286-
// First check if the SG_TEST_USE_XATTRS env variable is set
287-
dropIndexes := os.Getenv(TestEnvSyncGatewayDropIndexes)
288-
289-
if strings.EqualFold(dropIndexes, TestEnvSyncGatewayTrue) {
290-
return true
291-
}
292-
293-
// Otherwise fallback to hardcoded default
294-
return DefaultDropIndexes
295-
296-
}
297-
298264
// TestsDisableGSI returns true if tests should be forced to avoid any GSI-specific code.
299265
func TestsDisableGSI() bool {
300266
// Disable GSI when running with Walrus
@@ -844,14 +810,6 @@ func requireCasMismatchError(t testing.TB, err error) {
844810
require.True(t, IsCasMismatch(err), "Expected error of type IsCasMismatch but got %+v\n", err)
845811
}
846812

847-
// SkipImportTestsIfNotEnabled skips test that exercise import features
848-
func SkipImportTestsIfNotEnabled(t *testing.T) {
849-
850-
if !TestUseXattrs() {
851-
t.Skip("XATTR based tests not enabled. Enable via SG_TEST_USE_XATTRS=true environment variable")
852-
}
853-
}
854-
855813
// RequireAllAssertions ensures that all assertion results were true/ok, and fails the test if any were not.
856814
// Usage:
857815
//

db/attachment_compaction_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -610,9 +610,6 @@ func WaitForConditionWithOptions(t testing.TB, successFunc func() bool, maxNumAt
610610
}
611611

612612
func CreateLegacyAttachmentDoc(t *testing.T, ctx context.Context, db *DatabaseCollectionWithUser, docID string, body []byte, attID string, attBody []byte) string {
613-
if !base.TestUseXattrs() {
614-
t.Skip("Requires xattrs")
615-
}
616613

617614
attDigest := Sha1DigestKey(attBody)
618615

0 commit comments

Comments
 (0)