def test_tpid_config_port_interface(self): db = Db() obj = {'config_db': db.cfgdb, 'namespace': ''} runner = CliRunner() result = runner.invoke( config.config.commands["interface"].commands["tpid"], ["Ethernet0", "0x9200"], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0 result = runner.invoke( config.config.commands["interface"].commands["tpid"], ["Ethernet0", "0x9100"], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0 result = runner.invoke( config.config.commands["interface"].commands["tpid"], ["Ethernet0", "0x88a8"], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0 result = runner.invoke( config.config.commands["interface"].commands["tpid"], ["Ethernet0", "0x8100"], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0 result = runner.invoke( config.config.commands["interface"].commands["tpid"], ["Ethernet0", "0x2000"], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 1 assert result.output == bad_tpid_configured
def test_config_device_metadata(self): dbconnector.dedicated_dbs['CONFIG_DB'] = mock_db_path db = Db() runner = CliRunner() result = runner.invoke(config_main.config.commands['device-metadata']. commands['localhost'].commands['buffer-model'], ['dynamic'], obj=db) result = runner.invoke( show_main.cli.commands['device-metadata'].commands['localhost'], [], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS assert result.output == show_cmd_output.show_device_metadata_localhost_changed_buffer_model
def test_config_2_untagged_vlan_on_same_interface(self): runner = CliRunner() db = Db() # add Ethernet4 to vlan 2000 as untagged - should fail as ethrnet4 is already untagged member in 1000 result = runner.invoke( config.config.commands["vlan"].commands["member"].commands["add"], ["2000", "Ethernet4", "--untagged"], obj=db) print(result.exit_code) assert result.exit_code != 0 # add Ethernet4 to vlan 2000 as tagged - should succeed result = runner.invoke( config.config.commands["vlan"].commands["member"].commands["add"], ["2000", "Ethernet4"], obj=db) print(result.exit_code) assert result.exit_code == 0
def test_config_pbh_hash_add_invalid_hash_field_list( self, hash_name, hash_field_list, exit_code ): dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join(mock_db_path, 'hash_fields') db = Db() runner = CliRunner() result = runner.invoke( config.config.commands["pbh"].commands["hash"]. commands["add"], [hash_name, "--hash-field-list", hash_field_list], obj=db ) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == exit_code
def test_add_invalid_mclag_domain(self): runner = CliRunner() db = Db() obj = {'db': db.cfgdb} # add invalid mclag domain result = runner.invoke( config.config.commands["mclag"].commands["add"], [0, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format( type(result.exit_code), result.exit_code, result.output) # add invalid mclag domain result = runner.invoke( config.config.commands["mclag"].commands["add"], [5000, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid domain test case with code {}:{} Output:{}".format( type(result.exit_code), result.exit_code, result.output)
def test_show_pbh_statistics(self): dbconnector.dedicated_dbs['COUNTERS_DB'] = os.path.join( mock_db_path, 'counters_db') dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join( mock_db_path, 'full_pbh_config') self.remove_pbh_counters_file() db = Db() runner = CliRunner() result = runner.invoke(show.cli.commands["pbh"].commands["statistics"], [], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS assert result.output == assert_show_output.show_pbh_statistics
def test_console_port_info_connect_success(self): db = Db() port = ConsolePortInfo(db, { "LINE": "1", "baud_rate": "9600", "CUR_STATE": { "state": "idle" } }) port.refresh = mock.MagicMock(return_value=None) mock_proc = mock.MagicMock(spec=subprocess.Popen, pid="223") mock_proc.send = mock.MagicMock(return_value=None) mock_proc.expect = mock.MagicMock(return_value=0) with mock.patch('pexpect.spawn', mock.MagicMock(return_value=mock_proc)): session = port.connect() assert session.proc.pid == "223" assert session.port.line_num == "1"
def test_config_pbh_hash_field_add_mismatch_hash_field_ip_mask( self, hash_field_name, hash_field, ip_mask, ): db = Db() runner = CliRunner() result = runner.invoke(config.config.commands["pbh"]. commands["hash-field"].commands["add"], [ hash_field_name, "--hash-field", hash_field, "--ip-mask", ip_mask, "--sequence-id", "1" ], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == ERROR2
def test_config_device_neighbor_update(self, parameter, value, output): dbconnector.dedicated_dbs['CONFIG_DB'] = mock_db_path db = Db() runner = CliRunner() result = runner.invoke( config_main.config.commands['device-neighbor'].commands['update'], ['Ethernet0', parameter, value], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) result = runner.invoke(show_main.cli.commands['device-neighbor'], [], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS assert result.output == output
def test_config_snmp_contact_add_del_new_contact(self): db = Db() runner = CliRunner() with mock.patch('utilities_common.cli.run_command') as mock_run_command: result = runner.invoke(config.config.commands["snmp"].commands["contact"].commands["add"], ["testuser", "*****@*****.**"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert result.output == config_snmp_contact_add_del_new_contact assert db.cfgdb.get_entry("SNMP", "CONTACT") == {"testuser": "******"} result = runner.invoke(config.config.commands["snmp"].commands["contact"].commands["del"], ["testuser"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert 'SNMP contact testuser removed from configuration' in result.output assert db.cfgdb.get_entry("SNMP", "CONTACT") == {}
def test_config_sflow_collector(self): db = Db() runner = CliRunner() obj = {'db': db.cfgdb} # del a collector result = runner.invoke(config.config.commands["sflow"]. commands["collector"].commands["del"], ["prod"], obj=obj) print(result.exit_code, result.output) assert result.exit_code == 0 # change the output global show_sflow_output show_sflow_output_local = show_sflow_output.replace( "2 Collectors configured:\n\ Name: prod IP addr: fe80::6e82:6aff:fe1e:cd8e UDP port: 6343 VRF: mgmt\n\ Name: ser5 IP addr: 172.21.35.15 UDP port: 6343 VRF: default", "1 Collectors configured:\n\ Name: ser5 IP addr: 172.21.35.15 UDP port: 6343 VRF: default" ) # run show and check result = runner.invoke(show.cli.commands["sflow"], [], obj=db) print(result.exit_code, result.output, show_sflow_output_local) assert result.exit_code == 0 assert result.output == show_sflow_output_local # add collector result = runner.invoke( config.config.commands["sflow"].commands["collector"]. commands["add"], ["prod", "fe80::6e82:6aff:fe1e:cd8e", "--vrf", "mgmt"], obj=obj) assert result.exit_code == 0 # run show and check result = runner.invoke(show.cli.commands["sflow"], [], obj=db) print(result.exit_code, result.output) assert result.exit_code == 0 assert result.output == show_sflow_output return
def test_config_vlan_del_vlan(self): runner = CliRunner() db = Db() obj = {'config_db': db.cfgdb} # del vlan with IP result = runner.invoke(config.config.commands["vlan"].commands["del"], ["1000"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code != 0 assert "Error: Vlan1000 can not be removed. First remove IP addresses assigned to this VLAN" in result.output # remove vlan IP`s result = runner.invoke(config.config.commands["interface"]. commands["ip"].commands["remove"], ["Vlan1000", "192.168.0.1/21"], obj=obj) print(result.exit_code, result.output) assert result.exit_code != 0 result = runner.invoke(config.config.commands["interface"]. commands["ip"].commands["remove"], ["Vlan1000", "fc02:1000::1/64"], obj=obj) print(result.exit_code, result.output) assert result.exit_code != 0 result = runner.invoke(config.config.commands["vlan"].commands["del"], ["1000"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 # show output result = runner.invoke(show.cli.commands["vlan"].commands["brief"], [], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert result.output == show_vlan_brief_empty_output
def test_core_dump_cleanup(self): """ Scenario: CFG_STATE is enabled. core-dump limit is crossed Verify Whether is cleanup is performed """ db_wrap = Db() redis_mock = db_wrap.db set_auto_ts_cfg(redis_mock, state="enabled", max_core_size="6.0") with Patcher() as patcher: patcher.fs.set_disk_usage(1000, path="/var/core/") patcher.fs.create_file("/var/core/orchagent.12345.123.core.gz", st_size=25) patcher.fs.create_file("/var/core/lldpmgrd.12345.22.core.gz", st_size=25) patcher.fs.create_file("/var/core/python3.12345.21.core.gz", st_size=25) cdump_mod.handle_coredump_cleanup("python3.12345.21.core.gz", redis_mock) current_fs = os.listdir(cdump_mod.CORE_DUMP_DIR) assert len(current_fs) == 2 assert "orchagent.12345.123.core.gz" not in current_fs assert "lldpmgrd.12345.22.core.gz" in current_fs assert "python3.12345.21.core.gz" in current_fs
def test_config_syslog_basic(self, server_ip): db = Db() runner = CliRunner() result = runner.invoke( config.config.commands["syslog"].commands["add"], [server_ip], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS result = runner.invoke( config.config.commands["syslog"].commands["del"], [server_ip], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS
def test_config_pbh_rule_add_invalid_flow_counter(self): dbconnector.dedicated_dbs['CONFIG_DB'] = os.path.join( mock_db_path, 'rule') db = Db() runner = CliRunner() result = runner.invoke( config.config.commands["pbh"].commands["rule"].commands["add"], [ "pbh_table1", "vxlan", "--priority", "2", "--ip-protocol", "0x11", "--inner-ether-type", "0x0800", "--l4-dst-port", "0x12b5", "--hash", "inner_v6_hash", "--packet-action", "SET_ECMP_HASH", "--flow-counter", INVALID_VALUE ], obj=db) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == ERROR2
def test_add_mclag_with_invalid_src_mcast_ip(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} # add mclag with invalid src result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_INVALID_SRC_IP2, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, RESERVED_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) assert "" in result.output result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, INVALID_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, NOT_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "mclag invalid src ip test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output)
def test_config_add_del_vlan_and_vlan_member(self): runner = CliRunner() db = Db() # add vlan 1001 result = runner.invoke(config.config.commands["vlan"].commands["add"], ["1001"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 # add Ethernet20 to vlan 1001 result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["add"], ["1001", "Ethernet20", "--untagged"], obj=db) print(result.exit_code) print(result.output) traceback.print_tb(result.exc_info[2]) assert result.exit_code == 0 # show output result = runner.invoke(show.cli.commands["vlan"].commands["brief"], [], obj=db) print(result.output) assert result.output == config_add_del_vlan_and_vlan_member_output # remove vlan member result = runner.invoke(config.config.commands["vlan"].commands["member"].commands["del"], ["1001", "Ethernet20"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 # add del 1001 result = runner.invoke(config.config.commands["vlan"].commands["del"], ["1001"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 # show output result = runner.invoke(show.cli.commands["vlan"].commands["brief"], [], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert result.output == show_vlan_brief_output
def test_config_sflow_agent_id(self): db = Db() runner = CliRunner() obj = {'db': db.cfgdb} # mock netifaces.interface config.netifaces.interfaces = mock.MagicMock(return_value="Ethernet0") # set agent-id result = runner.invoke(config.config.commands["sflow"]. commands["agent-id"].commands["add"], ["Ethernet0"], obj=obj) print(result.exit_code, result.output) assert result.exit_code == 0 # change the output global show_sflow_output show_sflow_output_local = show_sflow_output.replace( 'sFlow AgentID: default', 'sFlow AgentID: Ethernet0') # run show and check result = runner.invoke(show.cli.commands["sflow"], [], obj=db) print(result.exit_code, result.output, show_sflow_output_local) assert result.exit_code == 0 assert result.output == show_sflow_output_local #del agent id result = runner.invoke(config.config.commands["sflow"]. commands["agent-id"].commands["del"], [], obj=obj) print(result.exit_code, result.output) assert result.exit_code == 0 # run show and check result = runner.invoke(show.cli.commands["sflow"], [], obj=db) print(result.exit_code, result.output) assert result.exit_code == 0 assert result.output == show_sflow_output return
def test_kube_server(self, get_cmd_module): (config, show) = get_cmd_module db = Db() runner = CliRunner() # Check server not configured result = runner.invoke( show.cli.commands["kubernetes"].commands["server"]) self.__check_res(result, "empty server test", show_server_output_0) # Add IP & test show result = runner.invoke( config.config.commands["kubernetes"].commands["server"], ["ip", "10.10.10.11"], obj=db) self.__check_res(result, "set server IP", "") result = runner.invoke( show.cli.commands["kubernetes"].commands["server"]) self.__check_res(result, "check server IP", show_server_output_1) # set insecure as True & test show result = runner.invoke( config.config.commands["kubernetes"].commands["server"], ["insecure", "on"], obj=db) self.__check_res(result, "set server insecure", "") result = runner.invoke( show.cli.commands["kubernetes"].commands["server"]) self.__check_res(result, "check server IP", show_server_output_2) # set disable as True & test show result = runner.invoke( config.config.commands["kubernetes"].commands["server"], ["disable", "on"], obj=db) self.__check_res(result, "set server disable", "") result = runner.invoke( show.cli.commands["kubernetes"].commands["server"]) self.__check_res(result, "check server IP", show_server_output_3)
def test_no_kube_server(self, get_cmd_module): (config, show) = get_cmd_module runner = CliRunner() db = Db() db.cfgdb.delete_table("KUBERNETES_MASTER") # Check server not configured result = runner.invoke(show.cli.commands["kubernetes"]. commands["server"].commands["config"], [], obj=db) self.__check_res(result, "null server config test", show_no_server_output) # Add IP when not configured result = runner.invoke( config.config.commands["kubernetes"].commands["server"], ["ip", "10.10.10.11"], obj=db) self.__check_res(result, "set server IP when none", "")
def test_load_minigraph_with_port_config(self, get_cmd_module, setup_single_broadcom_asic): with mock.patch( "utilities_common.cli.run_command", mock.MagicMock(side_effect=mock_run_command_side_effect) ) as mock_run_command: (config, show) = get_cmd_module db = Db() # From up to down db.cfgdb.set_entry("PORT", "Ethernet0", {"admin_status": "up"}) port_config = [{"PORT": {"Ethernet0": {"admin_status": "down"}}}] self.check_port_config(db, config, port_config, "config interface shutdown Ethernet0") # From down to up db.cfgdb.set_entry("PORT", "Ethernet0", {"admin_status": "down"}) port_config = [{"PORT": {"Ethernet0": {"admin_status": "up"}}}] self.check_port_config(db, config, port_config, "config interface startup Ethernet0")
def test_config_loopback_action_on_physical_interface_alias(self): runner = CliRunner() db = Db() obj = {'config_db': db.cfgdb} action = 'forward' iface = 'Ethernet0' iface_alias = 'etp1' os.environ['SONIC_CLI_IFACE_MODE'] = "alias" result = runner.invoke(config.config.commands['interface']. commands["ip"].commands['loopback-action'], [iface_alias, action], obj=obj) os.environ['SONIC_CLI_IFACE_MODE'] = "default" table = db.cfgdb.get_table('INTERFACE') assert (table[iface]['loopback_action'] == action) print(result.exit_code, result.output) assert result.exit_code == 0
def test_config_snmp_feature_owner(self, get_cmd_module): (config, show) = get_cmd_module db = Db() runner = CliRunner() result = runner.invoke(config.config.commands["feature"].commands["owner"], ["snmp", "local"], obj=db) print(result.exit_code) print(result.output) result = runner.invoke(config.config.commands["feature"].commands["fallback"], ["snmp", "on"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 result = runner.invoke(show.cli.commands["feature"].commands["config"], ["foo"], obj=db) print(result.exit_code) assert result.exit_code == 1 result = runner.invoke(show.cli.commands["feature"].commands["config"], ["snmp"], obj=db) print(result.output) assert result.exit_code == 0 assert result.output == show_feature_snmp_config_owner_output
def test_add_mclag_with_invalid_peer_link(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} # add mclag with invalid peer link result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK1], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK2], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK3], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK4], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_INVALID_PEER_LINK5], obj=obj) assert result.exit_code != 0, "mclag invalid peer link test caase with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output)
def test_pfcwd_pfc_not_enabled(self, mock_os): import pfcwd.main as pfcwd runner = CliRunner() db = Db() # get initial config result = runner.invoke(pfcwd.cli.commands["show"].commands["config"], obj=db) print(result.output) assert result.output == pfcwd_show_config_output mock_os.geteuid.return_value = 0 result = runner.invoke(pfcwd.cli.commands["start"], [ "--action", "drop", "--restoration-time", "601", "Ethernet8", "602" ], obj=db) print(result.output) assert result.exit_code == 0 assert pfc_is_not_enabled == result.output
def test_config_buffer_profile_headroom(self): runner = CliRunner() db = Db() result = runner.invoke(config.config.commands["buffer"]. commands["profile"].commands["add"], [ "testprofile", "--dynamic_th", "3", "--xon", "18432", "--xoff", "32768" ], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 profile = db.cfgdb.get_entry('BUFFER_PROFILE', 'testprofile') assert profile == { 'dynamic_th': '3', 'pool': '[BUFFER_POOL|ingress_lossless_pool]', 'xon': '18432', 'xoff': '32768', 'size': '51200' }
def test_mclag_session_timeout(self): runner = CliRunner() db = Db() obj = {'db':db.cfgdb} # add valid mclag domain result = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) # configure valid session timeout result = runner.invoke(config.config.commands["mclag"].commands["session-timeout"], [MCLAG_DOMAIN_ID, MCLAG_SESSION_TIMEOUT], obj=obj) print(result.exit_code) print(result.output) assert result.exit_code == 0, "failed test for setting valid session timeout with code {}:{} Output:{}".format(type(result.exit_code), result.exit_code, result.output) mclag_entry = db.cfgdb.get_entry("MCLAG_DOMAIN", MCLAG_DOMAIN_ID) temp = mclag_entry.get("session_timeout") assert temp is not None, "session timeout not found" assert temp == MCLAG_SESSION_TIMEOUT, "keepalive timer value not set"
def test_show_pbh_statistics_on_empty_config(self): dbconnector.dedicated_dbs['CONFIG_DB'] = None dbconnector.dedicated_dbs['COUNTERS_DB'] = None SAVED_PBH_COUNTERS_FILE = '/tmp/.pbh_counters.txt' if os.path.isfile(SAVED_PBH_COUNTERS_FILE): os.remove(SAVED_PBH_COUNTERS_FILE) db = Db() runner = CliRunner() result = runner.invoke( show.cli.commands["pbh"]. commands["statistics"], [], obj=db ) logger.debug("\n" + result.output) logger.debug(result.exit_code) assert result.exit_code == SUCCESS assert result.output == assert_show_output.show_pbh_statistics_empty
def test_add_mclag_domain(self): runner = CliRunner() db = Db() obj = {'db': db.cfgdb} # add valid mclag domain result = runner.invoke( config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code == 0, "mclag creation failed with code {}:{} Output:{}".format( type(result.exit_code), result.exit_code, result.output) # add valid mclag domain agai = runner.invoke(config.config.commands["mclag"].commands["add"], [MCLAG_DOMAIN_ID2, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK], obj=obj) assert result.exit_code != 0, "test_mclag_domain_add_again with code {}:{} Output:{}".format( type(result.exit_code), result.exit_code, result.output) #verify config db for the mclag domain config assert self.verify_mclag_domain_cfg( db, MCLAG_DOMAIN_ID, MCLAG_SRC_IP, MCLAG_PEER_IP, MCLAG_PEER_LINK) == True, "mclag config not found"
def test_config_vlan_add_del_dhcp_relay_dest(self): runner = CliRunner() db = Db() # add new relay dest with mock.patch( "utilities_common.cli.run_command") as mock_run_command: result = runner.invoke(config.config.commands["vlan"]. commands["dhcp_relay"].commands["add"], ["1000", "192.0.0.100"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert result.output == config_vlan_add_dhcp_relay_output assert mock_run_command.call_count == 3 # show output result = runner.invoke(show.cli.commands["vlan"].commands["brief"], [], obj=db) print(result.output) assert result.output == show_vlan_brief_output_with_new_dhcp_relay_address # del relay dest with mock.patch( "utilities_common.cli.run_command") as mock_run_command: result = runner.invoke(config.config.commands["vlan"]. commands["dhcp_relay"].commands["del"], ["1000", "192.0.0.100"], obj=db) print(result.exit_code) print(result.output) assert result.exit_code == 0 assert result.output == config_vlan_del_dhcp_relay_output assert mock_run_command.call_count == 3 # show output result = runner.invoke(show.cli.commands["vlan"].commands["brief"], [], obj=db) print(result.output) assert result.output == show_vlan_brief_output