Example #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()
Example #2
0
    def test_report_criteria_without_label(self):
        obj = JUnitXMLReporter()
        obj.engine = EngineEmul()
        obj.parameters = BetterDict()

        pass_fail = PassFailStatus()

        crit_cfg = BetterDict.from_dict({'stop': True, 'fail': True, 'timeframe': -1, 'threshold': '150ms',
                                         'condition': '<', 'subject': 'avg-rt'})
        criteria = DataCriterion(crit_cfg, 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()
Example #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)
Example #4
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 = CriteriaProcessor([], None)

        crit_cfg1 = BetterDict()
        crit_cfg2 = BetterDict()
        crit_cfg3 = BetterDict()
        crit_cfg4 = BetterDict()

        crit_cfg1.merge({
            'stop': True, 'label': 'Sample 1 Triggered', 'fail': True,
            'timeframe': -1, 'threshold': '150ms', 'condition': '<', 'subject': 'avg-rt'})

        crit_cfg2.merge({
            'stop': True, 'label': 'Sample 1 Not Triggered', 'fail': True,
            'timeframe': -1, 'threshold': '300ms', 'condition': '>', 'subject': 'avg-rt'})

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

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

        fc1_triggered = DataCriterion(crit_cfg1, pass_fail1)
        fc1_not_triggered = DataCriterion(crit_cfg2, pass_fail1)

        pass_fail2 = CriteriaProcessor([], None)

        fc2_triggered = DataCriterion(crit_cfg3, pass_fail1)
        fc2_not_triggered = DataCriterion(crit_cfg4, 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

        pass_fail = PassFailStatus()
        pass_fail.processors.append(pass_fail1)
        pass_fail.processors.append(pass_fail2)
        obj.engine.reporters.append(pass_fail)
        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()

        ROOT_LOGGER.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)