Skip to content

Commit

Permalink
[CCXDEV-12345] Check DVO and OCP DB versions (#571)
Browse files Browse the repository at this point in the history
* check DVO and OCP DB versions

* fix lint
  • Loading branch information
juandspy authored Feb 6, 2024
1 parent 21955de commit 17f1ad0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
3 changes: 2 additions & 1 deletion features/insights-results-aggregator/basic_rest_api.feature
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ Feature: Basic REST API endpoints provided by Insights Results Aggregator
And BuildCommit is a proper sha1
And BuildTime is a proper datetime stamp
#And BuildVersion is in the proper format
And DBVersion is in the proper format
And OCPDBVersion is in the proper format
And DVODBVersion is in the proper format
And UtilsVersion is in the proper format
When I terminate Insights Results Aggregator
Then Insights Results Aggregator process should terminate
Expand Down
14 changes: 7 additions & 7 deletions features/src/process_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,6 @@ def process_generated_output(context: Context, out, return_code=None,
assert stderr is None, "Error during check"
assert stdout is not None, "No output from process"

# check the return code of a process
# TODO: we will need to support more return codes later
if return_code:
assert (
out.returncode == 0 or out.returncode == return_code
), f"Return code is {out.returncode}"

# try to decode output as flow of text lines
output = stdout.decode("utf-8").split("\n")

Expand All @@ -73,6 +66,13 @@ def process_generated_output(context: Context, out, return_code=None,
# check again, just for sure
assert output is not None

# check the return code of a process
# TODO: we will need to support more return codes later
if return_code:
assert (
out.returncode == 0 or out.returncode == return_code
), f"Return code is {out.returncode}"

# update testing context
context.output = output
context.stdout = stdout
Expand Down
19 changes: 13 additions & 6 deletions features/steps/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,21 @@ def check_build_datetime_stamp(context):
datetime.strptime(buildTime, timestampFormat)


@then("DBVersion is in the proper format")
def check_db_version(context):
"""Check database version taken from service output."""
dbVersion = context.response.json()["info"]["DB_version"]
@then("OCPDBVersion is in the proper format")
def check_ocp_db_version(context):
"""Check OCP database version taken from service output."""
check_db_version(context.response.json()["info"]["OCP_DB_version"])

# just try to parse the version, that's all
version = int(dbVersion)

@then("DVODBVersion is in the proper format")
def check_dvo_db_version(context):
"""Check DVO database version taken from service output."""
check_db_version(context.response.json()["info"]["DVO_DB_version"])


def check_db_version(db_version):
"""Just try to parse the version as int, that's all."""
version = int(db_version)
assert version >= 1, f"Improper DB version {version}"


Expand Down

0 comments on commit 17f1ad0

Please sign in to comment.