Exemple #1
0
    def test_report_criteria_without_label(self):
        obj = JUnitXMLReporter()
        obj.engine = EngineEmul()
        obj.parameters = BetterDict()

        pass_fail = PassFailStatus()

        criteria = DataCriterion(
            {
                'stop': True,
                'fail': True,
                'timeframe': -1,
                'threshold': '150ms',
                'condition': '<',
                'subject': 'avg-rt'
            }, pass_fail)
        pass_fail.criteria.append(criteria)
        criteria.is_triggered = True

        obj.engine.reporters.append(pass_fail)

        path_from_config = tempfile.mktemp(suffix='.xml',
                                           prefix='junit-xml_passfail',
                                           dir=obj.engine.artifacts_dir)
        obj.parameters.merge({
            "filename": path_from_config,
            "data-source": "pass-fail"
        })
        obj.prepare()
        obj.last_second = DataPoint(0)
        obj.post_process()
Exemple #2
0
    def test_short_data(self):
        crit_cfg = DataCriterion.string_to_config(
            "failures>0%, stop as failed")
        self.obj.criteria.append(DataCriterion(crit_cfg, self.obj))

        point = DataPoint(0)
        point[DataPoint.CUMULATIVE] = {}
        point[DataPoint.CUMULATIVE][''] = {}
        point[DataPoint.CUMULATIVE][''][KPISet.FAILURES] = 100 * 16
        point[DataPoint.CUMULATIVE][''][KPISet.SAMPLE_COUNT] = 100 * 16

        self.obj.check()
        self.obj.shutdown()
        self.obj.aggregated_second(point)
        self.assertRaises(AutomatedShutdown, self.obj.post_process)
Exemple #3
0
    def test_xml_format_passfail(self):
        obj = JUnitXMLReporter()
        obj.engine = EngineEmul()
        obj.parameters = BetterDict()
        obj.engine.provisioning = CloudProvisioning()
        obj.engine.provisioning.results_url = "http://test/report/123"

        pass_fail1 = PassFailStatus()

        fc1_triggered = DataCriterion(
            {
                'stop': True,
                'label': 'Sample 1 Triggered',
                'fail': True,
                'timeframe': -1,
                'threshold': '150ms',
                'condition': '<',
                'subject': 'avg-rt'
            }, pass_fail1)

        fc1_not_triggered = DataCriterion(
            {
                'stop': True,
                'label': 'Sample 1 Not Triggered',
                'fail': True,
                'timeframe': -1,
                'threshold': '300ms',
                'condition': '>',
                'subject': 'avg-rt'
            }, pass_fail1)

        pass_fail2 = PassFailStatus()

        fc2_triggered = DataCriterion(
            {
                'stop': True,
                'label': 'Sample 2 Triggered',
                'fail': True,
                'timeframe': -1,
                'threshold': '150ms',
                'condition': '<=',
                'subject': 'avg-rt'
            }, pass_fail1)

        fc2_not_triggered = DataCriterion(
            {
                'stop': True,
                'label': 'Sample 2 Not Triggered',
                'fail': True,
                'timeframe': -1,
                'threshold': '300ms',
                'condition': '=',
                'subject': 'avg-rt'
            }, pass_fail1)

        pass_fail1.criteria.append(fc1_triggered)
        pass_fail1.criteria.append(fc1_not_triggered)
        pass_fail2.criteria.append(fc2_triggered)
        pass_fail2.criteria.append(fc2_not_triggered)

        fc1_triggered.is_triggered = True
        fc2_triggered.is_triggered = True

        obj.engine.reporters.append(pass_fail1)
        obj.engine.reporters.append(pass_fail2)
        obj.engine.reporters.append(BlazeMeterUploader())

        path_from_config = tempfile.mktemp(suffix='.xml',
                                           prefix='junit-xml_passfail',
                                           dir=obj.engine.artifacts_dir)

        obj.parameters.merge({
            "filename": path_from_config,
            "data-source": "pass-fail"
        })
        obj.prepare()
        obj.last_second = DataPoint(0)
        obj.post_process()

        with open(obj.report_file_path, 'rb') as fds:
            f_contents = fds.read()

        logging.info("File: %s", f_contents)
        xml_tree = etree.fromstring(f_contents)
        self.assertEqual('testsuites', xml_tree.tag)
        suite = xml_tree.getchildren()[0]
        self.assertEqual('testsuite', suite.tag)
        test_cases = suite.getchildren()
        self.assertEqual(4, len(test_cases))
        self.assertEqual('testcase', test_cases[0].tag)
        self.assertEqual('error', test_cases[0].getchildren()[1].tag)
        self.assertEqual('error', test_cases[2].getchildren()[1].tag)

        sys_out = test_cases[0].getchildren()[0]
        self.assertEqual('system-out', sys_out.tag)
        self.assertIn('BlazeMeter report link: http://test/report/123',
                      sys_out.text)