Skip to content
Merged
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
75 changes: 75 additions & 0 deletions test/integration/models/linode/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,28 @@ def linode_with_disk_encryption(test_linode_client, request):
linode_instance.delete()


@pytest.fixture(scope="session")
def create_linode_with_authorized_key(test_linode_client, ssh_key_gen):
client = test_linode_client

region = get_region(client, {"Linodes", "Cloud Firewall"}, site_type="core")
label = get_test_label(length=8)
Comment on lines +237 to +242

linode_instance = client.linode.instance_create(
"g6-nanode-1",
region,
image="linode/debian12",
label=label,
kernel="linode/latest-64bit",
boot_size=9000,
authorized_keys=ssh_key_gen[0],
)
Comment on lines +244 to +252

yield linode_instance

linode_instance.delete()


# Test helper
def get_status(linode: Instance, status: str):
return linode.status == status
Expand Down Expand Up @@ -1159,3 +1181,56 @@ def test_update_linode_maintenance_policy(create_linode, test_linode_client):
linode.invalidate()
assert result
assert linode.maintenance_policy_id == non_default_policy.slug


def test_expected_error_if_fields_authorized_users_authorized_keys_root_pass_are_not_set(
test_linode_client,
):
client = test_linode_client
region = get_region(client, {"Linodes", "Cloud Firewall"}, site_type="core")
label = get_test_label(length=8)

with pytest.raises(ValueError) as create_instance_error:
client.linode.instance_create(
"g6-nanode-1",
region,
image="linode/debian12",
label=label,
kernel="linode/latest-64bit",
boot_size=9000,
)
assert (
"When creating an Instance from an Image, at least one of root_pass, authorized_users, or authorized_keys must be provided."
in str(create_instance_error.value)
)


Comment on lines +1186 to +1207
def test_create_linode_with_kernel_and_boot_size_then_add_disk_and_rebuild(
create_linode_with_authorized_key,
ssh_key_gen,
):
linode_create = create_linode_with_authorized_key
assert linode_create.image.id == "linode/debian12"

wait_for_condition(10, 300, get_status, linode_create, "running")
disk_create = send_request_when_resource_available(
300,
linode_create.disk_create,
size=2000,
image="linode/debian12",
label="python-disk-test-" + get_test_label(),
root_pass="aComplex@Password123",
)
wait_for_disk_status(disk_create, 120)
assert disk_create.status == "ready"

retry_sending_request(
3,
linode_create.rebuild,
"linode/debian12",
authorized_keys=ssh_key_gen[0],
)
Comment thread
zliang-akamai marked this conversation as resolved.
wait_for_condition(10, 300, get_status, linode_create, "rebuilding")
assert linode_create.status == "rebuilding"
Comment thread
zliang-akamai marked this conversation as resolved.
wait_for_condition(10, 300, get_status, linode_create, "running")
assert linode_create.image.id == "linode/debian12"
Loading