Skip to content

Commit 22ca1a3

Browse files
committed
[LT] Not allow configuring link-training at RJ45 ports
* Skip RJ-45 interfaces * Add unit test case to resolve coverage error
1 parent 3fc3273 commit 22ca1a3

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

scripts/portconfig

+4
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,10 @@ class portconfig(object):
160160
if self.is_lag:
161161
raise Exception("Invalid port %s" % (port))
162162

163+
if self.is_rj45_port:
164+
print("Setting RJ45 ports' link-training is not supported")
165+
exit(1)
166+
163167
if self.verbose:
164168
print("Setting link-training %s on port %s" % (mode, port))
165169
lt_modes = ['on', 'off']

tests/config_lt_test.py

+5
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ def test_config_link_training(self, ctx):
3838
result = self.basic_check("link-training", ["PortChannel0001", "on"], ctx, operator.ne)
3939
assert 'Invalid port PortChannel0001' in result.output
4040

41+
result = self.basic_check("link-training", ["Ethernet16", "on"], ctx, operator.ne)
42+
assert "Setting RJ45 ports' link-training is not supported" in result.output
43+
result = self.basic_check("link-training", ["Ethernet16", "off"], ctx, operator.ne)
44+
assert "Setting RJ45 ports' link-training is not supported" in result.output
45+
4146
def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0):
4247
runner = CliRunner()
4348
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx)

0 commit comments

Comments
 (0)