Skip to content
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

[LLDP]: Update init_db to load global database config #166

Merged
merged 5 commits into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sonic_ax_impl/mibs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def init_db():
Connects to DB
:return: db_conn
"""
SonicDBConfig.load_sonic_global_db_config()
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

load_sonic_global_db_config [](start = 18, length = 27)

Is it working for single ASIC use case? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this works for single asic as well.

# SyncD database connector. THIS MUST BE INITIALIZED ON A PER-THREAD BASIS.
# Redis PubSub objects (such as those within swsssdk) are NOT thread-safe.
db_conn = SonicV2Connector(**redis_kwargs)
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

redis_kwargs [](start = 33, length = 12)

Why remove existing feature? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously redis_kwargs had unix socket path, with the changes done in SonicV2Connector class, unix socket path should be read from database config file. Fixed this to use unix_socket_path from database config file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is still arguable and irrelevant to the LLDP test fix. Could you minimize the changes in this PR, and submit another PR if you really want to change this part?


In reply to: 503657219 [](ancestors = 503657219)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted back as suggested, only to provide fix for unit-test.

Expand Down
9 changes: 9 additions & 0 deletions tests/mock_tables/asic0/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@
"lldp_rem_port_id": "Ethernet2",
"lldp_rem_man_addr": "fe80::268a:7ff:fe3f:834c"
},
"LLDP_LOC_CHASSIS": {
"lldp_loc_chassis_id_subtype": "5",
"lldp_loc_chassis_id": "00:11:22:AB:CD:EF",
"lldp_loc_sys_name": "SONiC",
"lldp_loc_sys_desc": "Gotta go Fast!",
"lldp_loc_sys_cap_enabled": "28 00",
"lldp_loc_sys_cap_supported": "28 00",
"lldp_loc_man_addr": "10.224.25.36,fe80::ce37:abff:feec:de9c"
},
"PORT_TABLE:Ethernet0": {
"description": "snowflake",
"alias": "etp1",
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/asic1/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"lldp_loc_sys_desc": "Gotta go Fast!",
"lldp_loc_sys_cap_enabled": "28 00",
"lldp_loc_sys_cap_supported": "28 00",
"lldp_loc_man_addr": "10.224.25.26,fe80::ce37:abff:feec:de9c"
"lldp_loc_man_addr": "10.224.25.36,fe80::ce37:abff:feec:de9c"
},
"PORT_TABLE:Ethernet8": {
"description": "snowflake",
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/asic2/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"lldp_loc_sys_desc": "Gotta go Fast!",
"lldp_loc_sys_cap_enabled": "28 00",
"lldp_loc_sys_cap_supported": "28 00",
"lldp_loc_man_addr": "10.224.25.26,fe80::ce37:abff:feec:de9c"
"lldp_loc_man_addr": "10.224.25.36,fe80::ce37:abff:feec:de9c"
},
"PORT_TABLE:Ethernet-BP16": {
"description": "backplane",
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/dbconnector.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def connect_SonicV2Connector(self, db_name, retry_on=True):
# In case of multiple namespaces, namespace string passed to
# SonicV2Connector will specify the namespace or can be empty.
# Empty namespace represents global or host namespace.
if len(ns_list) > 1 and self.namespace == "":
if len(ns_list) > 1 and (self.namespace == "" or self.namespace == None):
self.dbintf.redis_kwargs['namespace'] = "global_db"
else:
self.dbintf.redis_kwargs['namespace'] = self.namespace
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/global_db/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"lldp_loc_sys_desc": "Gotta go Fast!",
"lldp_loc_sys_cap_enabled": "28 00",
"lldp_loc_sys_cap_supported": "28 00",
"lldp_loc_man_addr": "10.224.25.26,fe80::ce37:abff:feec:de9c"
"lldp_loc_man_addr": "10.224.25.36,fe80::ce37:abff:feec:de9c"
}
}
1 change: 1 addition & 0 deletions tests/namespace/test_lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def test_subtype_lldp_loc_man_addr_table(self):

response = get_pdu.make_response(self.lut)
value0 = response.values[0]
self.assertEqual(str(value0.name), str(ObjectIdentifier(13, 0, 1, 0, (1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, 3, 1, 4, 10, 224, 25, 36))))
self.assertEqual(value0.type_, ValueType.INTEGER)
self.assertEqual(value0.data, 5)

Expand Down
3 changes: 2 additions & 1 deletion tests/test_lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def test_subtype_lldp_loc_man_addr_table(self):

response = get_pdu.make_response(self.lut)
value0 = response.values[0]
self.assertEqual(str(value0.name), str(ObjectIdentifier(13, 0, 1, 0, (1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, 3, 1, 4, 10, 224, 25, 26))))
self.assertEqual(value0.type_, ValueType.INTEGER)
self.assertEqual(value0.data, 5)

Expand Down Expand Up @@ -224,4 +225,4 @@ def test_getnextpdu_lldpRemSysCapEnabled(self):
value0 = response.values[0]
self.assertEqual(value0.type_, ValueType.OCTET_STRING)
self.assertEqual(str(value0.name), str(ObjectIdentifier(12, 0, 1, 0, (1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, 12, 1, 1))))
self.assertEqual(str(value0.data), "\x28\x00")
self.assertEqual(str(value0.data), "\x28\x00")