summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-07-22 11:55:31 +0200
committerCédric Ollivier <cedric.ollivier@orange.com>2018-07-22 11:55:31 +0200
commita80ebe8794dd2693203ceea65a13a69dcf508f94 (patch)
treea8f25b2e4147b9bf013d5188da976fcc49390a50
parentb41b257fca32e09217acdec09113ae37bccbfa78 (diff)
Add helper to find string in console
It allows checking when cloud-init is finished (see heat_ims). Change-Id: I951aabff29457d7b7544a809f9fce1f83706035e Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
-rw-r--r--functest/core/singlevm.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/functest/core/singlevm.py b/functest/core/singlevm.py
index 0f7ba71b4..768e67d0e 100644
--- a/functest/core/singlevm.py
+++ b/functest/core/singlevm.py
@@ -14,6 +14,7 @@ advanced testcases (e.g. deploying an orchestrator).
"""
import logging
+import re
import tempfile
import time
@@ -184,6 +185,26 @@ class VmReady1(tenantnetwork.TenantNetwork1):
self.__logger.debug("vm: %s", vm1)
return vm1
+ def check_regex_in_console(self, name, regex=' login: ', loop=1):
+ """Wait for specific message in console
+
+ Returns: True or False on errors
+ """
+ assert self.cloud
+ for iloop in range(loop):
+ console = self.cloud.get_server_console(name)
+ self.__logger.debug("console: \n%s", console)
+ if re.search(regex, console):
+ self.__logger.debug("regex found: ''%s' in console", regex)
+ return True
+ else:
+ self.__logger.debug(
+ "try %s: cannot find regex '%s' in console",
+ iloop + 1, regex)
+ time.sleep(10)
+ self.__logger.error("cannot find regex '%s' in console", regex)
+ return False
+
def run(self, **kwargs):
"""Boot the new VM