@@ -622,7 +622,7 @@ func RunTestPreconditionalDeleteWithOnlySuggestionPass(ctx context.Context, t *t
622
622
expectNoDiff (t , "incorrect pod:" , updatedPod , out )
623
623
}
624
624
625
- func RunTestList (ctx context.Context , t * testing.T , store storage.Interface , compaction Compaction , ignoreWatchCacheTests bool ) {
625
+ func RunTestList (ctx context.Context , t * testing.T , store storage.Interface , increaseRV IncreaseRVFunc , ignoreWatchCacheTests bool ) {
626
626
initialRV , createdPods , updatedPod , err := seedMultiLevelData (ctx , store )
627
627
if err != nil {
628
628
t .Fatal (err )
@@ -648,10 +648,8 @@ func RunTestList(ctx context.Context, t *testing.T, store storage.Interface, com
648
648
pod := obj .(* example.Pod )
649
649
return nil , fields.Set {"metadata.name" : pod .Name , "spec.nodeName" : pod .Spec .NodeName }, nil
650
650
}
651
- // Use compact to increase etcd global revision without changes to any resources.
652
- // The increase in resources version comes from Kubernetes compaction updating hidden key.
653
- // Used to test consistent List to confirm it returns latest etcd revision.
654
- compaction (ctx , t , initialRV )
651
+ // Increase RV to test consistent List.
652
+ increaseRV (ctx , t )
655
653
currentRV := fmt .Sprintf ("%d" , continueRV + 1 )
656
654
657
655
tests := []struct {
@@ -1591,15 +1589,15 @@ func ExpectContinueMatches(t *testing.T, expect, got string) {
1591
1589
t .Errorf ("expected continue token: %s, got: %s" , expectDecoded , gotDecoded )
1592
1590
}
1593
1591
1594
- func RunTestConsistentList (ctx context.Context , t * testing.T , store storage.Interface , compaction Compaction , cacheEnabled , consistentReadsSupported bool ) {
1592
+ func RunTestConsistentList (ctx context.Context , t * testing.T , store storage.Interface , increaseRV IncreaseRVFunc , cacheEnabled , consistentReadsSupported bool ) {
1595
1593
outPod := & example.Pod {}
1596
1594
inPod := & example.Pod {ObjectMeta : metav1.ObjectMeta {Namespace : "default" , Name : "foo" }}
1597
1595
err := store .Create (ctx , computePodKey (inPod ), inPod , outPod , 0 )
1598
1596
if err != nil {
1599
1597
t .Errorf ("Unexpected error: %v" , err )
1600
1598
}
1601
1599
lastObjecRV := outPod .ResourceVersion
1602
- compaction (ctx , t , outPod . ResourceVersion )
1600
+ increaseRV (ctx , t )
1603
1601
parsedRV , _ := strconv .Atoi (outPod .ResourceVersion )
1604
1602
currentRV := fmt .Sprintf ("%d" , parsedRV + 1 )
1605
1603
@@ -1609,7 +1607,7 @@ func RunTestConsistentList(ctx context.Context, t *testing.T, store storage.Inte
1609
1607
}
1610
1608
1611
1609
secondNonConsistentReadRV := lastObjecRV
1612
- if consistentReadsSupported {
1610
+ if ! cacheEnabled || consistentReadsSupported {
1613
1611
secondNonConsistentReadRV = currentRV
1614
1612
}
1615
1613
@@ -1749,7 +1747,7 @@ func seedMultiLevelData(ctx context.Context, store storage.Interface) (initialRV
1749
1747
return initialRV , created , updated , nil
1750
1748
}
1751
1749
1752
- func RunTestGetListNonRecursive (ctx context.Context , t * testing.T , compaction Compaction , store storage.Interface ) {
1750
+ func RunTestGetListNonRecursive (ctx context.Context , t * testing.T , increaseRV IncreaseRVFunc , store storage.Interface ) {
1753
1751
key , prevStoredObj := testPropagateStore (ctx , t , store , & example.Pod {ObjectMeta : metav1.ObjectMeta {Name : "foo" , Namespace : "test-ns" }})
1754
1752
prevRV , _ := strconv .Atoi (prevStoredObj .ResourceVersion )
1755
1753
@@ -1763,10 +1761,8 @@ func RunTestGetListNonRecursive(ctx context.Context, t *testing.T, compaction Co
1763
1761
t .Fatalf ("update failed: %v" , err )
1764
1762
}
1765
1763
objRV , _ := strconv .Atoi (storedObj .ResourceVersion )
1766
- // Use compact to increase etcd global revision without changes to any resources.
1767
- // The increase in resources version comes from Kubernetes compaction updating hidden key.
1768
- // Used to test consistent List to confirm it returns latest etcd revision.
1769
- compaction (ctx , t , prevStoredObj .ResourceVersion )
1764
+ // Increase RV to test consistent List.
1765
+ increaseRV (ctx , t )
1770
1766
1771
1767
tests := []struct {
1772
1768
name string
@@ -2320,6 +2316,7 @@ func RunTestListContinuationWithFilter(ctx context.Context, t *testing.T, store
2320
2316
}
2321
2317
2322
2318
type Compaction func (ctx context.Context , t * testing.T , resourceVersion string )
2319
+ type IncreaseRVFunc func (ctx context.Context , t * testing.T )
2323
2320
2324
2321
func RunTestListInconsistentContinuation (ctx context.Context , t * testing.T , store storage.Interface , compaction Compaction ) {
2325
2322
if compaction == nil {
0 commit comments