Skip to content

Commit

Permalink
Accept 0 for queue and dscp (#2162)
Browse files Browse the repository at this point in the history
Signed-off-by: bingwang <wang.bing@microsoft.com>
  • Loading branch information
bingwang-ms authored May 12, 2022
1 parent 288c2d8 commit fac1769
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2025,7 +2025,7 @@ def gather_session_info(session_info, policer, queue, src_port, direction):
if policer:
session_info['policer'] = policer

if queue:
if queue is not None:
session_info['queue'] = queue

if src_port:
Expand All @@ -2051,7 +2051,7 @@ def add_erspan(session_name, src_ip, dst_ip, dscp, ttl, gre_type, queue, policer
"ttl": ttl
}

if gre_type:
if gre_type is not None:
session_info['gre_type'] = gre_type

session_info = gather_session_info(session_info, policer, queue, src_port, direction)
Expand Down
19 changes: 17 additions & 2 deletions tests/config_mirror_session_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def test_mirror_session_add():

mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None)

result = runner.invoke(
config.config.commands["mirror_session"].commands["add"],
["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"])

mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None)


def test_mirror_session_erspan_add():
runner = CliRunner()
Expand Down Expand Up @@ -153,6 +159,12 @@ def test_mirror_session_erspan_add():

mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0x1234, 100, None, None, None)

result = runner.invoke(
config.config.commands["mirror_session"].commands["erspan"].commands["add"],
["test_session", "100.1.1.1", "2.2.2.2", "8", "63", "0", "0"])

mocked.assert_called_with("test_session", "100.1.1.1", "2.2.2.2", 8, 63, 0, 0, None, None, None)


def test_mirror_session_span_add():
runner = CliRunner()
Expand Down Expand Up @@ -246,9 +258,12 @@ def test_mirror_session_span_add():
result = runner.invoke(
config.config.commands["mirror_session"].commands["span"].commands["add"],
["test_session", "Ethernet8", "Ethernet4", "tx", "100"])

mocked.assert_called_with("test_session", "Ethernet8", "Ethernet4", "tx", 100, None)

result = runner.invoke(
config.config.commands["mirror_session"].commands["span"].commands["add"],
["test_session", "Ethernet0", "Ethernet4", "rx", "100"])
["test_session", "Ethernet0", "Ethernet4", "rx", "0"])

mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 100, None)
mocked.assert_called_with("test_session", "Ethernet0", "Ethernet4", "rx", 0, None)

0 comments on commit fac1769

Please sign in to comment.