Skip to content

Commit

Permalink
test: fix parsing ill-formed TiDB version will panic (#37622)
Browse files Browse the repository at this point in the history
close #37628
  • Loading branch information
lance6716 authored Sep 5, 2022
1 parent 781e8ec commit 04dac01
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/integration-test-dumpling.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ on:
- 'br/pkg/storage/**'
- 'br/pkg/utils/**'
- 'br/pkg/summary/**'
- 'br/pkg/version/**'
- 'store/helper/**'
- 'tablecodec/**'
- 'util/codec/**'
Expand Down
3 changes: 2 additions & 1 deletion br/pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ func ParseServerInfo(src string) ServerInfo {
if isReleaseVersion {
versionStr = tidbReleaseVersionRegex.FindString(src)
} else {
versionStr = tidbVersionRegex.FindString(src)[1:]
versionStr = tidbVersionRegex.FindString(src)
versionStr = strings.TrimPrefix(versionStr, "-")
}
versionStr = strings.TrimPrefix(versionStr, "v")
} else {
Expand Down
1 change: 1 addition & 0 deletions br/pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ func TestDetectServerInfo(t *testing.T) {
{6, "invalid version", ServerTypeUnknown, mkVer(0, 0, 0, "")},
{7, "Release Version: v5.2.1\nEdition: Community\nGit Commit Hash: cd8fb24c5f7ebd9d479ed228bb41848bd5e97445", ServerTypeTiDB, mkVer(5, 2, 1, "")},
{8, "Release Version: v5.4.0-alpha-21-g86caab907\nEdition: Community\nGit Commit Hash: 86caab907c481bbc4243b5a3346ec13907cc8721\nGit Branch: master", ServerTypeTiDB, mkVer(5, 4, 0, "alpha-21-g86caab907")},
{9, "5.7.25-TiDB-5584f12", ServerTypeTiDB, mkVer(0, 0, 0, "")},
}
dec := func(d []interface{}) (tag int, verStr string, tp ServerType, v *semver.Version) {
return d[0].(int), d[1].(string), ServerType(d[2].(int)), d[3].(*semver.Version)
Expand Down

0 comments on commit 04dac01

Please sign in to comment.