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

Add autotest for Ghaf versioning #18

Merged
merged 1 commit into from
Jul 5, 2023
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
17 changes: 17 additions & 0 deletions Robot-Framework/lib/output_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

import re
from datetime import datetime


def get_systemctl_status(output):
Expand Down Expand Up @@ -42,3 +43,19 @@ def verify_shutdown_status(output):
return match.group(1), match.group(2)
else:
raise Exception("Couldn't parse shutdown status")

def verify_version_format(output):
version = output.split('.')

def parse_version(output):
versions = output.split(' ')
name = versions[1][1:-1] if len(versions) > 1 else None
major, minor, date, commit = versions[0].split(".")
version = f"{major}.{minor}"
return version, date, commit, name

def verify_date_format(date_string):
try:
datetime.strptime(date_string, '%Y%m%d')
except ValueError:
raise Exception("Wrong date format in version date field")
19 changes: 19 additions & 0 deletions Robot-Framework/resources/ssh_keywords.resource
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,22 @@ Create file
[Arguments] ${file_name}
Execute Command touch ${file_name} sudo=True sudo_password=${password}
SSHLibrary.File Should Exist ${file_name}

Verify Version Format
[Documentation] Check that ghaf-version contains date of commit in format yyyymmdd, 7 symbols of hash commit
... and returns the same NixOS version as the command "nixos-version"
${nixos_version} ${_} ${_} ${_} Get Version nixos
${ghaf_version} ${date} ${commit} ${_} Get Version ghaf
Should Be Equal As Strings ${nixos_version} ${ghaf_version}
Verify Date Format ${date}
Should Match Regexp ${commit} ^[0-9a-f]{7}$

Get Version
[Documentation] Get version of NixOS or Ghaf system, Examples:
... "ghaf-version" output: 23.05.20230628.92414ab parse result: 23.05, 20230628, 92414ab
... "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
Should Be Equal As Integers ${rc} 0 Couldn't get ghaf version, command return code
${version} ${date} ${commit} ${name} Parse Version ${output}
[Return] ${version} ${date} ${commit} ${name}
9 changes: 8 additions & 1 deletion Robot-Framework/test-suites/boot_test.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ ${IS_AVAILABLE} False
*** Test Cases ***

Verify booting after restart by power
[Tags] boot plug
[Documentation] Restart device by power and verify systemctl status is running
[Tags] boot plug
Reboot Device
Check If Device Is Up
IF ${IS_AVAILABLE} == False
Expand All @@ -33,6 +33,13 @@ Verify booting after restart by power
Verify Systemctl status via serial
END

Test version format
[Documentation] Test getting version of the system including NixOS version, date and hash of commit
[Tags] bat SP-T59
[Setup] Connect
Verify Version Format
[Teardown] Close All Connections


*** Keywords ***

Expand Down