- retrieve_test_cases_file(test_name, tests_path)
- print "Scenario successfully downloaded"
-
- print "Start test..."
- cmd = os.popen("rally task start --abort-on-sla-failure %s" % test_file_name)
- task_id = get_task_id(cmd.read())
-
- if task_id is None:
- print "./run_rally : failed to retrieve task_id"
- exit(-1)
-
- """ check for result directory and create it otherwise """
- report_path = "./results"
- if not os.path.exists(report_path):
- os.makedirs(report_path)
-
- report_file_name = '{}/opnfv-{}-{}.html'.format(report_path, test_name, test_date)
-
- os.popen("rally task report %s --out %s" % (task_id, report_file_name))
- cmd = os.popen("rally task results %s" % task_id)
- if task_succeed(cmd.read()):
- print "OK"
+ logger.debug('{} does not exists'.format(test_file_name))
+ proceed_test = retrieve_test_cases_file(test_name, tests_path)
+ logger.debug('successfully downloaded to : {}'.format(test_file_name))
+
+ """ we do the test only if we have a scenario test file """
+ if proceed_test:
+ cmd_line = "rally task start --abort-on-sla-failure %s" % test_file_name
+ logger.debug('running command line : {}'.format(cmd_line))
+ cmd = os.popen(cmd_line)
+ task_id = get_task_id(cmd.read())
+ logger.debug('task_id : {}'.format(task_id))
+
+ if task_id is None:
+ logger.error("failed to retrieve task_id")
+ exit(-1)
+
+ """ check for result directory and create it otherwise """
+ report_path = "./results"
+ if not os.path.exists(report_path):
+ logger.debug('does not exists, we create it'.format(report_path))
+ os.makedirs(report_path)
+
+ """ write html report file """
+ report_file_name = '{}/opnfv-{}-{}.html'.format(report_path, test_name, test_date)
+ cmd_line = "rally task report %s --out %s" % (task_id, report_file_name)
+ logger.debug('running command line : {}'.format(cmd_line))
+ os.popen(cmd_line)
+
+ """ get and save rally operation JSON result """
+ cmd_line = "rally task results %s" % task_id
+ logger.debug('running command line : {}'.format(cmd_line))
+ cmd = os.popen(cmd_line)
+ json_results = cmd.read()
+ with open('{}/opnfv-{}-{}.json'.format(report_path, test_name, test_date), 'w') as f:
+ logger.debug('saving json file')
+ f.write(json_results)
+
+ """ parse JSON operation result """
+ if task_succeed(json_results):
+ print '{} OK'.format(test_date)
+ else:
+ print '{} KO'.format(test_date)