2022-06-02 07:58:46 +00:00
|
|
|
# This file contains type hints that can be prepended to Nix test scripts so they can be type
|
|
|
|
# checked.
|
|
|
|
|
|
|
|
from test_driver.driver import Driver
|
|
|
|
from test_driver.vlan import VLan
|
|
|
|
from test_driver.machine import Machine
|
2024-04-08 14:17:06 +00:00
|
|
|
from test_driver.logger import AbstractLogger
|
2022-06-02 07:58:46 +00:00
|
|
|
from typing import Callable, Iterator, ContextManager, Optional, List, Dict, Any, Union
|
|
|
|
from typing_extensions import Protocol
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
class RetryProtocol(Protocol):
|
|
|
|
def __call__(self, fn: Callable, timeout: int = 900) -> None:
|
|
|
|
raise Exception("This is just type information for the Nix test driver")
|
|
|
|
|
|
|
|
|
|
|
|
class PollingConditionProtocol(Protocol):
|
|
|
|
def __call__(
|
|
|
|
self,
|
|
|
|
fun_: Optional[Callable] = None,
|
|
|
|
*,
|
|
|
|
seconds_interval: float = 2.0,
|
|
|
|
description: Optional[str] = None,
|
|
|
|
) -> Union[Callable[[Callable], ContextManager], ContextManager]:
|
|
|
|
raise Exception("This is just type information for the Nix test driver")
|
|
|
|
|
|
|
|
|
2024-02-26 10:30:43 +00:00
|
|
|
class CreateMachineProtocol(Protocol):
|
|
|
|
def __call__(
|
|
|
|
self,
|
2024-02-27 20:14:15 +00:00
|
|
|
start_command: str | dict,
|
2024-02-26 10:30:43 +00:00
|
|
|
*,
|
|
|
|
name: Optional[str] = None,
|
|
|
|
keep_vm_state: bool = False,
|
|
|
|
) -> Machine:
|
|
|
|
raise Exception("This is just type information for the Nix test driver")
|
|
|
|
|
|
|
|
|
2022-06-02 07:58:46 +00:00
|
|
|
start_all: Callable[[], None]
|
|
|
|
subtest: Callable[[str], ContextManager[None]]
|
|
|
|
retry: RetryProtocol
|
|
|
|
test_script: Callable[[], None]
|
|
|
|
machines: List[Machine]
|
|
|
|
vlans: List[VLan]
|
|
|
|
driver: Driver
|
2024-04-08 14:17:06 +00:00
|
|
|
log: AbstractLogger
|
2024-02-26 10:30:43 +00:00
|
|
|
create_machine: CreateMachineProtocol
|
2022-06-02 07:58:46 +00:00
|
|
|
run_tests: Callable[[], None]
|
|
|
|
join_all: Callable[[], None]
|
|
|
|
serial_stdout_off: Callable[[], None]
|
|
|
|
serial_stdout_on: Callable[[], None]
|
|
|
|
polling_condition: PollingConditionProtocol
|