-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sonic-utils: initial support for link-training #2071
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca3db28
sonic-utils: initial support for link-training
ds952811 393c7c9
address the test failures
ds952811 4643e75
address the test failures in intfutil_test.py
ds952811 5903101
drop LINK_TRAINING and typo fix
ds952811 6665a62
error out when invalid LT mode is specified
ds952811 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import click | ||
import config.main as config | ||
import operator | ||
import os | ||
import pytest | ||
import sys | ||
|
||
from click.testing import CliRunner | ||
from utilities_common.db import Db | ||
|
||
test_path = os.path.dirname(os.path.abspath(__file__)) | ||
modules_path = os.path.dirname(test_path) | ||
scripts_path = os.path.join(modules_path, "scripts") | ||
sys.path.insert(0, modules_path) | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def ctx(scope='module'): | ||
db = Db() | ||
obj = {'config_db':db.cfgdb, 'namespace': ''} | ||
yield obj | ||
|
||
|
||
class TestConfigInterface(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["PATH"] += os.pathsep + scripts_path | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_config_link_training(self, ctx): | ||
self.basic_check("link-training", ["Ethernet0", "on"], ctx) | ||
self.basic_check("link-training", ["Ethernet0", "off"], ctx) | ||
self.basic_check("link-training", ["Invalid", "on"], ctx, operator.ne) | ||
self.basic_check("link-training", ["Invalid", "off"], ctx, operator.ne) | ||
self.basic_check("link-training", ["Ethernet0", "invalid"], ctx, operator.ne) | ||
|
||
def basic_check(self, command_name, para_list, ctx, op=operator.eq, expect_result=0): | ||
runner = CliRunner() | ||
result = runner.invoke(config.config.commands["interface"].commands[command_name], para_list, obj = ctx) | ||
print(result.output) | ||
assert op(result.exit_code, expect_result) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to choose
show interfaces
vsshow interface
? #ClosedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea, this is a legacy command, and my best guess is that it supports both signle interface and multi-interface at the same time, hence the original author adopted 'show interfaces' instead of 'show interface'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you fix the PR description? I see many wrong subcommand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm not following you, is this about 'interfaces' v.s. 'interface' in show and config command?
If that's the case, this is a legacy command format since day 1, while the link-training is actually a plug-in to these legacy CLICK based CLI commands, hence it's not expected to change the upper level command syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. I see the difference between
show
andconfig
.