-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move a function out of the proposal buffer, so it can be shared between the proposal buffer and the side transport. Release note: None
- Loading branch information
1 parent
3ddfe0d
commit 8392017
Showing
4 changed files
with
94 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package kvserver | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cockroachdb/cockroach/pkg/roachpb" | ||
"github.com/cockroachdb/cockroach/pkg/util/hlc" | ||
"github.com/cockroachdb/cockroach/pkg/util/leaktest" | ||
"github.com/cockroachdb/cockroach/pkg/util/log" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestClosedTimestampTargetByPolicy(t *testing.T) { | ||
defer leaktest.AfterTest(t)() | ||
defer log.Scope(t).Close(t) | ||
|
||
const nowNanos = 100 | ||
const maxOffsetNanos = 20 | ||
manualClock := hlc.NewManualClock(nowNanos) | ||
clock := hlc.NewClock(manualClock.UnixNano, maxOffsetNanos) | ||
const lagTargetNanos = 10 | ||
|
||
for _, tc := range []struct { | ||
rangePolicy roachpb.RangeClosedTimestampPolicy | ||
expClosedTSTarget hlc.Timestamp | ||
}{ | ||
{ | ||
rangePolicy: roachpb.LAG_BY_CLUSTER_SETTING, | ||
expClosedTSTarget: hlc.Timestamp{WallTime: nowNanos - lagTargetNanos}, | ||
}, | ||
{ | ||
rangePolicy: roachpb.LEAD_FOR_GLOBAL_READS, | ||
expClosedTSTarget: hlc.Timestamp{WallTime: nowNanos - lagTargetNanos}, | ||
// TODO(andrei, nvanbenschoten): What we should be expecting here is the following, once | ||
// the propBuf starts properly implementing this timestamp closing policy: | ||
// expClosedTSTarget: hlc.Timestamp{WallTime: nowNanos + 2*maxOffsetNanos, Synthetic: true}, | ||
}, | ||
} { | ||
t.Run(tc.rangePolicy.String(), func(t *testing.T) { | ||
require.Equal(t, tc.expClosedTSTarget, closedTimestampTargetByPolicy(clock.NowAsClockTimestamp(), tc.rangePolicy, lagTargetNanos)) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters