diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py index 253f1498e..b572f69cf 100644 --- a/tests/integration/conftest.py +++ b/tests/integration/conftest.py @@ -22,6 +22,8 @@ exec_test_command, get_random_region_with_caps, get_random_text, + check_attribute_value, + wait_for_condition, ) @@ -96,6 +98,9 @@ def create_inbound_rule(ipv4_address, ipv6_address): command.extend(["--rules.inbound", inbound_rule]) firewall_id = exec_test_command(command) + # 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 diff --git a/tests/integration/domains/fixtures.py b/tests/integration/domains/fixtures.py index 476e38042..e054ca5bd 100644 --- a/tests/integration/domains/fixtures.py +++ b/tests/integration/domains/fixtures.py @@ -4,7 +4,9 @@ BASE_CMDS, delete_target_id, exec_test_command, + check_attribute_value, get_random_text, + wait_for_condition, ) @@ -27,6 +29,10 @@ def master_domain(): ] ) + # Verify domain status becomes active before proceeding with tests + wait_for_condition(5, 60, check_attribute_value, "domains", "view", + domain_id, "status", "active") + yield domain_id delete_target_id("domains", id=domain_id) @@ -52,6 +58,10 @@ def slave_domain(): ] ) + # Verify domain status becomes active before proceeding with tests + wait_for_condition(5, 60, check_attribute_value, "domains", "view", + domain_id, "status", "active") + yield domain_id delete_target_id("domains", domain_id) @@ -75,6 +85,10 @@ def domain_and_record(): ] ) + # Verify domain status becomes active before proceeding with tests + wait_for_condition(5, 60, check_attribute_value, "domains", "view", + domain_id, "status", "active") + # Create record record_id = exec_test_command( BASE_CMDS["domains"] diff --git a/tests/integration/domains/test_domain_records.py b/tests/integration/domains/test_domain_records.py index 59e307918..90306fd03 100644 --- a/tests/integration/domains/test_domain_records.py +++ b/tests/integration/domains/test_domain_records.py @@ -11,6 +11,7 @@ from tests.integration.helpers import ( BASE_CMDS, contains_at_least_one_of, + delete_target_id, exec_test_command, ) @@ -53,6 +54,9 @@ def test_create_a_domain(master_domain): ) assert another_domain in domain_list_after + # clean-up + delete_target_id("domains", id=another_domain) + @pytest.mark.smoke def test_create_domain_srv_record(domain_and_record): diff --git a/tests/integration/events/fixtures.py b/tests/integration/events/fixtures.py index 0c9b76478..eda3d4096 100644 --- a/tests/integration/events/fixtures.py +++ b/tests/integration/events/fixtures.py @@ -4,7 +4,9 @@ BASE_CMDS, delete_target_id, exec_test_command, + check_attribute_value, get_random_text, + wait_for_condition, ) @@ -27,6 +29,10 @@ def events_create_domain(): ] ) + # Verify domain status becomes active before proceeding with tests + wait_for_condition(5, 60, check_attribute_value, "domains", "view", + domain_id, "status", "active") + yield domain_id delete_target_id(target="domains", id=domain_id) diff --git a/tests/integration/helpers.py b/tests/integration/helpers.py index f74d81957..0cd2df27f 100644 --- a/tests/integration/helpers.py +++ b/tests/integration/helpers.py @@ -58,13 +58,15 @@ def get_random_text(length: int = 10): - return "".join(random.choice(ascii_lowercase) for i in range(length)) + return "".join(random.choice(ascii_lowercase) for _ in range(length)) -def wait_for_condition(interval: int, timeout: int, condition: Callable): +def wait_for_condition(interval: int, timeout: int, condition: Callable, *args): start_time = time.time() while True: - if condition(): + result = condition(*args) + + if result: break if time.time() - start_time > timeout: @@ -213,3 +215,22 @@ def assert_help_actions_list(expected_actions, help_output): output_actions = re.findall(r"│\s(\S+(?:,\s)?\S+)\s*│", help_output) for expected_action in expected_actions: assert expected_action in output_actions + + +def view_command_attribute(command: str, action: str, item_id: str, attribute: str) -> str: + return exec_test_command( + BASE_CMDS[command] + + [ + action, + item_id, + "--text", + "--no-header", + "--format", + attribute, + ] + ) + + +def check_attribute_value(command: str, action: str, item_id: str, attribute: str, expected_val: str) -> bool: + result = view_command_attribute(command, action, item_id, attribute) + return expected_val in result diff --git a/tests/integration/nodebalancers/fixtures.py b/tests/integration/nodebalancers/fixtures.py index ff07d0e57..7ae4be9da 100644 --- a/tests/integration/nodebalancers/fixtures.py +++ b/tests/integration/nodebalancers/fixtures.py @@ -4,6 +4,8 @@ BASE_CMDS, delete_target_id, exec_test_command, + check_attribute_value, + wait_for_condition ) from tests.integration.linodes.helpers import DEFAULT_TEST_IMAGE @@ -216,6 +218,9 @@ def nodebalancer_with_udp_config_and_node(linode_cloud_firewall): "id", ] ) + # Verify configs-list contains just created confid id + wait_for_condition(5, 60, check_attribute_value, "nodebalancers", + "configs-list", nodebalancer_id, "id", config_id) linode_create = exec_test_command( BASE_CMDS["linodes"] diff --git a/tests/integration/obj/test_object_storage.py b/tests/integration/obj/test_object_storage.py index 8a69c34df..1dde58b7c 100644 --- a/tests/integration/obj/test_object_storage.py +++ b/tests/integration/obj/test_object_storage.py @@ -34,7 +34,12 @@ def test_clusters_list(): assert cluster["id"] assert cluster["region"] - assert cluster["status"] in {"available", "unavailable"} + assert cluster["status"] in { + "available", + "unavailable", + "hidden", + "limited", + } assert cluster["domain"].endswith(".linodeobjects.com") assert cluster["static_site_domain"].startswith("website-")