Skip to content

Commit

Permalink
tests/RedpandaInstaller release_range method
Browse files Browse the repository at this point in the history
this method creates a list of versions to install to simulate an upgrade path.

each version is either the latest for its line,
or one from the provided do_not_skip list

the list starts with the "earliest" parameter (default oldest line)
and the "latest" parameter (default to HEAD)
  • Loading branch information
andijcr committed Mar 10, 2023
1 parent cf0cbbe commit 4f2d12a
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
66 changes: 66 additions & 0 deletions tests/rptest/services/redpanda_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# by the Apache License, Version 2.0

import errno
import copy
import json
import os
import re
Expand All @@ -17,6 +18,7 @@
import requests

from ducktape.utils.util import wait_until
from more_itertools import unique_justseen

# Match any version that may result from a redpanda binary, which may not be a
# released version.
Expand Down Expand Up @@ -411,6 +413,70 @@ def latest_for_line(self, release_line: tuple[int, int]):

assert False, f"no downloadable versions in {versions_in_line[0:2]} for {release_line=}"

def release_range(
self,
*,
earliest: typing.Optional[typing.Union[tuple[int, int],
tuple[int, int, int]]] = None,
latest: typing.Optional[typing.Union[str, tuple[int, int],
tuple[int, int, int]]] = None,
do_not_skip: list[tuple[int, int, int]] = []
) -> list[tuple[int, int, int]]:
"""
returns a list of version to implement an upgrade path. for each line, it will return the latest for the line,
from earliest up to latest line.
versions in the do_not_skip list will be integrated in the upgrade path
e.g release_range(earliest=(21, 2), latest=RedpandaInstaller.HEAD, do_not_skip=[(22, 2, 7)]) ->
[(21, 2, 8), (21, 3, 9), (22, 1, 7), (22, 2, 7), (22, 2, 8), (22, 3, 9), (23, 1, 0)]
:param earliest: first version or line to install DEFAULT the oldest line
:param latest: last version or line or HEAD to install DEFAULT RedpandaInstallerHEAD
:param do_not_skip: versions to integrate in the list DEFAULT empty
:return: a list of version in the range [earliest, latest],
each being a) the latest from its line or b) one from do_not_skip.
"""

self.start()
self._initialize_released_versions()

# default to oldest
if not earliest:
earliest = self._released_versions[-1][0:2]

# convert to specific version
if len(earliest) == 2:
earliest, _ = self.latest_for_line(earliest)

# default to _head_version
if not latest or latest == RedpandaInstaller.HEAD:
latest = self._head_version

# convert to specific version
if len(latest) == 2:
latest, _ = self.latest_for_line(latest)

# setup a copy (we are going to modify it)
rel_range = copy.deepcopy(self._released_versions)

# glue head in front, as the most recent version
rel_range.insert(0, self._head_version)

# clamp to [latest, earliest]
rel_range = rel_range[rel_range.index(latest
):rel_range.index(earliest) + 1]

# keep one version per release line (needs to reintegrate earliest)
rel_range = list(unique_justseen(rel_range, key=lambda v: v[0:2]))
rel_range.insert(0, earliest)

# integrate versions that needs to be in
rel_range.extend(do_not_skip)
# put them in order
rel_range = sorted(rel_range, reverse=True)

# final unique pass, to remove duplicates + sort them in upgrade order
return sorted(unique_justseen(rel_range))

def install(self, nodes, version: typing.Union[str, tuple[int, int],
tuple[int, int, int]]):
"""
Expand Down
3 changes: 2 additions & 1 deletion tests/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
'xxhash==2.0.2', 'protobuf==3.19.5', 'fastavro==1.4.9',
'psutil==5.9.0', 'numpy==1.22.3', 'pygal==3.0', 'pytest==7.1.2',
'jump-consistent-hash==3.2.0', 'azure-storage-blob==12.14.1',
'kafkatest@git+https://github.com/apache/kafka.git@058589b03db686803b33052d574ce887fb5cfbd1#egg=kafkatest&subdirectory=tests'
'kafkatest@git+https://github.com/apache/kafka.git@058589b03db686803b33052d574ce887fb5cfbd1#egg=kafkatest&subdirectory=tests',
'more-itertools>=9.0.0'
],
scripts=[],
)

0 comments on commit 4f2d12a

Please sign in to comment.