Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-3396

Fix flaky test test_validate_tally_on_openshift_cores

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Undefined Undefined
    • 2025-04-16 - API
    • None
    • None
    • None
    • 5
    • False
    • Hide

      None

      Show
      None
    • False

      Test:

      application = <iqe.base.application.Application object at 0x7f24fa3abc80>
      cores_per_socket = 3
      
          @pytest.mark.ephemeral
          @pytest.mark.parametrize("cores_per_socket", [choice([1, 2, 3])])
          def test_validate_tally_on_openshift_cores(application, cores_per_socket):
              """Create openshift cluster with cores and validate tally data. Get Tally API response.
          
              metadata:
                  assignee: liwalker
                  negative: false
                  importance: medium
                  bugzilla: 1834990
                  customer_scenario: true
                  requirements: prepay_tally
                  test_steps:
                      1. Read existing tally data.
                      2. Register openshift cluster with some cores to account.
                      3. Sync Tally data for account.
                      4. Read new tally data.
                      5. Verify tally data shows increased count for openshift cores.
                  expected_results:
                      1. Tally data shown is correct.
              """
              sockets = randint(1, 20)
          
              openshift_tally_initial_daily_usage = (
                  application.rhsm_subscriptions.get_today_tally_report_with_metrics_filter(
                      product_id="OpenShift Container Platform", metric_id="Cores"
                  )
              )
          
              # Register openshift cluster as consumer in candlepin
              cluster = application.rhsm_subscriptions.create_openshift_cluster(
                  sockets=sockets,
                  cores_per_socket=cores_per_socket,
                  ocm_units="Cores/vCPU",
                  usage="Disaster Recovery",
              )
              application.rhsm_subscriptions.sync_swatch(
                  wait=True,
                  product_id="OpenShift Container Platform",
                  hostname=cluster["display_name"],
                  metric_id="Cores",
              )
          
              system_table = application.rhsm_subscriptions.search_system_table(
                  "OpenShift Container Platform",
                  display_name_contains=cluster["display_name"],
                  metric_id="Cores",
              )
              assert system_table
              assert system_table["display_name"] == cluster["display_name"]
              # https://issues.redhat.com/browse/SWATCH-2028
              threads_per_core = 2.0
              assert system_table["_labeled_measurements"]["Cores"] == ceil(
                  (cluster["sockets"] * cluster["cores"]) / threads_per_core
              )
              assert system_table["category"] == "virtual"
              # check cluster don't exist in sockets metric_id
              system_table_cores = application.rhsm_subscriptions.search_system_table(
                  "OpenShift Container Platform",
                  display_name_contains=cluster["display_name"],
                  metric_id="Sockets",
              )
              assert not system_table_cores, (
                  f"Cluster {cluster['display_name']} with metric_id cores in sockets"
              )
          
              # check cluster not exists in openshift-metrics
              system_table = application.rhsm_subscriptions.search_system_table(
                  "OpenShift-metrics", display_name_contains=cluster["display_name"], metric_id="Cores"
              )
              assert not system_table
              current_usage = application.rhsm_subscriptions.get_today_tally_report_with_metrics_filter(
                  product_id="OpenShift Container Platform", metric_id="Cores"
              )
          
              # verify openshift cores increased
          
      >       assert current_usage["cores"] == openshift_tally_initial_daily_usage["cores"] + ceil(
                  (sockets * cores_per_socket) / threads_per_core
              )
      E       assert 160 == (0 + 15)
      E        +  where 15 = ceil(((10 * 3) / 2.0))
      
      /iqe_venv/lib/python3.12/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_tally/test_tally_openshift.py:174: AssertionError
      

      Output:

      --------------------------------- Captured Log ---------------------------------
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Cores with query params [('granularity', 'Daily'), ('beginning', '2025-03-17T09:22:13.947164+00:00'), ('ending', '2025-03-18T10:09:23.137616+00:00')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO {'date': datetime.datetime(2025, 3, 18, 0, 0, tzinfo=tzlocal()),
       'has_data': False,
       'value': 0}
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Sockets with query params [('granularity', 'Daily'), ('beginning', '2025-03-17T09:22:13.947164+00:00'), ('ending', '2025-03-18T10:09:23.148065+00:00')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO {'date': datetime.datetime(2025, 3, 18, 0, 0, tzinfo=tzlocal()),
       'has_data': False,
       'value': 0}
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO Total Hosts in OpenShift Container Platform system table: 0
      2025-03-18 10:09:23 INFO producing host messages
      2025-03-18 10:09:23 INFO Produced message: {'data': {'ansible_host': 'desktop-52.mosley-miranda.com', 'display_name': 'virtual_mockjwvnujaw.example.org', 'org_id': '18939572', 'insights_id': 'adbcb50c-be42-4a0b-97c7-576229020ce4', 'subscription_manager_id': 'b25d4ea6-d4f3-4b4d-b808-f5c78de7e102', 'bios_uuid': 'adbcb50c-be42-4a0b-97c7-576229020ce4', 'fqdn': 'virtual_mockjwvnujaw.example.org', 'ip_addresses': ['172.21.120.138', '10.150.94.169'], 'mac_addresses': ['94:ee:20:8d:77:cb', '48:1f:05:65:57:11'], 'facts': [{'namespace': 'rhsm', 'facts': {'orgId': '18939572', 'MEMORY': 62, 'RH_PROD': ['290'], 'IS_VIRTUAL': True, 'ARCHITECTURE': 'x86_64', 'SYNC_TIMESTAMP': '2025-03-24T10:09:23.201004+00:00', 'SYSPURPOSE_ADDONS': [], 'BILLING_MODEL': 'Standard', 'SYSPURPOSE_UNITS': 'Cores/vCPU', 'SYSPURPOSE_USAGE': 'Disaster Recovery'}}], 'tags': [], 'reporter': 'rhsm-conduit', 'stale_timestamp': '2025-03-20T22:17:34.129981+00:00', 'system_profile': {'arch': 'x86_64', 'basearch': 'string', 'bios_release_date': 'string', 'bios_vendor': 'string', 'bios_version': 'string', 'cloud_provider': 'test cloud provider', 'cores_per_socket': 3, 'cpu_flags': [], 'disk_devices': [], 'enabled_services': [], 'infrastructure_type': 'virtual', 'infrastructure_vendor': 'string', 'insights_client_version': 'string', 'insights_egg_version': 'string', 'installed_packages': [], 'installed_products': [], 'installed_services': [], 'katello_agent_running': False, 'kernel_modules': [], 'last_boot_time': '2025-03-08T23:33:09.743432+00:00', 'network_interfaces': [], 'number_of_cpus': 0, 'number_of_sockets': 10, 'operating_system': {'name': 'RHEL', 'major': 8, 'minor': 7}, 'os_kernel_version': '3.10.0', 'os_release': 'string', 'releasever': 'string', 'running_processes': [], 'satellite_managed': True, 'subscription_auto_attach': 'string', 'subscription_status': 'string', 'system_memory_bytes': 77824, 'yum_repos': [], 'owner_id': 'b25d4ea6-d4f3-4b4d-b808-f5c78de7e102', 'threads_per_core': 0}, 'satellite_id': 'adbcb50c-be42-4a0b-97c7-576229020ce4'}, 'operation': 'add_host', 'platform_metadata': {'b64_identity': 'eyJpZGVudGl0eSI6IHsib3JnX2lkIjogIjE4OTM5NTcyIiwgInR5cGUiOiAiVXNlciIsICJhdXRoX3R5cGUiOiAiYmFzaWMtYXV0aCJ9fQ==', 'request_id': '63a75158-14c0-4fea-bdcb-b08e54c0d0da'}}
      2025-03-18 10:09:23 INFO Message key=b'18939572' for insights_id=adbcb50c-be42-4a0b-97c7-576229020ce4 delivered to platform.inventory.host-ingress (P 1 O 8)
      2025-03-18 10:09:23 INFO flush completed, 0 still in queue
      2025-03-18 10:09:23 INFO search messages having DataAlias(name='insights_id', lookup_alias='_data') in ['adbcb50c-be42-4a0b-97c7-576229020ce4']
      2025-03-18 10:09:23 INFO Attempt 0 to fetch resource
      2025-03-18 10:09:23 INFO REST: GET http://host-inventory-service.ephemeral-is1hqa.svc:8000/api/inventory/v1/hosts/24495e7a-e094-450c-b6c7-9fd69308007b with query params None and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO POST request response url: http://swatch-system-conduit-service:8000/api/rhsm-subscriptions/v1/internal/rpc/syncOrg, status_code: 200
      2025-03-18 10:09:23 INFO Trace log using : 00-0f76b7c8556cbc9e53d48101172f7018-2e4bdd4741a3e004-00  
      2025-03-18 10:09:23 INFO REST: GET http://host-inventory-service.ephemeral-is1hqa.svc:8000/api/inventory/v1/hosts with query params [('display_name', 'virtual_mockjwvnujaw.example.org'), ('page', 1)] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO RHSM-conduit sync finished successfully!
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO Total Hosts in OpenShift Container Platform system table: 0
      2025-03-18 10:09:23 INFO PUT request response url: http://swatch-tally-service:8000/api/rhsm-subscriptions/v1/internal/rpc/tally/snapshots/18939572, status_code: 200
      2025-03-18 10:09:23 INFO Trace log using : 00-d2e4d0d5385276da9dae157aafc3f385-6e8501ecc2bb7992-00  
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO Total Hosts in OpenShift Container Platform system table: 2
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockjwvnujaw.example.org'), ('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO [{'id': '1cf2c8a1-3294-4169-9e89-e9f7fc506f01', 'instance_id': '24495e7a-e094-450c-b6c7-9fd69308007b', 'display_name': 'virtual_mockjwvnujaw.example.org', 'measurements': [15.0, 0.0], 'last_seen': datetime.datetime(2025, 3, 18, 10, 9, 23, 333637, tzinfo=tzlocal()), 'number_of_guests': 0, 'category': 'virtual', 'subscription_manager_id': 'b25d4ea6-d4f3-4b4d-b808-f5c78de7e102', 'inventory_id': '24495e7a-e094-450c-b6c7-9fd69308007b', '_labeled_measurements': {'Cores': 15.0, 'Sockets': 0.0}}]
      2025-03-18 10:09:23 INFO Tally Sync Finished Successfully!
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockjwvnujaw.example.org'), ('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO [{'id': '1cf2c8a1-3294-4169-9e89-e9f7fc506f01', 'instance_id': '24495e7a-e094-450c-b6c7-9fd69308007b', 'display_name': 'virtual_mockjwvnujaw.example.org', 'measurements': [15.0, 0.0], 'last_seen': datetime.datetime(2025, 3, 18, 10, 9, 23, 333637, tzinfo=tzlocal()), 'number_of_guests': 0, 'category': 'virtual', 'subscription_manager_id': 'b25d4ea6-d4f3-4b4d-b808-f5c78de7e102', 'inventory_id': '24495e7a-e094-450c-b6c7-9fd69308007b', '_labeled_measurements': {'Cores': 15.0, 'Sockets': 0.0}}]
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockjwvnujaw.example.org'), ('metric_id', 'Sockets')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift-metrics with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockjwvnujaw.example.org'), ('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Cores with query params [('granularity', 'Daily'), ('beginning', '2025-03-17T09:22:13.947164+00:00'), ('ending', '2025-03-18T10:09:23.609355+00:00')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO {'date': datetime.datetime(2025, 3, 18, 0, 0, tzinfo=tzlocal()),
       'has_data': True,
       'value': 160}
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Sockets with query params [('granularity', 'Daily'), ('beginning', '2025-03-17T09:22:13.947164+00:00'), ('ending', '2025-03-18T10:09:23.688534+00:00')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO {'date': datetime.datetime(2025, 3, 18, 0, 0, tzinfo=tzlocal()),
       'has_data': True,
       'value': 0}
      2025-03-18 10:09:23 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-is1hqa.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-03-18 10:09:23 INFO Total Hosts in OpenShift Container Platform system table: 2
      --------------------------------- Captured Out ---------------------------------
      
      

              rhn-engineering-wpoteat William Poteat
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: