Skip to content

Commit

Permalink
fix scenarios validation
Browse files Browse the repository at this point in the history
Signed-off-by: tnazarew <[email protected]>
  • Loading branch information
tnazarew committed Nov 7, 2024
1 parent 38e86ed commit 55c66a9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 21 deletions.
10 changes: 6 additions & 4 deletions scripts/compare_releases.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ def min_version(v1, v2):
return v2 if version_to_number(v1) > version_to_number(v2) else v1


def version_between(v, v_min, v_max):
ge_min = v_min is None or version_to_number(v) >= version_to_number(v_min)
le_max = v_max is None or version_to_number(v) <= version_to_number(v_max)
return ge_min and le_max
def release_between(release, min_version, max_version):
max_ver = 999999999 if max_version is None else version_to_number(max_version)
min_ver = 0 if min_version is None else version_to_number(min_version)
rel = version_to_number(release)

return min_ver <= rel <= max_ver


def version_to_number(version):
Expand Down
2 changes: 1 addition & 1 deletion scripts/report.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from scripts.compare_releases import max_version, min_version
from compare_releases import max_version, min_version


class Report:
Expand Down
17 changes: 1 addition & 16 deletions scripts/validate_ol_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os.path import isfile, join, isdir
from jsonschema import Draft202012Validator
from report import Test, Scenario, Component, Report
from compare_releases import release_between
from compare_events import match


Expand Down Expand Up @@ -119,22 +120,6 @@ def all_tests_succeeded(syntax_tests):
return not any(t.status == "FAILURE" for t in syntax_tests.values())


def version_to_number(version):
split = version.split('.')
major = int(split[0])
minor = int(split[0])
patch = int(split[0])
return major * 1000000 + minor * 1000 + patch


def release_between(release, min_version, max_version):
max_ver = 999999999 if max_version is None else version_to_number(max_version)
min_ver = 0 if min_version is None else version_to_number(min_version)
rel = version_to_number(release)

return min_ver <= rel <= max_ver


def get_expected_events(producer_dir, component, scenario_name, config, release):
if component == 'scenarios':
return None
Expand Down

0 comments on commit 55c66a9

Please sign in to comment.