Esempio n. 1
0
 def _wait_for_bw_rule_applied(self, vm, limit, burst, direction):
     port_name = linuxbridge_agent.LinuxBridgeManager.get_tap_device_name(
         vm.neutron_port['id'])
     tc = tc_lib.TcCommand(port_name,
                           linuxbridge_agent_config.DEFAULT_KERNEL_HZ_VALUE,
                           namespace=vm.host.host_namespace)
     if direction == constants.EGRESS_DIRECTION:
         utils.wait_until_true(lambda: tc.get_filters_bw_limits() ==
                               (limit, burst))
     elif direction == constants.INGRESS_DIRECTION:
         utils.wait_until_true(lambda: tc.get_tbf_bw_limits() ==
                               (limit, burst))
Esempio n. 2
0
 def setUp(self):
     super(TestTcCommand, self).setUp()
     self.tc = tc_lib.TcCommand(DEVICE_NAME, KERNEL_HZ_VALUE)
     self.mock_list_tc_qdiscs = mock.patch.object(tc_lib,
                                                  'list_tc_qdiscs').start()
     self.mock_add_tc_qdisc = mock.patch.object(tc_lib,
                                                'add_tc_qdisc').start()
     self.mock_delete_tc_qdisc = mock.patch.object(
         tc_lib, 'delete_tc_qdisc').start()
     self.mock_list_tc_filters = mock.patch.object(
         tc_lib, 'list_tc_filters').start()
     self.mock_add_tc_filter_policy = mock.patch.object(
         tc_lib, 'add_tc_filter_policy').start()
Esempio n. 3
0
 def setUp(self):
     super(TestTcCommand, self).setUp()
     self.tc = tc_lib.TcCommand(DEVICE_NAME, KERNEL_HZ_VALUE)
     self.bw_limit = "%s%s" % (BW_LIMIT, tc_lib.BW_LIMIT_UNIT)
     self.burst = "%s%s" % (BURST, tc_lib.BURST_UNIT)
     self.latency = "%s%s" % (LATENCY, tc_lib.LATENCY_UNIT)
     self.execute = mock.patch('neutron.agent.common.utils.execute').start()
     self.mock_list_tc_qdiscs = mock.patch.object(tc_lib,
                                                  'list_tc_qdiscs').start()
     self.mock_add_tc_qdisc = mock.patch.object(tc_lib,
                                                'add_tc_qdisc').start()
     self.mock_delete_tc_qdisc = mock.patch.object(
         tc_lib, 'delete_tc_qdisc').start()
Esempio n. 4
0
    def test_minimum_bandwidth(self):
        device_name = "tap_testmin"
        self.create_device(device_name)
        tc = tc_lib.TcCommand(device_name)

        tc.set_bw(None, None, BW_MIN, DIRECTION_EGRESS)
        _, _, bw_min = tc.get_limits(DIRECTION_EGRESS)
        self.assertEqual(BW_MIN, bw_min)

        new_bw_min = BW_MIN + 50

        tc.set_bw(None, None, new_bw_min, DIRECTION_EGRESS)
        _, _, bw_min = tc.get_limits(DIRECTION_EGRESS)
        self.assertEqual(new_bw_min, bw_min)

        tc.delete_bw(DIRECTION_EGRESS)
        _, _, bw_min = tc.get_limits(DIRECTION_EGRESS)
        self.assertIsNone(bw_min)
Esempio n. 5
0
    def test_tbf_bandwidth_limit(self):
        device_name = "%s_tbf" % BASE_DEV_NAME
        self.create_device(device_name)
        tc = tc_lib.TcCommand(device_name, TEST_HZ_VALUE)

        tc.set_tbf_bw_limit(BW_LIMIT, BURST, LATENCY)
        bw_limit, burst = tc.get_tbf_bw_limits()
        self.assertEqual(BW_LIMIT, bw_limit)
        self.assertEqual(BURST, burst)

        new_bw_limit = BW_LIMIT + 500
        new_burst = BURST + 50

        tc.set_tbf_bw_limit(new_bw_limit, new_burst, LATENCY)
        bw_limit, burst = tc.get_tbf_bw_limits()
        self.assertEqual(new_bw_limit, bw_limit)
        self.assertEqual(new_burst, burst)

        tc.delete_tbf_bw_limit()
        bw_limit, burst = tc.get_tbf_bw_limits()
        self.assertIsNone(bw_limit)
        self.assertIsNone(burst)
Esempio n. 6
0
    def test_bandwidth_limit(self):
        device_name = "tap_testmax"
        self.create_device(device_name)
        tc = tc_lib.TcCommand(device_name)

        tc.set_bw(BW_LIMIT, BURST, None, DIRECTION_EGRESS)
        bw_limit, burst, _ = tc.get_limits(DIRECTION_EGRESS)
        self.assertEqual(BW_LIMIT, bw_limit)
        self.assertEqual(BURST, burst)

        new_bw_limit = BW_LIMIT + 100
        new_burst = BURST + 50

        tc.set_bw(new_bw_limit, new_burst, None, DIRECTION_EGRESS)
        bw_limit, burst, _ = tc.get_limits(DIRECTION_EGRESS)
        self.assertEqual(new_bw_limit, bw_limit)
        self.assertEqual(new_burst, burst)

        tc.delete_bw(DIRECTION_EGRESS)
        bw_limit, burst, _ = tc.get_limits(DIRECTION_EGRESS)
        self.assertIsNone(bw_limit)
        self.assertIsNone(burst)
Esempio n. 7
0
 def _get_tc_wrapper(self, port):
     return tc_lib.TcCommand(
         port['device'],
         cfg.CONF.QOS.kernel_hz,
     )
Esempio n. 8
0
 def _wait_for_bw_rule_applied(self, vm, limit=None, burst=None, min=None):
     port_name = linuxbridge_agent.LinuxBridgeManager.get_tap_device_name(
         vm.neutron_port['id'])
     tc = tc_lib.TcCommand(port_name, namespace=vm.host.host_namespace)
     utils.wait_until_true(lambda: _check_bw_limits(tc, limit, burst, min))
Esempio n. 9
0
 def setUp(self):
     super(TestTcCommand, self).setUp()
     self.tc = tc_lib.TcCommand(self.DEVICE_NAME)
     self.execute = mock.patch('neutron.agent.common.utils.execute').start()
Esempio n. 10
0
 def setUp(self):
     super(TcLibTestCase, self).setUp()
     self.create_device()
     self.tc = tc_lib.TcCommand(DEV_NAME, TEST_HZ_VALUE)