Best Python code snippet using avocado_python
l2-018-bridge_fdb_team.py
Source:l2-018-bridge_fdb_team.py
...25 sw_br = sw.create_bridge(slaves = [sw_lag1, sw_lag2], options=br_options)26 sleep(15)27 tl = TestLib(ctl, aliases)28 tl.ping_simple(m1_lag1, m2_lag1)29 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software")30 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")31 sleep(20)32 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)33 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False)34 # Disable learning and make sure FDB is not populated.35 sw_lag1.set_br_learning(on=False, self=True)36 tl.ping_simple(m1_lag1, m2_lag1)37 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)38 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False)39 # Disable flooding and make sure ping fails.40 sw_lag1.set_br_flooding(on=False, self=True)41 tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True)42 # Set a static FDB entry and make sure ping works again.43 sw_lag1.add_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1)44 tl.ping_simple(m1_lag1, m2_lag1)45 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)46 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")47 # Remove static FDB entry. Ping should fail.48 sw_lag1.del_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1)49 tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True)50 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)51 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False)52 # Enable learning_sync and make sure both FDBs are populated.53 sw_lag1.set_br_learning(on=True, self=True)54 sw_lag1.set_br_flooding(on=True, self=True)55 sw_lag1.set_br_learning_sync(on=True, self=True)56 tl.ping_simple(m1_lag1, m2_lag1)57 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software")58 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")59 sleep(20)60 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)61 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False)62 # Disable learning_sync and make sure only hardware FDB is populated.63 sw_lag1.set_br_learning_sync(on=False, self=True)64 tl.ping_simple(m1_lag1, m2_lag1)65 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)66 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")67 # Remove port from bridge and add it back. Disable flooding and learning68 # and make sure ping doesn't work. Note that port must be removed from69 # bridge when the FDB entry exists only in the hardware table. Otherwise,70 # bridge code will flush it himself, instead of driver.71 sw_br.slave_del(sw_lag1.get_id())72 sw_br.slave_add(sw_lag1.get_id()) # Enables learning sync by default.73 sw_lag1.set_br_learning(on=False, self=True)74 sw_lag1.set_br_flooding(on=False, self=True)75 tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True)76 # Enable learning and make sure ping works again.77 sw_lag1.set_br_learning(on=True, self=True)78 tl.ping_simple(m1_lag1, m2_lag1)79 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software")80 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")81 sleep(20)82 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)83 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware", False)84 # Insert a static FDB entry and disable learning sync. Ping should work.85 sw_lag1.add_br_fdb(str(m1_lag1.get_hwaddr()), self=True, vlan_tci=1)86 sw_lag1.set_br_learning_sync(on=False, self=True)87 tl.ping_simple(m1_lag1, m2_lag1)88 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)89 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")90 sleep(20)91 # Make sure static entry is not aged out.92 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "software", False)93 tl.check_fdb(sw_lag1, m1_lag1.get_hwaddr(), 1, "hardware")94 # Remove port from bridge and add it back. Disable flooding and learning95 # and make sure ping doesn't work. Note that port must be removed from96 # bridge when the FDB entry exists only in the hardware table. Otherwise,97 # bridge code will flush it himself, instead of driver. Unlike the98 # previous case, here we check if the driver correctly removes the static99 # entry.100 sw_br.slave_del(sw_lag1.get_id())101 sw_br.slave_add(sw_lag1.get_id())102 sw_lag1.set_br_learning(on=False, self=True)103 sw_lag1.set_br_flooding(on=False, self=True)104 tl.ping_simple(m1_lag1, m2_lag1, fail_expected=True)105do_task(ctl, [ctl.get_host("machine1"),106 ctl.get_host("machine2"),107 ctl.get_host("switch")],...
l2-017-bridge_fdb_vlan1d.py
Source:l2-017-bridge_fdb_vlan1d.py
...25 sw_br = sw.create_bridge(slaves = [sw_if1_10, sw_if2_20], options=br_options)26 sleep(15)27 tl = TestLib(ctl, aliases)28 tl.ping_simple(m1_if1_10, m2_if1_20)29 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software")30 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")31 sleep(20)32 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)33 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False)34 # Disable learning and make sure FDB is not populated.35 sw_if1_10.set_br_learning(on=False, self=True)36 tl.ping_simple(m1_if1_10, m2_if1_20)37 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)38 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False)39 # Disable flooding and make sure ping fails.40 sw_if1_10.set_br_flooding(on=False, self=True)41 tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True)42 # Set a static FDB entry and make sure ping works again.43 sw_if1_10.add_br_fdb(str(m1_if1_10.get_hwaddr()), self=True)44 tl.ping_simple(m1_if1_10, m2_if1_20)45 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)46 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")47 # Remove static FDB entry. Ping should fail.48 sw_if1_10.del_br_fdb(str(m1_if1_10.get_hwaddr()), self=True)49 tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True)50 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)51 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False)52 # Enable learning_sync and make sure both FDBs are populated.53 sw_if1_10.set_br_learning(on=True, self=True)54 sw_if1_10.set_br_flooding(on=True, self=True)55 sw_if1_10.set_br_learning_sync(on=True, self=True)56 tl.ping_simple(m1_if1_10, m2_if1_20)57 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software")58 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")59 sleep(20)60 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)61 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False)62 # Disable learning_sync and make sure only hardware FDB is populated.63 sw_if1_10.set_br_learning_sync(on=False, self=True)64 tl.ping_simple(m1_if1_10, m2_if1_20)65 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)66 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")67 # Remove port from bridge and add it back. Disable flooding and learning68 # and make sure ping doesn't work. Note that port must be removed from69 # bridge when the FDB entry exists only in the hardware table. Otherwise,70 # bridge code will flush it himself, instead of driver.71 sw_br.slave_del(sw_if1_10.get_id())72 sw_br.slave_add(sw_if1_10.get_id()) # Enables learning sync by default.73 sw_if1_10.set_br_learning(on=False, self=True)74 sw_if1_10.set_br_flooding(on=False, self=True)75 tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True)76 # Enable learning and make sure ping works again.77 sw_if1_10.set_br_learning(on=True, self=True)78 tl.ping_simple(m1_if1_10, m2_if1_20)79 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software")80 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")81 sleep(20)82 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)83 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware", False)84 # Insert a static FDB entry and disable learning sync. Ping should work.85 sw_if1_10.add_br_fdb(str(m1_if1_10.get_hwaddr()), self=True)86 sw_if1_10.set_br_learning_sync(on=False, self=True)87 tl.ping_simple(m1_if1_10, m2_if1_20)88 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)89 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")90 sleep(20)91 # Make sure static entry is not aged out.92 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "software", False)93 tl.check_fdb(sw_if1_10, m1_if1_10.get_hwaddr(), 0, "hardware")94 # Remove port from bridge and add it back. Disable flooding and learning95 # and make sure ping doesn't work. Note that port must be removed from96 # bridge when the FDB entry exists only in the hardware table. Otherwise,97 # bridge code will flush it himself, instead of driver. Unlike the98 # previous case, here we check if the driver correctly removes the static99 # entry.100 sw_br.slave_del(sw_if1_10.get_id())101 sw_br.slave_add(sw_if1_10.get_id())102 sw_if1_10.set_br_learning(on=False, self=True)103 sw_if1_10.set_br_flooding(on=False, self=True)104 tl.ping_simple(m1_if1_10, m2_if1_20, fail_expected=True)105do_task(ctl, [ctl.get_host("machine1"),106 ctl.get_host("machine2"),107 ctl.get_host("switch")],...
l2-002-bridge_fdb.py
Source:l2-002-bridge_fdb.py
...23 sw_br = sw.create_bridge(slaves = [sw_if1, sw_if2], options=br_options)24 sleep(15)25 tl = TestLib(ctl, aliases)26 tl.ping_simple(m1_if1, m2_if1)27 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software")28 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")29 sleep(30)30# tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)31 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware", False)32 # Disable learning and make sure FDB is not populated.33 sw_if1.set_br_learning(on=False, self=True)34 tl.ping_simple(m1_if1, m2_if1)35 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)36 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware", False)37 # Disable flooding and make sure ping fails.38 sw_if1.set_br_flooding(on=False, self=True)39 tl.ping_simple(m1_if1, m2_if1, fail_expected=True)40 # Set a static FDB entry and make sure ping works again.41 sw_if1.add_br_fdb(str(m1_if1.get_hwaddr()), self=True, vlan_tci=1)42 tl.ping_simple(m1_if1, m2_if1)43 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)44 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")45 # Remove static FDB entry. Ping should fail.46 sw_if1.del_br_fdb(str(m1_if1.get_hwaddr()), self=True, vlan_tci=1)47 tl.ping_simple(m1_if1, m2_if1, fail_expected=True)48 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)49 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware", False)50 # Enable learning_sync and make sure both FDBs are populated.51 sw_if1.set_br_learning(on=True, self=True)52 sw_if1.set_br_flooding(on=True, self=True)53 sw_if1.set_br_learning_sync(on=True, self=True)54 tl.ping_simple(m1_if1, m2_if1)55 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software")56 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")57 sleep(20)58 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)59 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware", False)60 # Disable learning_sync and make sure only hardware FDB is populated.61 sw_if1.set_br_learning_sync(on=False, self=True)62 tl.ping_simple(m1_if1, m2_if1)63 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)64 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")65 # Remove port from bridge and add it back. Disable flooding and learning66 # and make sure ping doesn't work. Note that port must be removed from67 # bridge when the FDB entry exists only in the hardware table. Otherwise,68 # bridge code will flush it himself, instead of driver.69 sw_br.slave_del(sw_if1.get_id())70 sw_br.slave_add(sw_if1.get_id()) # Enables learning sync by default.71 sw_if1.set_br_learning(on=False, self=True)72 sw_if1.set_br_flooding(on=False, self=True)73 tl.ping_simple(m1_if1, m2_if1, fail_expected=True)74 # Enable learning and make sure ping works again.75 sw_if1.set_br_learning(on=True, self=True)76 tl.ping_simple(m1_if1, m2_if1)77 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software")78 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")79 sleep(20)80 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)81 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware", False)82 # Insert a static FDB entry and disable learning sync. Ping should work.83 sw_if1.add_br_fdb(str(m1_if1.get_hwaddr()), self=True, vlan_tci=1)84 sw_if1.set_br_learning_sync(on=False, self=True)85 tl.ping_simple(m1_if1, m2_if1)86 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)87 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")88 sleep(20)89 # Make sure static entry is not aged out.90 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "software", False)91 tl.check_fdb(sw_if1, m1_if1.get_hwaddr(), 1, "hardware")92 # Remove port from bridge and add it back. Disable flooding and learning93 # and make sure ping doesn't work. Note that port must be removed from94 # bridge when the FDB entry exists only in the hardware table. Otherwise,95 # bridge code will flush it himself, instead of driver. Unlike the96 # previous case, here we check if the driver correctly removes the static97 # entry.98 sw_br.slave_del(sw_if1.get_id())99 sw_br.slave_add(sw_if1.get_id())100 sw_if1.set_br_learning(on=False, self=True)101 sw_if1.set_br_flooding(on=False, self=True)102 tl.ping_simple(m1_if1, m2_if1, fail_expected=True)103do_task(ctl, [ctl.get_host("machine1"),104 ctl.get_host("machine2"),105 ctl.get_host("switch")],...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!