Skip to content

Commit

Permalink
Merge branch 'fix/add_network_reconnectin_in_ot_ci_case_v5.4' into 'r…
Browse files Browse the repository at this point in the history
…elease/v5.4'

feat(openthread): flush ipv6 addr in openthread ci cases(Backport v5.4)

See merge request espressif/esp-idf!34675
  • Loading branch information
chshu committed Nov 20, 2024
2 parents dfe11eb + cad2ff8 commit c46fe1f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions examples/openthread/ot_ci_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,26 @@ def get_domain() -> str:
return str(role)


def flush_ipv6_addr_by_interface() -> None:
interface_name = get_host_interface_name()
print(f'flush ipv6 addr : {interface_name}')
command_show_addr = f'ip -6 addr show dev {interface_name}'
command_show_route = f'ip -6 route show dev {interface_name}'
addr_before = subprocess.getoutput(command_show_addr)
route_before = subprocess.getoutput(command_show_route)
print(f'Before flush, IPv6 addresses: \n{addr_before}')
print(f'Before flush, IPv6 routes: \n{route_before}')
subprocess.run(['ip', 'link', 'set', interface_name, 'down'])
subprocess.run(['ip', '-6', 'addr', 'flush', 'dev', interface_name])
subprocess.run(['ip', '-6', 'route', 'flush', 'dev', interface_name])
subprocess.run(['ip', 'link', 'set', interface_name, 'up'])
time.sleep(5)
addr_after = subprocess.getoutput(command_show_addr)
route_after = subprocess.getoutput(command_show_route)
print(f'After flush, IPv6 addresses: \n{addr_after}')
print(f'After flush, IPv6 routes: \n{route_after}')


class tcp_parameter:

def __init__(self, tcp_type:str='', addr:str='::', port:int=12345, listen_flag:bool=False, recv_flag:bool=False, timeout:float=15.0, tcp_bytes:bytes=b''):
Expand Down
4 changes: 2 additions & 2 deletions examples/openthread/pytest_otbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def fixture_Init_avahi() -> bool:
@pytest.fixture(name='Init_interface')
def fixture_Init_interface() -> bool:
print('Init interface')
ocf.init_interface_ipv6_address()
ocf.reset_host_interface()
ocf.flush_ipv6_addr_by_interface()
# The sleep time is set based on experience; reducing it might cause the host to be unready.
time.sleep(30)
ocf.set_interface_sysctl_options()
return True
Expand Down

0 comments on commit c46fe1f

Please sign in to comment.