Skip to content
Merged
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
19 changes: 9 additions & 10 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
import os
import random
import subprocess
import time
from test.integration.helpers import (
get_test_label,
Expand Down Expand Up @@ -262,21 +263,19 @@ def create_linode_for_pass_reset(test_linode_client, e2e_test_firewall):


@pytest.fixture(scope="session")
def ssh_key_gen():
output = os.popen("ssh-keygen -q -t rsa -f ./sdk-sshkey -q -N ''")
def ssh_key_gen(tmp_path_factory):
key_path = tmp_path_factory.mktemp("ssh-key-gen") / "sdk-sshkey"

time.sleep(1)

pub_file = open("./sdk-sshkey.pub", "r")
pub_key = pub_file.read().rstrip()
subprocess.run(
["ssh-keygen", "-q", "-t", "rsa", "-f", str(key_path), "-N", ""],
check=True,
)
Comment thread
lgarber-akamai marked this conversation as resolved.

priv_file = open("./sdk-sshkey", "r")
priv_key = priv_file.read().rstrip()
pub_key = key_path.with_suffix(".pub").read_text().rstrip()
priv_key = key_path.read_text().rstrip()
Comment on lines +266 to +275

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.

This is necessary because the previous implementation was non-blocking, which caused some weird timing issues in CI


yield pub_key, priv_key

os.popen("rm ./sdk-sshkey*")


@pytest.fixture(scope="session")
def test_linode_client():
Expand Down
24 changes: 18 additions & 6 deletions test/integration/models/linode/interfaces/test_interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,33 @@ def build_interface_public_ipv4(firewall, ip_address):
)


def create_linode_with_legacy_config(client, ip_address, label, firewall):
linode, _ = client.linode.instance_create(
def create_linode_with_legacy_config(
client, ip_address, label, firewall, authorized_key
):
linode = client.linode.instance_create(
"g6-nanode-1",
ip_address.region,
image="linode/debian12",
label=label,
firewall=firewall,
interface_generation=InterfaceGeneration.LEGACY_CONFIG,
authorized_keys=authorized_key,
ipv4=[ip_address.address],
)
Comment thread
lgarber-akamai marked this conversation as resolved.
return linode


def create_linode_with_standard_interfaces(client, ip_address, label, firewall):
def create_linode_with_standard_interfaces(
client, ip_address, label, firewall, authorized_key
):
interface = build_interface_public_ipv4(firewall.id, ip_address.address)
linode, _ = client.linode.instance_create(
linode = client.linode.instance_create(
"g6-nanode-1",
ip_address.region,
image="linode/debian12",
label=label,
interface_generation=InterfaceGeneration.LINODE,
authorized_keys=authorized_key,
interfaces=[interface],
)
Comment thread
lgarber-akamai marked this conversation as resolved.
return linode
Expand Down Expand Up @@ -415,13 +421,19 @@ def test_linode_interface_firewalls(e2e_test_firewall, linode_interface_public):
ids=["legacy_config", "standard_interfaces"],
)
def test_linode_interfaces_with_reserved_ips(
test_linode_client, e2e_test_firewall, create_reserved_ip, create_linode_fn
test_linode_client,
e2e_test_firewall,
create_reserved_ip,
create_linode_fn,
ssh_key_gen,
):
client = test_linode_client
reserved_ip = create_reserved_ip
label = get_test_label(length=8)

linode = create_linode_fn(client, reserved_ip, label, e2e_test_firewall)
linode = create_linode_fn(
client, reserved_ip, label, e2e_test_firewall, ssh_key_gen[0]
)

try:
linode_ips = linode.ips.ipv4.public
Expand Down
5 changes: 3 additions & 2 deletions test/integration/models/linode/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,18 +1247,19 @@ def test_create_linode_with_kernel_and_boot_size_then_add_disk_and_rebuild(


def test_update_linode_with_reserved_ip_in_address(
test_linode_client, e2e_test_firewall, create_reserved_ip
test_linode_client, e2e_test_firewall, create_reserved_ip, ssh_key_gen
):
label = get_test_label(length=8)
client = test_linode_client
reserved_ip = create_reserved_ip

linode, _ = client.linode.instance_create(
linode = client.linode.instance_create(
"g6-nanode-1",
reserved_ip.region,
image="linode/debian12",
label=label,
firewall=e2e_test_firewall,
authorized_keys=ssh_key_gen[0],
Comment thread
lgarber-akamai marked this conversation as resolved.
)
Comment thread
lgarber-akamai marked this conversation as resolved.

linode_ips = linode.ips.ipv4.public
Expand Down
5 changes: 3 additions & 2 deletions test/integration/models/vpc/test_vpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ def test_get_all_vpcs(test_linode_client, create_multiple_vpcs):
vpc_1, vpc_2 = create_multiple_vpcs

all_vpcs = test_linode_client.vpcs()
all_vpc_ids = {vpc.id for vpc in all_vpcs}

assert str(vpc_1) in str(all_vpcs.lists)
assert str(vpc_2) in str(all_vpcs.lists)
assert vpc_1.id in all_vpc_ids
assert vpc_2.id in all_vpc_ids


def test_fails_update_vpc_invalid_data(create_vpc):
Expand Down