-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_blueprints.py
More file actions
65 lines (50 loc) · 1.96 KB
/
Copy pathtest_blueprints.py
File metadata and controls
65 lines (50 loc) · 1.96 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
from __future__ import annotations
from typing import Iterator
import pytest
from runloop_api_client import Runloop
from runloop_api_client.lib.polling import PollingConfig
from .utils import unique_name
pytestmark = [pytest.mark.smoketest]
@pytest.fixture(autouse=True, scope="module")
def _cleanup(client: Runloop) -> Iterator[None]: # pyright: ignore[reportUnusedFunction]
yield
global _blueprint_id
if _blueprint_id:
try:
client.blueprints.delete(_blueprint_id)
except Exception:
pass
"""
Tests are run sequentially and can be dependent on each other.
This is to avoid overloading resources and save efficiency.
"""
_blueprint_id = None
_blueprint_name = unique_name("bp")
@pytest.mark.timeout(30)
def test_create_blueprint_and_await_build(client: Runloop) -> None:
global _blueprint_id
created = client.blueprints.create_and_await_build_complete(
name=_blueprint_name,
polling_config=PollingConfig(max_attempts=180, interval_seconds=5.0, timeout_seconds=30 * 60),
)
assert created.status == "build_complete"
_blueprint_id = created.id
@pytest.mark.timeout(30)
def test_start_devbox_from_base_blueprint_by_id(client: Runloop) -> None:
assert _blueprint_id
devbox = client.devboxes.create_and_await_running(
blueprint_id=_blueprint_id,
polling_config=PollingConfig(max_attempts=120, interval_seconds=5.0, timeout_seconds=20 * 60),
)
assert devbox.blueprint_id == _blueprint_id
assert devbox.status == "running"
client.devboxes.shutdown(devbox.id)
@pytest.mark.timeout(30)
def test_start_devbox_from_base_blueprint_by_name(client: Runloop) -> None:
devbox = client.devboxes.create_and_await_running(
blueprint_name=_blueprint_name,
polling_config=PollingConfig(max_attempts=120, interval_seconds=5.0, timeout_seconds=20 * 60),
)
assert devbox.blueprint_id
assert devbox.status == "running"
client.devboxes.shutdown(devbox.id)