From 92e2ccb4d3d1ab5521c44ca084d8903f28b72651 Mon Sep 17 00:00:00 2001 From: Mariia_Azbeleva Date: Mon, 27 Nov 2023 13:45:19 +0200 Subject: [PATCH] Change ghaf version format Signed-off-by: Mariia Azbeleva --- Robot-Framework/lib/output_parser.py | 7 +++- .../resources/ssh_keywords.resource | 33 ++++++++++--------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/Robot-Framework/lib/output_parser.py b/Robot-Framework/lib/output_parser.py index 4a331f5..819ae05 100644 --- a/Robot-Framework/lib/output_parser.py +++ b/Robot-Framework/lib/output_parser.py @@ -40,7 +40,12 @@ def verify_shutdown_status(output): raise Exception("Couldn't parse shutdown status") -def parse_version(output): +def parse_ghaf_version(output): + major, minor = output.split(".") + return major, minor + + +def parse_nixos_version(output): versions = output.split(' ') name = versions[1][1:-1] if len(versions) > 1 else None major, minor, date, commit = versions[0].split(".") diff --git a/Robot-Framework/resources/ssh_keywords.resource b/Robot-Framework/resources/ssh_keywords.resource index 70eb161..b5257e8 100644 --- a/Robot-Framework/resources/ssh_keywords.resource +++ b/Robot-Framework/resources/ssh_keywords.resource @@ -176,21 +176,15 @@ Check file doesn't exist Log To Console File ${file_name} doesn't exist Verify Ghaf Version Format - [Documentation] Check that ghaf-version contains version number in the format:"dd.dd", - ... date of commit in format yyyymmdd and 7 symbols of hash commit - ${major} ${minor} ${date} ${commit} ${name} Get Version ghaf + [Documentation] Check that ghaf-version contains version number in the format:"dd.dd" + ${major} ${minor} Get Ghaf Version Should Match Regexp ${major} ^\\d{2}$ Should Match Regexp ${minor} ^\\d{2}$ - Verify Date Format ${date} - Should Match Regexp ${commit} ^[0-9a-f]{7}$ - IF ${name} != None - FAIL Unexpected string in Ghaf version: ${name} - END Verify Nixos Version Format [Documentation] Check that nixos-version contains version number in the format:"dd.dd", ... date of commit in format yyyymmdd, 7 symbols of hash commit and version name in brackets - ${major} ${minor} ${date} ${commit} ${name} Get Version nixos + ${major} ${minor} ${date} ${commit} ${name} Get Nixos Version Should Match Regexp ${major} ^\\d{2}$ Should Match Regexp ${minor} ^\\d{2}$ Verify Date Format ${date} @@ -199,15 +193,22 @@ Verify Nixos Version Format FAIL Expected NixOS version name, but there is None END -Get Version - [Documentation] Get version of NixOS or Ghaf system, Examples: - ... "ghaf-version" output: 23.05.20230628.92414ab parse result: 23.05, 20230628, 92414ab +Get Ghaf Version + [Documentation] Get version of Ghaf system, Example: + ... "ghaf-version" output: 23.05 parse result: 23.05 + ${output} ${rc} Execute Command ghaf-version return_rc=True + Should Be Equal As Integers ${rc} 0 Couldn't get ghaf version, command return code + Log To Console ghaf-version: ${output} + ${major} ${minor} Parse Ghaf Version ${output} + [Return] ${major} ${minor} + +Get Nixos Version + [Documentation] Get version of NixOS, Example: ... "nixos-version" output: 23.05.20230625.35130d4 (Stoat) parse result: 23.05, 20230625, 35130d4, Stoat - [Arguments] ${whose} - ${output} ${rc} Execute Command ${whose}-version return_rc=True + ${output} ${rc} Execute Command nixos-version return_rc=True Should Be Equal As Integers ${rc} 0 Couldn't get ghaf version, command return code - Log To Console ${whose}-version: ${output} - ${major} ${minor} ${date} ${commit} ${name} Parse Version ${output} + Log To Console nixos-version: ${output} + ${major} ${minor} ${date} ${commit} ${name} Parse Nixos Version ${output} [Return] ${major} ${minor} ${date} ${commit} ${name} Save log