Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[9.0](backport #6578) Fix selection of testing version #7024

Open
wants to merge 2 commits into
base: 9.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions testing/upgradetest/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func findRequiredVersions(sortedParsedVersions []*version.ParsedSemVer, reqs Ver
currentMajor := parsedUpgradeToVersion.Major()
currentMinor := parsedUpgradeToVersion.Minor()

skipCurrentMajor := false
currentMajorsToFind := reqs.CurrentMajors
previousMajorsToFind := reqs.PreviousMajors
previousMinorsToFind := reqs.PreviousMinors
Expand All @@ -214,15 +215,18 @@ func findRequiredVersions(sortedParsedVersions []*version.ParsedSemVer, reqs Ver
currentMajorsToFind-- // counts as the current major as well

// current majors
case currentMajorsToFind > 0 && version.Major() == currentMajor:
case currentMajorsToFind > 0 && version.Major() == currentMajor && !skipCurrentMajor:
upgradableVersions = append(upgradableVersions, version.String())
currentMajorsToFind--

// previous majors
case previousMajorsToFind > 0 && version.Major() < currentMajor:
upgradableVersions = append(upgradableVersions, version.String())
currentMajor = version.Major()
currentMinor = version.Minor()
previousMajorsToFind--
previousMinorsToFind-- // count as prev minor as well
skipCurrentMajor = true

// since the list is sorted we can stop here
default:
Expand Down Expand Up @@ -252,7 +256,13 @@ func PreviousMinor() (*version.ParsedSemVer, error) {
// will only contain minors from the previous major (vX-1). Further, since the
// version list is sorted in descending order (newer versions first), we can return the
// first item from the list as it will be the newest minor of the previous major.
return versions[0], nil
for _, v := range versions {
if v.Less(*current) {
return v, nil
}
}

return nil, ErrNoPreviousMinor
}

for _, v := range versions {
Expand Down
Loading