-#!/bin/bash
+#!/usr/bin/env python
#
# Author: Jose Lausuch (jose.lausuch@ericsson.com)
#
import argparse
import os
-import subprocess
+import re
import sys
import functest.ci.tier_builder as tb
import functest.utils.clean_openstack as clean_os
import functest.utils.functest_logger as ft_logger
+import functest.utils.functest_utils as ft_utils
import functest.utils.openstack_utils as os_utils
""" logging configuration """
-logger = ft_logger.Logger("run_test").getLogger()
+logger = ft_logger.Logger("run_tests").getLogger()
""" global variables """
line = ""
for i in range(0, count - 1):
line += str
-
logger.info("%s" % line)
def cleanup():
- print_separator("+")
- logger.info("Cleaning OpenStack resources...")
- print_separator("+")
clean_os.main()
- print_separator("")
def run_test(test):
test_name = test.get_name()
- print_separator("")
print_separator("=")
logger.info("Running test case '%s'..." % test_name)
print_separator("=")
cmd = ("%s%s" % (EXEC_SCRIPT, flags))
logger.debug("Executing command '%s'" % cmd)
- print_separator("")
-
- p = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
- while p.poll() is None:
- line = p.stdout.readline().rstrip()
- logger.debug(line)
+ result = ft_utils.execute_command(cmd, logger, exit_on_error=False)
- if p != 0:
- logger.error("The command '%s' failed. Cleaning and exiting." % cmd)
+ if result != 0:
+ logger.error("The test case '%s' failed. Cleaning and exiting."
+ % test_name)
if CLEAN_FLAG:
cleanup()
sys.exit(1)
cleanup()
-
def run_tier(tier):
print_separator("#")
logger.info("Running tier '%s'" % tier.get_name())
def run_all(tiers):
- logger.debug("Tiers to be executed:")
- for tier in tiers.get_tiers():
- logger.info("\n - %s. %s:\n\t%s"
- % (tier.get_order(), tier.get_name(), tier.get_tests()))
+ summary = ""
+ BUILD_TAG = os.getenv('BUILD_TAG')
+ if BUILD_TAG is not None and re.search("daily", BUILD_TAG) is not None:
+ CI_LOOP = "daily"
+ else:
+ CI_LOOP = "weekly"
+
+ tiers_to_run = []
for tier in tiers.get_tiers():
+ if re.search(CI_LOOP, tier.get_ci_loop()) is not None:
+ tiers_to_run.append(tier)
+ summary += ("\n - %s. %s:\n\t %s"
+ % (tier.get_order(),
+ tier.get_name(),
+ tier.get_test_names()))
+
+ logger.info("Tiers to be executed:%s" % summary)
+
+ for tier in tiers_to_run:
run_tier(tier)