Commit 906c6810 authored by Carlos Ramos Carreño's avatar Carlos Ramos Carreño

Clean attributes in SlapOSInstanceTestCase.

Class attributes of `SlapOSInstanceTestCase` have been typed and
documented.

See merge request !664
parent e3183d39
...@@ -54,11 +54,20 @@ from .check_software import checkSoftware ...@@ -54,11 +54,20 @@ from .check_software import checkSoftware
from ..proxy.db_version import DB_VERSION from ..proxy.db_version import DB_VERSION
try: from typing import (
from typing import Callable, ClassVar, Dict, Iterable, List, Optional, Tuple, Type, TypeVar Callable,
ManagedResourceType = TypeVar("ManagedResourceType", bound=ManagedResource) ClassVar,
except ImportError: Dict,
pass Iterable,
List,
Mapping,
Optional,
Sequence,
Tuple,
Type,
TypeVar,
)
ManagedResourceType = TypeVar("ManagedResourceType", bound=ManagedResource)
def makeModuleSetUpAndTestCaseClass( def makeModuleSetUpAndTestCaseClass(
...@@ -253,7 +262,8 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False): ...@@ -253,7 +262,8 @@ def installSoftwareUrlList(cls, software_url_list, max_retry=10, debug=False):
class SlapOSInstanceTestCase(unittest.TestCase): class SlapOSInstanceTestCase(unittest.TestCase):
"""Install one slapos instance. """
Install one slapos instance.
This test case install software(s) and request one instance This test case install software(s) and request one instance
during `setUpClass` and destroy that instance during `tearDownClass`. during `setUpClass` and destroy that instance during `tearDownClass`.
...@@ -263,62 +273,76 @@ class SlapOSInstanceTestCase(unittest.TestCase): ...@@ -263,62 +273,76 @@ class SlapOSInstanceTestCase(unittest.TestCase):
All tests from the test class will run with the same instance. All tests from the test class will run with the same instance.
The following class attributes are available: Note:
This class is not supposed to be imported directly, but needs to be setup
* `computer_partition`: the `slapos.slap.slap.ComputerPartition` by calling makeModuleSetUpAndTestCaseClass.
computer partition instance.
* `computer_partition_root_path`: the path of the instance root
directory.
This class is not supposed to be imported directly, but needs to be setup by
calling makeModuleSetUpAndTestCaseClass.
Attributes: Attributes:
computer_partition: The computer partition instance.
computer_partition_root_path: The path of the instance root directory.
computer_partition_ipv6_address: The IPv6 of the instance.
instance_max_retry: Maximum retries for ``slapos node instance``.
report_max_retry: Maximum retries for ``slapos node report``.
partition_count: Number of partitions needed for this instance.
default_partition_reference: Reference of the default requested partition.
request_instance: Whether an instance needs to be requested for this test request_instance: Whether an instance needs to be requested for this test
case. case.
software_id: A short name of that software URL. E.g. helloworld instead of
https://lab.nexedi.com/nexedi/slapos/raw/software/helloworld/software.cfg .
logger: A logger for messages of the testing framework.
slap: Standalone SlapOS instance.
""" """
# can set this to true to enable debugging utilities
_debug = False
# can set this to true to enable more verbose output
_verbose = False
# maximum retries for `slapos node instance`
instance_max_retry = 20
# maximum retries for `slapos node report`
report_max_retry = 20
# number of partitions needed for this instance
partition_count = 10
# reference of the default requested partition
default_partition_reference = 'testing partition 0'
# skips software checks
_skip_software_check = False
# skips software rebuild
_skip_software_rebuild = False
instance_max_retry: ClassVar[int] = 20
report_max_retry: ClassVar[int] = 20
partition_count: ClassVar[int] = 10
default_partition_reference: ClassVar[str] = 'testing partition 0'
request_instance: ClassVar[bool] = True request_instance: ClassVar[bool] = True
software_id: ClassVar[str] = ""
# a logger for messages of the testing framework logger: ClassVar[logging.Logger] = logging.getLogger(__name__)
logger = logging.getLogger(__name__)
# Dynamic members # Dynamic members
slap = None # type: StandaloneSlapOS slap: ClassVar[StandaloneSlapOS]
_ipv4_address = "" computer_partition: ClassVar[ComputerPartition]
_ipv6_address = "" computer_partition_root_path: ClassVar[str]
computer_partition_ipv6_address: ClassVar[str]
_resources = {} # type: Dict[str, ManagedResource]
_instance_parameter_dict = None # type: Dict
computer_partition = None # type: ComputerPartition # Private settings
computer_partition_root_path = None # type: str
# True to enable debugging utilities.
# a short name of that software URL. _debug: ClassVar[bool] = False
# eg. helloworld instead of
# https://lab.nexedi.com/nexedi/slapos/raw/software/helloworld/software.cfg # True to enable more verbose output.
software_id = "" _verbose: ClassVar[bool] = False # TODO: Remove?
_base_directory = "" # base directory for standalone
_test_file_snapshot_directory = "" # directory to save snapshot files for inspections # True to skip software checks.
# patterns of files to save for inspection, relative to instance directory _skip_software_check: ClassVar[bool] = False
_save_instance_file_pattern_list = (
# True to skip software rebuild.
_skip_software_rebuild: ClassVar[bool] = False
# The IPv4 address used by ``slapos node format``.
_ipv4_address: ClassVar[str] = ""
# The IPv6 address used by ``slapos node format``.
_ipv6_address: ClassVar[str] = ""
# Used resources.
_resources: ClassVar[Dict[str, ManagedResource]] = {}
# Instance parameters
_instance_parameter_dict: ClassVar[Mapping[str, object]]
# Base directory for standalone SlapOS.
_base_directory: ClassVar[str] = ""
# Directory to save snapshot files for inspections.
_test_file_snapshot_directory: ClassVar[str] = ""
# Patterns of files to save for inspection, relative to instance directory.
_save_instance_file_pattern_list: ClassVar[Sequence[str]] = (
'*/bin/*', '*/bin/*',
'*/etc/*', '*/etc/*',
'*/var/log/*', '*/var/log/*',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment