Skip to content

Commit

Permalink
Add user journey test to check that logs can be found for failed buil…
Browse files Browse the repository at this point in the history
…ds (#797)
  • Loading branch information
peytondmurray authored Mar 28, 2024
1 parent 7a83246 commit 9a9496f
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name: simple-broken-environment
channels:
- conda-forge
dependencies:
- invalidpackagenamefaasdfagksdjfhgaskdf==3.1
17 changes: 17 additions & 0 deletions conda-store-server/tests/user_journeys/test_user_journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,20 @@ def test_admin_delete_environment(base_url: str):

assert len(api.list_environments(namespace).json()["data"]) == 0
api.delete_namespace(namespace)


@pytest.mark.user_journey
def test_failed_build_logs(base_url: str):
"""Test that a user can access logs for a failed build."""
api = utils.API(base_url=base_url)
namespace = "default"
build_request = api.create_environment(
namespace,
"tests/user_journeys/test_data/broken_environment.yaml",
).json()

assert build_request["data"]["status"] == "FAILED"
assert (
"invalidpackagenamefaasdfagksdjfhgaskdf"
in api.get_logs(build_request["data"]["id"]).text
)
19 changes: 18 additions & 1 deletion conda-store-server/tests/user_journeys/utils/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,22 @@ def _make_request(
response.raise_for_status()
return response

def get_logs(self, build_id: int) -> requests.Response:
"""Get the logs for the given build id.
Parameters
----------
build_id : int
ID of the build to get the logs for
Returns
-------
requests.Response
Response from the conda-store-server. Logs are stored in the
`.text` property, i.e. response.json()['text']
"""
return self._make_request(f"api/v1/build/{build_id}/logs/")

def _login(self, username: str, password: str) -> None:
"""Log in to the API and set an access token."""
json_data = {"username": username, "password": password}
Expand Down Expand Up @@ -151,7 +167,8 @@ def create_environment(
Returns
-------
requests.Response
Response from the conda-store server
Response from the conda-store server's api/v1/build/{build_id}/
endpoint
"""
with open(specification_path, "r", encoding="utf-8") as file:
specification_content = file.read()
Expand Down

0 comments on commit 9a9496f

Please sign in to comment.