Skip to content

Commit

Permalink
Merge pull request #4191 from HollyGurza/T6801
Browse files Browse the repository at this point in the history
T6801: QoS: Policy rate-control is broken by default
  • Loading branch information
c-po authored Nov 15, 2024
2 parents ab47079 + e6558a5 commit 89a7e17
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions smoketest/scripts/cli/test_qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,27 @@ def test_20_round_robin_policy_default(self):
tmp[2]['options'],
)

def test_22_rate_control_default(self):
interface = self._interfaces[0]
policy_name = f'qos-policy-{interface}'
bandwidth = 5000

self.cli_set(base_path + ['interface', interface, 'egress', policy_name])
self.cli_set(base_path + ['policy', 'rate-control', policy_name])
with self.assertRaises(ConfigSessionError):
# Bandwidth not defined
self.cli_commit()

self.cli_set(base_path + ['policy', 'rate-control', policy_name, 'bandwidth', str(bandwidth)])
# commit changes
self.cli_commit()

tmp = get_tc_qdisc_json(interface)

self.assertEqual('tbf', tmp['kind'])
# TC store rates as a 32-bit unsigned integer in bps (Bytes per second)
self.assertEqual(int(bandwidth * 125), tmp['options']['rate'])


if __name__ == '__main__':
unittest.main(verbosity=2)
3 changes: 3 additions & 0 deletions src/conf_mode/qos.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def verify(qos):
if policy_type in ['priority_queue']:
if 'default' not in policy_config:
raise ConfigError(f'Policy {policy} misses "default" class!')
if policy_type in ['rate_control']:
if 'bandwidth' not in policy_config:
raise ConfigError('Bandwidth not defined')
if 'default' in policy_config:
if 'bandwidth' not in policy_config['default'] and policy_type not in ['priority_queue', 'round_robin', 'shaper_hfsc']:
raise ConfigError('Bandwidth not defined for default traffic!')
Expand Down

0 comments on commit 89a7e17

Please sign in to comment.