Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Validate target OS update version is not same as current #381

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions balena/hup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ def get_hup_action_type(device_type: str, current_version: Optional[str], target
if Version.parse(target_version).compare(current_version) < 0:
raise exceptions.OsUpdateError("OS downgrades are not allowed")

if Version.compare(parsed_current_ver, parsed_target_ver) == 0:
raise exceptions.OsUpdateError("Current OS version matches Target OS version")

# For 1.x -> 2.x or 2.x to 2.x only
if parsed_target_ver.major > 1 and Version.parse(target_version).compare(MIN_TARGET_VERSION) < 0:
raise exceptions.OsUpdateError("Target balenaOS version must be greater than {0}".format(MIN_TARGET_VERSION))
Expand Down
21 changes: 12 additions & 9 deletions tests/functional/models/test_device_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ def test_01_get_supported_os_versions_by_device_type_slug(self):
self.assertGreater(len(supported_device_os_versions["versions"]), 2)

def test_02_get_hup_action_type(self):
# Ensure version advances
testVersion = [
"2.108.1+rev2",
"2.106.7",
"2.98.11+rev4",
"2.98.11+rev3",
"2.98.11+rev2",
"2.98.11",
"2.91.5",
"2.85.2+rev4.prod",
"2.91.5",
"2.98.11",
"2.98.11+rev2",
"2.98.11+rev3",
"2.98.11+rev4",
"2.106.7",
"2.108.1+rev2"
]
for ver in testVersion:
get_hup_action_type("", ver, ver)
last_ver = testVersion[0]
for ver in testVersion[1:]:
get_hup_action_type("", last_ver, ver)
last_ver = ver

def test_03_get_supervisor_releases_for_cpu_architecture(self):
# return an empty array if no image was found
Expand Down
Loading