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

Make LocalNode and RemoteNode extendable classes (yml-wise) #1280

Closed
wants to merge 3 commits into from

Commits on Apr 23, 2021

  1. ✨ Make LocalNode and RemoteNode extendable classes (yml-wise).

    We do so by making use of BaseClassWithRunbookMixin, on the actual
    instance classes, and ExtendableSchemaMixin, on the respective schema
    classes. This makes it possible to have custom, type-defined sections
    on general (SUT) nodes coming from the runbook, together with Platform
    and Notifier.
    
    This will come in handy for LISA users who have node logic/fields that
    go beyond what is originally defined to work for (e.g.) Azure.
    
    Example of power/usage:
    
    By declaring this, on code:
    
    @dataclass_json()
    @DataClass
    class MyNodeSchema(schema.RemoteNode):
        type: str = field(
            default=MYNAME,
            metadata=schema.metadata(
                required=True,
                validate=validate.OneOf([MYNAME]),
            ),
        )
    
        my_example_extra_field: Optional[str] = field(default=None)
    
    class MyNode(node.RemoteNode):
        def __init__(
            self,
            index: int,
            runbook: MyNodeSchema,
            logger_name: str,
            base_log_path: Optional[Path] = None,
            name: str = "",
        ) -> None:
            super().__init__(index, runbook,
                             logger_name=logger_name,
                             base_log_path=base_log_path,
                             name=name)
            self.my_example_extra_field = runbook.my_example_extra_field
            assert self.my_example_extra_field, \
                f"my_example_extra_field field of {MYNAME}-typed " \
                "nodes cannot be empty "
    
        @classmethod
        def type_name(cls) -> str:
            return MYNAME
    
        @classmethod
        def type_schema(cls) -> Type[schema.TypedSchema]:
            return MyNodeSchema
    
    one is able to do this, yml-wise:
    
    environment:
      warn_as_error: true
      environments:
        - nodes:
          - type: MYNAME
            public_address: ...
            public_port: ...
            username: ...
            password: ...
    ->      my_example_extra_field: ...
    
    Of course, custom logic for only that type of node will be at your
    fingertips, just by extending/overriding your node class. Of course
    this is advanced usage and not meant for the average user.
    
    UTs were added to help enforce regression testing.
    
    ammend to nodes
    glima committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    cb4f983 View commit details
    Browse the repository at this point in the history
  2. poetry: update

    glima committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    b0bc822 View commit details
    Browse the repository at this point in the history
  3. 🔊 [wait_tcp_port_ready] make logs more meaningful, by showing name of…

    … host
    
    The user deserves to know which host was unreachable, at least, not
    just the port:
    
    ```2021-04-19 23:54:54.453 INFO LISA.lisa 'customized_0' attached to test case 'ATest.a_test': [Errno -2] Name or service not known```
    
    was not telling anything
    glima committed Apr 23, 2021
    Configuration menu
    Copy the full SHA
    d61780e View commit details
    Browse the repository at this point in the history