Repository navigation
TPT-4651: Add integration tests for Premium NodeBalancer changes #933
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -362,3 +364,84 @@ 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( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO, this name is a bit redundant. What do you think to make it simpler, e.g. |
||
| linode_cloud_firewall, | ||
| vpc_for_nodebalancer_type_premium_backend_connectivity_vpc, | ||
| ): | ||
| test_region = get_random_region_with_caps( | ||
| ["NodeBalancers", "Premium NodeBalancers"] | ||
| ) | ||
|
Comment on lines
+374
to
+376
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree, it will probably fail on Prod |
||
| test_subnet_id = exec_test_command( | ||
| BASE_CMDS["vpcs"] | ||
|
Copilot marked this conversation as resolved.
|
||
| + [ | ||
| "subnets-list", | ||
| vpc_for_nodebalancer_type_premium_backend_connectivity_vpc, | ||
| "--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) | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def vpc_for_nodebalancer_type_premium_backend_connectivity_vpc(): | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1. What do you think about: |
||
| 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", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. BASE_CMDS["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", | ||
| ] | ||
| ) | ||
|
|
||
| yield test_vpc_id | ||
| delete_target_id(target="vpcs", id=test_vpc_id) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,16 +5,21 @@ | |
| 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, | ||
| nodebalancer_with_udp_config_and_node, | ||
| simple_nodebalancer_with_config, | ||
| vpc_for_nodebalancer_type_premium_backend_connectivity_vpc, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems to be never used in this file |
||
| ) | ||
|
|
||
|
|
||
|
|
@@ -52,6 +57,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] | ||
|
|
||
|
|
@@ -564,3 +591,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) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it will never fail without
assert