From 0cd598d67c905a86e8a88cd15b7a7a12083a9eba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mattias=20Walstr=C3=B6m?= Date: Wed, 29 Apr 2026 09:21:56 +0200 Subject: [PATCH] test: containers: host_commands/test.py: Adapt to new yangerd Slightly slower to detect changes --- test/case/containers/host_commands/test.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/test/case/containers/host_commands/test.py b/test/case/containers/host_commands/test.py index 001bcb7c..8e207d92 100755 --- a/test/case/containers/host_commands/test.py +++ b/test/case/containers/host_commands/test.py @@ -9,6 +9,10 @@ can change the hostname of the host. import infamy from infamy.util import until, to_binary +def get_hostname(dut): + oper = target.get_data("/ietf-system:system") + return oper["system"]["hostname"] + with infamy.Test() as test: cont_image = f"oci-archive:{infamy.Container.NFTABLES_IMAGE}" cont_name = "cont0" @@ -32,12 +36,7 @@ with infamy.Test() as test: }) with test.step("Verify initial hostname in operational"): - oper = target.get_data("/ietf-system:system") - name = oper["system"]["hostname"] - - if name != hostname_init: - print(f"Expected hostname: {hostname_init}, actual hostname: {name}") - test.fail() + until(lambda: get_hostname(target) == hostname_init) with test.step("Include script in OCI image to modify host hostname"): commands = to_binary(f"""#!/bin/sh @@ -79,5 +78,5 @@ nsenter -m/1/ns/mnt -u/1/ns/uts -i/1/ns/ipc -n/1/ns/net hostname {hostname_new} until(lambda: c.running(cont_name), attempts=60) with test.step("Verify the new hostname set by the container"): - until(lambda: c.running(cont_name) != target.get_data("/ietf-system:system")["system"]["hostname"], attempts=30) + until(lambda: c.running(cont_name) != get_hostname(target), attempts=30) test.succeed()