Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(eos_validate_state): ANTA Fix logs in tests to be more accurate #3219

Closed
carl-baillargeon opened this issue Oct 6, 2023 · 1 comment
Closed

Comments

@carl-baillargeon
Copy link
Contributor

Some tests have a single try except block when assigning the required variables, leading to a less accurate log message if one of the variable is missing.

The try except block will also catch the first missing variable but not the others:

        for ethernet_interface in ethernet_interfaces:
            try:
                for var in required_vars:
                    get(ethernet_interface, var, required=True)

                peer_ethernet_interfaces = get(self.hostvars, f"{ethernet_interface['peer']}.ethernet_interfaces", required=True)
                peer_interface = get_item(
                    peer_ethernet_interfaces,
                    "name",
                    ethernet_interface["peer_interface"],
                    required=True,
                    var_name=f"name: {ethernet_interface['peer_interface']}",
                )
                peer_interface_ip = get(peer_interface, "ip_address", required=True)
                [...]
            except AristaAvdMissingVariableError as e:
                LOGGER.info("Variable '%s' is missing. Please validate the Ethernet interfaces data model of this host and his peer(s).", str(e))
                continue

The tests should be refactor to have accurate logs with the missing variables for the test.

@carl-baillargeon
Copy link
Contributor Author

Fixed in #3352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants