From a08fc340f548a4b223c7c139b4fe59531cf7c694 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Thu, 9 Jan 2020 13:45:06 +0000 Subject: [PATCH] FIX: Container test + We should check if container is UP + We should adjust privileges. Change-Id: I3f604b7b9740943b4fd3b0574c18d2729e88b816 Signed-off-by: Peter Mikus --- resources/libraries/python/ContainerUtils.py | 23 +++++++++++++++-------- resources/libraries/robot/shared/container.robot | 1 - 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 6e413c64f0..456cd221f3 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -564,12 +564,13 @@ class ContainerEngine: self.container.name, f"/tmp/vpp_sockets/{self.container.name}/stats.sock" ) + self.verify_vpp() + self.adjust_privileges() def restart_vpp(self): """Restart VPP service inside a container.""" self.execute(u"pkill vpp") self.start_vpp() - self.execute(u"cat /tmp/vppd.log") # TODO Rewrite to use the VPPUtil.py functionality and remove this. def verify_vpp(self, retries=120, retry_wait=1): @@ -578,19 +579,25 @@ class ContainerEngine: :param retries: Check for VPP for this number of times Default: 120 :param retry_wait: Wait for this number of seconds between retries. """ - cmd = (u"vppctl show pci 2>&1 | " - u"fgrep -v 'Connection refused' | " - u"fgrep -v 'No such file or directory'") - for _ in range(retries + 1): try: - self.execute(cmd) + self.execute( + u"vppctl show pci 2>&1 | " + u"fgrep -v 'Connection refused' | " + u"fgrep -v 'No such file or directory'" + ) break except RuntimeError: sleep(retry_wait) else: - msg = f"VPP did not come up in container: {self.container.name}" - raise RuntimeError(msg) + self.execute(u"cat /tmp/vppd.log") + raise RuntimeError( + f"VPP did not come up in container: {self.container.name}" + ) + + def adjust_privileges(self): + """Adjust privileges to control VPP without sudo.""" + self.execute("chmod -R o+rwx /run/vpp") def create_base_vpp_startup_config(self, cpuset_cpus=None): """Create base startup configuration of VPP on container. diff --git a/resources/libraries/robot/shared/container.robot b/resources/libraries/robot/shared/container.robot index 485bc7e633..dbe2ae73a4 100644 --- a/resources/libraries/robot/shared/container.robot +++ b/resources/libraries/robot/shared/container.robot @@ -331,7 +331,6 @@ | | ... | tg_if2_ip4=${tg_if2_ip4} | tg_if2_mac=${tg_if2_mac} | | ... | nodes=${nodes} | | Start VPP in all '${container_group}' containers -| | Verify VPP in all '${container_group}' containers | Start vswitch in container | | [Documentation] -- 2.16.6