Skip to content

Commit 979dc0f

Browse files
committed
roachtest: wait 10m for initial lease preference conformance
The `lease-preferences/*` roachtests wait for lease preferences to be initially conformed before purposefully forcing leases out of conformance. Its possible to the initial lease preference conformance to take up to 10 minutes (a replica scanner cycle). Allow this much time. Note the non-initial conformance should be quicker, as leases are checked on acquisition, to see whether they violate the lease preferences. Resolves: #141359 Resolves: #145055 Release note: None
1 parent cb692bc commit 979dc0f

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pkg/cmd/roachtest/tests/lease_preferences.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,9 @@ func runLeasePreferences(
172172
// waitForLessPreferred=false). This duration is used to ensure the lease
173173
// preference satisfaction is reasonably permanent.
174174
const stableDuration = 30 * time.Second
175+
// initialWaitDuration is how long the test will wait for initial lease
176+
// preference conformance. This duration is approx. a replica scanner cycle.
177+
const initialWaitDuration = 10 * time.Minute
175178

176179
numNodes := c.Spec().NodeCount
177180
allNodes := make([]int, 0, numNodes)
@@ -209,9 +212,13 @@ func runLeasePreferences(
209212
conn := c.Conn(ctx, t.L(), numNodes)
210213
defer conn.Close()
211214

212-
checkLeasePreferenceConformance := func(ctx context.Context) {
215+
checkLeasePreferenceConformance := func(ctx context.Context, initial bool) {
216+
duration := spec.postEventWaitDuration
217+
if initial {
218+
duration = initialWaitDuration
219+
}
213220
result, err := waitForLeasePreferences(
214-
ctx, t, c, spec.checkNodes, spec.waitForLessPreferred, stableDuration, spec.postEventWaitDuration)
221+
ctx, t, c, spec.checkNodes, spec.waitForLessPreferred, stableDuration, duration)
215222
require.NoError(t, err, result)
216223
require.Truef(t, !result.violating(), "violating lease preferences %s", result)
217224
if spec.waitForLessPreferred {
@@ -254,7 +261,7 @@ func runLeasePreferences(
254261
leasePreference: spec.preferences,
255262
})
256263
t.L().Printf("waiting for initial lease preference conformance")
257-
checkLeasePreferenceConformance(ctx)
264+
checkLeasePreferenceConformance(ctx, true /* initial */)
258265

259266
// Run the spec event function. The event function will move leases to
260267
// non-conforming localities.
@@ -267,7 +274,7 @@ func runLeasePreferences(
267274
// Wait for the preference conformance with some leases in non-conforming
268275
// localities.
269276
t.L().Printf("waiting for post-event lease preference conformance")
270-
checkLeasePreferenceConformance(ctx)
277+
checkLeasePreferenceConformance(ctx, false /* initial */)
271278
}
272279

273280
type leasePreferencesResult struct {

0 commit comments

Comments
 (0)