Skip to content
Open
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
5 changes: 5 additions & 0 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ def assert_help_actions_list(expected_actions, help_output):
assert expected_action in output_actions


def assert_help_parameters_list_for_command(expected_parameters, help_output):
for expected_parameter in expected_parameters:
assert expected_parameter in help_output


def view_command_attribute(
command: str, action: str, item_id: str, attribute: str
) -> str:
Expand Down
71 changes: 71 additions & 0 deletions tests/integration/nodebalancers/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
check_attribute_value,
delete_target_id,
exec_test_command,
get_random_region_with_caps,
get_random_text,
wait_for_condition,
)
from tests.integration.linodes.helpers import DEFAULT_TEST_IMAGE
Expand Down Expand Up @@ -362,3 +364,72 @@ def nodebalancer_with_reserved_ipv4(create_reserved_ip):
yield res_ip, nodebalancer_id

delete_target_id(target="nodebalancers", id=nodebalancer_id)


@pytest.fixture
def nodebalancer_type_premium_backend_connectivity_vpc(linode_cloud_firewall):
vpc_label = get_random_text(5) + "label"
subnet_label = get_random_text(5) + "label"
test_region = get_random_region_with_caps(
["NodeBalancers", "Premium NodeBalancers"]
)

test_vpc_id = exec_test_command(
[
"linode-cli",
"vpcs",
"create",
"--label",
vpc_label,
"--region",
test_region,
"--subnets.ipv4",
"192.168.0.0/25",
"--subnets.label",
subnet_label,
"--text",
"--suppress-warnings",
"--format",
"id",
"--no-headers",
]
)
test_subnet_id = exec_test_command(
BASE_CMDS["vpcs"]
Comment on lines +397 to +398
+ [
"subnets-list",
test_vpc_id,
"--text",
"--no-headers",
"--delimiter=,",
]
).split(",")[0]

result = exec_test_command(
BASE_CMDS["nodebalancers"]
+ [
"create",
"--region",
test_region,
"--firewall_id",
linode_cloud_firewall,
"--type",
"premium",
"--backend_connectivity",
"vpc",
"--vpcs.ipv4_range",
"192.168.0.64/30",
"--vpcs.subnet_id",
test_subnet_id,
"--text",
"--delimiter",
",",
"--suppress-warnings",
"--no-headers",
]
)
nodebalancer_id = result.split(",")[0]

yield nodebalancer_id, result
delete_target_id(target="nodebalancers", id=nodebalancer_id)
delete_target_id(target="vpcs", id=test_vpc_id)
90 changes: 90 additions & 0 deletions tests/integration/nodebalancers/test_node_balancers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
from linodecli.exit_codes import ExitCodes
from tests.integration.helpers import (
BASE_CMDS,
assert_headers_in_lines,
assert_help_parameters_list_for_command,
exec_failing_test_command,
exec_test_command,
get_random_text,
)
from tests.integration.nodebalancers.fixtures import ( # noqa: F401
linode_to_add,
nodebalancer_type_premium_backend_connectivity_vpc,
nodebalancer_w_config_and_node,
nodebalancer_with_default_conf,
nodebalancer_with_reserved_ipv4,
Expand Down Expand Up @@ -52,6 +56,28 @@ def test_list_nodebalancers_and_status(nodebalancer_w_config_and_node):
assert re.search(nodebalancer_created(), result)


def test_verify_columns_for_list_nodebalancers():
result = exec_test_command(
BASE_CMDS["nodebalancers"]
+ [
"list",
"--text",
"--delimiter",
",",
]
)
lines = result.splitlines()
headers = [
"id",
"label",
"region",
"type",
"backend_connectivity",
"backend_ipv6_prefix",
]
assert_headers_in_lines(headers, lines)


def test_display_public_ipv4_for_nodebalancer(nodebalancer_w_config_and_node):
nodebalancer_id = nodebalancer_w_config_and_node[0]

Expand Down Expand Up @@ -564,3 +590,67 @@ def test_view_node_for_node_balancer_udp_configuration(

def nodebalancer_created():
return "[0-9]+,balancer[0-9]+,us-ord,[0-9]+-[0-9]+-[0-9]+-[0-9]+.ip.linodeusercontent.com,0"


def test_premium_nodebalancer_with_vpc_backend_connectivity(
nodebalancer_type_premium_backend_connectivity_vpc,
):
result_create = nodebalancer_type_premium_backend_connectivity_vpc[1]
assert "premium" in result_create
assert "vpc" in result_create
assert "/96" in result_create

result_view = exec_test_command(
BASE_CMDS["nodebalancers"]
+ [
"view",
nodebalancer_type_premium_backend_connectivity_vpc[0],
"--text",
"--no-headers",
"--format",
"type,backend_connectivity,backend_ipv6_prefix",
"--delimiter",
",",
]
).split(",")
assert result_view[0] == "premium"
assert result_view[1] == "vpc"
assert result_view[2].endswith("/96")

result_update = exec_test_command(
BASE_CMDS["nodebalancers"]
+ [
"update",
nodebalancer_type_premium_backend_connectivity_vpc[0],
"--label",
"update_label_" + get_random_text(5),
"--client_conn_throttle",
"0",
"--text",
"--no-headers",
"--delimiter",
",",
]
)
assert "premium" in result_update
assert "vpc" in result_update
assert "/96" in result_update


def test_create_nodebalancer_help_command():
output = exec_test_command(
BASE_CMDS["nodebalancers"] + ["create", "--help", "--text"]
)
available_arguments = [
"backend_connectivity",
"client_conn_throttle",
"configs",
"firewall_id",
"ipv4",
"region",
"type",
"vpcs.ipv4_range",
"vpcs.ipv4_range_auto_assign",
"vpcs.subnet_id",
]
assert_help_parameters_list_for_command(available_arguments, output)
Loading