def testIperfUDPStreamSamples(self):
        lost = 35148
        sent = 62949
        bandwidth = 5000
        internal_ip_used = True

        fake_vm = namedtuple('fake_vm', 'machine_type zone')

        sending_vm = fake_vm(machine_type='A', zone='B')
        receiving_vm = fake_vm(machine_type='A', zone='B')

        samples = iperf3.GetUDPStreamSamples(sending_vm, receiving_vm,
                                             iperf3_results, bandwidth,
                                             internal_ip_used)

        expected_metadata = {
            'protocol': 'UDP',
            'total_lost': lost,
            'total_sent': sent,
            'bandwidth': bandwidth,
            'receiving_machine_type': receiving_vm.machine_type,
            'receiving_zone': receiving_vm.zone,
            'sending_machine_type': sending_vm.machine_type,
            'sending_zone': sending_vm.zone,
            'internal_ip_used': internal_ip_used
        }

        expected_samples = [
            sample.Sample('Loss Rate', 55.836, 'Percent', expected_metadata),
            sample.Sample('Bandwidth Achieved', 1380, 'Mbits/sec',
                          expected_metadata),
            sample.Sample('Jitter', 0.072, 'ms', expected_metadata),
        ]

        self.assertSampleListsEqualUpToTimestamp(samples, expected_samples)
Exemple #2
0
    def testIperfUDPStreamSamples(self):
        lost = 35148
        sent = 62949
        bandwidth = 5000
        internal_ip_used = True

        samples = iperf3.GetUDPStreamSamples(iperf3_results, bandwidth,
                                             internal_ip_used)

        expected_metadata = {
            'total_lost': lost,
            'total_sent': sent,
            'bandwidth': bandwidth,
            'internal_ip_used': internal_ip_used
        }

        expected_samples = [
            sample.Sample('Loss Rate', 55.836, 'Percent', expected_metadata),
            sample.Sample('Bandwidth Achieved', 1380, 'Mbits/sec',
                          expected_metadata),
            sample.Sample('Jitter', 0.072, 'ms', expected_metadata),
        ]

        self.assertSampleListsEqualUpToTimestamp(samples, expected_samples)