Skip to content
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
7 changes: 7 additions & 0 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import random
import re
import subprocess
import time
from string import ascii_lowercase
Expand Down Expand Up @@ -204,3 +205,9 @@ def get_random_region_with_caps(
matching_region_ids = [region["id"] for region in matching_regions]

return random.choice(matching_region_ids) if matching_region_ids else None


def assert_help_actions_list(expected_actions, help_output):
output_actions = re.findall("\│\s(\S+)\s*\│", help_output)
for expected_action in expected_actions:
assert expected_action in output_actions
38 changes: 38 additions & 0 deletions tests/integration/monitor/test_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,35 @@
from tests.integration.helpers import (
BASE_CMDS,
assert_headers_in_lines,
assert_help_actions_list,
delete_target_id,
exec_test_command,
get_random_text,
retry_exec_test_command_with_delay,
)


def test_help_alerts():
output = exec_test_command(
BASE_CMDS["alerts"]
+ [
"--help",
"--text",
"--delimiter=,",
]
)

actions = [
"channels-list",
"definition-create",
"definition-delete",
"definition-update",
"definition-view",
"definitions-list-all",
]
assert_help_actions_list(actions, output)


def test_channels_list():
res = exec_test_command(
BASE_CMDS["alerts"] + ["channels-list", "--text", "--delimiter=,"]
Expand Down Expand Up @@ -77,6 +99,22 @@ def test_alerts_definition_create(get_channel_id, get_service_type):
)


def test_list_alert_definitions_for_service_type(get_service_type):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, techdocs PR was merged and I can remove skip notation for this test. It should work

service_type = get_service_type
output = exec_test_command(
BASE_CMDS["alerts"]
+ [
"service-definition-view",
service_type,
"--text",
"--delimiter=,",
]
)

headers = ["class", "created", "label", "severity", "service_type"]
assert_headers_in_lines(headers, output.splitlines())


def test_alerts_list():
res = exec_test_command(
BASE_CMDS["alerts"]
Expand Down
32 changes: 26 additions & 6 deletions tests/integration/monitor/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import pytest

from linodecli.exit_codes import ExitCodes
from tests.integration.helpers import (
BASE_CMDS,
assert_headers_in_lines,
exec_failing_test_command,
exec_test_command,
)

Expand Down Expand Up @@ -62,12 +64,12 @@ def test_service_list():


def test_service_view(get_service_type):
dashboard_id = get_service_type
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"service-view",
dashboard_id,
service_type,
"--text",
"--delimiter=,",
]
Expand All @@ -79,12 +81,12 @@ def test_service_view(get_service_type):


def test_dashboard_service_type_list(get_service_type):
dashboard_id = get_service_type
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"dashboards-list",
dashboard_id,
service_type,
"--text",
"--delimiter=,",
]
Expand All @@ -96,12 +98,12 @@ def test_dashboard_service_type_list(get_service_type):


def test_metrics_list(get_service_type):
dashboard_id = get_service_type
service_type = get_service_type
res = exec_test_command(
BASE_CMDS["monitor"]
+ [
"metrics-list",
dashboard_id,
service_type,
"--text",
"--delimiter=,",
]
Expand All @@ -117,3 +119,21 @@ def test_metrics_list(get_service_type):
"scrape_interval",
]
assert_headers_in_lines(headers, lines)


def test_try_create_token_with_not_existing_entity(get_service_type):
service_type = get_service_type
output = exec_failing_test_command(
BASE_CMDS["monitor"]
+ [
"token-get",
service_type,
"--entity_ids",
"99999999999",
"--text",
"--delimiter=,",
],
expected_code=ExitCodes.REQUEST_FAILED,
)
assert "Request failed: 403" in output
assert "The following entity_ids are not valid - [99999999999]" in output