Пример #1
0
    def test_shapesBandwidth(self):
        '''
        Tests that bandwidth shaping works.

        Examines the network speed before, during, and after shaping.

        Fails if the network speeds do not reflect expected results.
        '''
        with Vagrant.ssh('gateway', 'client', 'server') as machines:
            gateway, client, server = machines

            before = speedBetween(client, server, **IPERF_OPTS)

            print 'Actual speed before shaping:', before

            shapedSpeed = before / 1024

            print 'Desired shaping speed:', shapedSpeed

            shape(gateway, client, shapedSpeed)

            during = speedBetween(client, server, **IPERF_OPTS)

            print 'Actual speed during shaping:', during

            unshape(gateway, client)

            after = speedBetween(client, server, **IPERF_OPTS)

            print 'Actual speed after shaping:', after

            if before.slower(Megabit):
                self.fail(
                    'Actual speed before shaping is too slow for shape'
                    ' testing. (is it already being shaped?)')

            if during.faster(shapedSpeed):
                self.fail(
                    'Actual speed during shaping exceeded'
                    ' shaping speed.')

            if after.slower(shapedSpeed * 2):
                self.fail(
                    'Actual speed after shaping appears'
                    ' to still be shaped.')

            if after.slower(before * 0.7):
                self.fail(
                    'Actual speed after shaping did not return'
                    ' to normal value after shaping.')
Пример #2
0
    def test_shapesBandwidth(self):
        """
        Tests that bandwidth shaping works.

        Examines the network speed before, during, and after shaping.

        Fails if the network speeds do not reflect expected results.
        """
        with Vagrant.ssh("gateway", "client", "server") as machines:
            gateway, client, server = machines

            before = speedBetween(client, server, **IPERF_OPTS)

            print "Actual speed before shaping:", before

            shapedSpeed = before / 1024

            print "Desired shaping speed:", shapedSpeed

            shape(gateway, client, shapedSpeed)

            during = speedBetween(client, server, **IPERF_OPTS)

            print "Actual speed during shaping:", during

            unshape(gateway, client)

            after = speedBetween(client, server, **IPERF_OPTS)

            print "Actual speed after shaping:", after

            if before.slower(Megabit):
                self.fail("Actual speed before shaping is too slow for shape" " testing. (is it already being shaped?)")

            if during.faster(shapedSpeed):
                self.fail("Actual speed during shaping exceeded" " shaping speed.")

            if after.slower(shapedSpeed * 2):
                self.fail("Actual speed after shaping appears" " to still be shaped.")

            if after.slower(before * 0.7):
                self.fail("Actual speed after shaping did not return" " to normal value after shaping.")
Пример #3
0
def test_network(gateway, server, rate):
    shape(gateway, None, rate)
    print_results(rate, run_iperf(server))
def test_network(gateway, server, rate):
    shape(gateway, None, rate)
    print_results(rate, run_iperf(server))