-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[CLI] Cluster logs CLI improvements: new log labels + test coverage increasing #14459
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fc8a5ae
Cluster logs improvements
dmitsf c0780c6
Unit test fix
dmitsf 6b0450d
Merge branch 'master' into dmitsf/improvings_on_cluster_logs
dmitsf 98e9400
Labels for processing deletion errors
dmitsf 6be0d33
Merge branch 'dmitsf/improvings_on_cluster_logs' of github.com:Lightn…
dmitsf 36a0801
Merge branch 'master' into dmitsf/improvings_on_cluster_logs
dmitsf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from unittest import mock | ||
from unittest.mock import MagicMock | ||
|
||
from click.testing import CliRunner | ||
from lightning_cloud.openapi import Externalv1Cluster | ||
|
||
from lightning_app.cli.cmd_clusters import ClusterList | ||
from lightning_app.cli.lightning_cli import cluster_logs | ||
|
||
|
||
@mock.patch("lightning_app.cli.lightning_cli.LightningClient", MagicMock()) | ||
@mock.patch("lightning_app.cli.cmd_clusters.LightningClient", MagicMock()) | ||
@mock.patch("lightning_app.cli.lightning_cli.AWSClusterManager.get_clusters") | ||
def test_show_logs_errors(get_clusters): | ||
"""Test that the CLI prints the errors for the show logs command.""" | ||
|
||
runner = CliRunner() | ||
|
||
# Run without arguments | ||
get_clusters.return_value = ClusterList([]) | ||
result = runner.invoke(cluster_logs, []) | ||
|
||
assert result.exit_code == 2 | ||
assert "Usage: logs" in result.output | ||
|
||
# No clusters | ||
get_clusters.return_value = ClusterList([]) | ||
result = runner.invoke(cluster_logs, ["NonExistentCluster"]) | ||
|
||
assert result.exit_code == 1 | ||
assert "Error: You don't have any clusters" in result.output | ||
|
||
# One cluster | ||
clusters = ClusterList([Externalv1Cluster(name="MyFakeCluster", id="MyFakeCluster")]) | ||
get_clusters.return_value = clusters | ||
|
||
result = runner.invoke(cluster_logs, ["MyFakeClusterTwo"]) | ||
|
||
assert result.exit_code == 1 | ||
assert "Please select one of the following: [MyFakeCluster]" in str(result.output) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.