Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
39 changes: 27 additions & 12 deletions integrationservertest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,11 @@ func parseConfig(reader io.Reader) (upgradeTestConfig, error) {
}

for _, e := range configYAML.LazyRolloverExceptions {
from, err := parseLazyRolloverExceptionVersionRange(e.From)
lre, err := parseLazyRolloverException(e.From, e.To)
if err != nil {
return upgradeTestConfig{}, fmt.Errorf(
"failed to parse lazy-rollover-exception version '%s': %w", e.From, err)
return upgradeTestConfig{}, fmt.Errorf("failed to parse lazy-rollover exception: %w", err)
}
to, err := parseLazyRolloverExceptionVersionRange(e.To)
if err != nil {
return upgradeTestConfig{}, fmt.Errorf(
"failed to parse lazy-rollover-exception version '%s': %w", e.From, err)
}
config.LazyRolloverExceptions = append(config.LazyRolloverExceptions, lazyRolloverException{
From: from,
To: to,
})
config.LazyRolloverExceptions = append(config.LazyRolloverExceptions, lre)
}

return config, nil
Expand Down Expand Up @@ -220,6 +211,30 @@ func parseNumberOrWildcard(s string) (numberOrWildcard, error) {
return numberOrWildcard{Num: &num, Str: s}, nil
}

func parseLazyRolloverException(fromStr, toStr string) (lazyRolloverException, error) {
from, err := parseLazyRolloverExceptionVersionRange(fromStr)
if err != nil {
return lazyRolloverException{}, fmt.Errorf(
"failed to parse from version '%s': %w", fromStr, err)
}
to, err := parseLazyRolloverExceptionVersionRange(toStr)
if err != nil {
return lazyRolloverException{}, fmt.Errorf(
"failed to parse to version '%s': %w", toStr, err)
}
// Check that if one version have x wildcard, the other should also have it.
if (from.isSingularWithMinorX() && !to.isSingularWithMinorX()) ||
(!from.isSingularWithMinorX() && to.isSingularWithMinorX()) {
return lazyRolloverException{}, fmt.Errorf(
"both versions ('%s', '%s') should have special wildcard or none at all", fromStr, toStr)
}

return lazyRolloverException{
From: from,
To: to,
}, nil
}

var (
lazyRolloverVersionRg = regexp.MustCompile(`^(\d+).(\d+|\*|x).(\d+|\*)$`)
lazyRolloverVersionRangeRg = regexp.MustCompile(`^([\[(])\s*(\d+.\d+.\d+)\s*-\s*(\d+.\d+.\d+)\s*([])])$`)
Expand Down
7 changes: 3 additions & 4 deletions integrationservertest/upgrade-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ data-stream-lifecycle:
# ```
#
# Both major and patch positions are not given the special wildcard (x) because
# it is unlikely to be useful in our use cases. If due to some mistake, the
# special wildcard (x) is used only in one of the strings, it is treated as a
# normal wildcard (*), so the following example would be effectively the same
# as 9.*.*.
# it is unlikely to be useful in our use cases. The special wildcard (x) must
# either appear in both from and to versions, or none at all. The following
# example will be considered invalid.
# ```
# - from: "9.x.*"
# to: "9.1.2"
Expand Down