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

Fix test test_validate_tally_on_openshift_cores_for_new_candlepin_facts

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Blocker Blocker
    • None
    • None
    • swatch-tally
    • None
    • 3
    • False
    • Hide

      None

      Show
      None
    • False
    • subs-swatch-thunder
    • Swatch Thunder Sprint 1

      This test is consistently failing in Jenkins. Example link: https://ci.ext.devshift.net/job/RedHatInsights-rhsm-subscriptions-pr-check/12117/

      Test:

      application = <iqe.base.application.Application object at 0x7fc876edf590>
      threads_per_core = 0.06666666666666667, number_of_cpus = 4
      
          @pytest.mark.ephemeral
          @pytest.mark.ephemeral_only
          @pytest.mark.parametrize("threads_per_core", get_random_choices_or_leading_elements([0, 3, None]))
          @pytest.mark.parametrize("number_of_cpus", get_random_choices_or_leading_elements([4, 2, 6, 0]))
          def test_validate_tally_on_openshift_cores_for_new_candlepin_facts(
              application, threads_per_core, number_of_cpus
          ):
              """Create openshift cluster with new candlepin facts and verify cores.
          
              metadata:
                  assignee: aunayak
                  negative: false
                  importance: medium
                  bugzilla: SWATCH-401
                  customer_scenario: true
                  requirements: prepay_tally
                  test_steps:
                      1. Read existing tally data.
                      2. Register openshift cluster with new candlepin facts.
                      3. Sync Tally data for account.
                      4. Read new tally data.
                      5. Verify tally data shows correct value for new candlepin facts .
                  expected_results:
                      1. Tally data shown is correct.
              """
              sockets = 4
              cores_per_socket = 15
              openshift_tally_initial_daily_usage = (
                  application.rhsm_subscriptions.get_today_tally_report_with_metrics_filter(
                      product_id="OpenShift Container Platform", metric_id="Cores"
                  )
              )
          
              parameter = {
                  "sockets": sockets,
                  "cores_per_socket": cores_per_socket,
                  "number_of_cpus": number_of_cpus,
                  "ocm_units": "Cores/vCPU",
                  "usage": "Disaster Recovery",
              }
              if threads_per_core:
                  parameter["threads_per_core"] = threads_per_core
          
              logging.info(f"Creating cluster with parameter:{parameter}")
          
              # Register openshift cluster as consumer in candlepin
              cluster = application.rhsm_subscriptions.create_openshift_cluster(**parameter)
              assert cluster, "Problem with cluster creation"
              logging.info(f"Cluster created, cluster id: {cluster}")
              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[0]["display_name"] == cluster["display_name"], (
                  f"Cluster in system table {system_table[0]['display_name']}"
                  f" is not matching with the created cluster {cluster['display_name']}"
              )
          
              if not threads_per_core:
                  if not number_of_cpus:
                      threads_per_core = 2
                  else:
                      threads_per_core = number_of_cpus / (sockets * cores_per_socket)
                  cores = ceil((sockets * cores_per_socket) / threads_per_core)
              else:
                  cores = ceil((sockets * cores_per_socket) / threads_per_core)
          
              openshift_tally_final_daily_usage = (
                  application.rhsm_subscriptions.get_today_tally_report_with_metrics_filter(
                      product_id="OpenShift Container Platform", metric_id="Cores"
                  )
              )
      >       assert (
                  openshift_tally_final_daily_usage["cores"]
                  == openshift_tally_initial_daily_usage["cores"] + cores
              ), (
                  f"Initial openshift core:{openshift_tally_initial_daily_usage['cores']} + cores:{cores} "
                  f"is not matching with final openshift core:{openshift_tally_final_daily_usage['cores']}"
              )
      E       AssertionError: Initial openshift core:0 + cores:900 is not matching with final openshift core:1100
      E       assert 1100 == (0 + 900)
      
      /iqe_venv/lib/python3.12/site-packages/iqe_rhsm_subscriptions/tests/integration/swatch_tally/test_tally_openshift.py:272: AssertionError
      

      Output:

      --------------------------------- Captured Log ---------------------------------
      2025-09-26 11:44:24 INFO Using random seed value for random generation: 4950
      2025-09-26 11:44:24 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Cores with query params [('granularity', 'Daily'), ('beginning', '2025-09-25T11:11:19.288309+00:00'), ('ending', '2025-09-26T11:44:24.946848+00:00')] and x-rh-insights-request-id=None
      2025-09-26 11:44:24 INFO {'date': datetime.datetime(2025, 9, 26, 0, 0, tzinfo=tzlocal()),
       'has_data': False,
       'value': 0}
      2025-09-26 11:44:24 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Sockets with query params [('granularity', 'Daily'), ('beginning', '2025-09-25T11:11:19.288309+00:00'), ('ending', '2025-09-26T11:44:24.957152+00:00')] and x-rh-insights-request-id=None
      2025-09-26 11:44:24 INFO {'date': datetime.datetime(2025, 9, 26, 0, 0, tzinfo=tzlocal()),
       'has_data': False,
       'value': 0}
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.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-09-26 11:44:25 INFO Total Hosts in OpenShift Container Platform system table: 0
      2025-09-26 11:44:25 INFO Creating cluster with parameter:{'sockets': 4, 'cores_per_socket': 15, 'number_of_cpus': 4, 'ocm_units': 'Cores/vCPU', 'usage': 'Disaster Recovery'}
      2025-09-26 11:44:25 INFO producing host messages
      2025-09-26 11:44:25 INFO Produced message: {'data': {'ansible_host': 'db-76.miller-white.com', 'display_name': 'virtual_mockfdcfcb60kvagwjje.test.gov', 'org_id': '18939572', 'insights_id': 'ae1d1b51-8cde-4634-9ae1-f548979ae5f0', 'subscription_manager_id': 'd47676b8-fdcc-47fb-87a6-87c1ffdecf94', 'bios_uuid': 'ae1d1b51-8cde-4634-9ae1-f548979ae5f0', 'fqdn': 'virtual_mockfdcfcb60kvagwjje.test.gov', 'ip_addresses': ['172.20.114.59', '172.30.75.8'], 'mac_addresses': ['08:9a:da:d8:97:65', '96:81:da:e8:bf:c6'], 'facts': [{'namespace': 'rhsm', 'facts': {'orgId': '18939572', 'MEMORY': 62, 'RH_PROD': ['290'], 'IS_VIRTUAL': True, 'ARCHITECTURE': 'x86_64', 'SYNC_TIMESTAMP': '2025-10-03T11:44:25.048595+00:00', 'SYSPURPOSE_ADDONS': [], 'BILLING_MODEL': 'Standard', 'SYSPURPOSE_UNITS': 'Cores/vCPU', 'SYSPURPOSE_USAGE': 'Disaster Recovery'}}], 'tags': [], 'reporter': 'rhsm-conduit', 'stale_timestamp': '2025-09-29T23:43:32.943848+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': 15, '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-09-24T05:26:45.349512+00:00', 'network_interfaces': [], 'number_of_cpus': 4, 'number_of_sockets': 4, 'operating_system': {'name': 'RHEL', 'major': 9, 'minor': 4}, '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': 'd47676b8-fdcc-47fb-87a6-87c1ffdecf94', 'threads_per_core': 0}, 'satellite_id': 'ae1d1b51-8cde-4634-9ae1-f548979ae5f0'}, 'operation': 'add_host', 'platform_metadata': {'b64_identity': 'eyJpZGVudGl0eSI6IHsiYWNjb3VudF9udW1iZXIiOiAiMTE0OTE2ODYiLCAib3JnX2lkIjogIjE4OTM5NTcyIiwgInVzZXJfaWQiOiAiMTI0MjM1Njg5IiwgInR5cGUiOiAiVXNlciIsICJhdXRoX3R5cGUiOiAiYmFzaWMtYXV0aCIsICJ1c2VyIjogeyJ1c2VybmFtZSI6ICJzd2F0Y2gtcHItY2hlY2siLCAiZW1haWwiOiAiamRvZTRAYWNtZS5jb20iLCAiZmlyc3RfbmFtZSI6ICJKb2huIiwgImxhc3RfbmFtZSI6ICJEb2UiLCAiaXNfYWN0aXZlIjogdHJ1ZSwgImlzX29yZ19hZG1pbiI6IHRydWUsICJpc19pbnRlcm5hbCI6IGZhbHNlLCAibG9jYWxlIjogImVuX1VTIn0sICJpbnRlcm5hbCI6IHsib3JnX2lkIjogIjE4OTM5NTcyIiwgImF1dGhfdGltZSI6IDYzMDAsICJjcm9zc19hY2NvdW50IjogZmFsc2V9fX0=', 'request_id': '9d59cd5a-66fb-415c-9fcd-9d36a3c07857'}}
      2025-09-26 11:44:25 INFO Message key=b'18939572' for insights_id=ae1d1b51-8cde-4634-9ae1-f548979ae5f0 delivered to platform.inventory.host-ingress (P 1 O 9)
      2025-09-26 11:44:25 INFO flush completed, 0 still in queue
      2025-09-26 11:44:25 INFO search messages having DataAlias(name='insights_id', lookup_alias='_data') in ['ae1d1b51-8cde-4634-9ae1-f548979ae5f0']
      2025-09-26 11:44:25 INFO Attempt 0 to fetch resource
      2025-09-26 11:44:25 INFO REST: GET http://host-inventory-service.ephemeral-bleckh.svc:8000/api/inventory/v1/hosts/fcc29080-61b7-402e-ae64-ffee33e82fdc with query params None and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO Cluster created, cluster id: {'display_name': 'virtual_mockfdcfcb60kvagwjje.test.gov', 'hardware_type': 'VIRTUAL', 'sockets': 4, 'cores': 15, 'subscription_manager_id': 'd47676b8-fdcc-47fb-87a6-87c1ffdecf94'}
      2025-09-26 11:44:25 INFO Requesting POST http://swatch-system-conduit-service:8000/api/rhsm-subscriptions/v1/internal/rpc/syncOrg
      2025-09-26 11:44:25 INFO POST request response url: http://swatch-system-conduit-service:8000/api/rhsm-subscriptions/v1/internal/rpc/syncOrg, status_code: 200
      2025-09-26 11:44:25 INFO Trace log using : 00-9a50184de5548806449e02a5b5473f81-bb238d54c52c2f6b-00  
      2025-09-26 11:44:25 INFO REST: GET http://host-inventory-service.ephemeral-bleckh.svc:8000/api/inventory/v1/hosts with query params [('display_name', 'virtual_mockfdcfcb60kvagwjje.test.gov'), ('page', 1)] and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO RHSM-conduit sync finished successfully!
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.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-09-26 11:44:25 INFO Total Hosts in OpenShift Container Platform system table: 0
      2025-09-26 11:44:25 INFO Requesting PUT http://swatch-tally-service:8000/api/rhsm-subscriptions/v1/internal/rpc/tally/snapshots/18939572
      2025-09-26 11:44:25 INFO PUT request response url: http://swatch-tally-service:8000/api/rhsm-subscriptions/v1/internal/rpc/tally/snapshots/18939572, status_code: 200
      2025-09-26 11:44:25 INFO Trace log using : 00-d8e4bddd5fe930b4d77001a3971b7c36-a256270a3f4d1432-00  
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.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-09-26 11:44:25 INFO Total Hosts in OpenShift Container Platform system table: 2
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockfdcfcb60kvagwjje.test.gov'), ('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO Found 1 hosts:
      [{'id': '2f139740-e031-4174-9433-95a7cd97d14b', 'instance_id': 'fcc29080-61b7-402e-ae64-ffee33e82fdc', 'display_name': 'virtual_mockfdcfcb60kvagwjje.test.gov', 'measurements': [900.0, 0.0], 'last_seen': datetime.datetime(2025, 9, 26, 11, 44, 25, 168656, tzinfo=tzlocal()), 'number_of_guests': 0, 'category': 'virtual', 'subscription_manager_id': 'd47676b8-fdcc-47fb-87a6-87c1ffdecf94', 'inventory_id': 'fcc29080-61b7-402e-ae64-ffee33e82fdc', '_labeled_measurements': {'Cores': 900.0, 'Sockets': 0.0}}]
      2025-09-26 11:44:25 INFO Tally Sync Finished Successfully!
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/instances/products/OpenShift%20Container%20Platform with query params [('limit', 100), ('offset', 0), ('display_name_contains', 'virtual_mockfdcfcb60kvagwjje.test.gov'), ('metric_id', 'Cores')] and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO Found 1 hosts:
      [{'id': '2f139740-e031-4174-9433-95a7cd97d14b', 'instance_id': 'fcc29080-61b7-402e-ae64-ffee33e82fdc', 'display_name': 'virtual_mockfdcfcb60kvagwjje.test.gov', 'measurements': [900.0, 0.0], 'last_seen': datetime.datetime(2025, 9, 26, 11, 44, 25, 168656, tzinfo=tzlocal()), 'number_of_guests': 0, 'category': 'virtual', 'subscription_manager_id': 'd47676b8-fdcc-47fb-87a6-87c1ffdecf94', 'inventory_id': 'fcc29080-61b7-402e-ae64-ffee33e82fdc', '_labeled_measurements': {'Cores': 900.0, 'Sockets': 0.0}}]
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Cores with query params [('granularity', 'Daily'), ('beginning', '2025-09-25T11:11:19.288309+00:00'), ('ending', '2025-09-26T11:44:25.574669+00:00')] and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO {'date': datetime.datetime(2025, 9, 26, 0, 0, tzinfo=tzlocal()),
       'has_data': True,
       'value': 1100}
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.svc:8000/api/rhsm-subscriptions/v1/tally/products/OpenShift%20Container%20Platform/Sockets with query params [('granularity', 'Daily'), ('beginning', '2025-09-25T11:11:19.288309+00:00'), ('ending', '2025-09-26T11:44:25.584679+00:00')] and x-rh-insights-request-id=None
      2025-09-26 11:44:25 INFO {'date': datetime.datetime(2025, 9, 26, 0, 0, tzinfo=tzlocal()),
       'has_data': True,
       'value': 0}
      2025-09-26 11:44:25 INFO REST: GET http://swatch-api-nginx-proxy.ephemeral-bleckh.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-09-26 11:44:25 INFO Total Hosts in OpenShift Container Platform system table: 2
      --------------------------------- Captured Out ---------------------------------
      

              rh-ee-liwalker Lisa Walker
              jcarvaja@redhat.com Jose Carvajal Hilario
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: