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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# This file contains type hints that can be prepended to Nix test scripts so they can be type
# checked.
import datetime as dt
from contextlib import contextmanager
from typing import Any, Callable, ContextManager, Generator, List, Optional, Union
from unittest import TestCase
from test_driver.debug import DebugAbstract, DebugNop
from test_driver.driver import Driver
from test_driver.logger import AbstractLogger, CompositeLogger
from typing_extensions import Protocol
from test_driver.machine import BaseMachine, NspawnMachine, QemuMachine
from test_driver.vlan import VLan
# Protocols
class CreateMachineProtocol(Protocol):
def __call__(
self,
start_command: str | dict,
*,
name: Optional[str] = None,
keep_machine_state: bool = False,
**kwargs: Any, # to allow usage of deprecated keep_vm_state
) -> QemuMachine:
raise Exception("This is just type information for the Nix test driver")
class PollingConditionProtocol(Protocol):
def __call__(
self,
fun_: Callable | None = None,
*,
seconds_interval: dt.timedelta | float | None = None,
interval: dt.timedelta | None = None,
description: str | None = None,
) -> Union[Callable[[Callable], ContextManager], ContextManager]:
raise Exception("This is just type information for the Nix test driver")
# Classes
class AssertionTester(TestCase):
pass
# Global Variables
debug: DebugAbstract = DebugNop()
machines: List[BaseMachine] = []
machines_nspawn: List[NspawnMachine] = []
machines_qemu: List[QemuMachine] = []
t = AssertionTester()
vlans: List[VLan] = []
def create_fake_driver() -> Driver:
raise Exception("fake driver")
driver = create_fake_driver()
# Functions
# these are going to be called by the testScriptWithTypes in driver.nix
def create_fake_qemu_machine() -> QemuMachine:
raise Exception("fake qemu machine")
def create_fake_nspawn_machine() -> NspawnMachine:
raise Exception("fake nspawn machine")
def create_fake_vlan() -> VLan:
raise Exception("fake vlan")
def create_machine(
start_command: str, name: str | None = None, keep_machine_state: bool = False
) -> QemuMachine:
raise Exception("fake machine")
def dump_machine_ssh() -> None:
return None
def join_all() -> None:
return None
log: AbstractLogger = CompositeLogger([])
def polling_condition(
fun_: Callable | None = None,
*,
seconds_interval: float | dt.timedelta | None = None,
interval: dt.timedelta | None = None,
description: str | None = None,
):
pass
def retry(
fn: Callable,
timeout_seconds: int | dt.timedelta | None = None,
timeout: dt.timedelta | None = None,
) -> None:
pass
def run_tests() -> None:
return
def serial_stdout_off() -> None:
return None
def serial_stdout_on() -> None:
return None
def start_all() -> None:
return
def test_script() -> None:
return
@contextmanager
def subtest(str: str) -> Generator[None, None, None]:
yield
|