canonical / pytest-interface-tester

Pytest plugin for checking charm relation interface protocol compliance.
0 stars 4 forks source link

Support testing multiple endpoints with the same interface name #27

Open arturo-seijas opened 2 weeks ago

arturo-seijas commented 2 weeks ago

Hi, Since version 1.0.7 support for multiple endpoints with the same interface name has been dropped and we have a couple of use cases for this functionality, for example, the smtp integrator operator:

provides:
  smtp:
    interface: smtp
  smtp-legacy:
    interface: smtp

On version 3.2.0 we are seeing the following error, as the framework is not able to determine for which endpoint it need to run the test:

ERROR    pytest_interface_tester:plugin.py:332 Interface tester plugin failed with Multiple endpoints found for provider/smtp: ['smtp', 'smtp-legacy']: cannot guess which one it is we're supposed to be testing
Traceback (most recent call last):
  File "/home/arturo/smtp-integrator-operator/.tox/interface/lib/python3.10/site-packages/interface_tester/plugin.py", line 330, in run
    test_fn()
  File "/tmp/tmpj65im5gl/charm-relation-interfaces/interfaces/smtp/v0/interface_tests/test_provider.py", line 18, in test_data_published_on_created
  File "/home/arturo/smtp-integrator-operator/.tox/interface/lib/python3.10/site-packages/interface_tester/interface_test.py", line 267, in run
    state_out = self._run(event)
  File "/home/arturo/smtp-integrator-operator/.tox/interface/lib/python3.10/site-packages/interface_tester/interface_test.py", line 387, in _run
    relations = self._generate_relations_state(
  File "/home/arturo/smtp-integrator-operator/.tox/interface/lib/python3.10/site-packages/interface_tester/interface_test.py", line 484, in _generate_relations_state
    endpoint = self._get_endpoint(supported_endpoints, role, interface_name=interface_name)
  File "/home/arturo/smtp-integrator-operator/.tox/interface/lib/python3.10/site-packages/interface_tester/interface_test.py", line 465, in _get_endpoint
    raise ValueError(
ValueError: Multiple endpoints found for provider/smtp: ['smtp', 'smtp-legacy']: cannot guess which one it is we're supposed to be testing

The discussion can be found here

tonyandrewmeyer commented 4 days ago

Given that the recommendation for tracing is that charms have two endpoints that use the same interface, this issue is perhaps going to become more common, and we should probably prioritise (re) adding support for this.