Allow setting QoS shaper values to 0

Change-Id: I751fcb61adf0a18a82c961a6fede4656b2643660
This commit is contained in:
Adit Sarfaty 2017-01-16 10:53:48 +02:00
parent fc6dcf073c
commit 1e760fe4f5
2 changed files with 23 additions and 9 deletions

View File

@ -108,14 +108,14 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
self._body(description=new_description))
def _enable_qos_switching_profile_shaping(
self, direction=nsx_constants.EGRESS):
self, direction=nsx_constants.EGRESS, new_burst_size=100):
"""Test updating a qos-switching profile
returns the correct response
"""
original_profile = self._body_with_shaping(direction=direction)
burst_size = 100
original_burst = 10
original_profile = self._body_with_shaping(direction=direction,
burst_size=original_burst)
peak_bandwidth = 200
average_bandwidth = 300
qos_marking = "untrusted"
@ -128,7 +128,7 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
self.nsxlib.qos_switching_profile.update_shaping(
test_constants.FAKE_QOS_PROFILE['id'],
shaping_enabled=True,
burst_size=burst_size,
burst_size=new_burst_size,
peak_bandwidth=peak_bandwidth,
average_bandwidth=average_bandwidth,
qos_marking=qos_marking,
@ -138,9 +138,11 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
actual_path = update.call_args[0][0]
expected_path = ('switching-profiles/%s' %
test_constants.FAKE_QOS_PROFILE['id'])
expected_burst = (new_burst_size if new_burst_size is not None
else original_burst)
expected_body = self._body_with_shaping(
shaping_enabled=True,
burst_size=burst_size,
burst_size=expected_burst,
peak_bandwidth=peak_bandwidth,
average_bandwidth=average_bandwidth,
qos_marking="untrusted", dscp=10,
@ -156,6 +158,18 @@ class NsxLibQosTestCase(nsxlib_testcase.NsxClientTestCase):
self._enable_qos_switching_profile_shaping(
direction=nsx_constants.INGRESS)
def test_update_qos_switching_profile_with_burst_size(self):
self._enable_qos_switching_profile_shaping(
direction=nsx_constants.EGRESS, new_burst_size=101)
def test_update_qos_switching_profile_without_burst_size(self):
self._enable_qos_switching_profile_shaping(
direction=nsx_constants.EGRESS, new_burst_size=None)
def test_update_qos_switching_profile_zero_burst_size(self):
self._enable_qos_switching_profile_shaping(
direction=nsx_constants.EGRESS, new_burst_size=0)
def _disable_qos_switching_profile_shaping(
self, direction=nsx_constants.EGRESS):
"""Test updating a qos-switching profile.

View File

@ -247,11 +247,11 @@ class NsxLibQosSwitchingProfile(utils.NsxLibApiBase):
for shaper in body["shaper_configuration"]:
if shaper["resource_type"] == resource_type:
shaper["enabled"] = True
if burst_size:
if burst_size is not None:
shaper["burst_size_bytes"] = burst_size
if peak_bandwidth:
if peak_bandwidth is not None:
shaper["peak_bandwidth_mbps"] = peak_bandwidth
if average_bandwidth:
if average_bandwidth is not None:
shaper["average_bandwidth_mbps"] = average_bandwidth
break