Fix None comparisons in TIAF scripts.
Signed-off-by: John <jonawals@amazon.com>
This commit is contained in:
@@ -100,7 +100,7 @@ class FilebeatClient(object):
|
||||
self._open_socket()
|
||||
|
||||
def send_event(self, payload, index, timestamp=None, pipeline="filebeat"):
|
||||
if timestamp is None:
|
||||
if not timestamp:
|
||||
timestamp = datetime.datetime.utcnow().timestamp()
|
||||
|
||||
event = {
|
||||
@@ -437,7 +437,7 @@ def transmit_report_to_mars(mars_index_prefix: str, tiaf_result: dict, driver_ar
|
||||
mars_job = generate_mars_job(tiaf_result, driver_args)
|
||||
filebeat.send_event(mars_job, f"{mars_index_prefix}.tiaf.job")
|
||||
|
||||
if tiaf_result[REPORT_KEY] is not None:
|
||||
if tiaf_result[REPORT_KEY]:
|
||||
# Generate and transmit the MARS sequence document
|
||||
mars_sequence = generate_mars_sequence(tiaf_result[REPORT_KEY], mars_job, tiaf_result[CHANGE_LIST_KEY], t0_timestamp)
|
||||
filebeat.send_event(mars_sequence, f"{mars_index_prefix}.tiaf.sequence")
|
||||
|
||||
@@ -49,6 +49,8 @@ class TestImpact:
|
||||
if self._use_test_impact_analysis and not self._tiaf_bin.is_file():
|
||||
logger.warning(f"Could not find TIAF binary at location {self._tiaf_bin}, TIAF will be turned off.")
|
||||
self._use_test_impact_analysis = False
|
||||
else:
|
||||
logger.info(f"Runtime binary found at location {self._tiaf_bin}")
|
||||
|
||||
# Workspaces
|
||||
self._active_workspace = self._config["workspace"]["active"]["root"]
|
||||
@@ -72,7 +74,7 @@ class TestImpact:
|
||||
|
||||
# Check whether or not a previous commit hash exists (no hash is not a failure)
|
||||
self._src_commit = last_commit_hash
|
||||
if self._src_commit is not None:
|
||||
if self._src_commit:
|
||||
if self._repo.is_descendent(self._src_commit, self._dst_commit) == False:
|
||||
logger.info(f"Source commit '{self._src_commit}' and destination commit '{self._dst_commit}' are not related.")
|
||||
return
|
||||
@@ -182,7 +184,7 @@ class TestImpact:
|
||||
logger.info(f"Dst branch: '{self._dst_branch}'.")
|
||||
|
||||
# Source of truth (the branch from which the coverage data will be stored/retrieved from)
|
||||
if self._dst_branch is None or self._src_branch == self._dst_branch:
|
||||
if not self._dst_branch or self._src_branch == self._dst_branch:
|
||||
# Branch builds are their own source of truth and will update the coverage data for the source of truth after any instrumented sequences complete
|
||||
self._is_source_of_truth_branch = True
|
||||
self._source_of_truth_branch = self._src_branch
|
||||
@@ -207,7 +209,7 @@ class TestImpact:
|
||||
logger.info("Test impact analysis is enabled.")
|
||||
try:
|
||||
# Persistent storage location
|
||||
if s3_bucket is not None:
|
||||
if s3_bucket:
|
||||
persistent_storage = PersistentStorageS3(self._config, suite, s3_bucket, self._source_of_truth_branch)
|
||||
else:
|
||||
persistent_storage = PersistentStorageLocal(self._config, suite)
|
||||
@@ -215,7 +217,7 @@ class TestImpact:
|
||||
logger.warning(f"The persistent storage encountered an irrecoverable error, test impact analysis will be disabled: '{e}'")
|
||||
persistent_storage = None
|
||||
|
||||
if persistent_storage is not None:
|
||||
if persistent_storage:
|
||||
if persistent_storage.has_historic_data:
|
||||
logger.info("Historic data found.")
|
||||
self._attempt_to_generate_change_list(persistent_storage.last_commit_hash, instance_id)
|
||||
@@ -278,10 +280,10 @@ class TestImpact:
|
||||
logger.info(f"Test suite is set to '{suite}'.")
|
||||
|
||||
# Timeouts
|
||||
if test_timeout != None:
|
||||
if test_timeout is not None:
|
||||
args.append(f"--ttimeout={test_timeout}")
|
||||
logger.info(f"Test target timeout is set to {test_timeout} seconds.")
|
||||
if global_timeout != None:
|
||||
if global_timeout is not None:
|
||||
args.append(f"--gtimeout={global_timeout}")
|
||||
logger.info(f"Global sequence timeout is set to {test_timeout} seconds.")
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ if __name__ == "__main__":
|
||||
tiaf = TestImpact(args.config)
|
||||
tiaf_result = tiaf.run(args.commit, args.src_branch, args.dst_branch, args.s3_bucket, args.suite, args.test_failure_policy, args.safe_mode, args.test_timeout, args.global_timeout)
|
||||
|
||||
if args.mars_index_prefix is not None:
|
||||
if args.mars_index_prefix:
|
||||
logger.info("Transmitting report to MARS...")
|
||||
mars_utils.transmit_report_to_mars(args.mars_index_prefix, tiaf_result, sys.argv)
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ class PersistentStorage(ABC):
|
||||
"""
|
||||
|
||||
historic_data_json = self._pack_historic_data(last_commit_hash)
|
||||
if historic_data_json is not None:
|
||||
if historic_data_json:
|
||||
self._store_historic_data(historic_data_json)
|
||||
else:
|
||||
logger.info("The historic data could not be successfully stored.")
|
||||
|
||||
Reference in New Issue
Block a user