-
Task
-
Resolution: Done
-
Critical
-
None
-
None
-
5
-
False
-
-
True
-
-
Failing tests:
- test_event_conflict_resolution_multiple_event_source
- test_event_conflict_resolution_multiple_product_tags
Error message:
AssertionError: Number of events does not match specified number of measurements. assert 0 == 1 + where 0 = len([]) + and 1 = len([3.0])
Trace:
application = <iqe.base.application.Application object at 0x7f8dbaff1a90> @pytest.mark.ephemeral def test_event_conflict_resolution_multiple_event_source(application): """Validate that event conflicts are resolved on ingestion. metadata: assignee: aunayak negative: false importance: high requirements: payg_tally test_steps: 1. Reset the account 2. Create multiple events for the same instance/timestamp with multiple event source through kafka message and varying the measurement value. expected_results: 1. Verify that as the events are created and conflicts are resolved resulting in deduction events based on the event source. """ application.rhsm_subscriptions.reset_account() org_id = application.user.identity.org_id start_date = datetime.now(timezone.utc) - timedelta(hours=1) end_date = datetime.now(timezone.utc) + timedelta(hours=2) # Create events via kafka with rhelmeter event source(when no events exist already) # Initial measurements, no deduction events expected. messages = [ { "event_source": "rhelemeter", "event_type": "snapshot_vCPUs", "org_id": org_id, "product_tag": ["rhel-for-x86-els-payg-addon"], "product_ids": ["204", "69"], "service_type": "RHEL System", "display_name": "Rhel_cluster" + str(random.randint(1, 100)), "measurements": [{"value": 3, "metric_id": "vCPUs"}], "sla": "Premium", "billing_provider": "aws", "billing_account_id": "test-300", "instance_id": "dummy_instance_id", "timestamp": datetime_to_iso8601_format(start_date), "expiration": datetime_to_iso8601_format(end_date), } ] for message in messages: application.rhsm_subscriptions.send_kafka_message( "platform.rhsm-subscriptions.service-instance-ingress", message ) rhelmeter_events = application.rhsm_subscriptions.poll_for_events( hours=7, predicate=lambda e: e["instance_id"] == "dummy_instance_id" and e["measurements"][0]["metric_id"] == "vCPUs" and e["product_tag"][0] == "rhel-for-x86-els-payg-addon" and e["event_source"] == "rhelemeter", expected_events=1, ) assert rhelmeter_events > _assert_measurement_total( rhelmeter_events, start_date, org_id, "dummy_instance_id", "vCPUs", [3.0], True ) /iqe_venv/lib/python3.11/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_metrics/test_events.py:294: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ current_events = [{'billing_account_id': 'test-300', 'billing_provider': 'aws', 'conversion': False, 'display_name': 'Rhel_cluster79', ...}] start = datetime.datetime(2025, 1, 11, 4, 58, 16, 682110, tzinfo=datetime.timezone.utc) org_id = '18064240', instance_id = 'dummy_instance_id', metric_id = 'vCPUs' ordered_values = [3.0], event_via_kafka = True timestamp = '2025-01-11T04:58:16.682110Z' def _assert_measurement_total( current_events, start, org_id, instance_id, metric_id, ordered_values, event_via_kafka=False, timestamp=None, ): """ :param bool event_via_kafka : True if event created via kafka else False """ if event_via_kafka: timestamp = datetime_to_iso8601_format(start) elif not timestamp: timestamp = datetime_to_iso8601_format(start.replace(minute=0, second=0, microsecond=0)) to_check = list( filter( lambda e: _filter_event(org_id, timestamp, instance_id, metric_id, e), current_events ) ) # Assumes one measurement value per event as that is how events are currently created. > assert len(to_check) == len(ordered_values), ( "Number of events does not match specified number of measurements." ) E AssertionError: Number of events does not match specified number of measurements. E assert 0 == 1 E + where 0 = len([]) E + and 1 = len([3.0]) /iqe_venv/lib/python3.11/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_metrics/test_events.py:448: AssertionError
Output:
--------------------------------- Captured Log --------------------------------- 2025-01-11 05:58:14 INFO Flushing usage messages off from billable usage kafka topic 2025-01-11 05:58:14 INFO PUT request response url: http://swatch-billable-usage-service:8000/api/swatch-billable-usage/internal/rpc/topics/flush, status_code: 200 2025-01-11 05:58:14 INFO Trace log using : 00-00000000000000000000000000000000-0000000000000000-00 2025-01-11 05:58:14 INFO Response: { "status": "Success" } 2025-01-11 05:58:16 INFO DELETE request response url: http://swatch-tally-service:8000/api/rhsm-subscriptions/v1/internal/rpc/tally/18064240, status_code: 200 2025-01-11 05:58:16 INFO Trace log using : 00-7000eca7237690a241667aeea4f5406e-2bc3cc9af6e435ee-00 2025-01-11 05:58:16 INFO Response: { "detail": "Finished deleting data associated with organization 18064240" } 2025-01-11 05:58:16 INFO Reset moto b'{"status": "ok"}' 2025-01-11 05:58:16 INFO Sending the following kafka message to platform.rhsm-subscriptions.service-instance-ingress: {'event_source': 'rhelemeter', 'event_type': 'snapshot_vCPUs', 'org_id': '18064240', 'product_tag': ['rhel-for-x86-els-payg-addon'], 'product_ids': ['204', '69'], 'service_type': 'RHEL System', 'display_name': 'Rhel_cluster79', 'measurements': [{'value': 3, 'metric_id': 'vCPUs'}], 'sla': 'Premium', 'billing_provider': 'aws', 'billing_account_id': 'test-300', 'instance_id': 'dummy_instance_id', 'timestamp': '2025-01-11T04:58:16.682110Z', 'expiration': '2025-01-11T07:58:16.682119Z'} 2025-01-11 05:58:16 INFO POST request response url: http://kafka-bridge-bridge-service:8080/topics/platform.rhsm-subscriptions.service-instance-ingress, status_code: 200 2025-01-11 05:58:16 INFO Trace log using : None 2025-01-11 05:58:16 INFO Response: { "offsets": [ { "offset": 30, "partition": 1 } ] } 2025-01-11 05:58:16 INFO GET request response url: http://swatch-tally-service:8000/api/rhsm-subscriptions/v1/internal/rpc/tally/events/18064240?begin=2025-01-10T22%3A58%3A16.700110Z&end=2025-01-11T05%3A58%3A16.700133Z, status_code: 200 2025-01-11 05:58:16 INFO Trace log using : 00-fca2790a5e1799ce94150949db6c784b-e6ea327af931d187-00 2025-01-11 05:58:16 INFO Response: { "detail": "[{\"event_source\":\"rhelemeter\",\"event_type\":\"snapshot_vCPUs\",\"org_id\":\"18064240\",\"instance_id\":\"dummy_instance_id\",\"event_id\":\"04da92d5-9798-41f3-b464-0352e7485d18\",\"service_type\":\"RHEL System\",\"timestamp\":\"2025-01-11T04:58:16.68211Z\",\"record_date\":\"2025-01-11T05:58:16.702108775Z\",\"expiration\":\"2025-01-11T07:58:16.682119Z\",\"display_name\":\"Rhel_cluster79\",\"measurements\":[{\"value\":3.0,\"metric_id\":\"vCPUs\"}],\"product_ids\":[\"204\",\"69\"],\"sla\":\"Premium\",\"billing_provider\":\"aws\",\"billing_account_id\":\"test-300\",\"product_tag\":[\"rhel-for-x86-els-payg-addon\"],\"conversion\":false}]" } --------------------------------- Captured Out ---------------------------------
Links:
- https://ci.ext.devshift.net/job/RedHatInsights-rhsm-subscriptions-pr-check/9482/testReport/junit/tests.integration.swatch_metrics/test_events/test_event_conflict_resolution_multiple_event_source/
- https://ci.ext.devshift.net/job/RedHatInsights-rhsm-subscriptions-pr-check/9488/testReport/junit/tests.integration.swatch_metrics/test_events/test_event_conflict_resolution_multiple_product_tags/
(the links will be automatically removed in some days)