Skip to content

ANTA catalog for GreenT tests

VerifyGreenT

Verifies if a GreenT (GRE Encapsulated Telemetry) policy other than the default is created.

Expected Results
  • Success: The test will pass if a GreenT policy is created other than the default one.
  • Failure: The test will fail if no other GreenT policy is created.
Examples
anta.tests.greent:
  - VerifyGreenTCounters:
Source code in anta/tests/greent.py
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
class VerifyGreenT(AntaTest):
    """Verifies if a GreenT (GRE Encapsulated Telemetry) policy other than the default is created.

    Expected Results
    ----------------
    * Success: The test will pass if a GreenT policy is created other than the default one.
    * Failure: The test will fail if no other GreenT policy is created.

    Examples
    --------
    ```yaml
    anta.tests.greent:
      - VerifyGreenTCounters:
    ```
    """

    name = "VerifyGreenT"
    description = "Verifies if a GreenT policy is created."
    categories: ClassVar[list[str]] = ["greent"]
    commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show monitor telemetry postcard policy profile", revision=1)]

    @AntaTest.anta_test
    def test(self) -> None:
        """Main test function for VerifyGreenT."""
        command_output = self.instance_commands[0].json_output

        profiles = [profile for profile in command_output["profiles"] if profile != "default"]

        if profiles:
            self.result.is_success()
        else:
            self.result.is_failure("No GreenT policy is created")

VerifyGreenTCounters

Verifies if the GreenT (GRE Encapsulated Telemetry) counters are incremented.

Expected Results
  • Success: The test will pass if the GreenT counters are incremented.
  • Failure: The test will fail if the GreenT counters are not incremented.
Examples
anta.tests.greent:
  - VerifyGreenT:
Source code in anta/tests/greent.py
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
class VerifyGreenTCounters(AntaTest):
    """Verifies if the GreenT (GRE Encapsulated Telemetry) counters are incremented.

    Expected Results
    ----------------
    * Success: The test will pass if the GreenT counters are incremented.
    * Failure: The test will fail if the GreenT counters are not incremented.

    Examples
    --------
    ```yaml
    anta.tests.greent:
      - VerifyGreenT:
    ```
    """

    name = "VerifyGreenTCounters"
    description = "Verifies if the GreenT counters are incremented."
    categories: ClassVar[list[str]] = ["greent"]
    commands: ClassVar[list[AntaCommand | AntaTemplate]] = [AntaCommand(command="show monitor telemetry postcard counters", revision=1)]

    @AntaTest.anta_test
    def test(self) -> None:
        """Main test function for VerifyGreenTCounters."""
        command_output = self.instance_commands[0].json_output

        if command_output["grePktSent"] > 0:
            self.result.is_success()
        else:
            self.result.is_failure("GreenT counters are not incremented")