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
38 changes: 38 additions & 0 deletions tests/integration/linodes/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,41 @@ def linode_with_label(linode_cloud_firewall):
res_arr = result.split(",")
linode_id = res_arr[4]
delete_target_id(target="linodes", id=linode_id)


@pytest.fixture(scope="module")
def linode_with_authorization_key(linode_cloud_firewall):
label = "cli" + get_random_text(5)
test_region = get_random_region_with_caps(
required_capabilities=["Linodes", "Disk Encryption"]
)
result = exec_test_command(
BASE_CMDS["linodes"]
+ [
"create",
"--type",
"g6-nanode-1",
"--region",
test_region,
"--image",
DEFAULT_TEST_IMAGE,
"--label",
label,
"--authorized_keys",
"ssh-rsa",
"--kernel",
"linode/latest-64bit",
"--boot_size",
"9000",
"--text",
"--delimiter",
",",
"--no-headers",
"--no-defaults",
"--format",
"id,type",
]
).split(",")

yield result
delete_target_id(target="linodes", id=result[0])
24 changes: 24 additions & 0 deletions tests/integration/linodes/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,27 @@ def get_disk_id(test_linode_instance):
).splitlines()
first_id = disk_id[0].split(",")[0]
return first_id


def wait_for_disk_status(
linode_id: "str", disk_id: "str", timeout, status: "str", period=10
Copy link
Copy Markdown
Contributor

@mawilk90 mawilk90 May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to use existing wait_for_condition instead of creating a new method?

):
must_end = time.time() + timeout
while time.time() < must_end:
time.sleep(period)
result = exec_test_command(
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify if test pass for you. I get error randomly:

E Request failed: 404
E Not found

Copy link
Copy Markdown
Contributor

@mawilk90 mawilk90 May 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it fails so maybe usage of wait_for_condition is going to help (as mentioned here)?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm also getting the 404

[
"linode-cli",
"linodes",
"disk-view",
linode_id,
disk_id,
"--format",
"status",
"--text",
"--no-headers",
]
)
if status == result:
return True
return False
128 changes: 108 additions & 20 deletions tests/integration/linodes/test_linodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
exec_failing_test_command,
exec_test_command,
get_random_region_with_caps,
get_random_text,
retry_exec_test_command_with_delay,
)
from tests.integration.linodes.fixtures import ( # noqa: F401
linode_min_req,
linode_with_authorization_key,
linode_with_label,
linode_wo_image,
test_linode_instance,
Expand All @@ -23,6 +26,7 @@
DEFAULT_TEST_IMAGE,
create_linode,
get_disk_id,
wait_for_disk_status,
wait_until,
)

Expand All @@ -42,6 +46,110 @@ def test_create_linodes_with_a_label(linode_with_label):
)


def test_expected_error_if_fields_authorized_users_authorized_keys_root_pass_are_not_set():
test_region = get_random_region_with_caps(
required_capabilities=["Linodes", "Disk Encryption"]
)
result = exec_failing_test_command(
BASE_CMDS["linodes"]
+ [
"create",
"--type",
"g6-nanode-1",
"--region",
test_region,
"--image",
DEFAULT_TEST_IMAGE,
"--label",
"cli-negative-test-case",
"--kernel",
"linode/latest-64bit",
"--boot_size",
"9000",
"--text",
"--delimiter",
",",
"--no-headers",
"--format",
"label,region,type,image,id",
"--no-defaults",
],
expected_code=ExitCodes.REQUEST_FAILED,
)
assert "Request failed: 400" in result
assert (
"Must provide valid root_pass, authorized_keys, or authorized_users"
in result
)


def test_create_linode_with_kernel_and_boot_size_then_add_disk_and_rebuild(
linode_with_authorization_key,
):
result_create = linode_with_authorization_key
assert result_create[1] == "g6-nanode-1"
assert wait_until(
linode_id=result_create[0], timeout=180, status="running"
), "linode failed to change status to running from creating.."

response_create_disk = (
retry_exec_test_command_with_delay(
BASE_CMDS["linodes"]
+ [
"disk-create",
result_create[0],
"--size",
"2000",
"--label",
"cli" + get_random_text(5),
"--image",
"linode/debian12",
"--root_pass",
"aComplex@Password123",
"--text",
"--no-headers",
"--delimiter",
",",
],
retries=3,
delay=10,
)
.splitlines()[0]
.split(",")
)
assert "not ready" in response_create_disk
assert wait_for_disk_status(
linode_id=result_create[0],
disk_id=response_create_disk[0],
timeout=180,
status="ready",
), "linode failed to change disk status to ready after disk creation.."

result_rebuild = (
exec_test_command(
BASE_CMDS["linodes"]
+ [
"rebuild",
"--image",
DEFAULT_TEST_IMAGE,
"--authorized_keys",
"ssh-rsa-sha2-512",
"--text",
"--no-headers",
"--delimiter",
",",
result_create[0],
]
)
.splitlines()[0]
.split(",")
)
assert DEFAULT_TEST_IMAGE in result_rebuild
assert wait_until(
linode_id=result_create[0], timeout=180, status="running"
), "linode failed to change status to running from rebuilding.."


@pytest.mark.smoke
def test_view_linode_configuration(test_linode_instance):
linode_id = test_linode_instance
Expand Down Expand Up @@ -75,26 +183,6 @@ def test_create_linode_with_min_required_props(linode_min_req):
assert re.search("[0-9]+,us-ord,g6-nanode-1", result)


def test_create_linodes_fails_without_a_root_pass():
result = exec_failing_test_command(
BASE_CMDS["linodes"]
+ [
"create",
"--type",
"g6-nanode-1",
"--region",
"us-ord",
"--image",
DEFAULT_TEST_IMAGE,
"--text",
"--no-headers",
],
ExitCodes.REQUEST_FAILED,
)
assert "Request failed: 400" in result
assert "root_pass root_pass is required" in result


def test_create_linode_without_image_and_not_boot(linode_wo_image):
linode_id = linode_wo_image

Expand Down
Loading