Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 19 additions & 38 deletions ddtrace/testing/internal/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ def get_settings(self) -> Settings:
}

except KeyError as e:
log.error("Git info not available, cannot fetch settings")
log.debug("Git info not available, cannot fetch settings (missing key: %s)", e)
log.error("Git info not available, cannot fetch settings (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return Settings()

Expand All @@ -83,9 +82,8 @@ def get_settings(self) -> Settings:
)
result.on_error_raise_exception()

except Exception:
log.error("Error getting settings from API")
log.debug("Error getting settings from API", exc_info=True)
except Exception as e:
log.error("Error getting settings from API: %s", e)
return Settings()

try:
Expand Down Expand Up @@ -123,18 +121,16 @@ def get_known_tests(self) -> t.Set[TestRef]:
}

except KeyError as e:
log.error("Git info not available, cannot fetch known tests")
log.debug("Git info not available, cannot fetch known tests (missing key: %s)", e)
log.error("Git info not available, cannot fetch known tests (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return set()

try:
result = self.connector.post_json("/api/v2/ci/libraries/tests", request_data, telemetry=telemetry)
result.on_error_raise_exception()

except Exception:
log.error("Error getting known tests from API")
log.debug("Error getting known tests from API", exc_info=True)
except Exception as e:
log.exception("Error getting known tests from API: %s", e)
return set()

try:
Expand All @@ -149,8 +145,7 @@ def get_known_tests(self) -> t.Set[TestRef]:
known_test_ids.add(TestRef(suite_ref, test))

except Exception:
log.error("Error getting known tests from API")
log.debug("Error getting known tests from API", exc_info=True)
log.exception("Error getting known tests from API")
telemetry.record_error(ErrorType.BAD_JSON)
return set()

Expand Down Expand Up @@ -179,11 +174,7 @@ def get_test_management_properties(self) -> t.Dict[TestRef, TestProperties]:
}

except KeyError as e:
log.error("Git info not available, cannot fetch Test Management properties")
log.debug(
"Git info not available, cannot fetch Test Management properties (missing key: %s)",
e,
)
log.error("Git info not available, cannot fetch Test Management properties (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return {}

Expand All @@ -193,9 +184,8 @@ def get_test_management_properties(self) -> t.Dict[TestRef, TestProperties]:
)
result.on_error_raise_exception()

except Exception:
log.error("Error getting Test Management properties from API")
log.debug("Error getting Test Management properties from API", exc_info=True)
except Exception as e:
log.error("Error getting Test Management properties from API: %s", e)
return {}

try:
Expand All @@ -218,8 +208,7 @@ def get_test_management_properties(self) -> t.Dict[TestRef, TestProperties]:
)

except Exception:
log.error("Failed to parse Test Management tests data from API")
log.debug("Failed to parse Test Management tests data from API", exc_info=True)
log.exception("Failed to parse Test Management tests data from API")
telemetry.record_error(ErrorType.BAD_JSON)
return {}

Expand All @@ -243,8 +232,7 @@ def get_known_commits(self, latest_commits: t.List[str]) -> t.List[str]:
}

except KeyError as e:
log.error("Git info not available, cannot fetch known commits")
log.debug("Git info not available, cannot fetch known commits (missing key: %s)", e)
log.error("Git info not available, cannot fetch known commits (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return []

Expand All @@ -262,8 +250,7 @@ def get_known_commits(self, latest_commits: t.List[str]) -> t.List[str]:
known_commits = [item["id"] for item in result.parsed_response["data"] if item["type"] == "commit"]

except Exception:
log.error("Failed to parse search_commits data")
log.debug("Failed to parse search_commits data", exc_info=True)
log.exception("Failed to parse search_commits data")
telemetry.record_error(ErrorType.BAD_JSON)
return []

Expand All @@ -284,8 +271,7 @@ def send_git_pack_file(self, packfile: Path) -> t.Optional[int]:
}

except KeyError as e:
log.error("Git info not available, cannot send git packfile")
log.debug("Git info not available, cannot send git packfile (missing key: %s)", e)
log.error("Git info not available, cannot send git packfile (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return None

Expand All @@ -305,8 +291,7 @@ def send_git_pack_file(self, packfile: Path) -> t.Optional[int]:
]

except Exception:
log.error("Error sending Git pack data")
log.debug("Error sending Git pack data", exc_info=True)
log.exception("Error sending Git pack data")
telemetry.record_error(ErrorType.UNKNOWN)
return None

Expand All @@ -318,7 +303,6 @@ def send_git_pack_file(self, packfile: Path) -> t.Optional[int]:

except Exception:
log.warning("Failed to upload Git pack data")
log.debug("Failed to upload Git pack data", exc_info=True)
return None

return len(content)
Expand Down Expand Up @@ -348,18 +332,16 @@ def get_skippable_tests(self) -> t.Tuple[t.Set[t.Union[SuiteRef, TestRef]], t.Op
}

except KeyError as e:
log.error("Git info not available, cannot get skippable items")
log.debug("Git info not available, cannot get skippable items (missing key: %s)", e)
log.error("Git info not available, cannot get skippable items (missing key: %s)", e)
telemetry.record_error(ErrorType.UNKNOWN)
return set(), None

try:
result = self.connector.post_json("/api/v2/ci/tests/skippable", request_data, telemetry=telemetry)
result.on_error_raise_exception()

except Exception:
log.error("Error getting skippable tests from API")
log.debug("Error getting skippable tests from API", exc_info=True)
except Exception as e:
log.error("Error getting skippable tests from API: %s", e)
return set(), None

try:
Expand All @@ -378,8 +360,7 @@ def get_skippable_tests(self) -> t.Tuple[t.Set[t.Union[SuiteRef, TestRef]], t.Op
correlation_id = result.parsed_response["meta"]["correlation_id"]

except Exception:
log.error("Failed to parse skippable tests data from API")
log.debug("Failed to parse skippable tests data from API", exc_info=True)
log.exception("Failed to parse skippable tests data from API")
telemetry.record_error(ErrorType.BAD_JSON)
return set(), None

Expand Down
Loading