Merge "Exit with nonzero return code if Elastic indexing fails"

This commit is contained in:
Jenkins 2017-04-03 12:44:35 +00:00 committed by Gerrit Code Review
commit 19d73c20ae
5 changed files with 22 additions and 3 deletions

View File

@ -111,11 +111,22 @@ def main():
_logger.info("Saved browbeat result summary to {}".format(
os.path.join(result_dir,time_stamp + '.' + 'report')))
lib.WorkloadBase.WorkloadBase.print_summary()
browbeat_rc = 0
if lib.WorkloadBase.WorkloadBase.failure > 0:
_logger.info("Browbeat Finished with Failures, UUID: {}".format(browbeat_uuid))
sys.exit(1)
browbeat_rc = 1
if lib.WorkloadBase.WorkloadBase.index_failures > 0:
browbeat_rc = 2
if browbeat_rc == 1:
_logger.info("Browbeat finished with test failures, UUID: {}".format(browbeat_uuid))
sys.exit(browbeat_rc)
elif browbeat_rc == 2:
_logger.info("Browbeat finished with Elasticsearch indexing failures, UUID: {}"
.format(browbeat_uuid))
sys.exit(browbeat_rc)
else:
_logger.info("Browbeat Finished Successfully, UUID: {}".format(browbeat_uuid))
_logger.info("Browbeat finished successfully, UUID: {}".format(browbeat_uuid))
sys.exit(0)
if __name__ == '__main__':

View File

@ -104,6 +104,7 @@ class PerfKit(WorkloadBase.WorkloadBase):
if not self.elastic.index_result(result, test_name, result_dir,
str(result_count), 'result'):
index_success = False
self.update_index_failures()
else:
complete_result_json = {'browbeat_scenario': benchmark_config}
complete_result_json['perfkit_errors'] = self.get_error_details(result_dir)

View File

@ -351,6 +351,8 @@ class Rally(WorkloadBase.WorkloadBase):
# Start indexing
index_status = self.json_result(
task_id, scenario_name, run, test_name, result_dir)
if not index_status:
self.update_index_failures()
self.get_time_dict(to_time, from_time,
benchmark[
'name'], new_test_name,

View File

@ -126,6 +126,7 @@ class Shaker(WorkloadBase.WorkloadBase):
result = self.elastic.combine_metadata(shaker_stats)
index_status = self.elastic.index_result(result, test_name, result_dir, _type='error')
if index_status is False:
self.update_index_failures()
return False
else:
return True

View File

@ -23,6 +23,7 @@ class WorkloadBase(object):
failure = 0
total_tests = 0
total_scenarios = 0
index_failures = 0
browbeat = {}
@abc.abstractmethod
@ -53,6 +54,9 @@ class WorkloadBase(object):
def update_total_fail_tests(self):
WorkloadBase.failure += 1
def update_index_failures(self):
WorkloadBase.index_failures += 1
def workload_logger(self, result_dir, workload):
base = result_dir.split('/')
if not os.path.isfile("{}/{}/browbeat-{}-run.log".format(base[0], base[1], workload)):