Skip to content

Commit

Permalink
Merge pull request twmb#739 from twmb/683
Browse files Browse the repository at this point in the history
kversions: skip many more broker-to-broker keys
  • Loading branch information
twmb authored May 26, 2024
2 parents 128840a + 62c6b85 commit 5efa8cb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
10 changes: 1 addition & 9 deletions pkg/kversion/kversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,14 +205,6 @@ type guessOpt struct{ fn func(*guessCfg) }
func (opt guessOpt) apply(cfg *guessCfg) { opt.fn(cfg) }

// SkipKeys skips the given keys while guessing versions.
//
// The current default is to skip keys that are only used by brokers:
//
// 4: LeaderAndISR
// 5: StopReplica
// 6: UpdateMetadata
// 7: ControlledShutdown
// 27: WriteTxnMarkers
func SkipKeys(keys ...int16) VersionGuessOpt {
return guessOpt{func(cfg *guessCfg) { cfg.skipKeys = keys }}
}
Expand Down Expand Up @@ -341,7 +333,7 @@ func (vs *Versions) versionGuess(opts ...VersionGuessOpt) guess {
//
// TODO: add introduced-version to differentiate some specific
// keys.
skipKeys: []int16{4, 5, 6, 7, 27, 58},
skipKeys: []int16{4, 5, 6, 7, 27, 52, 53, 54, 55, 56, 57, 58, 59, 62, 63, 64, 67},
}
for _, opt := range opts {
opt.apply(&cfg)
Expand Down
39 changes: 39 additions & 0 deletions pkg/kversion/kversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,42 @@ func TestFromString(t *testing.T) {
}
}
}

func TestGuessVersions(t *testing.T) {
for _, test := range []struct {
vs *Versions
exp string
}{
{V0_8_0(), "v0.8.0"},
{V0_8_1(), "v0.8.1"},
{V0_8_2(), "v0.8.2"},
{V0_9_0(), "v0.9.0"},
{V0_10_0(), "v0.10.0"},
{V0_10_1(), "v0.10.1"},
{V0_10_2(), "v0.10.2"},
{V0_11_0(), "v0.11.0"},
{V1_0_0(), "v1.0"},
{V1_1_0(), "v1.1"},
{V2_0_0(), "v2.0"},
{V2_1_0(), "v2.1"},
{V2_2_0(), "v2.2"},
{V2_3_0(), "v2.3"},
{V2_4_0(), "v2.4"},
{V2_5_0(), "v2.5"},
{V2_6_0(), "v2.6"},
{V2_7_0(), "v2.7"},
{V2_8_0(), "v2.8"},
{V3_0_0(), "v3.0"},
{V3_1_0(), "v3.1"},
{V3_2_0(), "v3.2"},
{V3_3_0(), "v3.3"},
{V3_4_0(), "v3.4"},
{V3_5_0(), "v3.5"},
{V3_6_0(), "v3.6"},
} {
got := test.vs.VersionGuess()
if got != test.exp {
t.Errorf("got %s != exp %s", got, test.exp)
}
}
}

0 comments on commit 5efa8cb

Please sign in to comment.