def test_process_reply_tcp(self):
        executor = iperf.Iperf3Executor({}, AGENT)
        message = {
            'stdout':
            """
{
    "start": {},
    "intervals": [
        {
            "streams": [],
            "sum": {
                "start": 0,
                "end": 1.00002,
                "seconds": 1.00002,
                "bytes": 1712000,
                "bits_per_second": 1.36958e+07,
                "retransmits": 0
            }
        },
        {
            "streams": [],
            "sum": {
                "start": 1.00002,
                "end": 2.00001,
                "seconds": 0.999995,
                "bytes": 2043392,
                "bits_per_second": 1.63472e+07,
                "retransmits": 1
            }
        },
        {
            "streams": [],
            "sum": {
                "start": 2.00001,
                "end": 3.00002,
                "seconds": 1,
                "bytes": 2015872,
                "bits_per_second": 1.61269e+07,
                "retransmits": 0
            }
        }
    ],
    "end": {}
}"""
        }
        expected = {
            'samples': [
                [1.0, 13695800.0, 0],
                [2.0, 16347200.0, 1],
                [3.0, 16126900.0, 0],
            ],
            'meta': [['time', 's'], ['bandwidth', 'bit/s'],
                     ['retransmits', '']]
        }
        reply = executor.process_reply(message)
        self.assertEqual(expected['samples'],
                         reply['samples'],
                         message='Samples data')
        self.assertEqual(expected['meta'], reply['meta'], message='Metadata')
示例#2
0
    def test_process_reply_udp(self):
        executor = iperf.Iperf3Executor({'udp': True}, AGENT)
        message = {
            'stdout': """
{
    "start": {},
    "intervals": [
        {
            "streams": [],
            "sum": {
                "start": 0,
                "end": 1.00002,
                "seconds": 1.00002,
                "bytes": 1712000,
                "bits_per_second": 1.36958e+07,
                "packets": 53500
            }
        },
        {
            "streams": [],
            "sum": {
                "start": 1.00002,
                "end": 2.00001,
                "seconds": 0.999995,
                "bytes": 2043392,
                "bits_per_second": 1.63472e+07,
                "packets": 63856
            }
        },
        {
            "streams": [],
            "sum": {
                "start": 2.00001,
                "end": 3.00002,
                "seconds": 1,
                "bytes": 2015872,
                "bits_per_second": 1.61269e+07,
                "packets": 62996
            }
        }
    ],
    "end": {}
}"""
        }
        expected = {
            'samples': [
                [1.0, 53500],
                [2.0, 63856],
                [3.0, 62996],
            ],
            'meta': [
                ['time', 's'], ['packets', 'pps']
            ]
        }
        reply = executor.process_reply(message)
        self.assertEqual(expected['samples'], reply['samples'],
                         message='Samples data')
        self.assertEqual(expected['meta'], reply['meta'],
                         message='Metadata')
示例#3
0
    def test_get_command_reverse(self):
        executor = iperf.Iperf3Executor({'reverse': 'yes'}, AGENT)

        expected = {'data': ('iperf3 --client %s --format m '
                             '--time 60 --parallel 1 --interval 1 '
                             '--json --reverse') % IP,
                    'type': 'program'}
        self.assertEqual(expected, executor.get_command())
示例#4
0
    def test_get_command_udp_bandwidth_0(self):
        executor = iperf.Iperf3Executor({'udp': True, 'bandwidth': 0}, AGENT)

        expected = {'data': ('iperf3 --client %s --format m '
                             '--udp --bandwidth 0 --time 60 '
                             '--parallel 1 --interval 1 --json') % IP,
                    'type': 'program'}
        self.assertEqual(expected, executor.get_command())
示例#5
0
    def test_get_command_udp(self):
        executor = iperf.Iperf3Executor(
            {'udp': True, 'bandwidth': '100M', 'time': 30,
             'datagram_size': 1470}, AGENT)

        expected = {'data': ('iperf3 --client %s --format m '
                             '--udp --len 1470 --bandwidth 100M '
                             '--time 30 --parallel 1 --interval 1 '
                             '--json') % IP,
                    'type': 'program'}
        self.assertEqual(expected, executor.get_command())
示例#6
0
    def test_get_command(self):
        executor = iperf.Iperf3Executor({}, AGENT)

        expected = {
            'data': ('sudo nice -n -20 iperf3 --client %s --format m '
                     '--time 60 --parallel 1 --interval 1 '
                     '--json') % IP,
            'type':
            'program'
        }
        self.assertEqual(expected, executor.get_command())