diff --git a/test/case/system/timezone/test.py b/test/case/system/timezone/test.py index 58bfac2e..196c0930 100755 --- a/test/case/system/timezone/test.py +++ b/test/case/system/timezone/test.py @@ -8,6 +8,17 @@ import random, string import time import infamy import lxml + +from infamy.util import until + +def get_timezone_name(): + try: + tz=target.get_data("/ietf-system:system/clock/timezone-name") + name=tz.get("system", {}).get("clock",{}).get("timezone-name", "") + return name + except: + return None + with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() @@ -23,8 +34,6 @@ with infamy.Test() as test: }}) with test.step("Verify timezone is Australia/Perth"): - tz=target.get_data("/ietf-system:system/clock/timezone-name") - name=tz.get("system", {}).get("clock",{}).get("timezone-name", "") - assert(name == "Australia/Perth") + until(lambda: get_timezone_name() == "Australia/Perth") test.succeed() diff --git a/test/case/system/timezone_utc_offset/test.py b/test/case/system/timezone_utc_offset/test.py index 803e445a..c157f8d4 100755 --- a/test/case/system/timezone_utc_offset/test.py +++ b/test/case/system/timezone_utc_offset/test.py @@ -7,6 +7,16 @@ Verify that it is possible to set timezone using UTC offset import infamy import lxml +from infamy.util import until + +def get_timezone_offset(): + try: + tz=target.get_data("/ietf-system:system/clock/timezone-utc-offset") + offset=tz.get("system", {}).get("clock",{}).get("timezone-utc-offset", 0) + return offset + except: + return None + with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() @@ -22,8 +32,6 @@ with infamy.Test() as test: }}) with test.step("Verify current timezone is UTC+12:00"): - tz=target.get_data("/ietf-system:system/clock/timezone-utc-offset") - offset=tz.get("system", {}).get("clock",{}).get("timezone-utc-offset", 0) - assert(offset == 12) + until(lambda: get_timezone_offset() == 12) test.succeed() diff --git a/test/case/system/user_admin/test.py b/test/case/system/user_admin/test.py index d6b39ffb..10b946c8 100755 --- a/test/case/system/user_admin/test.py +++ b/test/case/system/user_admin/test.py @@ -11,6 +11,16 @@ import infamy.ssh as ssh import infamy.util as util from passlib.hash import sha256_crypt +def get_user(name): + try: + operational = target.get_data("/ietf-system:system/authentication") + users = operational["system"]["authentication"]["user"] + for user in users: + if user['name'] == name: + return user + except: + return None + with infamy.Test() as test: with test.step("Set up topology and attach to target DUT"): env = infamy.Env() @@ -84,20 +94,15 @@ with infamy.Test() as test: target.put_config_dicts({"ietf-system": running}) with test.step("Verify user jacky exists and has new password"): - operational = target.get_data("/ietf-system:system/authentication") - users = operational["system"]["authentication"]["user"] + def password_changed(): + user = get_user(USER) + if user and user['password'] != PASS: + return user + return None - found = None - for user in users: - if user['name'] == USER: - found = user - break + user = util.until(password_changed) - if found is None: - test.fail() - if found['password'] == "$factory$": - test.fail() - if found['password'] == PASS: + if user is None: test.fail() with test.step("Verify user jacky can log in with SSH"):