-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_devboxes.py
More file actions
74 lines (54 loc) · 2.19 KB
/
Copy pathtest_devboxes.py
File metadata and controls
74 lines (54 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import pytest
from runloop_api_client.lib.polling import PollingConfig, PollingTimeout
from .utils import make_client, unique_name
pytestmark = [pytest.mark.smoketest]
client = make_client()
"""
Tests are run sequentially and can be dependent on each other.
This is to avoid overloading resources and save efficiency.
"""
_devbox_id = None
@pytest.mark.timeout(30)
def test_create_devbox() -> None:
created = client.devboxes.create(name=unique_name("smoke-devbox"))
assert created.id
client.devboxes.shutdown(created.id)
@pytest.mark.timeout(30)
def test_await_running_create_and_await_running() -> None:
global _devbox_id
created = client.devboxes.create_and_await_running(
name=unique_name("smoketest-devbox2"),
polling_config=PollingConfig(max_attempts=120, interval_seconds=5.0, timeout_seconds=20 * 60),
)
assert created.status == "running"
_devbox_id = created.id
def test_list_devboxes() -> None:
page = client.devboxes.list(limit=10)
assert isinstance(page.devboxes, list)
assert len(page.devboxes) > 0
def test_retrieve_devbox() -> None:
assert _devbox_id
view = client.devboxes.retrieve(_devbox_id)
assert view.id == _devbox_id
def test_shutdown_devbox() -> None:
assert _devbox_id
view = client.devboxes.shutdown(_devbox_id)
assert view.id == _devbox_id
assert view.status == "shutdown"
@pytest.mark.timeout(90)
def test_create_and_await_running_long_set_up() -> None:
created = client.devboxes.create_and_await_running(
name=unique_name("smoketest-devbox-await-running-long-set-up"),
launch_parameters={"launch_commands": ["sleep 70"]},
polling_config=PollingConfig(interval_seconds=5.0, timeout_seconds=80),
)
assert created.status == "running"
client.devboxes.shutdown(created.id)
@pytest.mark.timeout(30)
def test_create_and_await_running_timeout() -> None:
with pytest.raises(PollingTimeout):
client.devboxes.create_and_await_running(
name=unique_name("smoketest-devbox-await-running-timeout"),
launch_parameters={"launch_commands": ["sleep 70"]},
polling_config=PollingConfig(max_attempts=1, interval_seconds=0.1),
)