|
| 1 | +// Copyright 2025 The Cockroach Authors. |
| 2 | +// |
| 3 | +// Use of this software is governed by the CockroachDB Software License |
| 4 | +// included in the /LICENSE file. |
| 5 | + |
| 6 | +package kvserver |
| 7 | + |
| 8 | +import ( |
| 9 | + "testing" |
| 10 | + |
| 11 | + "github.com/cockroachdb/cockroach/pkg/clusterversion" |
| 12 | + "github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverpb" |
| 13 | + "github.com/cockroachdb/cockroach/pkg/util/leaktest" |
| 14 | +) |
| 15 | + |
| 16 | +// TestObsoleteCode contains nudges for cleanups that may be possible in the |
| 17 | +// future. When this test fails (which is necessarily a result of bumping the |
| 18 | +// MinSupportedVersion), please carry out the cleanups that are now possible or |
| 19 | +// file issues against the KV team asking them to do so (at which point you may |
| 20 | +// comment out the failing check). |
| 21 | +func TestObsoleteCode(t *testing.T) { |
| 22 | + defer leaktest.AfterTest(t)() |
| 23 | + |
| 24 | + msv := clusterversion.RemoveDevOffset(clusterversion.MinSupported.Version()) |
| 25 | + t.Logf("MinSupported: %v", msv) |
| 26 | + |
| 27 | + v25dot2 := clusterversion.RemoveDevOffset(clusterversion.V25_2.Version()) |
| 28 | + |
| 29 | + // v25.2 is the last version to interpret RangeKeysInOrder. 25.3+ ignores |
| 30 | + // the field on incoming snapshots but continues to set it on outgoing |
| 31 | + // snapshots for compatibility reasons. This can be removed when the below |
| 32 | + // check fires. |
| 33 | + // |
| 34 | + // See https://github.com/cockroachdb/cockroach/pull/144613. |
| 35 | + // |
| 36 | + // NB: the below comparison intentionally minimizes the number of assumptions |
| 37 | + // on what release follows 25.2. |
| 38 | + if !msv.LessEq(v25dot2) { |
| 39 | + _ = kvserverpb.SnapshotRequest_Header{}.RangeKeysInOrder |
| 40 | + t.Fatalf("SnapshotRequest_Header.RangeKeysInOrder can be removed") |
| 41 | + } |
| 42 | +} |
0 commit comments