def test_load_reader_real2(self):
        reader1 = ApiritifLoadReader(self.obj.log)
        reader1.engine = EngineEmul()
        reader1.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif-0.csv")
        reader1.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif-1.csv")

        reader2 = ApiritifLoadReader(self.obj.log)
        reader2.engine = EngineEmul()
        reader2.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif--10.csv")
        reader2.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif--11.csv")

        reader = ConsolidatingAggregator()
        reader.engine = EngineEmul()
        reader.add_underling(reader1)
        reader.add_underling(reader2)

        items = list(reader.datapoints())
        self.assertEqual(0, len(items))

        all_items = []
        while True:
            items = list(reader.datapoints())
            all_items.extend(items)
            if not items:
                break

            for point in items:
                cnc = point[DataPoint.CURRENT][''][KPISet.CONCURRENCY]
                logging.info("%s: %s", point[DataPoint.TIMESTAMP], cnc)
                self.assertLessEqual(cnc, 4)
                cnc1 = point[DataPoint.CUMULATIVE][''][KPISet.CONCURRENCY]
                self.assertLessEqual(cnc1, 4)

        self.assertEqual(4, all_items[-1][DataPoint.CURRENT][''][KPISet.CONCURRENCY])
    def test_load_reader_real2(self):
        reader1 = ApiritifLoadReader(self.obj.log)
        reader1.engine = EngineEmul()
        reader1.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif-0.csv")
        reader1.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif-1.csv")

        reader2 = ApiritifLoadReader(self.obj.log)
        reader2.engine = EngineEmul()
        reader2.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif--10.csv")
        reader2.register_file(RESOURCES_DIR + "jmeter/jtl/apiritif-results/apiritif--11.csv")

        reader = ConsolidatingAggregator()
        reader.engine = EngineEmul()
        reader.add_underling(reader1)
        reader.add_underling(reader2)

        items = list(reader.datapoints())
        self.assertEqual(39, len(items))
        self.assertEqual(4, items[-1][DataPoint.CURRENT][''][KPISet.CONCURRENCY])
    def test_load_reader(self):
        reader = ApiritifLoadReader(self.obj.log)

        # add empty reader
        with tempfile.NamedTemporaryFile() as f_name:
            reader.register_file(f_name.name)
            items = list(reader.datapoints(True))

        self.assertEqual(len(items), 0)
        self.assertFalse(reader.read_records)
        reader.register_file(RESOURCES_DIR + "jmeter/jtl/tranctl.jtl")
        items = list(reader.datapoints(True))
        self.assertEqual(len(items), 1)
        items = list(reader.datapoints(True))
        self.assertEqual(len(items), 0)
        reader.register_file(RESOURCES_DIR + "jmeter/jtl/tranctl.jtl")
        reader.register_file(RESOURCES_DIR + "jmeter/jtl/tranctl.jtl")
        items = list(reader.datapoints(True))
        self.assertTrue(reader.read_records)
        self.assertEqual(len(items), 1)