Merging upstream version 0.14.0.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
082ce481df
commit
2265bd9c67
211 changed files with 12174 additions and 6401 deletions
|
@ -21,24 +21,32 @@ from anta.decorators import skip_on_platforms
|
|||
|
||||
|
||||
class VerifyTemperature(AntaTest):
|
||||
"""
|
||||
This test verifies if the device temperature is within acceptable limits.
|
||||
"""Verifies if the device temperature is within acceptable limits.
|
||||
|
||||
Expected Results:
|
||||
* success: The test will pass if the device temperature is currently OK: 'temperatureOk'.
|
||||
* failure: The test will fail if the device temperature is NOT OK.
|
||||
Expected Results
|
||||
----------------
|
||||
* Success: The test will pass if the device temperature is currently OK: 'temperatureOk'.
|
||||
* Failure: The test will fail if the device temperature is NOT OK.
|
||||
|
||||
Examples
|
||||
--------
|
||||
```yaml
|
||||
anta.tests.hardware:
|
||||
- VerifyTemperature:
|
||||
```
|
||||
"""
|
||||
|
||||
name = "VerifyTemperature"
|
||||
description = "Verifies if the device temperature is within the acceptable range."
|
||||
categories = ["hardware"]
|
||||
commands = [AntaCommand(command="show system environment temperature", ofmt="json")]
|
||||
description = "Verifies the device temperature."
|
||||
categories: ClassVar[list[str]] = ["hardware"]
|
||||
commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show system environment temperature", revision=1)]
|
||||
|
||||
@skip_on_platforms(["cEOSLab", "vEOS-lab"])
|
||||
@skip_on_platforms(["cEOSLab", "vEOS-lab", "cEOSCloudLab"])
|
||||
@AntaTest.anta_test
|
||||
def test(self) -> None:
|
||||
"""Main test function for VerifyTemperature."""
|
||||
command_output = self.instance_commands[0].json_output
|
||||
temperature_status = command_output["systemStatus"] if "systemStatus" in command_output.keys() else ""
|
||||
temperature_status = command_output.get("systemStatus", "")
|
||||
if temperature_status == "temperatureOk":
|
||||
self.result.is_success()
|
||||
else:
|
||||
|
@ -54,7 +62,7 @@ class VerifyTemperature(AntaTest):
|
|||
- `name` (`str`): Name of the test. Used during reporting.
|
||||
- `description` (`str`): A human readable description of your test.
|
||||
- `categories` (`list[str]`): A list of categories in which the test belongs.
|
||||
- `commands` (`list[Union[AntaTemplate, AntaCommand]]`): A list of command to collect from devices. This list __must__ be a list of [AntaCommand](../api/models.md#anta.models.AntaCommand) or [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances. Rendering [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances will be discussed later.
|
||||
- `commands` (`[list[AntaCommand | AntaTemplate]]`): A list of command to collect from devices. This list __must__ be a list of [AntaCommand](../api/models.md#anta.models.AntaCommand) or [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances. Rendering [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances will be discussed later.
|
||||
|
||||
!!! info
|
||||
All these class attributes are mandatory. If any attribute is missing, a `NotImplementedError` exception will be raised during class instantiation.
|
||||
|
@ -127,7 +135,7 @@ The base definition of [AntaTest.Input](../api/models.md#anta.models.AntaTest.In
|
|||
### Methods
|
||||
|
||||
- [test(self) -> None](../api/models.md#anta.models.AntaTest.test): This is an abstract method that __must__ be implemented. It contains the test logic that can access the collected command outputs using the `instance_commands` instance attribute, access the test inputs using the `inputs` instance attribute and __must__ set the `result` instance attribute accordingly. It must be implemented using the `AntaTest.anta_test` decorator that provides logging and will collect commands before executing the `test()` method.
|
||||
- [render(self, template: AntaTemplate) -> list[AntaCommand]](../api/models.md#anta.models.AntaTest.render): This method only needs to be implemented if [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances are present in the `commands` class attribute. It will be called for every [AntaTemplate](../api/models.md#anta.models.AntaTemplate) occurence and __must__ return a list of [AntaCommand](../api/models.md#anta.models.AntaCommand) using the [AntaTemplate.render()](../api/models.md#anta.models.AntaTemplate.render) method. It can access test inputs using the `inputs` instance attribute.
|
||||
- [render(self, template: AntaTemplate) -> list[AntaCommand]](../api/models.md#anta.models.AntaTest.render): This method only needs to be implemented if [AntaTemplate](../api/models.md#anta.models.AntaTemplate) instances are present in the `commands` class attribute. It will be called for every [AntaTemplate](../api/models.md#anta.models.AntaTemplate) occurrence and __must__ return a list of [AntaCommand](../api/models.md#anta.models.AntaCommand) using the [AntaTemplate.render()](../api/models.md#anta.models.AntaTemplate.render) method. It can access test inputs using the `inputs` instance attribute.
|
||||
|
||||
## Test execution
|
||||
|
||||
|
@ -191,8 +199,24 @@ If the user needs to provide inputs for your test, you need to define a [pydanti
|
|||
|
||||
```python
|
||||
class <YourTestName>(AntaTest):
|
||||
"""Verifies ...
|
||||
|
||||
Expected Results
|
||||
----------------
|
||||
* Success: The test will pass if ...
|
||||
* Failure: The test will fail if ...
|
||||
|
||||
Examples
|
||||
--------
|
||||
```yaml
|
||||
your.module.path:
|
||||
- YourTestName:
|
||||
field_name: example_field_value
|
||||
```
|
||||
"""
|
||||
...
|
||||
class Input(AntaTest.Input): # pylint: disable=missing-class-docstring
|
||||
class Input(AntaTest.Input):
|
||||
"""Inputs for my awesome test."""
|
||||
<input field name>: <input field type>
|
||||
"""<input field docstring>"""
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue