Exemplo n.º 1
0
    def get_statistics(self, context, view_name, output_type):

        stats_obj = IxlStatView(view_name, self.client_results_dir)
        stats_obj.read_stats()
        statistics = stats_obj.get_all_stats()
        if output_type.lower().strip() == 'json':
            statistics_str = json.dumps(statistics,
                                        indent=4,
                                        sort_keys=True,
                                        ensure_ascii=False)
            return json.loads(statistics_str)
        elif output_type.lower().strip() == 'csv':
            output = io.BytesIO()
            w = csv.DictWriter(output, ['Timestamp'] + stats_obj.captions)
            w.writeheader()
            for time_stamp in statistics:
                w.writerow(
                    OrderedDict({'Timestamp': time_stamp}.items() +
                                statistics[time_stamp].items()))
            attach_stats_csv(context, self.logger, view_name,
                             output.getvalue().strip())
            return output.getvalue().strip()
        else:
            raise Exception('Output type should be CSV/JSON - got "{}"'.format(
                output_type))
Exemplo n.º 2
0
 def testExistingStats(self):
     client_stats = IxlStatView('Test_Client')
     client_stats.read_stats()
     for time_stamp, values in client_stats.get_all_stats().items():
         print('{} : {}'.format(time_stamp, values))
     print(client_stats.get_time_stamp_stats(10))
     print(client_stats.get_stats('TCP Retries'))
     print(client_stats.get_counters('TCP Retries'))
Exemplo n.º 3
0
    def get_statistics(self, context, view_name, output_type):

        stats_obj = IxlStatView(view_name)
        stats_obj.read_stats()
        statistics = stats_obj.get_all_stats()
        if output_type.lower().strip() == 'json':
            statistics_str = json.dumps(statistics, indent=4, sort_keys=True, ensure_ascii=False)
            return json.loads(statistics_str)
        elif output_type.lower().strip() == 'csv':
            output = io.StringIO()
            w = csv.DictWriter(output, ['Timestamp'] + stats_obj.captions)
            w.writeheader()
            for time_stamp in statistics:
                line = OrderedDict({'Timestamp': time_stamp})
                line.update(statistics[time_stamp])
                w.writerow(line)
            attach_stats_csv(context, self.logger, view_name, output.getvalue().strip())
            return output.getvalue().strip()
        else:
            raise TgnError(f'Output type should be CSV/JSON - got "{output_type}"')
Exemplo n.º 4
0
 def testRunStats(self):
     self._reserve_ports(
         path.join(path.dirname(__file__), 'configs/test_config.rxf'))
     self.ixl.controller.set_results_dir('C:/temp/IxLoad')
     self.ixl.start_test(blocking=True)
     client_stats = IxlStatView('Test_Client')
     client_stats.read_stats()
     print(client_stats.get_all_stats())
     assert (client_stats.get_stat(16, 'TCP SYN Sent/s') > 0)
Exemplo n.º 5
0
def test_run_stats(ixload: IxlApp, originate: str, terminate: str):
    """ Test run and statistics. """
    logger.info(test_run_stats.__doc__)

    load_config(ixload, 'test_config.rxf')
    reserve_ports(ixload, originate, terminate)
    if not ixload.is_remote:
        ixload.controller.set_results_dir('c:/temp/TestIxlOnline')
    ixload.start_test(blocking=True)
    if supports_download(ixload):
        client_stats = IxlStatView('Test_Client')
        client_stats.read_stats()
        print(client_stats.get_all_stats())
        assert (client_stats.get_counter(16, 'TCP SYN Sent/s') > 0)