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

Conversation

SuvarnaMeenakshi
Copy link
Contributor

[LLDP]: Update init_db to load global database config
before initializing SonicV2Connector class.
LLDPLocManAddrUpdater requires information from host database hence uses init_db() to initialize the host db.
For unit-testing multi-asic code path, there are mock db files provided for global_db and namespace specific dbs.
As init_db did not load global database config, unit-test mock db was not loading global_db database files for LLDPLocManAddrUpdater unit-testing. Fixed this by loading global database config in init_db function.

- What I did
As init_db did not load global database config, unit-test mock db was not loading global_db database files for LLDPLocManAddrUpdater unit-testing. Fixed this by loading global database config in init_db function.

- How I did it

  • Load global database config in init_db()
  • unit-test: Load mock db files from "global_db" director for multi-asic platform if namespace is empty or None.

- How to verify it
Run unit-test test_subtype_lldp_loc_man_addr_table and make sure that for multi-asic platform, mock_tables/global_db/appl_db.json file is loaded and mock_tables/appl_db.json file is loaded for single-asic platform unit-test.

- Description for the changelog

before initializing SonicV2Connector class.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
OID string.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
# 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.

@@ -181,9 +181,10 @@ 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.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
With the changes done in SonicV2Connector class, unix socket
path should be read from database config file and flag to use
unix socket path should be set to true.

Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
Signed-off-by: SuvarnaMeenakshi <sumeenak@microsoft.com>
@SuvarnaMeenakshi SuvarnaMeenakshi merged commit 764030a into sonic-net:master Oct 15, 2020
abdosi pushed a commit that referenced this pull request Dec 31, 2020
[LLDP]: Update init_db to load global database config
before initializing SonicV2Connector class.
LLDPLocManAddrUpdater requires information from host database hence uses init_db() to initialize the host db.
For unit-testing multi-asic code path, there are mock db files provided for global_db and namespace specific dbs.
As init_db did not load global database config, unit-test mock db was not loading global_db database files for LLDPLocManAddrUpdater unit-testing. Fixed this by loading global database config in init_db function. Fixed by:
Loading global database config in init_db()
unit-test: Loading mock db files from "global_db" director for multi-asic platform if namespace is empty or None.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants