Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[config] Add unit tests for 'config interface breakout' command (soni…
…c-net#1223) Consideration for sonic utilities breakout config tests: -- create a breakout config file, -- mock load_configMgmt() to return specially constructed configMgmtDPB instance. -- Device info get_ path*__file function should return default file so it should be mocked. -- config db must have breakout config table. -- mock get child ports to return interfaces, if needed. -- mock shut down interfaces, if needed. *Test Plan:* *>>> Test _get_ breakout options()* -- create a file breakout config. This can be a PY test fixture. -- mock device information part to return breakout file. -- pass argument incomplete as below and observe the results: a.) 1x1 b.) 4x c.) 2x d.) Wrong interface. *>> Test Verbose Args:* Pass verbose as args, and observe that loadConfigMgmt is called with verbose. *>> Test breakout_extra_table_warning Args:* Test breakout_extra_table_warning for breakout port. Add unknown_table to config with port which will be broken out Observe: Warning and ask User confirmation for the tables WithOut Yang models. *>>> Test Negative case: Test negative case of breakout port. Such as: Wrong Interface, wrong option and Wrong breakout Mode for DPB Command. *>>> Test below Config Breakout commands:* [Mock loadConfigMgmt and device info part for all below tests] [Load a fixed config in Data Tree, i.e. may not be same as configDB from mockTables] [Replace the configDB.json with test config if needed. Or correct configDB then use it. Also replace it at the end with original Config] [Note: we are testing only main.py part not config_mgmt.py] [Observe point for all below will be: a.) Click.echo part and b.) Update to BRK_CFG table in in-memory DB] # Ethernet8: start from 4x25G-->2x50G with -f -l sudo config interface breakout Ethernet8 2x50G -f -l # Ethernet8: move from 2x50G-->1x100G without force, list deps sudo config interface breakout Ethernet8 1x100G[40G] -f -l # Ethernet8: move from 2x50G-->1x100G with force, where deps exists sudo config interface breakout Ethernet8 1x100G[40G] -f # Ethernet8: move from 1x100G-->4x25G without force, no deps sudo config interface breakout Ethernet8 4x25G # Ethernet8: move from 4x25G-->1x100G with force, no deps sudo config interface breakout Ethernet8 1x100G -f # Ethernet8: move from 1x100G-->1x50G(2)+2x25G(2) with -f -l, sudo config interface breakout Ethernet8 1x50G(2)+2x25G(2) -f -l # Ethernet4: breakout from 4x25G to 2x50G with -f -l sudo config interface breakout Ethernet4 2x50G -f -l Signed-off-by: Praveen Chaudhary<pchaudhary@linkedin.com>
- Loading branch information