diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 2f1e5ed76..dde6f9e6d 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -18,6 +18,7 @@ from linodecli import ENV_TOKEN_NAME from tests.integration.helpers import ( + DEFAULT_REGION, check_attribute_value, delete_target_id, exec_test_command, @@ -228,8 +229,8 @@ def create_vpc_w_subnet(): vpc_label, "--region", region, - # "--ipv6.range", TODO: Uncomment after VPC Dual Stack is ready to ship - # "auto", + "--ipv6.range", + "auto", "--subnets.ipv4", "10.0.0.0/24", "--subnets.label", @@ -248,3 +249,25 @@ def pytest_configure(config): config.addinivalue_line( "markers", "smoke: mark test as part of smoke test suite" ) + + +@pytest.fixture +def create_reserved_ip(request): + tags = getattr(request, "param", None) + command = [ + "linode-cli", + "networking", + "reserved-ip-add", + "--region", + DEFAULT_REGION, + "--json", + ] + + if tags: + command += ["--tags", tags] + + result = json.loads(exec_test_command(command))[0] + + yield result + + delete_target_id("networking", result["address"], "reserved-ip-delete") diff --git a/tests/integration/database/fixtures.py b/tests/integration/database/fixtures.py index 40212682d..c897b7fcd 100644 --- a/tests/integration/database/fixtures.py +++ b/tests/integration/database/fixtures.py @@ -58,7 +58,7 @@ def mysql_cluster(): "--label", mysql_database_label, "--engine", - "mysql/8", + "mysql/8.4", "--text", "--delimiter", ",", diff --git a/tests/integration/database/test_database_engine_config.py b/tests/integration/database/test_database_engine_config.py index 55c7fa8a9..f0611901c 100644 --- a/tests/integration/database/test_database_engine_config.py +++ b/tests/integration/database/test_database_engine_config.py @@ -404,7 +404,7 @@ def mysql_db_engine_config(linode_cloud_firewall): + [ "mysql-create", "--engine", - "mysql/8", + "mysql/8.4", "--label", label, "--region", diff --git a/tests/integration/firewalls/conftest.py b/tests/integration/firewalls/conftest.py index 3d8fc74a1..3b669bdc3 100644 --- a/tests/integration/firewalls/conftest.py +++ b/tests/integration/firewalls/conftest.py @@ -4,18 +4,32 @@ from tests.integration.helpers import ( BASE_CMDS, + check_attribute_value, delete_target_id, exec_test_command, get_random_text, + wait_for_condition, ) +def get_firewall_defaults(): + result = json.loads( + exec_test_command( + BASE_CMDS["firewalls"] + + [ + "firewall-settings-list", + "--json", + ], + ) + )[0]["default_firewall_ids"] + + return result + + @pytest.fixture(scope="function") def _firewall_id_and_label(): - # generate a unique label - label = "fw-" + get_random_text(5) - # create it and capture the ID - result = exec_test_command( + label = "test-fw-" + get_random_text(5) + firewall_id = exec_test_command( BASE_CMDS["firewalls"] + [ "create", @@ -31,20 +45,33 @@ def _firewall_id_and_label(): "id", ] ) - fw_id = result - yield fw_id, label - # cleanup - delete_target_id(target="firewalls", id=fw_id) + + # Verify firewall status is reachable before proceeding with tests + wait_for_condition( + 5, + 60, + check_attribute_value, + "firewalls", + "view", + firewall_id, + "status", + "enabled", + ) + + yield firewall_id, label + + # cleanup (possible for non-default firewalls only) + delete_target_id(target="firewalls", id=firewall_id) @pytest.fixture(scope="function") -def test_firewall_id(_firewall_id_and_label): +def get_firewall_id(_firewall_id_and_label): """Only the ID, so old tests keep working.""" return _firewall_id_and_label[0] @pytest.fixture(scope="function") -def test_firewall_label(_firewall_id_and_label): +def get_firewall_label(_firewall_id_and_label): """Only the label, for tests that need it explicitly.""" return _firewall_id_and_label[1] @@ -52,11 +79,7 @@ def test_firewall_label(_firewall_id_and_label): @pytest.fixture def restore_firewall_defaults(): # Fetch and store current default firewall settings - result = exec_test_command( - BASE_CMDS["firewalls"] + ["firewall-settings-list", "--json"] - ) - settings = json.loads(result) - original_defaults = settings[0]["default_firewall_ids"] + original_defaults = get_firewall_defaults() yield original_defaults diff --git a/tests/integration/firewalls/test_firewall_settings.py b/tests/integration/firewalls/test_firewall_settings.py index c89ecab4b..c6f77eef0 100644 --- a/tests/integration/firewalls/test_firewall_settings.py +++ b/tests/integration/firewalls/test_firewall_settings.py @@ -8,7 +8,7 @@ ) -def test_firewall_settings_defaults(test_firewall_id, test_firewall_label): +def test_firewall_settings_defaults(get_firewall_id, get_firewall_label): # list all firewalls and extract the IDs list_result = exec_test_command( BASE_CMDS["firewalls"] @@ -21,8 +21,8 @@ def test_firewall_settings_defaults(test_firewall_id, test_firewall_label): ] assert ( - test_firewall_id in firewall_ids - ), f"{test_firewall_id} not found in firewall list" + get_firewall_id in firewall_ids + ), f"{get_firewall_id} not found in firewall list" # get the default firewall settings settings_result = exec_test_command( @@ -57,7 +57,7 @@ def test_firewall_settings_defaults(test_firewall_id, test_firewall_label): ), f"{key} ID ({val}) not found in firewall list" -def test_update_firewall_defaults(test_firewall_id, restore_firewall_defaults): +def test_update_firewall_defaults(get_firewall_id, restore_firewall_defaults): # Fetch current default firewall settings settings = json.loads( exec_test_command( @@ -89,8 +89,8 @@ def test_update_firewall_defaults(test_firewall_id, restore_firewall_defaults): ] assert ( - test_firewall_id in firewall_ids - ), f"{test_firewall_id} not found in firewall list" + get_firewall_id in firewall_ids + ), f"{get_firewall_id} not found in firewall list" new_id = next( fid diff --git a/tests/integration/firewalls/test_firewalls.py b/tests/integration/firewalls/test_firewalls.py index 27baf3e2e..af963e174 100644 --- a/tests/integration/firewalls/test_firewalls.py +++ b/tests/integration/firewalls/test_firewalls.py @@ -195,20 +195,22 @@ def test_update_firewall(firewall_id): assert re.search(firewall_id + "," + updated_label + ",enabled", result) -@pytest.mark.skip("skip until there is a way to delete default firewall") -def test_firewall_settings_update_and_list(test_firewall_id): +@pytest.mark.skip( + reason="Test skipped until there is a way to delete default firewall" +) +def test_firewall_settings_update_and_list(get_firewall_id): for cmd in [ BASE_CMDS["firewalls"] + [ "firewall-settings-update", - "--default_firewall_ids.vpc_interfac", - test_firewall_id, + "--default_firewall_ids.vpc_interface", + get_firewall_id, "--default_firewall_ids.public_interface", - test_firewall_id, + get_firewall_id, "--default_firewall_ids.nodebalancer", - test_firewall_id, + get_firewall_id, "--default_firewall_ids.linode", - test_firewall_id, + get_firewall_id, "--json", ], BASE_CMDS["firewalls"] @@ -217,15 +219,11 @@ def test_firewall_settings_update_and_list(test_firewall_id): "--json", ], ]: - data = json.loads(exec_test_command(cmd).stdout.decode().rstrip()) - firewall_ids = data[0]["default_firewall_ids"] - for key in [ - "linode", - "nodebalancer", - "public_interface", - "vpc_interface", - ]: - assert firewall_ids[key] == int(test_firewall_id) + data = json.loads(exec_test_command(cmd)) + def_firewall_ids = data[0]["default_firewall_ids"] + + for key in def_firewall_ids: + assert def_firewall_ids[key] == int(get_firewall_id) def test_firewall_templates_list(monkeypatch: MonkeyPatch): diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index 03a0fc30b..a1ba7d6ef 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -1,4 +1,5 @@ import json +import os import random import re import subprocess @@ -14,6 +15,12 @@ FAILED_STATUS_CODE = 256 COMMAND_JSON_OUTPUT = ["--suppress-warnings", "--no-defaults", "--json"] +DEFAULT_REGION = ( + "pl-labkrk-2" + if "devcloud" in os.getenv("LINODE_CLI_API_HOST", "") + else "us-ord" +) + # TypeVars for generic type hints below T = TypeVar("T") diff --git a/tests/integration/linodes/fixtures.py b/tests/integration/linodes/fixtures.py index 85ec179ed..265fd5510 100644 --- a/tests/integration/linodes/fixtures.py +++ b/tests/integration/linodes/fixtures.py @@ -5,6 +5,7 @@ from tests.integration.helpers import ( BASE_CMDS, + DEFAULT_REGION, delete_target_id, exec_test_command, get_random_region_with_caps, @@ -16,7 +17,6 @@ DEFAULT_LABEL, DEFAULT_LINODE_TYPE, DEFAULT_RANDOM_PASS, - DEFAULT_REGION, DEFAULT_TEST_IMAGE, create_linode, create_linode_and_wait, @@ -487,8 +487,6 @@ def test_linode_instance(linode_cloud_firewall): "--delimiter", ",", "--no-headers", - "--format", - "id", "--no-defaults", "--format", "id", @@ -700,3 +698,33 @@ def linode_with_authorization_key(linode_cloud_firewall): yield result delete_target_id(target="linodes", id=result[0]) + + +@pytest.fixture +def linode_with_reserved_ip(linode_cloud_firewall, create_reserved_ip): + res_ip = create_reserved_ip["address"] + + linode_id = exec_test_command( + BASE_CMDS["linodes"] + + [ + "create", + "--type", + "g6-nanode-1", + "--region", + DEFAULT_REGION, + "--firewall_id", + linode_cloud_firewall, + "--ipv4", + res_ip, + "--text", + "--no-headers", + "--format", + "id", + ] + ) + + wait_until(linode_id=linode_id, timeout=180, status="offline") + + yield res_ip, linode_id + + delete_target_id(target="linodes", id=linode_id) diff --git a/tests/integration/linodes/helpers.py b/tests/integration/linodes/helpers.py index 39ff206ad..2714a6219 100644 --- a/tests/integration/linodes/helpers.py +++ b/tests/integration/linodes/helpers.py @@ -1,18 +1,13 @@ import json -import os import time from tests.integration.helpers import ( BASE_CMDS, + DEFAULT_REGION, exec_test_command, ) DEFAULT_RANDOM_PASS = exec_test_command(["openssl", "rand", "-base64", "32"]) -DEFAULT_REGION = ( - "pl-labkrk-2" - if "devcloud" in os.getenv("LINODE_CLI_API_HOST", "") - else "us-ord" -) DEFAULT_TEST_IMAGE = exec_test_command( [ diff --git a/tests/integration/linodes/test_linode_interfaces.py b/tests/integration/linodes/test_linode_interfaces.py index f36ed1a50..ca861750a 100644 --- a/tests/integration/linodes/test_linode_interfaces.py +++ b/tests/integration/linodes/test_linode_interfaces.py @@ -146,10 +146,6 @@ def test_interface_settings_update( interface_id, "--default_route.ipv6_interface_id", interface_id, - "--default_route.ipv4_eligible_interface_ids", - interface_id, - "--default_route.ipv6_eligible_interface_ids", - interface_id, "--json", ] ) @@ -161,8 +157,6 @@ def test_interface_settings_update( default_route = settings["default_route"] assert default_route["ipv4_interface_id"] == int(interface_id) assert default_route["ipv6_interface_id"] == int(interface_id) - assert default_route["ipv4_eligible_interface_ids"] == [int(interface_id)] - assert default_route["ipv6_eligible_interface_ids"] == [int(interface_id)] def test_interface_update(linode_interface_public, monkeypatch: MonkeyPatch): diff --git a/tests/integration/linodes/test_linodes.py b/tests/integration/linodes/test_linodes.py index 9b0d361f3..4bbb70bef 100644 --- a/tests/integration/linodes/test_linodes.py +++ b/tests/integration/linodes/test_linodes.py @@ -18,6 +18,7 @@ linode_min_req, linode_with_authorization_key, linode_with_label, + linode_with_reserved_ip, linode_wo_image, test_linode_instance, ) @@ -319,3 +320,40 @@ def test_create_linode_disk_encryption_disabled(linode_cloud_firewall): assert linode_id in res and "disabled" in res delete_target_id(target="linodes", id=linode_id) + + +def test_display_linode_with_res_ipv4(linode_with_reserved_ip): + res_ip, linode_id = linode_with_reserved_ip + result = exec_test_command( + BASE_CMDS["linodes"] + + ["view", linode_id, "--text", "--no-headers", "--no-defaults"] + ) + + assert linode_id in result + assert res_ip in result + + +def test_linode_allocate_res_ipv4(test_linode_instance, create_reserved_ip): + linode_id = test_linode_instance + res_ip = create_reserved_ip["address"] + new_headers = ["reserved", "tags"] + + result = exec_test_command( + BASE_CMDS["linodes"] + + [ + "ip-add", + linode_id, + "--address", + res_ip, + "--type", + "ipv4", + "--public", + "true", + "--text", + "--delimiter", + ",", + ] + ).splitlines() + + assert_headers_in_lines(new_headers, [result[0].split(",")]) + assert res_ip in result[1] diff --git a/tests/integration/monitor/test_alerts.py b/tests/integration/monitor/test_alerts.py index 15ff6449f..6d3328d3c 100644 --- a/tests/integration/monitor/test_alerts.py +++ b/tests/integration/monitor/test_alerts.py @@ -38,12 +38,18 @@ def test_channels_list(): ) lines = res.splitlines() headers = [ + "alerts.alert_count", + "alerts.type", + "alerts.url", "channel_type", - "content.email.email_addresses", + "created", + "created_by", + "details", "id", "label", "type", "updated", + "updated_by", ] assert_headers_in_lines(headers, lines) diff --git a/tests/integration/networking/fixtures.py b/tests/integration/networking/fixtures.py index d6948417e..723694adb 100644 --- a/tests/integration/networking/fixtures.py +++ b/tests/integration/networking/fixtures.py @@ -1,39 +1,12 @@ -import json - import pytest -from tests.integration.helpers import ( - BASE_CMDS, - delete_target_id, - exec_test_command, -) +from tests.integration.helpers import delete_target_id from tests.integration.linodes.helpers import ( - DEFAULT_REGION, create_linode, create_linode_and_wait, ) -@pytest.fixture -def create_reserved_ip(request): - tags = getattr(request, "param", None) - command = BASE_CMDS["networking"] + [ - "reserved-ip-add", - "--region", - DEFAULT_REGION, - "--json", - ] - - if tags: - command += ["--tags", tags] - - result = json.loads(exec_test_command(command))[0] - - yield result - - delete_target_id("networking", result["address"], "reserved-ip-delete") - - @pytest.fixture(scope="package") def get_linode_id(linode_cloud_firewall): linode_id = create_linode_and_wait(firewall_id=linode_cloud_firewall) @@ -60,11 +33,3 @@ def get_linode_ids_shared_ipv4(linode_cloud_firewall): for id_num in linode_ids: delete_target_id(target="linodes", id=id_num) - - -def get_command_heads_and_vals(command): - result = exec_test_command(command).splitlines() - headers = [item for item in result[0].split(",")] - values = [item for item in result[1].split(",")] - - return headers, values diff --git a/tests/integration/networking/test_networking.py b/tests/integration/networking/test_networking.py index 23904b956..445d389fa 100644 --- a/tests/integration/networking/test_networking.py +++ b/tests/integration/networking/test_networking.py @@ -7,13 +7,11 @@ from tests.integration.helpers import ( BASE_CMDS, + DEFAULT_REGION, assert_headers_in_lines, exec_test_command, ) -from tests.integration.linodes.helpers import DEFAULT_REGION from tests.integration.networking.fixtures import ( # noqa: F401 - create_reserved_ip, - get_command_heads_and_vals, get_linode_id, get_linode_ids_shared_ipv4, ) diff --git a/tests/integration/nodebalancers/fixtures.py b/tests/integration/nodebalancers/fixtures.py index a1a973e66..958b802de 100644 --- a/tests/integration/nodebalancers/fixtures.py +++ b/tests/integration/nodebalancers/fixtures.py @@ -336,3 +336,29 @@ def simple_nodebalancer_with_config(linode_cloud_firewall): yield nodebalancer_id, config_id delete_target_id(target="nodebalancers", id=nodebalancer_id) + + +@pytest.fixture +def nodebalancer_with_reserved_ipv4(create_reserved_ip): + res_ip = create_reserved_ip["address"] + region = create_reserved_ip["region"] + nodebalancer_id = exec_test_command( + BASE_CMDS["nodebalancers"] + + [ + "create", + "--region", + region, + "--ipv4", + res_ip, + "--text", + "--delimiter", + ",", + "--no-headers", + "--format", + "id", + ] + ) + + yield res_ip, nodebalancer_id + + delete_target_id(target="nodebalancers", id=nodebalancer_id) diff --git a/tests/integration/nodebalancers/test_node_balancers.py b/tests/integration/nodebalancers/test_node_balancers.py index 1a0bac919..69564852a 100644 --- a/tests/integration/nodebalancers/test_node_balancers.py +++ b/tests/integration/nodebalancers/test_node_balancers.py @@ -12,6 +12,7 @@ linode_to_add, nodebalancer_w_config_and_node, nodebalancer_with_default_conf, + nodebalancer_with_reserved_ipv4, nodebalancer_with_udp_config_and_node, simple_nodebalancer_with_config, ) @@ -68,6 +69,23 @@ def test_display_public_ipv4_for_nodebalancer(nodebalancer_w_config_and_node): assert re.search(r"^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}", result) +def test_display_nodebalancer_with_res_ipv4(nodebalancer_with_reserved_ipv4): + res_ip, nb_id = nodebalancer_with_reserved_ipv4 + result = exec_test_command( + BASE_CMDS["nodebalancers"] + + [ + "view", + nb_id, + "--format", + "ipv4", + "--text", + "--no-headers", + ] + ) + + assert res_ip in result + + def test_fail_to_view_nodebalancer_with_invalid_id(): result = exec_failing_test_command( BASE_CMDS["nodebalancers"] + ["view", "535", "--text", "--no-headers"], diff --git a/tests/integration/obj/conftest.py b/tests/integration/obj/conftest.py index 87006fce7..42b9b06a3 100644 --- a/tests/integration/obj/conftest.py +++ b/tests/integration/obj/conftest.py @@ -1,4 +1,5 @@ import json +import logging from dataclasses import dataclass from pathlib import Path from typing import Callable, List, Optional @@ -58,14 +59,17 @@ def _create_bucket(bucket_name: Optional[str] = None): exec_test_command(BASE_CMD + ["mb", bucket_name]) created_buckets.add(bucket_name) + return bucket_name yield _create_bucket - for bk in created_buckets: + + for bucket in created_buckets: try: - delete_bucket(bk) + delete_bucket(bucket) + except Exception as e: - logging.exception(f"Failed to cleanup bucket: {bk}, {e}") + logging.exception(f"Failed to cleanup bucket {bucket}: {e}") @pytest.fixture diff --git a/tests/integration/obj/test_object_storage.py b/tests/integration/obj/test_object_storage.py index 1dde58b7c..c5845a002 100644 --- a/tests/integration/obj/test_object_storage.py +++ b/tests/integration/obj/test_object_storage.py @@ -1,7 +1,6 @@ import json from typing import Callable, Optional -import pytest from pytest import MonkeyPatch from tests.integration.helpers import ( @@ -263,14 +262,11 @@ def test_endpoints(): assert us_east["s3_endpoint"] == "us-east-1.linodeobjects.com" -@pytest.mark.skipif( - reason="Skipping until the command is fixed and aligned with techdocs example. Applicable for spec version after 4.197.1" -) def test_transfers(): data = exec_test_command( BASE_CMDS["object-storage"] + [ - "transfers", + "transfer-view", "--json", ] ) diff --git a/tests/integration/support/test_support.py b/tests/integration/support/test_support.py index 7ceb2bd63..068399bca 100644 --- a/tests/integration/support/test_support.py +++ b/tests/integration/support/test_support.py @@ -5,26 +5,52 @@ assert_headers_in_lines, delete_target_id, exec_test_command, - get_random_text, ) from tests.integration.linodes.helpers import create_linode +HEADERS = ["id", "summary", "opened_by", "opened", "description"] + @pytest.fixture def support_test_linode_id(linode_cloud_firewall): - label = "cli-" + get_random_text(5) - - linode_id = create_linode() + linode_id = create_linode( + firewall_id=linode_cloud_firewall, + booted=False, + ) yield linode_id delete_target_id(target="linodes", id=linode_id) -# this will create a support ticket on your account -@pytest.mark.skip(reason="this will create a support ticket") +@pytest.fixture +def get_ticket_id(): + res = exec_test_command( + BASE_CMDS["tickets"] + + [ + "list", + "--text", + "--no-headers", + "--delimiter", + ",", + "--format", + "id", + ] + ) + ticket_ids = res.splitlines() + + if not ticket_ids or ticket_ids == [""]: + pytest.skip("No support tickets available to test.") + + yield ticket_ids[0] + + +@pytest.mark.skip( + reason="Test skipped because it creates a support ticket on the account" +) def test_create_support_ticket(support_test_linode_id): linode_id = support_test_linode_id + exec_test_command( BASE_CMDS["tickets"] + [ @@ -34,7 +60,8 @@ def test_create_support_ticket(support_test_linode_id): "--linode_id", linode_id, "--summary", - "Testing ticket" "--text", + "Testing ticket", + "--text", "--no-headers", ] ) @@ -45,49 +72,30 @@ def test_tickets_list(): BASE_CMDS["tickets"] + ["list", "--text", "--delimiter=,"] ) lines = res.splitlines() - headers = ["summary", "opened_by", "opened"] - assert_headers_in_lines(headers, lines) + assert_headers_in_lines(HEADERS, lines) -@pytest.fixture -def tickets_id(): - res = exec_test_command( - BASE_CMDS["tickets"] - + [ - "list", - "--text", - "--no-headers", - "--delimiter", - ",", - "--format", - "id", - ] - ) - ticket_ids = res.splitlines() - if not ticket_ids or ticket_ids == [""]: - pytest.skip("No support tickets available to test.") - first_id = ticket_ids[0] - yield first_id - -def test_tickets_view(tickets_id): - if not tickets_id: +def test_tickets_view(get_ticket_id): + if not get_ticket_id: pytest.skip("No support tickets available to view.") - ticket_id = tickets_id + ticket_id = get_ticket_id + res = exec_test_command( BASE_CMDS["tickets"] + ["view", ticket_id, "--text", "--delimiter=,"] ) lines = res.splitlines() - headers = ["summary", "opened_by", "opened"] - assert_headers_in_lines(headers, lines) + + assert_headers_in_lines(HEADERS, lines) @pytest.mark.skip( - reason="Creation of tickets are skipped no way of currently testing this" + reason="Test skipped because ticket creation test is skipped as well" ) -def test_reply_support_ticket(tickets_id): - ticket_id = tickets_id +def test_reply_support_ticket(get_ticket_id): + ticket_id = get_ticket_id + exec_test_command( BASE_CMDS["tickets"] + [ @@ -101,14 +109,15 @@ def test_reply_support_ticket(tickets_id): ) -def test_view_replies_support_ticket(tickets_id): - if not tickets_id: +def test_view_replies_support_ticket(get_ticket_id): + if not get_ticket_id: pytest.skip("No support tickets available to view replies.") - ticket_id = tickets_id + ticket_id = get_ticket_id res = exec_test_command( BASE_CMDS["tickets"] + ["replies", ticket_id, "--text", "--delimiter=,"] ) lines = res.splitlines() + headers = ["created_by", "created"] assert_headers_in_lines(headers, lines) diff --git a/tests/integration/tags/test_tags.py b/tests/integration/tags/test_tags.py index 4022cd746..e85fc5708 100644 --- a/tests/integration/tags/test_tags.py +++ b/tests/integration/tags/test_tags.py @@ -11,9 +11,6 @@ exec_test_command, get_random_text, ) -from tests.integration.networking.fixtures import ( # noqa: F401 - create_reserved_ip, -) @pytest.fixture(scope="session") @@ -64,7 +61,7 @@ def test_view_unique_tag(create_tag_instance): assert create_tag_instance in result -@pytest.mark.skip(reason="BUG = TPT-3650") +@pytest.mark.skip(reason="Defect: ARB-8130") def test_fail_to_create_tag_shorter_than_three_char(): bad_tag = "aa" result = exec_failing_test_command( diff --git a/tests/integration/vpc/conftest.py b/tests/integration/vpc/conftest.py index d4cbb033f..5639b6e60 100644 --- a/tests/integration/vpc/conftest.py +++ b/tests/integration/vpc/conftest.py @@ -34,8 +34,8 @@ def test_vpc_wo_subnet(): label, "--region", region, - # "--ipv6.range", TODO: Uncomment after VPC Dual Stack is ready to ship - # "auto", + "--ipv6.range", + "auto", "--no-headers", "--text", "--format=id", diff --git a/tests/integration/vpc/test_vpc.py b/tests/integration/vpc/test_vpc.py index 6616aa9f6..e802f8ba0 100644 --- a/tests/integration/vpc/test_vpc.py +++ b/tests/integration/vpc/test_vpc.py @@ -1,4 +1,5 @@ import json +import os import re import pytest @@ -10,15 +11,12 @@ exec_test_command, get_random_region_with_caps, get_random_text, + wait_for_condition, ) BASE_CMD = ["linode-cli", "vpcs"] -# TODO: Remove this variable and @pytest.mark.skipif once VPC Dual Stack is ready to ship -disable_vpc_dual_stack_tests = True - - def test_list_vpcs(test_vpc_wo_subnet): vpc_id = test_vpc_wo_subnet res = exec_test_command(BASE_CMDS["vpcs"] + ["ls", "--text"]) @@ -78,14 +76,15 @@ def test_list_subnets(test_vpc_w_subnet): lines = res.splitlines() - headers = ["id", "label", "ipv4"] + headers = ["id", "label", "ipv4", "vpc_type"] for header in headers: assert header in lines[0] for line in lines[1:]: assert re.match( - r"^(\d+),(\w+),(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d+)$", line + r"^(\d+),(\w+),(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/\d+),(\w+)$", + line, ), "String format does not match" @@ -137,6 +136,7 @@ def test_update_subnet(test_vpc_w_subnet): assert new_label == updated_label +@pytest.mark.skip(reason="Defect: ARB-8019") def test_fails_to_create_vpc_invalid_label(): invalid_label = "invalid_label" region = get_random_region_with_caps(required_capabilities=["VPCs"]) @@ -165,6 +165,7 @@ def test_fails_to_create_vpc_duplicate_label(test_vpc_wo_subnet): assert "Label must be unique among your VPCs" in res +@pytest.mark.skip(reason="Defect: ARB-8019") def test_fails_to_update_vpc_invalid_label(test_vpc_wo_subnet): vpc_id = test_vpc_wo_subnet invalid_label = "invalid_label" @@ -178,6 +179,7 @@ def test_fails_to_update_vpc_invalid_label(test_vpc_wo_subnet): assert "Must only use ASCII letters, numbers, and dashes" in res +@pytest.mark.skip(reason="Defect: ARB-8019") def test_fails_to_create_vpc_subnet_w_invalid_label(test_vpc_wo_subnet): vpc_id = test_vpc_wo_subnet invalid_label = "invalid_label" @@ -199,6 +201,7 @@ def test_fails_to_create_vpc_subnet_w_invalid_label(test_vpc_wo_subnet): assert "Must only use ASCII letters, numbers, and dashes" in res +@pytest.mark.skip(reason="Defect: ARB-8019") def test_fails_to_update_vpc_subnet_w_invalid_label(test_vpc_w_subnet): vpc_id = test_vpc_w_subnet @@ -228,9 +231,6 @@ def test_fails_to_update_vpc_subnet_w_invalid_label(test_vpc_w_subnet): assert "Must only use ASCII letters, numbers, and dashes" in res -@pytest.mark.skipif( - disable_vpc_dual_stack_tests, reason="Dual-stack tests disabled" -) def test_create_vpc_with_ipv6_auto(): region = get_random_region_with_caps(required_capabilities=["VPCs"]) label = get_random_text(5) + "-vpc" @@ -261,9 +261,6 @@ def test_create_vpc_with_ipv6_auto(): @pytest.mark.parametrize("prefix_len", ["52"]) -@pytest.mark.skipif( - disable_vpc_dual_stack_tests, reason="Dual-stack tests disabled" -) def test_create_vpc_with_custom_ipv6_prefix_length(prefix_len): region = get_random_region_with_caps(required_capabilities=["VPCs"]) label = get_random_text(5) + f"-vpc{prefix_len}" @@ -291,9 +288,6 @@ def test_create_vpc_with_custom_ipv6_prefix_length(prefix_len): assert ipv6_range.endswith(f"/{prefix_len}") -@pytest.mark.skipif( - disable_vpc_dual_stack_tests, reason="Dual-stack tests disabled" -) def test_create_subnet_with_ipv6_auto(test_vpc_wo_subnet): vpc_id = test_vpc_wo_subnet subnet_label = get_random_text(5) + "-ipv6subnet" @@ -330,9 +324,6 @@ def test_create_subnet_with_ipv6_auto(test_vpc_wo_subnet): assert "/" in ipv6_range, f"Unexpected IPv6 CIDR format: {ipv6_range}" -@pytest.mark.skipif( - disable_vpc_dual_stack_tests, reason="Dual-stack tests disabled" -) def test_fails_to_create_vpc_with_invalid_ipv6_range(): region = get_random_region_with_caps(required_capabilities=["VPCs"]) label = get_random_text(5) + "-invalidvpc" @@ -368,9 +359,6 @@ def test_list_vpc_ip_address(): assert header in lines[0] -@pytest.mark.skipif( - disable_vpc_dual_stack_tests, reason="Dual-stack tests disabled" -) def test_list_vpc_ipv6s_address(): res = exec_test_command( @@ -385,6 +373,10 @@ def test_list_vpc_ipv6s_address(): assert header in lines[0] +@pytest.mark.skipif( + os.environ.get("LINODE_CLI_API_VERSION", None) != "v4beta", + reason="At the moment default-ranges-all-list command is available on beta env only", +) def test_get_vpc_default_ranges(): headers = ["default_ipv4_ranges", "forbidden_ipv4_ranges"] @@ -408,10 +400,15 @@ def test_get_vpc_default_ranges(): def test_vpc_with_ipv4(create_vpc_with_ipv4, expected): vpc_id = create_vpc_with_ipv4 - result = exec_test_command( - BASE_CMDS["vpcs"] + ["list", "--text", "--format=id", "--no-headers"] - ) - assert vpc_id in result.splitlines() + def vpc_ready(): + vpc_ids = exec_test_command( + BASE_CMDS["vpcs"] + + ["list", "--text", "--format=id", "--no-headers"] + ).splitlines() + + return vpc_id in vpc_ids + + wait_for_condition(3, 30, vpc_ready) result = json.loads( exec_test_command(BASE_CMDS["vpcs"] + ["view", vpc_id, "--json"]) @@ -446,6 +443,10 @@ def test_vpc_update_with_ipv4(create_vpc_with_ipv4, updated): assert result["ipv4"][0]["range"] == updated +@pytest.mark.skipif( + os.environ.get("LINODE_CLI_API_VERSION", None) != "v4beta", + reason="At the moment default-ranges-all-list command is available on beta env only", +) def test_vpc_with_forbidden_ipv4_fail(): forbidden_ipv4 = exec_test_command( BASE_CMD