Uploaded image for project: 'Red Hat Advanced Cluster Management'
  1. Red Hat Advanced Cluster Management
  2. ACM-28615

Add cluster information to Junit file

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Normal Normal
    • None
    • None
    • Installer
    • Installer Train 36 - 3
    • Moderate
    • None

      When browsing jobs in Jenkins, it will put the "Last Successful Artifacts" Junit XML file at the top. We frequently run on many ACM/MCE/OCP version, platforms, etc... so it would be nice to see this information in the Junit file without having to browse each job. At a high level, it would require these changes:

      In each playbook:

      - name: Get ACM build
          shell: |
            oc get csv -n ocm -o jsonpath='{.items[?(@.metadata.name contains "advanced-cluster-management")].spec.version}' | awk -F'[-.]' '{print $1"."$2"-"$4}'
          register: acm_build
      
        - name: Get MCE build
          shell: |
            oc get csv -n multicluster-engine -o jsonpath='{.items[?(@.metadata.name contains "multicluster-engine")].spec.version}' | awk -F'[-.]' '{print $1"."$2"-"$4}'
          register: mce_build
      
        - name: Get ACM catalog image
          shell: |
            oc get catalogsource -n openshift-marketplace -o json | jq -r '.items[] | select(.spec.image | contains("acm-dev-catalog")) | .spec.image'
          register: acm_image
      
        - name: Get MCE catalog image
          shell: |
            oc get catalogsource -n openshift-marketplace -o json | jq -r '.items[] | select(.spec.image | contains("mce-dev-catalog")) | .spec.image'
          register: mce_image
      
      - name: Set cluster info stats for JUnit report
          set_stats:
            data:
              acmBuild: "{{ acm_build.stdout }}"
              mceBuild: "{{ mce_build.stdout }}"
              acmImage: "{{ acm_image.stdout }}"
              mceImage: "{{ mce_image.stdout }}"
              ocpUrl: "{{ ocp_url.stdout }}"
              ocpVersion: "{{ ocp_version.stdout }}"
              ocpArch: "{{ ocp_arch.stdout }}"
              ocpPlatform: "{{ ocp_platform.stdout }}"
            aggregate: no
      

      In the Junit Python code:

        test_suite = TestSuite(name=self._playbook_name, cases=test_cases, timestamp=self._playbook_start_time)
      
        # Generate XML with testsuite as root element (not testsuites)
        xml_element = test_suite.get_xml_element()
      
        # Add ACM/MCE/OCP properties from Ansible stats
        if hasattr(self, '_custom_stats') and self._custom_stats:
            properties = ET.SubElement(xml_element, 'properties')
            for key in ['acmBuild', 'mceBuild', 'acmImage', 'mceImage', 'ocpUrl', 'ocpVersion', 'ocpArch', 'ocpPlatform']:
                if key in self._custom_stats:
                    prop = ET.SubElement(properties, 'property')
                    prop.set('name', key)
                    prop.set('value', str(self._custom_stats[key]))
      
        report = minidom.parseString(ET.tostring(xml_element, encoding='unicode')).toprettyxml()
      

      Which will give a report like this:

      <testsuite name="acm-install-tests" ...>
          <properties>
            <property name="acmBuild" value="2.16-154"/>
            <property name="mceBuild" value="2.11-182"/>
            <property name="acmImage" value="quay.io:443/acm-d/acm-dev-catalog:2.16.0-DOWNSTREAM-2026-01-15-05-29-45"/>
            <property name="mceImage" value="quay.io:443/acm-d/mce-dev-catalog:2.11.0-DOWNSTREAM-2026-01-15-05-16-51"/>
            <property name="ocpUrl" value="https://api.cluster-name.example.com:6443"/>
            <property name="ocpVersion" value="4.17.0"/>
            <property name="ocpArch" value="amd64"/>
            <property name="ocpPlatform" value="AWS"/>
          </properties>
          <testcase name="..." .../>
          ...
        </testsuite>
      

              rh-ee-msmigiel Matthew Smigielski
              rh-ee-msmigiel Matthew Smigielski
              Matthew Smigielski Matthew Smigielski
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: