Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user journey test to check that logs can be found for failed builds #797

Merged
Merged
Show file tree
Hide file tree
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
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
Loading