result_dir: '/tmp/yardstick/result'
shell_dir: '/tmp/yardstick'
shell_dir_name: 'prepare_test_yard'
+ testcase:
+ build_test_cmd: '/tmp/yardstick/build_run_test.sh %s.yaml /tmp/yardstick/result/%s.out'
+ test_cmd: '/tmp/yardstick/run_test.sh %s.yaml /tmp/yardstick/result/%s.out'
result:
dir: '/tmp/yardstick/result'
store_type: 'file'
db_url: 'http://testresults.opnfv.org/test/api/v1/results?case=%s&last=1'
- file_path: '/tmp/yardstick/result/yardstick.log'
+ file_path: '/home/opnfv/dovetail/results/yardstick.log'
class Container:
container_list = {}
+ has_pull_latest_image = {'yardstick':False, 'functest':False}
+ has_build_images = {'yardstick':False, 'functest':False}
def __init__(cls):
pass
@classmethod
def pull_image(cls, type):
docker_image = cls.get_docker_image(type)
- if container_config[type]['has_pull'] == True:
+ if cls.has_pull_latest_image[type] == True:
logger.debug('%s is already the newest version.' % (docker_image))
else:
cmd = 'sudo docker pull %s' % (docker_image)
dt_utils.exec_cmd(cmd,logger)
- container_config[type]['has_pull'] = True
+ cls.has_pull_latest_image[type] = True
@classmethod
def clean(cls, container_id):
cmd = 'sudo docker exec %s %s' % (container_id, sub_cmd)
dt_utils.exec_cmd(cmd,logger,exit_on_error)
-
+ @classmethod
+ def copy_file(cls, file_dir, container_id, container_dir):
+ for root, dirs, files in os.walk(file_dir):
+ for file_name in files:
+ cmd = 'sudo docker cp %s %s:%s' % (os.path.join(file_dir,file_name), container_id, container_dir)
+ dt_utils.exec_cmd(cmd, logger, exit_on_error = False)
def load_testcase():
Testcase.load()
-def copy_file(file_dir, container_id, container_dir):
- for root, dirs, files in os.walk(file_dir):
- for file_name in files:
- cmd = 'sudo docker cp %s %s:%s' % (os.path.join(file_dir,file_name), container_id, container_dir)
- dt_utils.exec_cmd(cmd, logger, exit_on_error = False)
-
def run_functest(testcase, container_id):
sub_cmd = dovetail_config[testcase.script_type()]['testcase']['pre_cmd']
Container.exec_cmd(container_id, sub_cmd)
Container.exec_cmd(container_id, sub_cmd)
def run_yardstick(testcase, container_id):
- copy_file(os.path.join(os.getcwd(),container_config[testcase.script_type()]['shell_dir_name']),\
- container_id,container_config[testcase.script_type()]['shell_dir'])
- if container_config[testcase.script_type()]['has_build_images'] == True:
- cmd = 'sudo docker exec %s %s/run_test.sh %s.yaml %s/%s.out' \
- % (container_id, container_config[testcase.script_type()]['shell_dir'], testcase.script_testcase(),\
- container_config[testcase.script_type()]['result_dir'], testcase.name())
+ type = testcase.script_type()
+ Container.copy_file(os.path.join(os.getcwd(), dovetail_config[type]['shell_dir_name']),\
+ container_id, dovetail_config[type]['shell_dir'])
+ if Container.has_build_images[type] == True:
+ sub_cmd = dovetail_config[type]['testcase']['test_cmd'] % (testcase.script_testcase(), testcase.name())
else:
- container_config[testcase.script_type()]['has_build_images'] = True
- cmd = 'sudo docker exec %s %s/build_run_test.sh %s.yaml %s/%s.out' \
- % (container_id, container_config[testcase.script_type()]['shell_dir'], testcase.script_testcase(),\
- container_config[testcase.script_type()]['result_dir'], testcase.name())
- dt_utils.exec_cmd(cmd,logger,exit_on_error = False)
+ Container.has_build_images[type] = True
+ sub_cmd = dovetail_config[type]['testcase']['build_test_cmd'] % (testcase.script_testcase(), testcase.name())
+ Container.exec_cmd(container_id, sub_cmd)
time.sleep(5)
def run_test(scenario):