marking test for broker sys plugin as xfail, because it fails on github workflow but not locally

pull/218/head
Andrew Mirsky 2025-06-14 15:28:46 -04:00
rodzic 92f373db66
commit 364273e684
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: A98E67635CDF2C39
1 zmienionych plików z 48 dodań i 46 usunięć

Wyświetl plik

@ -13,49 +13,51 @@ from amqtt.mqtt.constants import QOS_0
logger = logging.getLogger(__name__)
# test broker sys
# @pytest.mark.asyncio
# async def test_broker_sys_plugin() -> None:
#
# class MockEntryPoints:
#
# def select(self, group) -> list[EntryPoint]:
# match group:
# case 'tests.mock_plugins':
# return [
# EntryPoint(name='BrokerSysPlugin', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'),
# ]
# case _:
# return list()
#
#
# with patch("amqtt.plugins.manager.entry_points", side_effect=MockEntryPoints) as mocked_mqtt_publish:
#
# config = {
# "listeners": {
# "default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
# },
# 'sys_interval': 1
# }
#
# broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
# await broker.start()
# client = MQTTClient()
# await client.connect("mqtt://127.0.0.1:1883/")
# await client.subscribe([("$SYS/broker/uptime", QOS_0),])
# await client.publish('test/topic', b'my test message')
# await asyncio.sleep(2)
# sys_msg_count = 0
# try:
# while True:
# message = await client.deliver_message(timeout_duration=0.5)
# if '$SYS' in message.topic:
# sys_msg_count += 1
# except asyncio.TimeoutError:
# pass
#
# logger.warning(f">>> sys message: {message.topic} - {message.data}")
# await client.disconnect()
# await broker.shutdown()
#
#
# assert sys_msg_count > 1
@pytest.mark.asyncio
@pytest.mark.xfail(
reason="see https://github.com/Yakifo/aio-amqtt/issues/215",
strict=False,
)
async def test_broker_sys_plugin() -> None:
class MockEntryPoints:
def select(self, group) -> list[EntryPoint]:
match group:
case 'tests.mock_plugins':
return [
EntryPoint(name='BrokerSysPlugin', group='tests.mock_plugins', value='amqtt.plugins.sys.broker:BrokerSysPlugin'),
]
case _:
return list()
with patch("amqtt.plugins.manager.entry_points", side_effect=MockEntryPoints) as mocked_mqtt_publish:
config = {
"listeners": {
"default": {"type": "tcp", "bind": "127.0.0.1:1883", "max_connections": 10},
},
'sys_interval': 1
}
broker = Broker(plugin_namespace='tests.mock_plugins', config=config)
await broker.start()
client = MQTTClient()
await client.connect("mqtt://127.0.0.1:1883/")
await client.subscribe([("$SYS/broker/uptime", QOS_0),])
await client.publish('test/topic', b'my test message')
await asyncio.sleep(2)
sys_msg_count = 0
try:
while True:
message = await client.deliver_message(timeout_duration=1)
if '$SYS' in message.topic:
sys_msg_count += 1
except asyncio.TimeoutError:
pass
await client.disconnect()
await broker.shutdown()
assert sys_msg_count > 1