Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zliang-akamai committed Dec 18, 2023
1 parent 6365285 commit d5eef74
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 19 deletions.
11 changes: 5 additions & 6 deletions test/integration/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import random
import time
from typing import Callable

Expand All @@ -8,7 +7,7 @@


def get_test_label():
unique_timestamp = str(int(time.time()) + random.randint(0, 1000))
unique_timestamp = str(time.time_ns())
label = "IntTestSDK_" + unique_timestamp
return label

Expand Down Expand Up @@ -94,13 +93,13 @@ def retry_sending_request(retries: int, condition: Callable, *args) -> object:


def send_request_when_resource_available(
timeout: int, func: Callable, *args
timeout: int, func: Callable, *args, **kwargs
) -> object:
start_time = time.time()

while True:
try:
res = func(*args)
res = func(*args, **kwargs)
return res
except ApiError as e:
if (
Expand All @@ -110,9 +109,9 @@ def send_request_when_resource_available(
):
if time.time() - start_time > timeout:
raise TimeoutError(
"Timeout Error: resource is not available in"
"Timeout Error: resource is not available in "
+ str(timeout)
+ "seconds"
+ " seconds"
)
time.sleep(10)
else:
Expand Down
20 changes: 7 additions & 13 deletions test/integration/models/test_linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def test_linode_resize_with_class(


def test_linode_resize_with_migration_type(
get_client, create_linode_for_long_running_tests
create_linode_for_long_running_tests,
):
linode = create_linode_for_long_running_tests
m_type = MigrationType.WARM
Expand Down Expand Up @@ -440,22 +440,16 @@ def test_linode_initate_migration(test_linode_client):
chosen_region = available_regions[4]
label = get_test_label() + "_migration"

linode, password = client.linode.instance_create(
"g6-nanode-1", chosen_region, image="linode/debian10", label=label
linode, _ = client.linode.instance_create(
"g6-nanode-1", chosen_region, image="linode/debian12", label=label
)

wait_for_condition(10, 100, get_status, linode, "running")
# Says it could take up to ~6 hrs for migration to fully complete
linode.initiate_migration(
region="us-central", migration_type=MigrationType.COLD
)

res = linode.delete()

assert res

send_request_when_resource_available(
300, linode.initiate_migration, "us-mia"
300,
linode.initiate_migration,
region="us-central",
migration_type=MigrationType.COLD,
)

res = linode.delete()
Expand Down

0 comments on commit d5eef74

Please sign in to comment.