Skip to content

Commit 3ccfd56

Browse files
TPT-4275: Resolve failings tests blocking release (#708)
* Resolve failings tests blocking release * Correct interfaces test
1 parent 898dbce commit 3ccfd56

4 files changed

Lines changed: 33 additions & 20 deletions

File tree

test/integration/conftest.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import logging
33
import os
44
import random
5+
import subprocess
56
import time
67
from test.integration.helpers import (
78
get_test_label,
@@ -262,21 +263,19 @@ def create_linode_for_pass_reset(test_linode_client, e2e_test_firewall):
262263

263264

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

268-
time.sleep(1)
269-
270-
pub_file = open("./sdk-sshkey.pub", "r")
271-
pub_key = pub_file.read().rstrip()
269+
subprocess.run(
270+
["ssh-keygen", "-q", "-t", "rsa", "-f", str(key_path), "-N", ""],
271+
check=True,
272+
)
272273

273-
priv_file = open("./sdk-sshkey", "r")
274-
priv_key = priv_file.read().rstrip()
274+
pub_key = key_path.with_suffix(".pub").read_text().rstrip()
275+
priv_key = key_path.read_text().rstrip()
275276

276277
yield pub_key, priv_key
277278

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

281280
@pytest.fixture(scope="session")
282281
def test_linode_client():

test/integration/models/linode/interfaces/test_interfaces.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,33 @@ def build_interface_public_ipv4(firewall, ip_address):
4343
)
4444

4545

46-
def create_linode_with_legacy_config(client, ip_address, label, firewall):
47-
linode, _ = client.linode.instance_create(
46+
def create_linode_with_legacy_config(
47+
client, ip_address, label, firewall, authorized_key
48+
):
49+
linode = client.linode.instance_create(
4850
"g6-nanode-1",
4951
ip_address.region,
5052
image="linode/debian12",
5153
label=label,
5254
firewall=firewall,
5355
interface_generation=InterfaceGeneration.LEGACY_CONFIG,
56+
authorized_keys=authorized_key,
5457
ipv4=[ip_address.address],
5558
)
5659
return linode
5760

5861

59-
def create_linode_with_standard_interfaces(client, ip_address, label, firewall):
62+
def create_linode_with_standard_interfaces(
63+
client, ip_address, label, firewall, authorized_key
64+
):
6065
interface = build_interface_public_ipv4(firewall.id, ip_address.address)
61-
linode, _ = client.linode.instance_create(
66+
linode = client.linode.instance_create(
6267
"g6-nanode-1",
6368
ip_address.region,
6469
image="linode/debian12",
6570
label=label,
6671
interface_generation=InterfaceGeneration.LINODE,
72+
authorized_keys=authorized_key,
6773
interfaces=[interface],
6874
)
6975
return linode
@@ -415,13 +421,19 @@ def test_linode_interface_firewalls(e2e_test_firewall, linode_interface_public):
415421
ids=["legacy_config", "standard_interfaces"],
416422
)
417423
def test_linode_interfaces_with_reserved_ips(
418-
test_linode_client, e2e_test_firewall, create_reserved_ip, create_linode_fn
424+
test_linode_client,
425+
e2e_test_firewall,
426+
create_reserved_ip,
427+
create_linode_fn,
428+
ssh_key_gen,
419429
):
420430
client = test_linode_client
421431
reserved_ip = create_reserved_ip
422432
label = get_test_label(length=8)
423433

424-
linode = create_linode_fn(client, reserved_ip, label, e2e_test_firewall)
434+
linode = create_linode_fn(
435+
client, reserved_ip, label, e2e_test_firewall, ssh_key_gen[0]
436+
)
425437

426438
try:
427439
linode_ips = linode.ips.ipv4.public

test/integration/models/linode/test_linode.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,18 +1247,19 @@ def test_create_linode_with_kernel_and_boot_size_then_add_disk_and_rebuild(
12471247

12481248

12491249
def test_update_linode_with_reserved_ip_in_address(
1250-
test_linode_client, e2e_test_firewall, create_reserved_ip
1250+
test_linode_client, e2e_test_firewall, create_reserved_ip, ssh_key_gen
12511251
):
12521252
label = get_test_label(length=8)
12531253
client = test_linode_client
12541254
reserved_ip = create_reserved_ip
12551255

1256-
linode, _ = client.linode.instance_create(
1256+
linode = client.linode.instance_create(
12571257
"g6-nanode-1",
12581258
reserved_ip.region,
12591259
image="linode/debian12",
12601260
label=label,
12611261
firewall=e2e_test_firewall,
1262+
authorized_keys=ssh_key_gen[0],
12621263
)
12631264

12641265
linode_ips = linode.ips.ipv4.public

test/integration/models/vpc/test_vpc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,10 @@ def test_get_all_vpcs(test_linode_client, create_multiple_vpcs):
6767
vpc_1, vpc_2 = create_multiple_vpcs
6868

6969
all_vpcs = test_linode_client.vpcs()
70+
all_vpc_ids = {vpc.id for vpc in all_vpcs}
7071

71-
assert str(vpc_1) in str(all_vpcs.lists)
72-
assert str(vpc_2) in str(all_vpcs.lists)
72+
assert vpc_1.id in all_vpc_ids
73+
assert vpc_2.id in all_vpc_ids
7374

7475

7576
def test_fails_update_vpc_invalid_data(create_vpc):

0 commit comments

Comments
 (0)