Skip to content

Commit

Permalink
add data for telemtery enhancement for 'active-active' cable type (so…
Browse files Browse the repository at this point in the history
…nic-net#332)

Signed-off-by: vaibhav-dahiya vdahiya@microsoft.com
This PR adds logic to add the following gRPC relevant telemetry schema fields in the state DB table
MUX_CABLE_INFO

1) "self_link_state"
2) "up"
3) "peer_link_state"
4) "up"
5) "self_oper_state"
6) "up"
7) "peer_oper_state"
8) "up"
9) "server_version"
10) "1.0"
11) "grpc_connection_status"
12) "READY"
13) "self_mux_direction"
14) "active"
15) "peer_mux_direction"
16) "active"
17) "peer_mux_direction_probe_count"
18) "23"
19) "mux_direction_probe_count"
20) "23"
21) "link_state_probe_count"
22) "1"
23) "peer_link_state_probe_count"
24) "1"
25) "operation_state_probe_count"
26) "1"
27) "peer_operation_state_probe_count"
28)"1"
This data will allow telemetry to check gRPC stats and version of the server and be able to raise alert if needed appropriatley.

Description
gPRC data for telemetry
appropriate logic is added for handling the gRPC stats and RPC's are called and counted as appropriate

Motivation and Context
How Has This Been Tested?
UT and putting the changes on the testbed
  • Loading branch information
vdahiya12 committed Jan 21, 2023
1 parent a931d6c commit 906d198
Show file tree
Hide file tree
Showing 2 changed files with 402 additions and 18 deletions.
215 changes: 203 additions & 12 deletions sonic-ycabled/tests/test_y_cable_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5529,8 +5529,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(False, None, 0)
rc = parse_grpc_response_forwarding_state(False, None, 0, port)
assert(rc == ("unknown", "unknown"))


Expand All @@ -5543,8 +5544,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 0)
rc = parse_grpc_response_forwarding_state(True, response, 0, port)
assert(rc == ("active", "standby"))


Expand All @@ -5557,8 +5559,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 0)
rc = parse_grpc_response_forwarding_state(True, response, 0, port)
assert(rc == ("active", "active"))


Expand All @@ -5571,8 +5574,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("standby", "active"))


Expand All @@ -5585,8 +5589,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("active", "active"))


Expand All @@ -5599,8 +5604,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("active", "active"))


Expand All @@ -5613,8 +5619,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("standby", "active"))


Expand All @@ -5627,8 +5634,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 0)
rc = parse_grpc_response_forwarding_state(True, response, 0, port)
assert(rc == ("standby", "active"))


Expand All @@ -5641,8 +5649,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("standby", "standby"))


Expand All @@ -5655,8 +5664,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 0)
rc = parse_grpc_response_forwarding_state(True, response, 0, port)
assert(rc == ("standby", "standby"))


Expand All @@ -5669,8 +5679,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 0)
rc = parse_grpc_response_forwarding_state(True, response, 0, port)
assert(rc == ("active", "active"))


Expand All @@ -5683,8 +5694,9 @@ def __init__(self):


response = Response_Helper()
port = "Ethernet4"

rc = parse_grpc_response_forwarding_state(True, response, 1)
rc = parse_grpc_response_forwarding_state(True, response, 1, port)
assert(rc == ("standby", "standby"))


Expand Down Expand Up @@ -5820,3 +5832,182 @@ def test_handle_ycable_active_standby_probe_notification(self):
rc = handle_ycable_active_standby_probe_notification("active-standby", fvp_dict, test_db, hw_mux_cable_tbl, port_m, asic_index, y_cable_response_tbl)
assert(rc == True)


def test_parse_grpc_response_link_and_oper_state_down_down(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [False,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 1, "oper_state", "Ethernet4")
assert(rc == ("down", "down"))

def test_parse_grpc_response_link_and_oper_state_up_down(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 1, "oper_state", "Ethernet4")
assert(rc == ("down", "up"))

def test_parse_grpc_response_link_and_oper_state_up_up(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True, True]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 1, "oper_state", "Ethernet4")
assert(rc == ("up", "up"))

def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [False,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "oper_state", "Ethernet4")
assert(rc == ("down", "down"))

def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "oper_state", "Ethernet4")
assert(rc == ("up", "down"))

def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True, True]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "oper_state", "Ethernet4")
assert(rc == ("up", "up"))

def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_unknown(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [False,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(False, response, 0, "oper_state", "Ethernet4")
assert(rc == ("unknown", "unknown"))

def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero(self):

class Response_Helper():
def __init__(self):
self.portid = [0]
self.state = [False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "oper_state", "Ethernet4")
assert(rc == ("unknown", "unknown"))

def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "link_state", "Ethernet4")
assert(rc == ("unknown", "unknown"))

def test_parse_grpc_response_link_and_oper_state_down_down_read_side_zero_link_state(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [False,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "link_state", "Ethernet4")
assert(rc == ("down", "down"))

def test_parse_grpc_response_link_and_oper_state_up_down_read_side_zero_link_state(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True,False]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "link_state", "Ethernet4")
assert(rc == ("up", "down"))

def test_parse_grpc_response_link_and_oper_state_up_up_read_side_zero_link_state(self):

class Response_Helper():
def __init__(self):
self.portid = [0,1]
self.state = [True, True]


response = Response_Helper()

rc = parse_grpc_response_link_and_oper_state(True, response, 0, "link_state", "Ethernet4")
assert(rc == ("up", "up"))

def test_get_muxcable_info_for_active_active(self):
physical_port = 20

logical_port_name = "Ethernet20"
swsscommon.Table.return_value.get.return_value = (
True, {"read_side": "1"})
asic_index = 0
y_cable_tbl = {}
mux_tbl = {}
test_db = "TEST_DB"
status = True
fvs = [('state', "auto"), ('read_side', 1)]
y_cable_tbl[asic_index] = swsscommon.Table(
test_db[asic_index], "Y_CABLE_TABLE")
y_cable_tbl[asic_index].get.return_value = (status, fvs)

rc = get_muxcable_info_for_active_active(physical_port, logical_port_name, mux_tbl, asic_index, y_cable_tbl)

assert(rc['self_mux_direction'] == 'unknown')
assert(rc['peer_mux_direction'] == 'unknown')
assert(rc['mux_direction_probe_count'] == 'unknown')
assert(rc['peer_mux_direction_probe_count'] == 'unknown')
Loading

0 comments on commit 906d198

Please sign in to comment.