Skip to content
Draft
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/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
exec_test_command,
get_random_region_with_caps,
get_random_text,
check_attribute_value,
wait_for_condition,
)


Expand Down Expand Up @@ -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

Expand Down
14 changes: 14 additions & 0 deletions tests/integration/domains/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
BASE_CMDS,
delete_target_id,
exec_test_command,
check_attribute_value,
get_random_text,
wait_for_condition,
)


Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/domains/test_domain_records.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from tests.integration.helpers import (
BASE_CMDS,
contains_at_least_one_of,
delete_target_id,
exec_test_command,
)

Expand Down Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/events/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
BASE_CMDS,
delete_target_id,
exec_test_command,
check_attribute_value,
get_random_text,
wait_for_condition,
)


Expand All @@ -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)
27 changes: 24 additions & 3 deletions tests/integration/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
5 changes: 5 additions & 0 deletions tests/integration/nodebalancers/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"]
Expand Down
7 changes: 6 additions & 1 deletion tests/integration/obj/test_object_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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-")

Expand Down
Loading