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

Infra: Fix node version detection #4004

Merged
merged 4 commits into from
Jul 1, 2022
Merged
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
2 changes: 1 addition & 1 deletion .daily_canary
Original file line number Diff line number Diff line change
@@ -1 +1 @@
.
It's a new canary
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ if(BUILD_TESTS)
if(NOT UNSAFE_VERSION)
# Unsafe builds do not follow normal version conventions
add_test(NAME versionifier_test
COMMAND ${PYTHON} ${CMAKE_SOURCE_DIR}/python/versionifier.py
COMMAND ${PYTHON}
${CMAKE_SOURCE_DIR}/python/ccf/_versionifier.py
)

add_test(NAME github_version_lts_test
Expand Down
8 changes: 8 additions & 0 deletions python/versionifier.py → python/ccf/_versionifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,34 +50,42 @@ def to_python_version(original):

v = to_python_version("1.2.3")
assert v.release == (1, 2, 3)
assert v == to_python_version("ccf-1.2.3")

v = to_python_version("ccf-1.2.3")
assert v.release == (1, 2, 3)
assert v == to_python_version("ccf-1.2.3")

v = to_python_version("ccf-1.2.3-a42")
assert v.release == (1, 2, 3)
assert v.pre == ("a", 42)
assert v < to_python_version("ccf-1.2.3") # -x precedes main release

v = to_python_version("ccf-1.2.3-rc1")
assert v.release == (1, 2, 3)
assert v.pre == ("rc", 1)
assert v < to_python_version("ccf-1.2.3") # RC precedes main release

v = to_python_version("ccf-1.2.3-dev2")
assert v.release == (1, 2, 3)
assert v.dev == 2
assert v < to_python_version("ccf-1.2.3") # dev precedes main release

v = to_python_version("ccf-1.2.3-dev3-5-deadbeef")
assert v.release == (1, 2, 3)
assert v.dev == 3
assert v.local == "5.deadbeef"
assert v < to_python_version("ccf-1.2.3") # dev precedes main release

v = to_python_version("ccf-1.2.3-42-deadbeef")
assert v.release == (1, 2, 3)
assert v.post == 42
assert v.local == "deadbeef"
assert v > to_python_version("ccf-1.2.3") # -N comes after main release

v = to_python_version("ccf-2.0.0-rc4-26-g49d7b7941+unsafe")
assert v.release == (2, 0, 0)
assert v.pre == ("rc", 4)
assert v.post == 26
assert v.local == "g49d7b7941unsafe"
assert v < to_python_version("ccf-2.0.0") # RC precedes main release
5 changes: 3 additions & 2 deletions python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
# pylint: disable=import-error
import version # type: ignore

import versionifier
# pylint: disable=protected-access
import ccf._versionifier

PACKAGE_NAME = "ccf"
UTILITIES_PATH = "utils"
Expand All @@ -23,7 +24,7 @@

setup(
name=PACKAGE_NAME,
version=str(versionifier.to_python_version(version.CCF_VERSION)),
version=str(ccf._versionifier.to_python_version(version.CCF_VERSION)),
description="Set of tools and utilities for the Confidential Consortium Framework (CCF)",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
4 changes: 2 additions & 2 deletions tests/infra/consortium.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ def check_for_service(self, remote_node, status, recovery_count=None):
r = c.get("/node/network").body.json()
current_status = r["service_status"]
current_cert = r["service_certificate"]
if remote_node.version_after("ccf-2.0.4"):
if remote_node.version_after("ccf-2.0.3"):
current_recovery_count = r["recovery_count"]
else:
assert "recovery_count" not in r
Expand All @@ -729,7 +729,7 @@ def check_for_service(self, remote_node, status, recovery_count=None):
assert (
current_status == status.value
), f"Service status {current_status} (expected {status.value})"
if remote_node.version_after("ccf-2.0.4"):
if remote_node.version_after("ccf-2.0.3"):
assert (
recovery_count is None or current_recovery_count == recovery_count
), f"Current recovery count {current_recovery_count} is not expected {recovery_count}"
Expand Down
15 changes: 7 additions & 8 deletions tests/infra/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import time
import http

# pylint: disable=protected-access
import ccf._versionifier

# pylint: disable=import-error, no-name-in-module
from setuptools.extern.packaging.version import Version # type: ignore

Expand Down Expand Up @@ -99,14 +102,10 @@ def version_after(version, cmp_version):
# It is assumed that version is None for latest development
# branch (i.e. main)
return True
rc, _ = version_rc(cmp_version)
self_rc, self_num_rc_tkns = version_rc(version)
ver = Version(strip_version(cmp_version))
self_ver = Version(strip_version(version))
return self_ver > ver or (
self_ver == ver
and (not self_rc or self_rc > rc or (self_rc == rc and self_num_rc_tkns > 3))
)

return ccf._versionifier.to_python_version(
version
) > ccf._versionifier.to_python_version(cmp_version)


class Node:
Expand Down
4 changes: 2 additions & 2 deletions tests/lts_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ def run_ledger_compatibility_since_first(args, local_branch, use_snapshot):
committed_ledger_dirs,
snapshots_dir=snapshots_dir,
)
# Recovery count is not stored in pre-2.0.4 ledgers
# Recovery count is not stored in pre-2.0.3 ledgers
network.recover(
args,
expected_recovery_count=1
if not infra.node.version_after(previous_version, "ccf-2.0.4")
if not infra.node.version_after(previous_version, "ccf-2.0.3")
else None,
)

Expand Down