-
Notifications
You must be signed in to change notification settings - Fork 672
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* [show] vnet endpoint [ip/ipv6] command
- Loading branch information
1 parent
84a0712
commit 94a3436
Showing
6 changed files
with
233 additions
and
15 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
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,74 @@ | ||
import os | ||
import sys | ||
import traceback | ||
import mock_tables.dbconnector | ||
from click.testing import CliRunner | ||
from unittest import mock | ||
from utilities_common.db import Db | ||
import show.main as show | ||
|
||
#test_path = os.path.dirname(os.path.abspath(__file__)) | ||
|
||
|
||
|
||
class TestShowVnet(object): | ||
@classmethod | ||
def setup_class(cls): | ||
print("SETUP") | ||
os.environ["UTILITIES_UNIT_TESTING"] = "1" | ||
|
||
def test_show_vnet_routes_all_basic(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['routes'].commands['all'], [], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
vnet name prefix nexthop interface | ||
----------- -------- --------- ----------- | ||
vnet name prefix endpoint mac address vni status | ||
--------------- ------------------------ ------------------------------------------- ------------- ----- -------- | ||
Vnet_v6_in_v6-0 fddd:a156:a251::a6:1/128 fddd:a100:a251::a10:1,fddd:a101:a251::a10:1 active | ||
test_v4_in_v4-0 160.162.191.1/32 100.251.7.1 active | ||
test_v4_in_v4-0 160.163.191.1/32 100.251.7.1 active | ||
test_v4_in_v4-0 160.164.191.1/32 100.251.7.1 | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], [], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix count status | ||
--------------------- --------------------- -------------- -------- | ||
fddd:a100:a251::a10:1 fddd:a100:a251::a10:1 1 Unknown | ||
fddd:a101:a251::a10:1 fddd:a101:a251::a10:1 1 Down | ||
100.251.7.1 100.251.7.1 3 Up | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint_ipv4(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['100.251.7.1'], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix status | ||
----------- ------------------ ------------------------------------------------------------ -------- | ||
100.251.7.1 ['100.251.7.1'] ['160.162.191.1/32', '160.163.191.1/32', '160.164.191.1/32'] Up | ||
""" | ||
assert result.output == expected_output | ||
|
||
def test_show_vnet_endpoint_ipv6(self): | ||
runner = CliRunner() | ||
db = Db() | ||
result = runner.invoke(show.cli.commands['vnet'].commands['endpoint'], ['fddd:a101:a251::a10:1'], obj=db) | ||
assert result.exit_code == 0 | ||
expected_output = """\ | ||
Endpoint Endpoint Monitor prefix status | ||
--------------------- ------------------------- ---------------------------- -------- | ||
fddd:a101:a251::a10:1 ['fddd:a101:a251::a10:1'] ['fddd:a156:a251::a6:1/128'] Down | ||
""" | ||
assert result.output == expected_output |