forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CLI for configuring synchronous mode (sonic-net#1094)
* Add CLI for configuring synchronous mode * Integrate switch for sync mode as a config CLI * Add unit test
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from click.testing import CliRunner | ||
import config.main as config | ||
|
||
class TestSynchronousMode(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
|
||
def __check_result(self, result_msg, mode): | ||
if mode == "enable" or mode == "disable": | ||
expected_msg = """Wrote %s synchronous mode into CONFIG_DB, swss restart required to apply the configuration: \n | ||
Option 1. config save -y \n | ||
config reload -y \n | ||
Option 2. systemctl restart swss""" % mode | ||
else: | ||
expected_msg = "Error: Invalid argument %s, expect either enable or disable" % mode | ||
|
||
return expected_msg in result_msg | ||
|
||
|
||
def test_synchronous_mode(self): | ||
runner = CliRunner() | ||
|
||
result = runner.invoke(config.config.commands["synchronous_mode"], ["enable"]) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert self.__check_result(result.output, "enable") | ||
|
||
result = runner.invoke(config.config.commands["synchronous_mode"], ["disable"]) | ||
print(result.output) | ||
assert result.exit_code == 0 | ||
assert self.__check_result(result.output, "disable") | ||
|
||
result = runner.invoke(config.config.commands["synchronous_mode"], ["invalid-input"]) | ||
print(result.output) | ||
assert result.exit_code != 0 | ||
assert self.__check_result(result.output, "invalid-input") |