11# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
22# SPDX-License-Identifier: CC0-1.0
3+ import base64
4+ import io
35import ipaddress
46import logging
7+ import os
58import re
69import socket
710import subprocess
811import time
912from concurrent .futures import Future
1013from concurrent .futures import ThreadPoolExecutor
1114from typing import List
15+ from typing import Optional
1216from typing import Union
1317
1418import netifaces
1822from netmiko import ConnectHandler
1923from pytest_embedded import Dut
2024from pytest_embedded_idf .utils import idf_parametrize
25+
2126# Testbed configuration
2227
28+ ETHVM_ENDNODE_USER = 'ci.ethvm'
29+
2330BR_PORTS_NUM = 2
2431IPERF_BW_LIM = 6
2532MIN_UDP_THROUGHPUT = 5
2633MIN_TCP_THROUGHPUT = 4
2734
2835
2936class EndnodeSsh :
30- def __init__ (self , host_ip : str , usr : str , passwd : str ):
37+ def __init__ (self , host_ip : str , usr : str , passwd : Optional [str ] = None ):
38+ key_string = os .getenv ('CI_ETHVM_KEY' )
39+ key = None
40+ if key_string :
41+ decoded_key_string = base64 .b64decode (key_string )
42+ key = paramiko .Ed25519Key .from_private_key (io .StringIO (decoded_key_string .decode ('utf-8' )))
43+
3144 self .host_ip = host_ip
3245 self .ssh_client = paramiko .SSHClient ()
3346 self .ssh_client .set_missing_host_key_policy (paramiko .AutoAddPolicy ())
34- self .ssh_client .connect (hostname = self .host_ip , username = usr , password = passwd )
47+ self .ssh_client .connect (hostname = self .host_ip , username = usr , pkey = key , password = passwd )
3548 self .executor : ThreadPoolExecutor
3649 self .async_result : Future
3750
@@ -281,14 +294,16 @@ def test_esp_eth_bridge(dut: Dut, dev_user: str, dev_password: str) -> None:
281294 port_num = int (sw_info .group (2 ))
282295 port_num_endnode = int (port_num ) + 1 # endnode address is always + 1 to the host
283296
284- endnode = EndnodeSsh (f'10.10.{ sw_num } .{ port_num_endnode } ' , dev_user , dev_password )
297+ endnode = EndnodeSsh (f'10.10.{ sw_num } .{ port_num_endnode } ' , ETHVM_ENDNODE_USER )
285298 switch1 = SwitchSsh (f'10.10.{ sw_num } .100' , dev_user , dev_password , SwitchSsh .EDGE_SWITCH_10XP )
286299
287300 # Collect all addresses in our network
288301 # ------------------------------------
289302 # Bridge (DUT) MAC
290303 br_mac = dut .expect (
291- r'esp_netif_br_glue: ([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})'
304+ r'esp_netif_br_glue: '
305+ r'([0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:'
306+ r'[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2})'
292307 )
293308 br_mac = br_mac .group (1 ).decode ('utf-8' )
294309 logging .info ('ESP Bridge MAC %s' , br_mac )
@@ -387,7 +402,8 @@ def test_esp_eth_bridge(dut: Dut, dev_user: str, dev_password: str) -> None:
387402 bandwidth_udp = run_iperf ('udp' , endnode , host_ip , IPERF_BW_LIM , 5 )
388403 if bandwidth_udp < MIN_UDP_THROUGHPUT :
389404 logging .warning (
390- 'Unicast UDP bandwidth was less than expected. Trying again over longer period to compensate transient drops.'
405+ 'Unicast UDP bandwidth was less than expected. '
406+ 'Trying again over longer period to compensate transient drops.'
391407 )
392408 bandwidth_udp = run_iperf ('udp' , endnode , host_ip , IPERF_BW_LIM , 60 )
393409 logging .info ('Unicast UDP average bandwidth: %s Mbits/s' , bandwidth_udp )
@@ -396,7 +412,8 @@ def test_esp_eth_bridge(dut: Dut, dev_user: str, dev_password: str) -> None:
396412 bandwidth_tcp = run_iperf ('tcp' , endnode , host_ip , IPERF_BW_LIM , 5 )
397413 if bandwidth_tcp < MIN_TCP_THROUGHPUT :
398414 logging .warning (
399- 'Unicast TCP bandwidth was less than expected. Trying again over longer period to compensate transient drops.'
415+ 'Unicast TCP bandwidth was less than expected. '
416+ 'Trying again over longer period to compensate transient drops.'
400417 )
401418 bandwidth_tcp = run_iperf ('tcp' , endnode , host_ip , IPERF_BW_LIM , 60 )
402419 logging .info ('Unicast TCP average bandwidth: %s Mbits/s' , bandwidth_tcp )
@@ -405,7 +422,8 @@ def test_esp_eth_bridge(dut: Dut, dev_user: str, dev_password: str) -> None:
405422 bandwidth_mcast_udp = run_iperf ('udp' , endnode , '224.0.1.4' , IPERF_BW_LIM , 5 , host_if , endnode_if )
406423 if bandwidth_mcast_udp < MIN_UDP_THROUGHPUT :
407424 logging .warning (
408- 'Multicast UDP bandwidth was less than expected. Trying again over longer period to compensate transient drops.'
425+ 'Multicast UDP bandwidth was less than expected. '
426+ 'Trying again over longer period to compensate transient drops.'
409427 )
410428 bandwidth_mcast_udp = run_iperf ('udp' , endnode , '224.0.1.4' , IPERF_BW_LIM , 60 , host_if , endnode_if )
411429 logging .info ('Multicast UDP average bandwidth: %s Mbits/s' , bandwidth_mcast_udp )
0 commit comments