-
Bug
-
Resolution: Not a Bug
-
Undefined
-
None
-
None
-
None
-
False
-
-
False
-
-
Running locally test_hbi_created_updated_events.py highlights a flaky behavior of the test test_delete_hbi_host.
Investigate and fix the the flakiness.
The flakiness could be related to how SwatchMetricsHbiTestHelper consumes events from local Kafka broker (maybe timeout issue).
To try reproducing it:
- Compose the cluster for local testing inside rhsm-subscriptions
podman compose up -d
- Run inside rhsm-subscriptions
./mvnw install -Prun-migration
- Start swatch-metric-hbi inside rhsm-subscriptions
make swatch-metrics-hbi
- Setup IQE to run locally (virtual env+ setup for local testing)
- Run the test
iqe tests plugin rhsm_subscriptions -k test_hbi_delete_events
Failed run logs:
2025-07-17 15:46:02 INFO Using random seed value for random generation: 5082 2025-07-17 15:46:02 INFO Message key=None for insights_id=1134dac3-ad90-45a0-bf29-039a0ca7bf76 delivered to platform.inventory.events (P 0 O 20) 2025-07-17 15:46:02 INFO Searching messages in the topic: platform.rhsm-subscriptions.service-instance-ingress 2025-07-17 15:46:02 INFO Consumer subscribed to: {'platform.rhsm-subscriptions.service-instance-ingress': {0: -1001}} 2025-07-17 15:46:07 INFO Topic scan time limit elapsed ERROR [ 25%] iqe_rhsm_subscriptions/tests/component/swatch_metrics_hbi/test_hbi_delete_events.py::test_hypervisor_deleted _____________________________________________________________________________________________________________________________________________ ERROR at setup of test_delete_hbi_host ______________________________________________________________________________________________________________________________________________helpers = <iqe_rhsm_subscriptions.tests.component.swatch_metrics_hbi.helpers.SwatchMetricsHbiTestHelper object at 0x7f5990a878c0> @pytest.fixture(scope="function") def existing_physical_host(helpers): hbi_event_dt = today() hbi_event = helpers.hbi_events.physical_rhel_x86_host_event( datetime_to_iso8601_format(hbi_event_dt), event_type="created", cores=2, sockets=2 ) swatch_created_event_dt, expected_swatch_created_event_timestamp = helpers.as_swatch_event_dt( hbi_event_dt ) > swatch_event = helpers.kafka.trigger_and_find_swatch_event( expected_swatch_created_event_timestamp, hbi_event, "INSTANCE_CREATED" )iqe_rhsm_subscriptions/tests/component/swatch_metrics_hbi/test_hbi_delete_events.py:42: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ iqe_rhsm_subscriptions/tests/component/swatch_metrics_hbi/helpers.py:223: in trigger_and_find_swatch_event event = self.find_swatch_event(swatch_event_type, inventory_id, expected_timestamp) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ iqe_rhsm_subscriptions/tests/component/swatch_metrics_hbi/helpers.py:207: in find_swatch_event event = self.swatch_event_consumer.find_msgs( _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _self = IQEKafkaConsumer(_consumer=<iqe_mq._kafka_consumer.InsightsDeserializingConsumer object at 0x7f5990885860>), topic = 'platform.rhsm-subscriptions.service-instance-ingress', data_to_match = {'event_type': 'INSTANCE_CREATED', 'instance_id': '12f4e0fa-1c12-4685-812c-2dad44fcead3', 'timestamp': '2025-07-17T13:00:00Z'} num_matches = 1, matching_func = <bound method SwatchMetricsHbiKafkaHelper._filter_by_mapping of <iqe_rhsm_subscriptions.tests.component.swatch_metrics_hbi.helpers.SwatchMetricsHbiKafkaHelper object at 0x7f5990a87cb0>>, allow_empty = False, timeout_in_seconds = 5 def find_msgs( self, topic: str | list[str], data_to_match: Any, num_matches: int = 1, matching_func: Callable[[Any, Any], bool] = operator.eq, allow_empty: bool = True, timeout_in_seconds: int = 30, ) -> list[Message | MessageWrapper] | Message | MessageWrapper: if topic is not None: self.subscribe([topic] if isinstance(topic, str) else topic) logger.info(f"Searching messages in the topic: {topic}") result = list( self._find_messages( data_to_match=data_to_match, num_matches=num_matches, matching_func=matching_func, timeout_in_seconds=timeout_in_seconds, ) ) if not result: if allow_empty: return [] > raise NoMessageConsumedError() E iqe_mq.exceptions.NoMessageConsumedError../.iqe-venv/lib64/python3.13/site-packages/iqe_mq/_kafka_consumer.py:172: NoMessageConsumedError
Successful run logs:
2025-07-17 15:46:58 INFO Using random seed value for random generation: 9076 2025-07-17 15:46:58 INFO Message key=None for insights_id=8abf88ef-feed-4450-913a-f8c10033b211 delivered to platform.inventory.events (P 0 O 30) 2025-07-17 15:46:58 INFO Searching messages in the topic: platform.rhsm-subscriptions.service-instance-ingress 2025-07-17 15:46:58 INFO Consumer subscribed to: {'platform.rhsm-subscriptions.service-instance-ingress': {0: -1001}} 2025-07-17 15:46:58 INFO All messages found matching: {'event_type': 'INSTANCE_CREATED', 'instance_id': 'ec403551-df0b-48dc-ac98-75b9e80708d1', 'timestamp': '2025-07-17T13:00:00Z'} ---------------------------------------------------------------------------------------------------------------------------------------------------------- live log call ---------------------------------------------------------------------------------------------------------------------------------------------------------- 2025-07-17 15:46:58 INFO Message key=None for insights_id=8abf88ef-feed-4450-913a-f8c10033b211 delivered to platform.inventory.events (P 0 O 31) 2025-07-17 15:46:58 INFO Searching messages in the topic: platform.rhsm-subscriptions.service-instance-ingress 2025-07-17 15:46:58 INFO Consumer subscribed to: {'platform.rhsm-subscriptions.service-instance-ingress': {0: -1001}} 2025-07-17 15:46:58 INFO All messages found matching: {'event_type': 'INSTANCE_DELETED', 'instance_id': 'ec403551-df0b-48dc-ac98-75b9e80708d1', 'timestamp': '2025-07-17T13:00:00Z'} PASSED
- is related to
-
SWATCH-3771 Fix flaky local test test_hbi_physical_x86_host_events
-
- Closed
-