Пример #1
0
 def test_properties_ne2(self):
     prop1 = Property('prop1', '1')
     prop2 = Property('prop1', '2')
     prop3 = deepcopy(prop1)
     props1 = Properties()
     props1.add_property(prop1)
     props1.add_property(prop2)
     props2 = Properties()
     props2.add_property(prop3)
     self.assertNotEqual(props1, props2)
Пример #2
0
 def test_properties_ne2(self):
     prop1 = Property("prop1", "1")
     prop2 = Property("prop1", "2")
     prop3 = deepcopy(prop1)
     props1 = Properties()
     props1.add_property(prop1)
     props1.add_property(prop2)
     props2 = Properties()
     props2.add_property(prop3)
     self.assertNotEqual(props1, props2)
Пример #3
0
 def test_properties_eq(self):
     prop1 = Property('prop1', '1')
     prop2 = Property('prop1', '2')
     prop3 = deepcopy(prop1) # Note: an attribute can only be used at one place.
     prop4 = deepcopy(prop2)
     props1 = Properties()
     props1.add_property(prop1)
     props1.add_property(prop2)
     props2 = Properties()
     props2.add_property(prop3)
     props2.add_property(prop4)
     self.assertEqual(props1, props2)
Пример #4
0
def generate_test_case(name, duration, status, polarion_id=None):
    """Create test case object.

    Args:
        name: test case name
        duration: test run duration
        status: test status
        polarion_id: polarion Id (default: None)

    Returns:
        test_case: junit parser test case object
    """
    test_case = TestCase(name)

    if isinstance(duration, timedelta):
        test_case.time = duration.total_seconds()
    else:
        test_case.time = 0.0

    if status != "Pass":
        test_case.result = Failure("test failed")

    if polarion_id:
        props = Properties()
        props.append(Property(name="polarion-testcase-id", value=polarion_id))
        test_case.append(props)
    return test_case
Пример #5
0
def check_for_ltm(results_dir, props):
    """Check to see if the results directory was created by the LTM and
    adjust the properties accordingly.  Returns true if we are in LTM
    mode.
    """
    try:
        out_f = open(os.path.join(results_dir, 'ltm-run-stats'))
        for line in out_f:
            key, value = line.split(': ', 1)
            value = value.rstrip('\n').strip('"')
            remove_properties(props, key)
            props.add_property(Property(key, value))
        out_f.close()
        remove_properties(props, 'GCE ID')
        remove_properties(props, 'FSTESTCFG')
        return True
    except IOError:
        return False
Пример #6
0
 def test_property_ne(self):
     prop1 = Property("prop1", "1")
     prop2 = Property("prop1", "2")
     self.assertNotEqual(prop1, prop2)
Пример #7
0
 def test_property_eq(self):
     prop1 = Property("prop1", "1")
     prop2 = Property("prop1", "1")
     self.assertEqual(prop1, prop2)
Пример #8
0
 def test_property_repr1(self):
     prop1 = Property("prop1", "1")
     self.assertEqual(prop1.__repr__(),
                      '<Element \'property\' name="prop1" value="1">')
Пример #9
0
 def test_remove_property_from_none(self):
     suite = TestSuite()
     suite.remove_property(Property("key", "value"))
Пример #10
0
def create_xunit_results(suite_name, test_cases, test_run_metadata):
    """Create an xUnit result file for the test suite's executed test cases.

    Args:
        suite_name: the test suite name
        test_cases: the test cases objects
        test_run_metadata: test run meta information in dict

    Returns: None
    """
    _file = suite_name.split("/")[-1].split(".")[0]
    run_dir = test_run_metadata["log-dir"]
    run_id = test_run_metadata["run-id"]
    xml_file = f"{run_dir}/xunit.xml"
    ceph_version = test_run_metadata["ceph-version"]
    ansible_version = test_run_metadata["ceph-ansible-version"]
    distribution = test_run_metadata["distro"]
    build = test_run_metadata["build"]
    test_run_id = f"RHCS-{build}-{_file}-{run_id}".replace(".", "-")
    test_group_id = (
        f"ceph-build: {ceph_version} "
        f"ansible-build: {ansible_version} OS distro: {distribution}")
    log.info(f"Creating xUnit {_file} for test run-id {test_run_id}")

    suite = TestSuite(_file)
    for k, v in test_run_metadata.items():
        suite.add_property(k, f" {v}" if v else " --NA--")

    for tc in test_cases:
        test_name = tc["name"]
        pol_ids = tc.get("polarion-id")
        test_status = tc["status"]
        elapsed_time = tc.get("duration")

        if pol_ids:
            _ids = pol_ids.split(",")
            for _id in _ids:
                suite.add_testcase(
                    generate_test_case(
                        test_name,
                        elapsed_time,
                        test_status,
                        polarion_id=_id,
                    ))
        else:
            suite.add_testcase(
                generate_test_case(
                    test_name,
                    elapsed_time,
                    test_status,
                ))

    suite.update_statistics()

    xml = JUnitXml()
    props = Properties()
    props.append(Property(name="polarion-project-id", value="CEPH"))
    props.append(Property(name="polarion-testrun-id", value=test_run_id))
    props.append(Property(name="polarion-group-id", value=test_group_id))
    xml.append(props)
    xml.add_testsuite(suite)
    xml.write(xml_file, pretty=True)

    log.info(f"xUnit result file created: {xml_file}")
Пример #11
0
 def test_property_ne(self):
     prop1 = Property('prop1', '1')
     prop2 = Property('prop1', '2')
     self.assertNotEqual(prop1, prop2)
Пример #12
0
 def test_property_eq(self):
     prop1 = Property('prop1', '1')
     prop2 = Property('prop1', '1')
     self.assertEqual(prop1, prop2)
Пример #13
0
 def test_remove_property_from_none(self):
     suite = TestSuite()
     suite.remove_property(Property('key', 'value'))