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

Add entry points for supported inventory sources #61

Open
wants to merge 2 commits into
base: devel
Choose a base branch
from

Conversation

jessicamack
Copy link
Member

A related change for ansible/awx#15658

also fix inventory name to match class
Copy link

codecov bot commented Nov 22, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
57 2 55 0
View the top 2 failed tests by shortest run time
tests/importable_test.py::::test_entry_points_are_inventory_plugin[azure-rm=awx_plugins.inventory.plugins:azure_rm@awx_plugins.inventory]
Stack Traces | 0.002s run time
self = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]
name = 'azure-rm'

    def __getitem__(self, name):  # -> EntryPoint:
        """
        Get the EntryPoint in self matching name.
        """
        if isinstance(name, int):
            warnings.warn(
                "Accessing entry points by index is deprecated. "
                "Cast to tuple if needed.",
                DeprecationWarning,
                stacklevel=2,
            )
            return super().__getitem__(name)
        try:
>           return next(iter(self.select(name=name)))
#x1B[1m#x1B[31mE           StopIteration#x1B[0m

__class__  = <class 'importlib.metadata.EntryPoints'>
name       = 'azure-rm'
self       = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]

#x1B[1m#x1B[.../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11....../importlib/metadata/__init__.py#x1B[0m:371: StopIteration

#x1B[33mDuring handling of the above exception, another exception occurred:#x1B[0m

entry_point = EntryPointParam(group='awx_plugins.inventory', name='azure-rm', spec='awx_plugins.inventory.plugins:azure_rm')

    @with_inventory_plugins
    def test_entry_points_are_inventory_plugin(
            entry_point: EntryPointParam,
    ) -> None:
        """Ensure all exposed inventory plugins are of the same class."""  # noqa: D200, DAR101; FIXME
        entry_points = _discover_entry_points(group=entry_point.group)
>       loaded_plugin_class = entry_points[entry_point.name].load()

entry_point = EntryPointParam(group='awx_plugins.inventory', name='azure-rm', spec='awx_plugins.inventory.plugins:azure_rm')
entry_points = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]

#x1B[1m#x1B[31mtests/importable_test.py#x1B[0m:192: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]
name = 'azure-rm'

    def __getitem__(self, name):  # -> EntryPoint:
        """
        Get the EntryPoint in self matching name.
        """
        if isinstance(name, int):
            warnings.warn(
                "Accessing entry points by index is deprecated. "
                "Cast to tuple if needed.",
                DeprecationWarning,
                stacklevel=2,
            )
            return super().__getitem__(name)
        try:
            return next(iter(self.select(name=name)))
        except StopIteration:
>           raise KeyError(name)
#x1B[1m#x1B[31mE           KeyError: 'azure-rm'#x1B[0m

__class__  = <class 'importlib.metadata.EntryPoints'>
name       = 'azure-rm'
self       = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]

#x1B[1m#x1B[.../Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11....../importlib/metadata/__init__.py#x1B[0m:373: KeyError
tests/importable_test.py::::test_entry_points_exposed[azure-rm=awx_plugins.inventory.plugins:azure_rm@awx_plugins.inventory]
Stack Traces | 0.002s run time
entry_point = EntryPointParam(group='awx_plugins.inventory', name='azure-rm', spec='awx_plugins.inventory.plugins:azure_rm')

    @with_all_plugins
    def test_entry_points_exposed(entry_point: EntryPointParam) -> None:
        """Verify the plugin entry points are discoverable.
    
        This check relies on the plugin-declaring distribution package to be
        pre-installed.
        """  # noqa: DAR101; FIXME
        entry_points = _discover_entry_points(group=entry_point.group)
    
>       assert entry_point.name in entry_points.names
#x1B[1m#x1B[31mE       AssertionError: assert 'azure-rm' in {'azure_rm', 'constructed', 'controller', 'ec2', 'gce', 'insights', ...}#x1B[0m
#x1B[1m#x1B[31mE        +  where 'azure-rm' = EntryPointParam(group='awx_plugins.inventory', name='azure-rm', spec='awx_plugins.inventory.plugins:azure_rm').name#x1B[0m
#x1B[1m#x1B[31mE        +  and   {'azure_rm', 'constructed', 'controller', 'ec2', 'gce', 'insights', ...} = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')].names#x1B[0m

entry_point = EntryPointParam(group='awx_plugins.inventory', name='azure-rm', spec='awx_plugins.inventory.plugins:azure_rm')
entry_points = [EntryPoint(name='azure_rm', value='awx_plugins.inventory.plugins:azure_rm', group='awx_plugins.inventory'), EntryPoin...ns.inventory'), EntryPoint(name='vmware', value='awx_plugins.inventory.plugins:vmware', group='awx_plugins.inventory')]

#x1B[1m#x1B[31mtests/importable_test.py#x1B[0m:170: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
📢 Thoughts on this report? Let us know!

pyproject.toml Outdated Show resolved Hide resolved
@@ -76,7 +76,7 @@ thycotic_tss = "awx_plugins.credentials.tss:tss_plugin"
aws_secretsmanager_credential = "awx_plugins.credentials.aws_secretsmanager:aws_secretmanager_plugin"

[project.entry-points."awx_plugins.inventory"] # new entry points group name
azure-rm = "awx_plugins.inventory.plugins:azure_rm"
azure_rm = "awx_plugins.inventory.plugins:azure_rm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests must be adjusted for this, so they don't fail.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which tests? When I point the requirements for awx at this branch on my repo the related tests pass. I'll run them again to confirm.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +93 to +96
satellite6 = "awx_plugins.inventory.plugins:satellite6_supported"
controller = "awx_plugins.inventory.plugins:controller_supported"
insights = "awx_plugins.inventory.plugins:insights_supported"
openshift_virtualization = "awx_plugins.inventory.plugins:openshift_virtualization_supported"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should probably be mentioned in the tests too.

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants