From d51c9a6d5056e8c5670bdadcd08b798e0423f04c Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Thu, 3 Aug 2023 23:12:33 +0000 Subject: [PATCH 01/13] Revert "Change run_tests.sh to use python3 unconditionally (#8988)" This reverts commit d88236c0881b697bd64ef2686c6293d251509f6a. --- tests/python3_test_files.txt | 357 ++++++++++++++++++++++++++++++++++- tests/run_tests.sh | 46 +++-- 2 files changed, 386 insertions(+), 17 deletions(-) diff --git a/tests/python3_test_files.txt b/tests/python3_test_files.txt index 0702cb5bfb..04c7a3e8c5 100644 --- a/tests/python3_test_files.txt +++ b/tests/python3_test_files.txt @@ -1 +1,356 @@ -all +acl/custom_acl_table/test_custom_acl_table.py +acl/null_route/test_null_route_helper.py +acl/test_acl.py +acl/test_acl_outer_vlan.py +acl/test_stress_acl.py +arp/test_arp_dualtor.py +arp/test_arp_extended.py +arp/test_arpall.py +arp/test_neighbor_mac.py +arp/test_neighbor_mac_noptf.py +arp/test_stress_arp.py +arp/test_tagged_arp.py +arp/test_unknown_mac.py +arp/test_wr_arp.py +autorestart/test_container_autorestart.py +bfd/test_bfd.py +bgp/test_bgp_allow_list.py +bgp/test_bgp_bbr.py +bgp/test_bgp_bounce.py +bgp/test_bgp_dual_asn.py +bgp/test_bgp_fact.py +bgp/test_bgp_gr_helper.py +bgp/test_bgp_multipath_relax.py +bgp/test_bgp_session_flap.py +bgp/test_bgp_slb.py +bgp/test_bgp_speaker.py +bgp/test_bgp_update_timer.py +bgp/test_bgpmon.py +bgp/test_traffic_shift.py +cacl/test_cacl_application.py +cacl/test_cacl_function.py +cacl/test_ebtables_application.py +configlet/test_add_rack.py +console/test_console_availability.py +console/test_console_driver.py +console/test_console_loopback.py +console/test_console_reversessh.py +console/test_console_udevrule.py +container_checker/test_container_checker.py +container_hardening/test_container_hardening.py +copp/test_copp.py +crm/test_crm.py +dash/test_dash_vnet.py +decap/test_decap.py +dhcp_relay/test_dhcp_pkt_fwd.py +dhcp_relay/test_dhcp_relay.py +dhcp_relay/test_dhcpv6_relay.py +disk/test_disk_exhaustion.py +dns/test_dns_resolv_conf.py +drop_packets/test_configurable_drop_counters.py +drop_packets/test_drop_counters.py +dualtor/test_ipinip.py +dualtor/test_orch_stress.py +dualtor/test_orchagent_active_tor_downstream.py +dualtor/test_orchagent_mac_move.py +dualtor/test_orchagent_slb.py +dualtor/test_orchagent_standby_tor_downstream.py +dualtor/test_standby_tor_upstream_mux_toggle.py +dualtor/test_tor_ecn.py +dualtor/test_tunnel_memory_leak.py +dualtor_io/test_grpc_server_failure.py +dualtor_io/test_heartbeat_failure.py +dualtor_io/test_link_drop.py +dualtor_io/test_link_failure.py +dualtor_io/test_normal_op.py +dualtor_io/test_tor_bgp_failure.py +dualtor_io/test_tor_failure.py +dualtor_mgmt/test_dualtor_bgp_update_delay.py +dualtor_mgmt/test_grpc_periodical_sync.py +dualtor_mgmt/test_ingress_drop.py +dualtor_mgmt/test_server_failure.py +dualtor_mgmt/test_toggle_mux.py +dut_console/test_console_baud_rate.py +dut_console/test_escape_character.py +dut_console/test_idle_timeout.py +ecmp/inner_hashing/test_inner_hashing.py +ecmp/inner_hashing/test_inner_hashing_lag.py +ecmp/inner_hashing/test_wr_inner_hashing.py +ecmp/inner_hashing/test_wr_inner_hashing_lag.py +ecmp/test_fgnhg.py +everflow/test_everflow_ipv6.py +everflow/test_everflow_per_interface.py +everflow/test_everflow_testbed.py +fdb/test_fdb.py +fdb/test_fdb_flush.py +fdb/test_fdb_mac_expire.py +fdb/test_fdb_mac_move.py +fib/test_fib.py +generic_config_updater/test_aaa.py +generic_config_updater/test_bgp_prefix.py +generic_config_updater/test_bgp_speaker.py +generic_config_updater/test_bgpl.py +generic_config_updater/test_cacl.py +generic_config_updater/test_dhcp_relay.py +generic_config_updater/test_eth_interface.py +generic_config_updater/test_incremental_qos.py +generic_config_updater/test_ipv6.py +generic_config_updater/test_lo_interface.py +generic_config_updater/test_mmu_dynamic_threshold_config_update.py +generic_config_updater/test_monitor_config.py +generic_config_updater/test_ntp.py +generic_config_updater/test_pfcwd_interval.py +generic_config_updater/test_portchannel_interface.py +generic_config_updater/test_syslog.py +generic_config_updater/test_vlan_interface.py +gnmi/test_gnmi.py +gnmi/test_gnmi_appldb.py +gnmi/test_gnmi_configdb.py +http/test_http_copy.py +iface_loopback_action/test_iface_loopback_action.py +iface_namingmode/test_iface_namingmode.py +ip/test_ip_packet.py +ipfwd/test_dip_sip.py +ipfwd/test_dir_bcast.py +ipfwd/test_mtu.py +ipfwd/test_nhop_group.py +ixia/ecn/test_dequeue_ecn.py +ixia/ecn/test_red_accuracy.py +ixia/ixanvl/test_bgp_conformance.py +ixia/pfc/test_global_pause.py +ixia/pfc/test_pfc_congestion.py +ixia/pfc/test_pfc_pause_lossless.py +ixia/pfc/test_pfc_pause_lossy.py +ixia/pfcwd/test_pfcwd_a2a.py +ixia/pfcwd/test_pfcwd_basic.py +ixia/pfcwd/test_pfcwd_burst_storm.py +ixia/pfcwd/test_pfcwd_m2o.py +ixia/pfcwd/test_pfcwd_runtime_traffic.py +ixia/test_ixia_traffic.py +ixia/test_tgen.py +k8s/test_config_reload.py +k8s/test_disable_flag.py +k8s/test_join_available_master.py +lldp/test_lldp.py +log_fidelity/test_bgp_shutdown.py +macsec/test_controlplane.py +macsec/test_dataplane.py +macsec/test_deployment.py +macsec/test_fault_handling.py +macsec/test_interop_protocol.py +macsec/test_interop_wan_isis.py +mclag/test_mclag_l3.py +memory_checker/test_memory_checker.py +monit/test_monit_status.py +mpls/test_mpls.py +mvrf/test_mgmtvrf.py +nat/test_dynamic_nat.py +nat/test_static_nat.py +ntp/test_ntp.py +override_config_table/test_override_config_table.py +passw_hardening/test_passw_hardening.py +pc/test_lag_2.py +pc/test_lag_member.py +pc/test_po_cleanup.py +pc/test_po_update.py +pc/test_po_voq.py +pfc_asym/test_pfc_asym.py +pfcwd/test_pfc_config.py +pfcwd/test_pfcwd_all_port_storm.py +pfcwd/test_pfcwd_function.py +pfcwd/test_pfcwd_timer_accuracy.py +pfcwd/test_pfcwd_warm_reboot.py +platform_tests/api/test_chassis.py +platform_tests/api/test_chassis_fans.py +platform_tests/api/test_component.py +platform_tests/api/test_fan_drawer.py +platform_tests/api/test_fan_drawer_fans.py +platform_tests/api/test_module.py +platform_tests/api/test_psu.py +platform_tests/api/test_psu_fans.py +platform_tests/api/test_sfp.py +platform_tests/api/test_thermal.py +platform_tests/api/test_watchdog.py +platform_tests/broadcom/test_ser.py +platform_tests/cli/test_show_chassis_module.py +platform_tests/cli/test_show_platform.py +platform_tests/counterpoll/test_counterpoll_watermark.py +platform_tests/daemon/test_chassisd.py +platform_tests/daemon/test_fancontrol.py +platform_tests/daemon/test_ledd.py +platform_tests/daemon/test_pcied.py +platform_tests/daemon/test_psud.py +platform_tests/daemon/test_syseepromd.py +platform_tests/fwutil/test_fwutil.py +platform_tests/link_flap/test_cont_link_flap.py +platform_tests/link_flap/test_link_flap.py +platform_tests/mellanox/test_check_sfp_eeprom.py +platform_tests/mellanox/test_check_sfp_presence.py +platform_tests/mellanox/test_check_sfp_using_ethtool.py +platform_tests/mellanox/test_check_sysfs.py +platform_tests/mellanox/test_hw_management_service.py +platform_tests/mellanox/test_psu_power_threshold.py +platform_tests/mellanox/test_reboot_cause.py +platform_tests/mellanox/test_thermal_control.py +platform_tests/sfp/test_sfpshow.py +platform_tests/sfp/test_sfputil.py +platform_tests/sfp/test_show_intf_xcvr.py +platform_tests/test_advanced_reboot.py +platform_tests/test_auto_negotiation.py +platform_tests/test_cont_warm_reboot.py +platform_tests/test_cpu_memory_usage.py +platform_tests/test_first_time_boot_password_change/test_first_time_boot_password_change.py +platform_tests/test_link_down.py +platform_tests/test_memory_exhaustion.py +platform_tests/test_platform_info.py +platform_tests/test_port_toggle.py +platform_tests/test_power_budget_info.py +platform_tests/test_reboot.py +platform_tests/test_reload_config.py +platform_tests/test_sensors.py +platform_tests/test_sequential_restart.py +platform_tests/test_service_warm_restart.py +platform_tests/test_thermal_state_db.py +platform_tests/test_xcvr_info_in_db.py +portstat/test_portstat.py +process_monitoring/test_critical_process_monitoring.py +qos/test_buffer.py +qos/test_buffer_traditional.py +qos/test_pfc_counters.py +qos/test_pfc_pause.py +qos/test_qos_masic.py +qos/test_qos_sai.py +qos/test_tunnel_qos_remap.py +radv/test_radv_ipv6_ra.py +radv/test_radv_restart.py +read_mac/test_read_mac_metadata.py +restapi/test_restapi.py +restapi/test_restapi_vxlan_ecmp.py +route/test_default_route.py +route/test_route_flap.py +route/test_route_flow_counter.py +route/test_route_perf.py +route/test_static_route.py +sai_qualify/test_brcm_t0.py +sai_qualify/test_community.py +sai_qualify/test_sai_ptf.py +sai_qualify/test_sai_ptf_warm_reboot.py +sai_qualify/test_sai_t0_warm_reboot.py +scp/test_scp_copy.py +sflow/test_sflow.py +show_techsupport/test_auto_techsupport.py +show_techsupport/test_techsupport.py +show_techsupport/test_techsupport_no_secret.py +snappi/bgp/test_bgp_convergence_performance.py +snappi/bgp/test_bgp_local_link_failover.py +snappi/bgp/test_bgp_remote_link_failover.py +snappi/bgp/test_bgp_rib_in_capacity.py +snappi/bgp/test_bgp_rib_in_convergence.py +snappi/bgp/test_bgp_scalability.py +snappi/ecn/test_dequeue_ecn_with_snappi.py +snappi/ecn/test_red_accuracy_with_snappi.py +snappi/lacp/test_add_remove_link_from_dut.py +snappi/lacp/test_add_remove_link_physically.py +snappi/lacp/test_lacp_timers_effect.py +snappi/pfc/test_global_pause_with_snappi.py +snappi/pfc/test_pfc_pause_lossless_with_snappi.py +snappi/pfc/test_pfc_pause_lossy_with_snappi.py +snappi/pfc/test_pfc_pause_response_with_snappi.py +snappi/pfcwd/test_pfcwd_a2a_with_snappi.py +snappi/pfcwd/test_pfcwd_basic_with_snappi.py +snappi/pfcwd/test_pfcwd_burst_storm_with_snappi.py +snappi/pfcwd/test_pfcwd_m2o_with_snappi.py +snappi/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py +snappi/reboot/test_cold_reboot.py +snappi/reboot/test_fast_reboot.py +snappi/reboot/test_soft_reboot.py +snappi/reboot/test_warm_reboot.py +snappi/test_snappi.py +snmp/test_snmp_cpu.py +snmp/test_snmp_default_route.py +snmp/test_snmp_fdb.py +snmp/test_snmp_interfaces.py +snmp/test_snmp_lldp.py +snmp/test_snmp_loopback.py +snmp/test_snmp_memory.py +snmp/test_snmp_pfc_counters.py +snmp/test_snmp_phy_entity.py +snmp/test_snmp_psu.py +snmp/test_snmp_queue.py +snmp/test_snmp_v2mib.py +span/test_port_mirroring.py +ssh/test_ssh_ciphers.py +ssh/test_ssh_default_password.py +ssh/test_ssh_limit.py +ssh/test_ssh_stress.py +stress/test_stress_routes.py +sub_port_interfaces/test_show_subinterface.py +sub_port_interfaces/test_sub_port_interfaces.py +sub_port_interfaces/test_sub_port_l2_forwarding.py +syslog/test_logrotate.py +syslog/test_syslog.py +syslog/test_syslog_rate_limit.py +syslog/test_syslog_source_ip.py +system_health/test_system_health.py +system_health/test_system_status.py +tacacs/test_accounting.py +tacacs/test_authorization.py +tacacs/test_jit_user.py +tacacs/test_ro_disk.py +tacacs/test_ro_user.py +tacacs/test_rw_user.py +telemetry/test_events.py +telemetry/test_telemetry.py +test_features.py +test_interfaces.py +test_nbr_health.py +test_posttest.py +test_pretest.py +test_procdockerstatsd.py +test_vs_chassis_setup.py +testbed_setup/test_add_property_spytest_junit_xml.py +testbed_setup/test_gen_spy_testbed.py +testbed_setup/test_populate_fdb.py +upgrade_path/test_upgrade_path.py +vlan/test_autostate_disabled.py +vlan/test_host_vlan.py +vlan/test_vlan.py +vlan/test_vlan_ping.py +voq/test_voq_disrupts.py +voq/test_voq_init.py +voq/test_voq_intfs.py +voq/test_voq_ipfwd.py +voq/test_voq_nbr.py +vrf/test_vrf.py +vrf/test_vrf_attr.py +vxlan/test_vnet_route_leak.py +vxlan/test_vnet_vxlan.py +vxlan/test_vxlan_crm.py +vxlan/test_vxlan_decap.py +vxlan/test_vxlan_ecmp.py +wan/isis/test_isis_authentication.py +wan/isis/test_isis_csnp_interval.py +wan/isis/test_isis_database.py +wan/isis/test_isis_dynamic_hostname.py +wan/isis/test_isis_ecmp.py +wan/isis/test_isis_hello_interval.py +wan/isis/test_isis_hello_pad.py +wan/isis/test_isis_holdtime.py +wan/isis/test_isis_intf_passive.py +wan/isis/test_isis_level_capacity.py +wan/isis/test_isis_log_adjacency_change.py +wan/isis/test_isis_lsp_fragment.py +wan/isis/test_isis_lsp_gen_interval.py +wan/isis/test_isis_lsp_lifetime.py +wan/isis/test_isis_lsp_refresh.py +wan/isis/test_isis_metric_wide.py +wan/isis/test_isis_neighbor.py +wan/isis/test_isis_overload_bit.py +wan/isis/test_isis_redistribute.py +wan/isis/test_isis_spf_default_interval.py +wan/isis/test_isis_spf_ietf_interval.py +wan/lacp/test_wan_lacp.py +wan/lacp/test_wan_lag_member.py +wan/lacp/test_wan_lag_min_link.py +wan/lldp/test_wan_lldp.py +wan/traffic_test/test_traffic.py diff --git a/tests/run_tests.sh b/tests/run_tests.sh index f3cc2cdd31..976f4a5ceb 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -45,14 +45,14 @@ function get_dut_from_testbed_file() { DUT_NAME=${ARRAY[9]//[\[\] ]/} elif [[ $TESTBED_FILE == *.yaml ]]; then - content=$(python3 -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") + content=$(python -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") if [[ -z ${content} ]]; then echo "Unable to find testbed '$TESTBED_NAME' in testbed file '$TESTBED_FILE'" show_help_and_exit 4 fi IFS=$'+' read -r -a tb_lines <<< $content tb_line=${tb_lines[0]} - DUT_NAME=$(python3 -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") + DUT_NAME=$(python -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") fi fi } @@ -130,7 +130,7 @@ function setup_test_options() # for the scenario of specifying test scripts using pattern like `subfolder/test_*.py`. The pattern will be # expanded to matched test scripts by bash. Among the expanded scripts, we may want to skip a few. Then we can # explicitly specify the script to be skipped. - ignores=$(python3 -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") + ignores=$(python -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") if [[ -z ${TEST_CASES} ]]; then # When TEST_CASES is not specified, find all the possible scripts, ignore the scripts under $SKIP_FOLDERS all_scripts=$(find ./ -name 'test_*.py' | sed s:^./:: | grep -vE "^(${ignores})") @@ -143,18 +143,18 @@ function setup_test_options() fi # Ignore the scripts specified in $SKIP_SCRIPTS if [[ x"${TEST_INPUT_ORDER}" == x"True" ]]; then - TEST_CASES=$(python3 -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") + TEST_CASES=$(python -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") else - TEST_CASES=$(python3 -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) + TEST_CASES=$(python -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) fi # Check against $INCLUDE_FOLDERS, filter out test cases not in the specified folders FINAL_CASES="" - includes=$(python3 -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") + includes=$(python -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") for test_case in ${TEST_CASES}; do FINAL_CASES="${FINAL_CASES} $(echo ${test_case} | grep -E "^(${includes})")" done - TEST_CASES=$(python3 -c "print('\n'.join('''${FINAL_CASES}'''.split()))") + TEST_CASES=$(python -c "print('\n'.join('''${FINAL_CASES}'''.split()))") if [[ -z $TEST_CASES ]]; then echo "No test case to run based on conditions of '-c', '-I' and '-S'. Please check..." @@ -264,22 +264,22 @@ function pre_post_extra_params() function prepare_dut() { echo "=== Preparing DUT for subsequent tests ===" - echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest - python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + echo Running: pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest } function cleanup_dut() { echo "=== Cleaning up DUT after tests ===" - echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest - python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + echo Running: pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest } function run_group_tests() { echo "=== Running tests in groups ===" - echo Running: python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear + echo Running: pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear } function run_individual_tests() @@ -300,9 +300,23 @@ function run_individual_tests() TEST_LOGGING_OPTIONS="--log-file ${LOG_PATH}/${test_dir}/${test_name}.log --junitxml=${LOG_PATH}/${test_dir}/${test_name}.xml" fi - echo Running: python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} - ret_code=$? + echo Running: pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + USE_PY3=0 + for i in `cat python3_test_files.txt` + do + USE_PY3=`expr match ${test_script} ${i}` + [[ ${USE_PY3} != 0 ]] && break + done + if [ ${USE_PY3} != 0 ]; then + echo Activate Python3 venv + source /var/AzDevOps/env-python3/bin/activate + fi + pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} + ret_code=$? + if [ ${USE_PY3} != 0 ]; then + echo Deactivate Python3 venv + deactivate + fi # Clear pytest cache for the first run if [[ -n ${CACHE_CLEAR} ]]; then From 6ceebe465eaad328408dbfd1813882078113b994 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Thu, 3 Aug 2023 23:12:52 +0000 Subject: [PATCH 02/13] Revert "[tests/crm] Fix python3 syntax error in `test_acl_entry` (#9208)" This reverts commit 1c5b8dd4e4df00af1350ef569817577f612f0153. --- tests/crm/test_crm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/crm/test_crm.py b/tests/crm/test_crm.py index 72182c72a3..56696ad4ea 100755 --- a/tests/crm/test_crm.py +++ b/tests/crm/test_crm.py @@ -910,7 +910,8 @@ def test_acl_entry(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro if duthost.facts["asic_type"] == "marvell": # Remove DATA ACL Table and add it again with ports in same port group mg_facts = duthost.get_extended_minigraph_facts(tbinfo) - tmp_ports = sorted(mg_facts["minigraph_ports"], key=lambda x: int(x[8:])) + tmp_ports = mg_facts["minigraph_ports"].keys() + tmp_ports.sort(key=lambda x: int(x[8:])) for i in range(4): if i == 0: ports = ",".join(tmp_ports[17:19]) From a12ac1e3efbf73ba759bd10df3d797d6f50e6028 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Thu, 3 Aug 2023 23:13:05 +0000 Subject: [PATCH 03/13] Revert "Fix import issue of tests/snappi_tests in python3 (#9232)" This reverts commit a3c0642a0cf6983ef94fc39b222705a96a481ede. --- .azure-pipelines/pytest-collect-only.yml | 2 +- tests/snappi_tests/bgp/test_bgp_convergence_performance.py | 2 +- tests/snappi_tests/bgp/test_bgp_local_link_failover.py | 2 +- tests/snappi_tests/bgp/test_bgp_remote_link_failover.py | 2 +- tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py | 2 +- tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py | 2 +- tests/snappi_tests/bgp/test_bgp_scalability.py | 3 +-- tests/snappi_tests/ecn/conftest.py | 2 +- tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py | 2 +- tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py | 2 +- tests/snappi_tests/lacp/test_add_remove_link_from_dut.py | 2 +- tests/snappi_tests/lacp/test_add_remove_link_physically.py | 2 +- tests/snappi_tests/lacp/test_lacp_timers_effect.py | 2 +- tests/snappi_tests/pfc/test_global_pause_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py | 2 +- .../snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py | 2 +- .../pfcwd/test_pfcwd_runtime_traffic_with_snappi.py | 2 +- tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py | 2 +- 25 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.azure-pipelines/pytest-collect-only.yml b/.azure-pipelines/pytest-collect-only.yml index 6d1d2bca9e..93057efdb9 100644 --- a/.azure-pipelines/pytest-collect-only.yml +++ b/.azure-pipelines/pytest-collect-only.yml @@ -35,7 +35,7 @@ steps: set -x sudo docker exec -t -w /var/src/sonic-mgmt/tests sonic-mgmt-collect \ - python3 -m pytest --inventory ../ansible/veos_vtb --host-pattern all \ + pytest --inventory ../ansible/veos_vtb --host-pattern all \ --testbed_file vtestbed.yaml --testbed vms-kvm-t0 \ --ignore saitests --ignore ptftests --ignore acstests \ --ignore scripts --ignore k8s --ignore sai_qualify --ignore common \ diff --git a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py index fa7ecdde38..45502f6831 100644 --- a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py +++ b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_test_gap_helper import run_bgp_convergence_performance +from .files.bgp_test_gap_helper import run_bgp_convergence_performance from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py index 02cd88ede7..354d277da9 100644 --- a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_bgp_local_link_failover_test +from .files.bgp_convergence_helper import run_bgp_local_link_failover_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py index 215021647c..afc53dc564 100755 --- a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_bgp_remote_link_failover_test +from .files.bgp_convergence_helper import run_bgp_remote_link_failover_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py index f58686f577..e2c64acbbf 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_RIB_IN_capacity_test +from .files.bgp_convergence_helper import run_RIB_IN_capacity_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py index afed29098b..30f19cb72a 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_rib_in_convergence_test +from .files.bgp_convergence_helper import run_rib_in_convergence_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_scalability.py b/tests/snappi_tests/bgp/test_bgp_scalability.py index e95847d589..08c672ccb6 100644 --- a/tests/snappi_tests/bgp/test_bgp_scalability.py +++ b/tests/snappi_tests/bgp/test_bgp_scalability.py @@ -1,7 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.bgp.files.bgp_test_gap_helper import duthost_bgp_scalability_config, \ - run_bgp_scalability_v4_v6, cleanup_config +from .files.bgp_test_gap_helper import duthost_bgp_scalability_config, run_bgp_scalability_v4_v6, cleanup_config from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/ecn/conftest.py b/tests/snappi_tests/ecn/conftest.py index 89a4b1a74d..9d0187b683 100644 --- a/tests/snappi_tests/ecn/conftest.py +++ b/tests/snappi_tests/ecn/conftest.py @@ -1,4 +1,4 @@ -from tests.snappi_tests.ecn.ecn_args.ecn_args import add_ecn_args +from ecn_args.ecn_args import add_ecn_args def pytest_addoption(parser): diff --git a/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py b/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py index 1048a0eacc..2eb96f2da8 100644 --- a/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py +++ b/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py @@ -7,7 +7,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 -from tests.snappi_tests.ecn.files.helper import run_ecn_test, is_ecn_marked +from files.helper import run_ecn_test, is_ecn_marked pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py b/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py index 3a23ef739c..7a33ab26bf 100644 --- a/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py +++ b/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py @@ -8,7 +8,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 -from tests.snappi_tests.ecn.files.helper import run_ecn_test, is_ecn_marked +from files.helper import run_ecn_test, is_ecn_marked pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py index de0675469f..fdb2869379 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api, snappi_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.lacp.files.lacp_dut_helper import run_lacp_add_remove_link_from_dut +from .files.lacp_dut_helper import run_lacp_add_remove_link_from_dut from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/lacp/test_add_remove_link_physically.py b/tests/snappi_tests/lacp/test_add_remove_link_physically.py index 0683f79149..e4084a2051 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_physically.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_physically.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.lacp.files.lacp_physical_helper import run_lacp_add_remove_link_physically +from .files.lacp_physical_helper import run_lacp_add_remove_link_physically from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/lacp/test_lacp_timers_effect.py b/tests/snappi_tests/lacp/test_lacp_timers_effect.py index 8acc81543a..8e48346d75 100644 --- a/tests/snappi_tests/lacp/test_lacp_timers_effect.py +++ b/tests/snappi_tests/lacp/test_lacp_timers_effect.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from tests.snappi_tests.lacp.files.lacp_physical_helper import run_lacp_timers_effect +from .files.lacp_physical_helper import run_lacp_timers_effect from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/pfc/test_global_pause_with_snappi.py b/tests/snappi_tests/pfc/test_global_pause_with_snappi.py index 1ebdbfb691..845e057a29 100644 --- a/tests/snappi_tests/pfc/test_global_pause_with_snappi.py +++ b/tests/snappi_tests/pfc/test_global_pause_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list # noqa F401 -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from .files.helper import run_pfc_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py index a3ac7e16bb..92b6835c5b 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from .files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py index 4ec5c68d0f..fd13ebad03 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from .files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py index 36b5c540cb..3598db4776 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from .files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py b/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py index 554e84a980..869f9d88de 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py b/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py index 66573b9a88..2bb73a28f6 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.pfc.files.helper import run_pfc_test +from files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py index 07b65529d0..3893926783 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 -from tests.snappi_tests.pfcwd.files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test +from .files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py index 6bf0980077..4fbdb70b70 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py @@ -10,7 +10,7 @@ from tests.common.config_reload import config_reload from tests.common.reboot import reboot from tests.common.utilities import wait_until -from tests.snappi_tests.pfcwd.files.pfcwd_basic_helper import run_pfcwd_basic_test +from .files.pfcwd_basic_helper import run_pfcwd_basic_test from tests.snappi_tests.files.helper import skip_warm_reboot logger = logging.getLogger(__name__) diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py index c065a9e51b..dfc31af523 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py @@ -7,7 +7,7 @@ from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port,\ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map # noqa F401 -from tests.snappi_tests.pfcwd.files.pfcwd_burst_storm_helper import run_pfcwd_burst_storm_test +from .files.pfcwd_burst_storm_helper import run_pfcwd_burst_storm_test logger = logging.getLogger(__name__) diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py index 9e1c664ee6..0d13eae92b 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 -from tests.snappi_tests.pfcwd.files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test +from .files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py index 13a0ef1745..82ba487ef2 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py @@ -7,7 +7,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list # noqa F401 -from tests.snappi_tests.pfcwd.files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test +from .files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py b/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py index 1123c4dcc6..b7c6fbbce1 100644 --- a/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py +++ b/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from tests.snappi_tests.qos.files.packet_reorder_helper import run_ipip_packet_reorder_test +from files.packet_reorder_helper import run_ipip_packet_reorder_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 From 3491d009fb02fcdc09d6c339ab2f25ff260598c5 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Fri, 4 Aug 2023 00:44:54 +0000 Subject: [PATCH 04/13] [SNMP]: Add snmp test case using link local as snmpagent address Signed-off-by: Suvarna Meenakshi --- tests/snmp/test_snmp_link_local.py | 55 ++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/snmp/test_snmp_link_local.py diff --git a/tests/snmp/test_snmp_link_local.py b/tests/snmp/test_snmp_link_local.py new file mode 100644 index 0000000000..c5970936c9 --- /dev/null +++ b/tests/snmp/test_snmp_link_local.py @@ -0,0 +1,55 @@ +import pytest +from tests.common.helpers.snmp_helpers import get_snmp_facts +from tests.common import config_reload + +pytestmark = [ + pytest.mark.topology('t0', 't1', 't2', 'm0', 'mx'), + pytest.mark.device_type('vs') +] + + +@pytest.fixture(autouse=True, scope='module') +def config_reload_after_test(duthosts, + enum_rand_one_per_hwsku_frontend_hostname): + yield + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + config_reload(duthost, config_source='config_db') + + +@pytest.mark.bsl +def test_snmp_link_local_ip(duthosts, enum_rand_one_per_hwsku_frontend_hostname, + nbrhosts, tbinfo, localhost, creds_all_duts): + """ + Test SNMP query to DUT over link local IP + - Send SNMP query over link local IP from one of the BGP Neighbors + - Get SysDescr from snmpfacts + - compare result from snmp query over link local IP and snmpfacts + """ + duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] + hostip = duthost.host.options['inventory_manager'].get_host( + duthost.hostname).vars['ansible_host'] + snmp_facts = get_snmp_facts( + localhost, host=hostip, version="v2c", + community=creds_all_duts[duthost.hostname]["snmp_rocommunity"], + wait=True)['ansible_facts'] + # Get link local IP of mamangement interface + ip_cmd = 'ip addr show eth0 | grep "inet6" | grep "link"\ + | awk "{print $2}" | cut -d/ -f1' + link_local_ips = duthost.shell(ip_cmd)['stdout_lines'] + # configure link local IP in config_db + for ip in link_local_ips: + if ip.split()[1].lower().startswith('fe80'): + link_local_ip = ip.split()[1] + break + # configure link local IP in config_db + duthost.shell( + 'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"'\ + .format(link_local_ip)) + # Restart snmp service to regenerate snmpd.conf with link local IP configured in MGMT_INTERFACE + duthost.shell("systemctl restart snmp") + stdout_lines = duthost.shell("docker exec snmp snmpget -v2c -c {} {}%eth0 1.3.6.1.2.1.1.1.0"\ + .format(creds_all_duts[duthost.hostname]['snmp_rocommunity'], link_local_ip))['stdout_lines'][0] + assert "SONiC Software Version" in stdout_lines,\ + "Sysdescr not found in SNMP result from Link Local IP {}".format(link_local_ip) + assert snmp_facts['ansible_sysdescr'] in stdout_lines,\ + "Sysdescr from IP{} not matching with result from Mgmt IPv4.".format(link_local_ip) From 9316dd23deb69b0174c827739ebc72f635e642c8 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Fri, 4 Aug 2023 00:46:10 +0000 Subject: [PATCH 05/13] Add test to PR checker Signed-off-by: Suvarna Meenakshi --- .azure-pipelines/pr_test_scripts.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/pr_test_scripts.yaml b/.azure-pipelines/pr_test_scripts.yaml index da41d94ca6..4188aa26b1 100644 --- a/.azure-pipelines/pr_test_scripts.yaml +++ b/.azure-pipelines/pr_test_scripts.yaml @@ -48,6 +48,7 @@ t0: - snmp/test_snmp_cpu.py - snmp/test_snmp_default_route.py - snmp/test_snmp_interfaces.py + - snmp/test_snmp_link_local_ip.py - snmp/test_snmp_lldp.py - snmp/test_snmp_loopback.py - snmp/test_snmp_pfc_counters.py From 66cdd4d0a5c683ec8fa1f2659d3cf0a627f64f41 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Fri, 4 Aug 2023 00:48:50 +0000 Subject: [PATCH 06/13] Revert "Revert "Fix import issue of tests/snappi_tests in python3 (#9232)"" This reverts commit a12ac1e3efbf73ba759bd10df3d797d6f50e6028. --- .azure-pipelines/pytest-collect-only.yml | 2 +- tests/snappi_tests/bgp/test_bgp_convergence_performance.py | 2 +- tests/snappi_tests/bgp/test_bgp_local_link_failover.py | 2 +- tests/snappi_tests/bgp/test_bgp_remote_link_failover.py | 2 +- tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py | 2 +- tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py | 2 +- tests/snappi_tests/bgp/test_bgp_scalability.py | 3 ++- tests/snappi_tests/ecn/conftest.py | 2 +- tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py | 2 +- tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py | 2 +- tests/snappi_tests/lacp/test_add_remove_link_from_dut.py | 2 +- tests/snappi_tests/lacp/test_add_remove_link_physically.py | 2 +- tests/snappi_tests/lacp/test_lacp_timers_effect.py | 2 +- tests/snappi_tests/pfc/test_global_pause_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py | 2 +- .../snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py | 2 +- tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py | 2 +- tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py | 2 +- .../pfcwd/test_pfcwd_runtime_traffic_with_snappi.py | 2 +- tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py | 2 +- 25 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.azure-pipelines/pytest-collect-only.yml b/.azure-pipelines/pytest-collect-only.yml index 93057efdb9..6d1d2bca9e 100644 --- a/.azure-pipelines/pytest-collect-only.yml +++ b/.azure-pipelines/pytest-collect-only.yml @@ -35,7 +35,7 @@ steps: set -x sudo docker exec -t -w /var/src/sonic-mgmt/tests sonic-mgmt-collect \ - pytest --inventory ../ansible/veos_vtb --host-pattern all \ + python3 -m pytest --inventory ../ansible/veos_vtb --host-pattern all \ --testbed_file vtestbed.yaml --testbed vms-kvm-t0 \ --ignore saitests --ignore ptftests --ignore acstests \ --ignore scripts --ignore k8s --ignore sai_qualify --ignore common \ diff --git a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py index 45502f6831..fa7ecdde38 100644 --- a/tests/snappi_tests/bgp/test_bgp_convergence_performance.py +++ b/tests/snappi_tests/bgp/test_bgp_convergence_performance.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_test_gap_helper import run_bgp_convergence_performance +from tests.snappi_tests.bgp.files.bgp_test_gap_helper import run_bgp_convergence_performance from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py index 354d277da9..02cd88ede7 100644 --- a/tests/snappi_tests/bgp/test_bgp_local_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_local_link_failover.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_convergence_helper import run_bgp_local_link_failover_test +from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_bgp_local_link_failover_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py index afc53dc564..215021647c 100755 --- a/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py +++ b/tests/snappi_tests/bgp/test_bgp_remote_link_failover.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_convergence_helper import run_bgp_remote_link_failover_test +from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_bgp_remote_link_failover_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py index e2c64acbbf..f58686f577 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_capacity.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_convergence_helper import run_RIB_IN_capacity_test +from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_RIB_IN_capacity_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py index 30f19cb72a..afed29098b 100644 --- a/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py +++ b/tests/snappi_tests/bgp/test_bgp_rib_in_convergence.py @@ -1,6 +1,6 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_convergence_helper import run_rib_in_convergence_test +from tests.snappi_tests.bgp.files.bgp_convergence_helper import run_rib_in_convergence_test from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/bgp/test_bgp_scalability.py b/tests/snappi_tests/bgp/test_bgp_scalability.py index 08c672ccb6..e95847d589 100644 --- a/tests/snappi_tests/bgp/test_bgp_scalability.py +++ b/tests/snappi_tests/bgp/test_bgp_scalability.py @@ -1,6 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 cvg_api, snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.bgp_test_gap_helper import duthost_bgp_scalability_config, run_bgp_scalability_v4_v6, cleanup_config +from tests.snappi_tests.bgp.files.bgp_test_gap_helper import duthost_bgp_scalability_config, \ + run_bgp_scalability_v4_v6, cleanup_config from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/ecn/conftest.py b/tests/snappi_tests/ecn/conftest.py index 9d0187b683..89a4b1a74d 100644 --- a/tests/snappi_tests/ecn/conftest.py +++ b/tests/snappi_tests/ecn/conftest.py @@ -1,4 +1,4 @@ -from ecn_args.ecn_args import add_ecn_args +from tests.snappi_tests.ecn.ecn_args.ecn_args import add_ecn_args def pytest_addoption(parser): diff --git a/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py b/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py index 2eb96f2da8..1048a0eacc 100644 --- a/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py +++ b/tests/snappi_tests/ecn/test_dequeue_ecn_with_snappi.py @@ -7,7 +7,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 -from files.helper import run_ecn_test, is_ecn_marked +from tests.snappi_tests.ecn.files.helper import run_ecn_test, is_ecn_marked pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py b/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py index 7a33ab26bf..3a23ef739c 100644 --- a/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py +++ b/tests/snappi_tests/ecn/test_red_accuracy_with_snappi.py @@ -8,7 +8,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, lossless_prio_list # noqa F401 -from files.helper import run_ecn_test, is_ecn_marked +from tests.snappi_tests.ecn.files.helper import run_ecn_test, is_ecn_marked pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py index fdb2869379..de0675469f 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_from_dut.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api, snappi_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.lacp_dut_helper import run_lacp_add_remove_link_from_dut +from tests.snappi_tests.lacp.files.lacp_dut_helper import run_lacp_add_remove_link_from_dut from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/lacp/test_add_remove_link_physically.py b/tests/snappi_tests/lacp/test_add_remove_link_physically.py index e4084a2051..0683f79149 100755 --- a/tests/snappi_tests/lacp/test_add_remove_link_physically.py +++ b/tests/snappi_tests/lacp/test_add_remove_link_physically.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.lacp_physical_helper import run_lacp_add_remove_link_physically +from tests.snappi_tests.lacp.files.lacp_physical_helper import run_lacp_add_remove_link_physically from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/lacp/test_lacp_timers_effect.py b/tests/snappi_tests/lacp/test_lacp_timers_effect.py index 8e48346d75..8acc81543a 100644 --- a/tests/snappi_tests/lacp/test_lacp_timers_effect.py +++ b/tests/snappi_tests/lacp/test_lacp_timers_effect.py @@ -1,7 +1,7 @@ from tests.common.snappi_tests.snappi_fixtures import cvg_api # noqa F401 from tests.common.snappi_tests.snappi_fixtures import ( # noqa F401 snappi_api_serv_ip, snappi_api_serv_port, tgen_ports) -from .files.lacp_physical_helper import run_lacp_timers_effect +from tests.snappi_tests.lacp.files.lacp_physical_helper import run_lacp_timers_effect from tests.common.fixtures.conn_graph_facts import ( # noqa F401 conn_graph_facts, fanout_graph_facts) import pytest diff --git a/tests/snappi_tests/pfc/test_global_pause_with_snappi.py b/tests/snappi_tests/pfc/test_global_pause_with_snappi.py index 845e057a29..1ebdbfb691 100644 --- a/tests/snappi_tests/pfc/test_global_pause_with_snappi.py +++ b/tests/snappi_tests/pfc/test_global_pause_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list, lossless_prio_list,\ lossy_prio_list # noqa F401 -from .files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py index 92b6835c5b..a3ac7e16bb 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_lossless_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from .files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py index fd13ebad03..4ec5c68d0f 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_lossy_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from .files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_assert, pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py b/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py index 3598db4776..36b5c540cb 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_response_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from .files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py b/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py index 869f9d88de..554e84a980 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_unset_bit_enable_vector.py @@ -1,7 +1,7 @@ import logging import pytest -from files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py b/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py index 2bb73a28f6..66573b9a88 100644 --- a/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py +++ b/tests/snappi_tests/pfc/test_pfc_pause_zero_mac.py @@ -1,7 +1,7 @@ import logging import pytest -from files.helper import run_pfc_test +from tests.snappi_tests.pfc.files.helper import run_pfc_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py index 3893926783..07b65529d0 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_a2a_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 -from .files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test +from tests.snappi_tests.pfcwd.files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py index 4fbdb70b70..6bf0980077 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_basic_with_snappi.py @@ -10,7 +10,7 @@ from tests.common.config_reload import config_reload from tests.common.reboot import reboot from tests.common.utilities import wait_until -from .files.pfcwd_basic_helper import run_pfcwd_basic_test +from tests.snappi_tests.pfcwd.files.pfcwd_basic_helper import run_pfcwd_basic_test from tests.snappi_tests.files.helper import skip_warm_reboot logger = logging.getLogger(__name__) diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py index dfc31af523..c065a9e51b 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_burst_storm_with_snappi.py @@ -7,7 +7,7 @@ from tests.common.snappi_tests.snappi_fixtures import snappi_api_serv_ip, snappi_api_serv_port,\ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map # noqa F401 -from .files.pfcwd_burst_storm_helper import run_pfcwd_burst_storm_test +from tests.snappi_tests.pfcwd.files.pfcwd_burst_storm_helper import run_pfcwd_burst_storm_test logger = logging.getLogger(__name__) diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py index 0d13eae92b..9e1c664ee6 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_m2o_with_snappi.py @@ -8,7 +8,7 @@ from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list,\ lossless_prio_list, lossy_prio_list # noqa F401 -from .files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test +from tests.snappi_tests.pfcwd.files.pfcwd_multi_node_helper import run_pfcwd_multi_node_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py b/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py index 82ba487ef2..13a0ef1745 100644 --- a/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py +++ b/tests/snappi_tests/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py @@ -7,7 +7,7 @@ snappi_api, snappi_testbed_config # noqa F401 from tests.common.snappi_tests.qos_fixtures import prio_dscp_map, all_prio_list # noqa F401 -from .files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test +from tests.snappi_tests.pfcwd.files.pfcwd_runtime_traffic_helper import run_pfcwd_runtime_traffic_test pytestmark = [pytest.mark.topology('tgen')] diff --git a/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py b/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py index b7c6fbbce1..1123c4dcc6 100644 --- a/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py +++ b/tests/snappi_tests/qos/test_ipip_packet_reorder_with_snappi.py @@ -1,7 +1,7 @@ import logging import pytest -from files.packet_reorder_helper import run_ipip_packet_reorder_test +from tests.snappi_tests.qos.files.packet_reorder_helper import run_ipip_packet_reorder_test from tests.common.helpers.assertions import pytest_require from tests.common.fixtures.conn_graph_facts import conn_graph_facts,\ fanout_graph_facts # noqa F401 From 878fa97945a988702a1e90b367817414fdbb7cdf Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Fri, 4 Aug 2023 00:48:58 +0000 Subject: [PATCH 07/13] Revert "Revert "[tests/crm] Fix python3 syntax error in `test_acl_entry` (#9208)"" This reverts commit 6ceebe465eaad328408dbfd1813882078113b994. --- tests/crm/test_crm.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/crm/test_crm.py b/tests/crm/test_crm.py index 56c8094002..8c63c54bf5 100755 --- a/tests/crm/test_crm.py +++ b/tests/crm/test_crm.py @@ -910,8 +910,7 @@ def test_acl_entry(duthosts, enum_rand_one_per_hwsku_frontend_hostname, enum_fro if duthost.facts["asic_type"] == "marvell": # Remove DATA ACL Table and add it again with ports in same port group mg_facts = duthost.get_extended_minigraph_facts(tbinfo) - tmp_ports = mg_facts["minigraph_ports"].keys() - tmp_ports.sort(key=lambda x: int(x[8:])) + tmp_ports = sorted(mg_facts["minigraph_ports"], key=lambda x: int(x[8:])) for i in range(4): if i == 0: ports = ",".join(tmp_ports[17:19]) From de9a1668783f059d9b1a8485d9bb078405627ee5 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Fri, 4 Aug 2023 00:49:22 +0000 Subject: [PATCH 08/13] Revert "Revert "Change run_tests.sh to use python3 unconditionally (#8988)"" This reverts commit d51c9a6d5056e8c5670bdadcd08b798e0423f04c. --- tests/python3_test_files.txt | 357 +---------------------------------- tests/run_tests.sh | 46 ++--- 2 files changed, 17 insertions(+), 386 deletions(-) diff --git a/tests/python3_test_files.txt b/tests/python3_test_files.txt index 04c7a3e8c5..0702cb5bfb 100644 --- a/tests/python3_test_files.txt +++ b/tests/python3_test_files.txt @@ -1,356 +1 @@ -acl/custom_acl_table/test_custom_acl_table.py -acl/null_route/test_null_route_helper.py -acl/test_acl.py -acl/test_acl_outer_vlan.py -acl/test_stress_acl.py -arp/test_arp_dualtor.py -arp/test_arp_extended.py -arp/test_arpall.py -arp/test_neighbor_mac.py -arp/test_neighbor_mac_noptf.py -arp/test_stress_arp.py -arp/test_tagged_arp.py -arp/test_unknown_mac.py -arp/test_wr_arp.py -autorestart/test_container_autorestart.py -bfd/test_bfd.py -bgp/test_bgp_allow_list.py -bgp/test_bgp_bbr.py -bgp/test_bgp_bounce.py -bgp/test_bgp_dual_asn.py -bgp/test_bgp_fact.py -bgp/test_bgp_gr_helper.py -bgp/test_bgp_multipath_relax.py -bgp/test_bgp_session_flap.py -bgp/test_bgp_slb.py -bgp/test_bgp_speaker.py -bgp/test_bgp_update_timer.py -bgp/test_bgpmon.py -bgp/test_traffic_shift.py -cacl/test_cacl_application.py -cacl/test_cacl_function.py -cacl/test_ebtables_application.py -configlet/test_add_rack.py -console/test_console_availability.py -console/test_console_driver.py -console/test_console_loopback.py -console/test_console_reversessh.py -console/test_console_udevrule.py -container_checker/test_container_checker.py -container_hardening/test_container_hardening.py -copp/test_copp.py -crm/test_crm.py -dash/test_dash_vnet.py -decap/test_decap.py -dhcp_relay/test_dhcp_pkt_fwd.py -dhcp_relay/test_dhcp_relay.py -dhcp_relay/test_dhcpv6_relay.py -disk/test_disk_exhaustion.py -dns/test_dns_resolv_conf.py -drop_packets/test_configurable_drop_counters.py -drop_packets/test_drop_counters.py -dualtor/test_ipinip.py -dualtor/test_orch_stress.py -dualtor/test_orchagent_active_tor_downstream.py -dualtor/test_orchagent_mac_move.py -dualtor/test_orchagent_slb.py -dualtor/test_orchagent_standby_tor_downstream.py -dualtor/test_standby_tor_upstream_mux_toggle.py -dualtor/test_tor_ecn.py -dualtor/test_tunnel_memory_leak.py -dualtor_io/test_grpc_server_failure.py -dualtor_io/test_heartbeat_failure.py -dualtor_io/test_link_drop.py -dualtor_io/test_link_failure.py -dualtor_io/test_normal_op.py -dualtor_io/test_tor_bgp_failure.py -dualtor_io/test_tor_failure.py -dualtor_mgmt/test_dualtor_bgp_update_delay.py -dualtor_mgmt/test_grpc_periodical_sync.py -dualtor_mgmt/test_ingress_drop.py -dualtor_mgmt/test_server_failure.py -dualtor_mgmt/test_toggle_mux.py -dut_console/test_console_baud_rate.py -dut_console/test_escape_character.py -dut_console/test_idle_timeout.py -ecmp/inner_hashing/test_inner_hashing.py -ecmp/inner_hashing/test_inner_hashing_lag.py -ecmp/inner_hashing/test_wr_inner_hashing.py -ecmp/inner_hashing/test_wr_inner_hashing_lag.py -ecmp/test_fgnhg.py -everflow/test_everflow_ipv6.py -everflow/test_everflow_per_interface.py -everflow/test_everflow_testbed.py -fdb/test_fdb.py -fdb/test_fdb_flush.py -fdb/test_fdb_mac_expire.py -fdb/test_fdb_mac_move.py -fib/test_fib.py -generic_config_updater/test_aaa.py -generic_config_updater/test_bgp_prefix.py -generic_config_updater/test_bgp_speaker.py -generic_config_updater/test_bgpl.py -generic_config_updater/test_cacl.py -generic_config_updater/test_dhcp_relay.py -generic_config_updater/test_eth_interface.py -generic_config_updater/test_incremental_qos.py -generic_config_updater/test_ipv6.py -generic_config_updater/test_lo_interface.py -generic_config_updater/test_mmu_dynamic_threshold_config_update.py -generic_config_updater/test_monitor_config.py -generic_config_updater/test_ntp.py -generic_config_updater/test_pfcwd_interval.py -generic_config_updater/test_portchannel_interface.py -generic_config_updater/test_syslog.py -generic_config_updater/test_vlan_interface.py -gnmi/test_gnmi.py -gnmi/test_gnmi_appldb.py -gnmi/test_gnmi_configdb.py -http/test_http_copy.py -iface_loopback_action/test_iface_loopback_action.py -iface_namingmode/test_iface_namingmode.py -ip/test_ip_packet.py -ipfwd/test_dip_sip.py -ipfwd/test_dir_bcast.py -ipfwd/test_mtu.py -ipfwd/test_nhop_group.py -ixia/ecn/test_dequeue_ecn.py -ixia/ecn/test_red_accuracy.py -ixia/ixanvl/test_bgp_conformance.py -ixia/pfc/test_global_pause.py -ixia/pfc/test_pfc_congestion.py -ixia/pfc/test_pfc_pause_lossless.py -ixia/pfc/test_pfc_pause_lossy.py -ixia/pfcwd/test_pfcwd_a2a.py -ixia/pfcwd/test_pfcwd_basic.py -ixia/pfcwd/test_pfcwd_burst_storm.py -ixia/pfcwd/test_pfcwd_m2o.py -ixia/pfcwd/test_pfcwd_runtime_traffic.py -ixia/test_ixia_traffic.py -ixia/test_tgen.py -k8s/test_config_reload.py -k8s/test_disable_flag.py -k8s/test_join_available_master.py -lldp/test_lldp.py -log_fidelity/test_bgp_shutdown.py -macsec/test_controlplane.py -macsec/test_dataplane.py -macsec/test_deployment.py -macsec/test_fault_handling.py -macsec/test_interop_protocol.py -macsec/test_interop_wan_isis.py -mclag/test_mclag_l3.py -memory_checker/test_memory_checker.py -monit/test_monit_status.py -mpls/test_mpls.py -mvrf/test_mgmtvrf.py -nat/test_dynamic_nat.py -nat/test_static_nat.py -ntp/test_ntp.py -override_config_table/test_override_config_table.py -passw_hardening/test_passw_hardening.py -pc/test_lag_2.py -pc/test_lag_member.py -pc/test_po_cleanup.py -pc/test_po_update.py -pc/test_po_voq.py -pfc_asym/test_pfc_asym.py -pfcwd/test_pfc_config.py -pfcwd/test_pfcwd_all_port_storm.py -pfcwd/test_pfcwd_function.py -pfcwd/test_pfcwd_timer_accuracy.py -pfcwd/test_pfcwd_warm_reboot.py -platform_tests/api/test_chassis.py -platform_tests/api/test_chassis_fans.py -platform_tests/api/test_component.py -platform_tests/api/test_fan_drawer.py -platform_tests/api/test_fan_drawer_fans.py -platform_tests/api/test_module.py -platform_tests/api/test_psu.py -platform_tests/api/test_psu_fans.py -platform_tests/api/test_sfp.py -platform_tests/api/test_thermal.py -platform_tests/api/test_watchdog.py -platform_tests/broadcom/test_ser.py -platform_tests/cli/test_show_chassis_module.py -platform_tests/cli/test_show_platform.py -platform_tests/counterpoll/test_counterpoll_watermark.py -platform_tests/daemon/test_chassisd.py -platform_tests/daemon/test_fancontrol.py -platform_tests/daemon/test_ledd.py -platform_tests/daemon/test_pcied.py -platform_tests/daemon/test_psud.py -platform_tests/daemon/test_syseepromd.py -platform_tests/fwutil/test_fwutil.py -platform_tests/link_flap/test_cont_link_flap.py -platform_tests/link_flap/test_link_flap.py -platform_tests/mellanox/test_check_sfp_eeprom.py -platform_tests/mellanox/test_check_sfp_presence.py -platform_tests/mellanox/test_check_sfp_using_ethtool.py -platform_tests/mellanox/test_check_sysfs.py -platform_tests/mellanox/test_hw_management_service.py -platform_tests/mellanox/test_psu_power_threshold.py -platform_tests/mellanox/test_reboot_cause.py -platform_tests/mellanox/test_thermal_control.py -platform_tests/sfp/test_sfpshow.py -platform_tests/sfp/test_sfputil.py -platform_tests/sfp/test_show_intf_xcvr.py -platform_tests/test_advanced_reboot.py -platform_tests/test_auto_negotiation.py -platform_tests/test_cont_warm_reboot.py -platform_tests/test_cpu_memory_usage.py -platform_tests/test_first_time_boot_password_change/test_first_time_boot_password_change.py -platform_tests/test_link_down.py -platform_tests/test_memory_exhaustion.py -platform_tests/test_platform_info.py -platform_tests/test_port_toggle.py -platform_tests/test_power_budget_info.py -platform_tests/test_reboot.py -platform_tests/test_reload_config.py -platform_tests/test_sensors.py -platform_tests/test_sequential_restart.py -platform_tests/test_service_warm_restart.py -platform_tests/test_thermal_state_db.py -platform_tests/test_xcvr_info_in_db.py -portstat/test_portstat.py -process_monitoring/test_critical_process_monitoring.py -qos/test_buffer.py -qos/test_buffer_traditional.py -qos/test_pfc_counters.py -qos/test_pfc_pause.py -qos/test_qos_masic.py -qos/test_qos_sai.py -qos/test_tunnel_qos_remap.py -radv/test_radv_ipv6_ra.py -radv/test_radv_restart.py -read_mac/test_read_mac_metadata.py -restapi/test_restapi.py -restapi/test_restapi_vxlan_ecmp.py -route/test_default_route.py -route/test_route_flap.py -route/test_route_flow_counter.py -route/test_route_perf.py -route/test_static_route.py -sai_qualify/test_brcm_t0.py -sai_qualify/test_community.py -sai_qualify/test_sai_ptf.py -sai_qualify/test_sai_ptf_warm_reboot.py -sai_qualify/test_sai_t0_warm_reboot.py -scp/test_scp_copy.py -sflow/test_sflow.py -show_techsupport/test_auto_techsupport.py -show_techsupport/test_techsupport.py -show_techsupport/test_techsupport_no_secret.py -snappi/bgp/test_bgp_convergence_performance.py -snappi/bgp/test_bgp_local_link_failover.py -snappi/bgp/test_bgp_remote_link_failover.py -snappi/bgp/test_bgp_rib_in_capacity.py -snappi/bgp/test_bgp_rib_in_convergence.py -snappi/bgp/test_bgp_scalability.py -snappi/ecn/test_dequeue_ecn_with_snappi.py -snappi/ecn/test_red_accuracy_with_snappi.py -snappi/lacp/test_add_remove_link_from_dut.py -snappi/lacp/test_add_remove_link_physically.py -snappi/lacp/test_lacp_timers_effect.py -snappi/pfc/test_global_pause_with_snappi.py -snappi/pfc/test_pfc_pause_lossless_with_snappi.py -snappi/pfc/test_pfc_pause_lossy_with_snappi.py -snappi/pfc/test_pfc_pause_response_with_snappi.py -snappi/pfcwd/test_pfcwd_a2a_with_snappi.py -snappi/pfcwd/test_pfcwd_basic_with_snappi.py -snappi/pfcwd/test_pfcwd_burst_storm_with_snappi.py -snappi/pfcwd/test_pfcwd_m2o_with_snappi.py -snappi/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py -snappi/reboot/test_cold_reboot.py -snappi/reboot/test_fast_reboot.py -snappi/reboot/test_soft_reboot.py -snappi/reboot/test_warm_reboot.py -snappi/test_snappi.py -snmp/test_snmp_cpu.py -snmp/test_snmp_default_route.py -snmp/test_snmp_fdb.py -snmp/test_snmp_interfaces.py -snmp/test_snmp_lldp.py -snmp/test_snmp_loopback.py -snmp/test_snmp_memory.py -snmp/test_snmp_pfc_counters.py -snmp/test_snmp_phy_entity.py -snmp/test_snmp_psu.py -snmp/test_snmp_queue.py -snmp/test_snmp_v2mib.py -span/test_port_mirroring.py -ssh/test_ssh_ciphers.py -ssh/test_ssh_default_password.py -ssh/test_ssh_limit.py -ssh/test_ssh_stress.py -stress/test_stress_routes.py -sub_port_interfaces/test_show_subinterface.py -sub_port_interfaces/test_sub_port_interfaces.py -sub_port_interfaces/test_sub_port_l2_forwarding.py -syslog/test_logrotate.py -syslog/test_syslog.py -syslog/test_syslog_rate_limit.py -syslog/test_syslog_source_ip.py -system_health/test_system_health.py -system_health/test_system_status.py -tacacs/test_accounting.py -tacacs/test_authorization.py -tacacs/test_jit_user.py -tacacs/test_ro_disk.py -tacacs/test_ro_user.py -tacacs/test_rw_user.py -telemetry/test_events.py -telemetry/test_telemetry.py -test_features.py -test_interfaces.py -test_nbr_health.py -test_posttest.py -test_pretest.py -test_procdockerstatsd.py -test_vs_chassis_setup.py -testbed_setup/test_add_property_spytest_junit_xml.py -testbed_setup/test_gen_spy_testbed.py -testbed_setup/test_populate_fdb.py -upgrade_path/test_upgrade_path.py -vlan/test_autostate_disabled.py -vlan/test_host_vlan.py -vlan/test_vlan.py -vlan/test_vlan_ping.py -voq/test_voq_disrupts.py -voq/test_voq_init.py -voq/test_voq_intfs.py -voq/test_voq_ipfwd.py -voq/test_voq_nbr.py -vrf/test_vrf.py -vrf/test_vrf_attr.py -vxlan/test_vnet_route_leak.py -vxlan/test_vnet_vxlan.py -vxlan/test_vxlan_crm.py -vxlan/test_vxlan_decap.py -vxlan/test_vxlan_ecmp.py -wan/isis/test_isis_authentication.py -wan/isis/test_isis_csnp_interval.py -wan/isis/test_isis_database.py -wan/isis/test_isis_dynamic_hostname.py -wan/isis/test_isis_ecmp.py -wan/isis/test_isis_hello_interval.py -wan/isis/test_isis_hello_pad.py -wan/isis/test_isis_holdtime.py -wan/isis/test_isis_intf_passive.py -wan/isis/test_isis_level_capacity.py -wan/isis/test_isis_log_adjacency_change.py -wan/isis/test_isis_lsp_fragment.py -wan/isis/test_isis_lsp_gen_interval.py -wan/isis/test_isis_lsp_lifetime.py -wan/isis/test_isis_lsp_refresh.py -wan/isis/test_isis_metric_wide.py -wan/isis/test_isis_neighbor.py -wan/isis/test_isis_overload_bit.py -wan/isis/test_isis_redistribute.py -wan/isis/test_isis_spf_default_interval.py -wan/isis/test_isis_spf_ietf_interval.py -wan/lacp/test_wan_lacp.py -wan/lacp/test_wan_lag_member.py -wan/lacp/test_wan_lag_min_link.py -wan/lldp/test_wan_lldp.py -wan/traffic_test/test_traffic.py +all diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 976f4a5ceb..f3cc2cdd31 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -45,14 +45,14 @@ function get_dut_from_testbed_file() { DUT_NAME=${ARRAY[9]//[\[\] ]/} elif [[ $TESTBED_FILE == *.yaml ]]; then - content=$(python -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") + content=$(python3 -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") if [[ -z ${content} ]]; then echo "Unable to find testbed '$TESTBED_NAME' in testbed file '$TESTBED_FILE'" show_help_and_exit 4 fi IFS=$'+' read -r -a tb_lines <<< $content tb_line=${tb_lines[0]} - DUT_NAME=$(python -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") + DUT_NAME=$(python3 -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") fi fi } @@ -130,7 +130,7 @@ function setup_test_options() # for the scenario of specifying test scripts using pattern like `subfolder/test_*.py`. The pattern will be # expanded to matched test scripts by bash. Among the expanded scripts, we may want to skip a few. Then we can # explicitly specify the script to be skipped. - ignores=$(python -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") + ignores=$(python3 -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") if [[ -z ${TEST_CASES} ]]; then # When TEST_CASES is not specified, find all the possible scripts, ignore the scripts under $SKIP_FOLDERS all_scripts=$(find ./ -name 'test_*.py' | sed s:^./:: | grep -vE "^(${ignores})") @@ -143,18 +143,18 @@ function setup_test_options() fi # Ignore the scripts specified in $SKIP_SCRIPTS if [[ x"${TEST_INPUT_ORDER}" == x"True" ]]; then - TEST_CASES=$(python -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") + TEST_CASES=$(python3 -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") else - TEST_CASES=$(python -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) + TEST_CASES=$(python3 -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) fi # Check against $INCLUDE_FOLDERS, filter out test cases not in the specified folders FINAL_CASES="" - includes=$(python -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") + includes=$(python3 -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") for test_case in ${TEST_CASES}; do FINAL_CASES="${FINAL_CASES} $(echo ${test_case} | grep -E "^(${includes})")" done - TEST_CASES=$(python -c "print('\n'.join('''${FINAL_CASES}'''.split()))") + TEST_CASES=$(python3 -c "print('\n'.join('''${FINAL_CASES}'''.split()))") if [[ -z $TEST_CASES ]]; then echo "No test case to run based on conditions of '-c', '-I' and '-S'. Please check..." @@ -264,22 +264,22 @@ function pre_post_extra_params() function prepare_dut() { echo "=== Preparing DUT for subsequent tests ===" - echo Running: pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest - pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest } function cleanup_dut() { echo "=== Cleaning up DUT after tests ===" - echo Running: pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest - pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest } function run_group_tests() { echo "=== Running tests in groups ===" - echo Running: pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear + echo Running: python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear } function run_individual_tests() @@ -300,23 +300,9 @@ function run_individual_tests() TEST_LOGGING_OPTIONS="--log-file ${LOG_PATH}/${test_dir}/${test_name}.log --junitxml=${LOG_PATH}/${test_dir}/${test_name}.xml" fi - echo Running: pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - USE_PY3=0 - for i in `cat python3_test_files.txt` - do - USE_PY3=`expr match ${test_script} ${i}` - [[ ${USE_PY3} != 0 ]] && break - done - if [ ${USE_PY3} != 0 ]; then - echo Activate Python3 venv - source /var/AzDevOps/env-python3/bin/activate - fi - pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} - ret_code=$? - if [ ${USE_PY3} != 0 ]; then - echo Deactivate Python3 venv - deactivate - fi + echo Running: python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} + ret_code=$? # Clear pytest cache for the first run if [[ -n ${CACHE_CLEAR} ]]; then From 2e9ecf96c410e61a0f65b32e227bd8a21e920ebe Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Mon, 7 Aug 2023 23:23:17 +0000 Subject: [PATCH 09/13] Fix flake8 errors Signed-off-by: Suvarna Meenakshi --- tests/snmp/test_snmp_link_local.py | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/snmp/test_snmp_link_local.py b/tests/snmp/test_snmp_link_local.py index c5970936c9..16b6514b0e 100644 --- a/tests/snmp/test_snmp_link_local.py +++ b/tests/snmp/test_snmp_link_local.py @@ -10,15 +10,16 @@ @pytest.fixture(autouse=True, scope='module') def config_reload_after_test(duthosts, - enum_rand_one_per_hwsku_frontend_hostname): + enum_rand_one_per_hwsku_frontend_hostname): yield duthost = duthosts[enum_rand_one_per_hwsku_frontend_hostname] config_reload(duthost, config_source='config_db') @pytest.mark.bsl -def test_snmp_link_local_ip(duthosts, enum_rand_one_per_hwsku_frontend_hostname, - nbrhosts, tbinfo, localhost, creds_all_duts): +def test_snmp_link_local_ip(duthosts, + enum_rand_one_per_hwsku_frontend_hostname, + nbrhosts, tbinfo, localhost, creds_all_duts): """ Test SNMP query to DUT over link local IP - Send SNMP query over link local IP from one of the BGP Neighbors @@ -43,13 +44,19 @@ def test_snmp_link_local_ip(duthosts, enum_rand_one_per_hwsku_frontend_hostname, break # configure link local IP in config_db duthost.shell( - 'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"'\ + 'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"' .format(link_local_ip)) - # Restart snmp service to regenerate snmpd.conf with link local IP configured in MGMT_INTERFACE + # Restart snmp service to regenerate snmpd.conf with + # link local IP configured in MGMT_INTERFACE duthost.shell("systemctl restart snmp") - stdout_lines = duthost.shell("docker exec snmp snmpget -v2c -c {} {}%eth0 1.3.6.1.2.1.1.1.0"\ - .format(creds_all_duts[duthost.hostname]['snmp_rocommunity'], link_local_ip))['stdout_lines'][0] + stdout_lines = duthost.shell("docker exec snmp snmpget \ + -v2c -c {} {}%eth0 1.3.6.1.2.1.1.1.0" + .format(creds_all_duts[duthost.hostname] + ['snmp_rocommunity'], + link_local_ip))['stdout_lines'][0] assert "SONiC Software Version" in stdout_lines,\ - "Sysdescr not found in SNMP result from Link Local IP {}".format(link_local_ip) + "Sysdescr not found in SNMP result from Link Local IP {}".format( + link_local_ip) assert snmp_facts['ansible_sysdescr'] in stdout_lines,\ - "Sysdescr from IP{} not matching with result from Mgmt IPv4.".format(link_local_ip) + "Sysdescr from IP{} not matching with result from Mgmt IPv4.".format( + link_local_ip) From dd256cd5a2b1abc3d401b2bd8e666446a70489d1 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Tue, 8 Aug 2023 00:35:08 +0000 Subject: [PATCH 10/13] Fix as per review comments Signed-off-by: Suvarna Meenakshi --- tests/snmp/test_snmp_link_local.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/snmp/test_snmp_link_local.py b/tests/snmp/test_snmp_link_local.py index 16b6514b0e..8f1d275952 100644 --- a/tests/snmp/test_snmp_link_local.py +++ b/tests/snmp/test_snmp_link_local.py @@ -37,6 +37,7 @@ def test_snmp_link_local_ip(duthosts, ip_cmd = 'ip addr show eth0 | grep "inet6" | grep "link"\ | awk "{print $2}" | cut -d/ -f1' link_local_ips = duthost.shell(ip_cmd)['stdout_lines'] + sysdescr_oid = '1.3.6.1.2.1.1.1.0' # configure link local IP in config_db for ip in link_local_ips: if ip.split()[1].lower().startswith('fe80'): @@ -44,16 +45,18 @@ def test_snmp_link_local_ip(duthosts, break # configure link local IP in config_db duthost.shell( - 'redis-cli -n 4 hset "MGMT_INTERFACE|eth0|{}" "gwaddr" "fe80::1"' + 'sonic-db-cli CONFIG_DB hset "MGMT_INTERFACE|eth0|{}" \ + "gwaddr" "fe80::1"' .format(link_local_ip)) # Restart snmp service to regenerate snmpd.conf with # link local IP configured in MGMT_INTERFACE duthost.shell("systemctl restart snmp") stdout_lines = duthost.shell("docker exec snmp snmpget \ - -v2c -c {} {}%eth0 1.3.6.1.2.1.1.1.0" + -v2c -c {} {}%eth0 {}" .format(creds_all_duts[duthost.hostname] ['snmp_rocommunity'], - link_local_ip))['stdout_lines'][0] + link_local_ip, + sysdescr_oid))['stdout_lines'][0] assert "SONiC Software Version" in stdout_lines,\ "Sysdescr not found in SNMP result from Link Local IP {}".format( link_local_ip) From 87ad5dbde3f118b7e4a59d60e6b8bc906326b818 Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Tue, 8 Aug 2023 00:38:42 +0000 Subject: [PATCH 11/13] Revert "Change run_tests.sh to use python3 unconditionally (#8988)" This reverts commit d88236c0881b697bd64ef2686c6293d251509f6a. --- tests/python3_test_files.txt | 357 ++++++++++++++++++++++++++++++++++- tests/run_tests.sh | 46 +++-- 2 files changed, 386 insertions(+), 17 deletions(-) diff --git a/tests/python3_test_files.txt b/tests/python3_test_files.txt index 0702cb5bfb..04c7a3e8c5 100644 --- a/tests/python3_test_files.txt +++ b/tests/python3_test_files.txt @@ -1 +1,356 @@ -all +acl/custom_acl_table/test_custom_acl_table.py +acl/null_route/test_null_route_helper.py +acl/test_acl.py +acl/test_acl_outer_vlan.py +acl/test_stress_acl.py +arp/test_arp_dualtor.py +arp/test_arp_extended.py +arp/test_arpall.py +arp/test_neighbor_mac.py +arp/test_neighbor_mac_noptf.py +arp/test_stress_arp.py +arp/test_tagged_arp.py +arp/test_unknown_mac.py +arp/test_wr_arp.py +autorestart/test_container_autorestart.py +bfd/test_bfd.py +bgp/test_bgp_allow_list.py +bgp/test_bgp_bbr.py +bgp/test_bgp_bounce.py +bgp/test_bgp_dual_asn.py +bgp/test_bgp_fact.py +bgp/test_bgp_gr_helper.py +bgp/test_bgp_multipath_relax.py +bgp/test_bgp_session_flap.py +bgp/test_bgp_slb.py +bgp/test_bgp_speaker.py +bgp/test_bgp_update_timer.py +bgp/test_bgpmon.py +bgp/test_traffic_shift.py +cacl/test_cacl_application.py +cacl/test_cacl_function.py +cacl/test_ebtables_application.py +configlet/test_add_rack.py +console/test_console_availability.py +console/test_console_driver.py +console/test_console_loopback.py +console/test_console_reversessh.py +console/test_console_udevrule.py +container_checker/test_container_checker.py +container_hardening/test_container_hardening.py +copp/test_copp.py +crm/test_crm.py +dash/test_dash_vnet.py +decap/test_decap.py +dhcp_relay/test_dhcp_pkt_fwd.py +dhcp_relay/test_dhcp_relay.py +dhcp_relay/test_dhcpv6_relay.py +disk/test_disk_exhaustion.py +dns/test_dns_resolv_conf.py +drop_packets/test_configurable_drop_counters.py +drop_packets/test_drop_counters.py +dualtor/test_ipinip.py +dualtor/test_orch_stress.py +dualtor/test_orchagent_active_tor_downstream.py +dualtor/test_orchagent_mac_move.py +dualtor/test_orchagent_slb.py +dualtor/test_orchagent_standby_tor_downstream.py +dualtor/test_standby_tor_upstream_mux_toggle.py +dualtor/test_tor_ecn.py +dualtor/test_tunnel_memory_leak.py +dualtor_io/test_grpc_server_failure.py +dualtor_io/test_heartbeat_failure.py +dualtor_io/test_link_drop.py +dualtor_io/test_link_failure.py +dualtor_io/test_normal_op.py +dualtor_io/test_tor_bgp_failure.py +dualtor_io/test_tor_failure.py +dualtor_mgmt/test_dualtor_bgp_update_delay.py +dualtor_mgmt/test_grpc_periodical_sync.py +dualtor_mgmt/test_ingress_drop.py +dualtor_mgmt/test_server_failure.py +dualtor_mgmt/test_toggle_mux.py +dut_console/test_console_baud_rate.py +dut_console/test_escape_character.py +dut_console/test_idle_timeout.py +ecmp/inner_hashing/test_inner_hashing.py +ecmp/inner_hashing/test_inner_hashing_lag.py +ecmp/inner_hashing/test_wr_inner_hashing.py +ecmp/inner_hashing/test_wr_inner_hashing_lag.py +ecmp/test_fgnhg.py +everflow/test_everflow_ipv6.py +everflow/test_everflow_per_interface.py +everflow/test_everflow_testbed.py +fdb/test_fdb.py +fdb/test_fdb_flush.py +fdb/test_fdb_mac_expire.py +fdb/test_fdb_mac_move.py +fib/test_fib.py +generic_config_updater/test_aaa.py +generic_config_updater/test_bgp_prefix.py +generic_config_updater/test_bgp_speaker.py +generic_config_updater/test_bgpl.py +generic_config_updater/test_cacl.py +generic_config_updater/test_dhcp_relay.py +generic_config_updater/test_eth_interface.py +generic_config_updater/test_incremental_qos.py +generic_config_updater/test_ipv6.py +generic_config_updater/test_lo_interface.py +generic_config_updater/test_mmu_dynamic_threshold_config_update.py +generic_config_updater/test_monitor_config.py +generic_config_updater/test_ntp.py +generic_config_updater/test_pfcwd_interval.py +generic_config_updater/test_portchannel_interface.py +generic_config_updater/test_syslog.py +generic_config_updater/test_vlan_interface.py +gnmi/test_gnmi.py +gnmi/test_gnmi_appldb.py +gnmi/test_gnmi_configdb.py +http/test_http_copy.py +iface_loopback_action/test_iface_loopback_action.py +iface_namingmode/test_iface_namingmode.py +ip/test_ip_packet.py +ipfwd/test_dip_sip.py +ipfwd/test_dir_bcast.py +ipfwd/test_mtu.py +ipfwd/test_nhop_group.py +ixia/ecn/test_dequeue_ecn.py +ixia/ecn/test_red_accuracy.py +ixia/ixanvl/test_bgp_conformance.py +ixia/pfc/test_global_pause.py +ixia/pfc/test_pfc_congestion.py +ixia/pfc/test_pfc_pause_lossless.py +ixia/pfc/test_pfc_pause_lossy.py +ixia/pfcwd/test_pfcwd_a2a.py +ixia/pfcwd/test_pfcwd_basic.py +ixia/pfcwd/test_pfcwd_burst_storm.py +ixia/pfcwd/test_pfcwd_m2o.py +ixia/pfcwd/test_pfcwd_runtime_traffic.py +ixia/test_ixia_traffic.py +ixia/test_tgen.py +k8s/test_config_reload.py +k8s/test_disable_flag.py +k8s/test_join_available_master.py +lldp/test_lldp.py +log_fidelity/test_bgp_shutdown.py +macsec/test_controlplane.py +macsec/test_dataplane.py +macsec/test_deployment.py +macsec/test_fault_handling.py +macsec/test_interop_protocol.py +macsec/test_interop_wan_isis.py +mclag/test_mclag_l3.py +memory_checker/test_memory_checker.py +monit/test_monit_status.py +mpls/test_mpls.py +mvrf/test_mgmtvrf.py +nat/test_dynamic_nat.py +nat/test_static_nat.py +ntp/test_ntp.py +override_config_table/test_override_config_table.py +passw_hardening/test_passw_hardening.py +pc/test_lag_2.py +pc/test_lag_member.py +pc/test_po_cleanup.py +pc/test_po_update.py +pc/test_po_voq.py +pfc_asym/test_pfc_asym.py +pfcwd/test_pfc_config.py +pfcwd/test_pfcwd_all_port_storm.py +pfcwd/test_pfcwd_function.py +pfcwd/test_pfcwd_timer_accuracy.py +pfcwd/test_pfcwd_warm_reboot.py +platform_tests/api/test_chassis.py +platform_tests/api/test_chassis_fans.py +platform_tests/api/test_component.py +platform_tests/api/test_fan_drawer.py +platform_tests/api/test_fan_drawer_fans.py +platform_tests/api/test_module.py +platform_tests/api/test_psu.py +platform_tests/api/test_psu_fans.py +platform_tests/api/test_sfp.py +platform_tests/api/test_thermal.py +platform_tests/api/test_watchdog.py +platform_tests/broadcom/test_ser.py +platform_tests/cli/test_show_chassis_module.py +platform_tests/cli/test_show_platform.py +platform_tests/counterpoll/test_counterpoll_watermark.py +platform_tests/daemon/test_chassisd.py +platform_tests/daemon/test_fancontrol.py +platform_tests/daemon/test_ledd.py +platform_tests/daemon/test_pcied.py +platform_tests/daemon/test_psud.py +platform_tests/daemon/test_syseepromd.py +platform_tests/fwutil/test_fwutil.py +platform_tests/link_flap/test_cont_link_flap.py +platform_tests/link_flap/test_link_flap.py +platform_tests/mellanox/test_check_sfp_eeprom.py +platform_tests/mellanox/test_check_sfp_presence.py +platform_tests/mellanox/test_check_sfp_using_ethtool.py +platform_tests/mellanox/test_check_sysfs.py +platform_tests/mellanox/test_hw_management_service.py +platform_tests/mellanox/test_psu_power_threshold.py +platform_tests/mellanox/test_reboot_cause.py +platform_tests/mellanox/test_thermal_control.py +platform_tests/sfp/test_sfpshow.py +platform_tests/sfp/test_sfputil.py +platform_tests/sfp/test_show_intf_xcvr.py +platform_tests/test_advanced_reboot.py +platform_tests/test_auto_negotiation.py +platform_tests/test_cont_warm_reboot.py +platform_tests/test_cpu_memory_usage.py +platform_tests/test_first_time_boot_password_change/test_first_time_boot_password_change.py +platform_tests/test_link_down.py +platform_tests/test_memory_exhaustion.py +platform_tests/test_platform_info.py +platform_tests/test_port_toggle.py +platform_tests/test_power_budget_info.py +platform_tests/test_reboot.py +platform_tests/test_reload_config.py +platform_tests/test_sensors.py +platform_tests/test_sequential_restart.py +platform_tests/test_service_warm_restart.py +platform_tests/test_thermal_state_db.py +platform_tests/test_xcvr_info_in_db.py +portstat/test_portstat.py +process_monitoring/test_critical_process_monitoring.py +qos/test_buffer.py +qos/test_buffer_traditional.py +qos/test_pfc_counters.py +qos/test_pfc_pause.py +qos/test_qos_masic.py +qos/test_qos_sai.py +qos/test_tunnel_qos_remap.py +radv/test_radv_ipv6_ra.py +radv/test_radv_restart.py +read_mac/test_read_mac_metadata.py +restapi/test_restapi.py +restapi/test_restapi_vxlan_ecmp.py +route/test_default_route.py +route/test_route_flap.py +route/test_route_flow_counter.py +route/test_route_perf.py +route/test_static_route.py +sai_qualify/test_brcm_t0.py +sai_qualify/test_community.py +sai_qualify/test_sai_ptf.py +sai_qualify/test_sai_ptf_warm_reboot.py +sai_qualify/test_sai_t0_warm_reboot.py +scp/test_scp_copy.py +sflow/test_sflow.py +show_techsupport/test_auto_techsupport.py +show_techsupport/test_techsupport.py +show_techsupport/test_techsupport_no_secret.py +snappi/bgp/test_bgp_convergence_performance.py +snappi/bgp/test_bgp_local_link_failover.py +snappi/bgp/test_bgp_remote_link_failover.py +snappi/bgp/test_bgp_rib_in_capacity.py +snappi/bgp/test_bgp_rib_in_convergence.py +snappi/bgp/test_bgp_scalability.py +snappi/ecn/test_dequeue_ecn_with_snappi.py +snappi/ecn/test_red_accuracy_with_snappi.py +snappi/lacp/test_add_remove_link_from_dut.py +snappi/lacp/test_add_remove_link_physically.py +snappi/lacp/test_lacp_timers_effect.py +snappi/pfc/test_global_pause_with_snappi.py +snappi/pfc/test_pfc_pause_lossless_with_snappi.py +snappi/pfc/test_pfc_pause_lossy_with_snappi.py +snappi/pfc/test_pfc_pause_response_with_snappi.py +snappi/pfcwd/test_pfcwd_a2a_with_snappi.py +snappi/pfcwd/test_pfcwd_basic_with_snappi.py +snappi/pfcwd/test_pfcwd_burst_storm_with_snappi.py +snappi/pfcwd/test_pfcwd_m2o_with_snappi.py +snappi/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py +snappi/reboot/test_cold_reboot.py +snappi/reboot/test_fast_reboot.py +snappi/reboot/test_soft_reboot.py +snappi/reboot/test_warm_reboot.py +snappi/test_snappi.py +snmp/test_snmp_cpu.py +snmp/test_snmp_default_route.py +snmp/test_snmp_fdb.py +snmp/test_snmp_interfaces.py +snmp/test_snmp_lldp.py +snmp/test_snmp_loopback.py +snmp/test_snmp_memory.py +snmp/test_snmp_pfc_counters.py +snmp/test_snmp_phy_entity.py +snmp/test_snmp_psu.py +snmp/test_snmp_queue.py +snmp/test_snmp_v2mib.py +span/test_port_mirroring.py +ssh/test_ssh_ciphers.py +ssh/test_ssh_default_password.py +ssh/test_ssh_limit.py +ssh/test_ssh_stress.py +stress/test_stress_routes.py +sub_port_interfaces/test_show_subinterface.py +sub_port_interfaces/test_sub_port_interfaces.py +sub_port_interfaces/test_sub_port_l2_forwarding.py +syslog/test_logrotate.py +syslog/test_syslog.py +syslog/test_syslog_rate_limit.py +syslog/test_syslog_source_ip.py +system_health/test_system_health.py +system_health/test_system_status.py +tacacs/test_accounting.py +tacacs/test_authorization.py +tacacs/test_jit_user.py +tacacs/test_ro_disk.py +tacacs/test_ro_user.py +tacacs/test_rw_user.py +telemetry/test_events.py +telemetry/test_telemetry.py +test_features.py +test_interfaces.py +test_nbr_health.py +test_posttest.py +test_pretest.py +test_procdockerstatsd.py +test_vs_chassis_setup.py +testbed_setup/test_add_property_spytest_junit_xml.py +testbed_setup/test_gen_spy_testbed.py +testbed_setup/test_populate_fdb.py +upgrade_path/test_upgrade_path.py +vlan/test_autostate_disabled.py +vlan/test_host_vlan.py +vlan/test_vlan.py +vlan/test_vlan_ping.py +voq/test_voq_disrupts.py +voq/test_voq_init.py +voq/test_voq_intfs.py +voq/test_voq_ipfwd.py +voq/test_voq_nbr.py +vrf/test_vrf.py +vrf/test_vrf_attr.py +vxlan/test_vnet_route_leak.py +vxlan/test_vnet_vxlan.py +vxlan/test_vxlan_crm.py +vxlan/test_vxlan_decap.py +vxlan/test_vxlan_ecmp.py +wan/isis/test_isis_authentication.py +wan/isis/test_isis_csnp_interval.py +wan/isis/test_isis_database.py +wan/isis/test_isis_dynamic_hostname.py +wan/isis/test_isis_ecmp.py +wan/isis/test_isis_hello_interval.py +wan/isis/test_isis_hello_pad.py +wan/isis/test_isis_holdtime.py +wan/isis/test_isis_intf_passive.py +wan/isis/test_isis_level_capacity.py +wan/isis/test_isis_log_adjacency_change.py +wan/isis/test_isis_lsp_fragment.py +wan/isis/test_isis_lsp_gen_interval.py +wan/isis/test_isis_lsp_lifetime.py +wan/isis/test_isis_lsp_refresh.py +wan/isis/test_isis_metric_wide.py +wan/isis/test_isis_neighbor.py +wan/isis/test_isis_overload_bit.py +wan/isis/test_isis_redistribute.py +wan/isis/test_isis_spf_default_interval.py +wan/isis/test_isis_spf_ietf_interval.py +wan/lacp/test_wan_lacp.py +wan/lacp/test_wan_lag_member.py +wan/lacp/test_wan_lag_min_link.py +wan/lldp/test_wan_lldp.py +wan/traffic_test/test_traffic.py diff --git a/tests/run_tests.sh b/tests/run_tests.sh index f3cc2cdd31..976f4a5ceb 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -45,14 +45,14 @@ function get_dut_from_testbed_file() { DUT_NAME=${ARRAY[9]//[\[\] ]/} elif [[ $TESTBED_FILE == *.yaml ]]; then - content=$(python3 -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") + content=$(python -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") if [[ -z ${content} ]]; then echo "Unable to find testbed '$TESTBED_NAME' in testbed file '$TESTBED_FILE'" show_help_and_exit 4 fi IFS=$'+' read -r -a tb_lines <<< $content tb_line=${tb_lines[0]} - DUT_NAME=$(python3 -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") + DUT_NAME=$(python -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") fi fi } @@ -130,7 +130,7 @@ function setup_test_options() # for the scenario of specifying test scripts using pattern like `subfolder/test_*.py`. The pattern will be # expanded to matched test scripts by bash. Among the expanded scripts, we may want to skip a few. Then we can # explicitly specify the script to be skipped. - ignores=$(python3 -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") + ignores=$(python -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") if [[ -z ${TEST_CASES} ]]; then # When TEST_CASES is not specified, find all the possible scripts, ignore the scripts under $SKIP_FOLDERS all_scripts=$(find ./ -name 'test_*.py' | sed s:^./:: | grep -vE "^(${ignores})") @@ -143,18 +143,18 @@ function setup_test_options() fi # Ignore the scripts specified in $SKIP_SCRIPTS if [[ x"${TEST_INPUT_ORDER}" == x"True" ]]; then - TEST_CASES=$(python3 -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") + TEST_CASES=$(python -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") else - TEST_CASES=$(python3 -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) + TEST_CASES=$(python -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) fi # Check against $INCLUDE_FOLDERS, filter out test cases not in the specified folders FINAL_CASES="" - includes=$(python3 -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") + includes=$(python -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") for test_case in ${TEST_CASES}; do FINAL_CASES="${FINAL_CASES} $(echo ${test_case} | grep -E "^(${includes})")" done - TEST_CASES=$(python3 -c "print('\n'.join('''${FINAL_CASES}'''.split()))") + TEST_CASES=$(python -c "print('\n'.join('''${FINAL_CASES}'''.split()))") if [[ -z $TEST_CASES ]]; then echo "No test case to run based on conditions of '-c', '-I' and '-S'. Please check..." @@ -264,22 +264,22 @@ function pre_post_extra_params() function prepare_dut() { echo "=== Preparing DUT for subsequent tests ===" - echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest - python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + echo Running: pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest } function cleanup_dut() { echo "=== Cleaning up DUT after tests ===" - echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest - python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + echo Running: pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest } function run_group_tests() { echo "=== Running tests in groups ===" - echo Running: python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear + echo Running: pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear } function run_individual_tests() @@ -300,9 +300,23 @@ function run_individual_tests() TEST_LOGGING_OPTIONS="--log-file ${LOG_PATH}/${test_dir}/${test_name}.log --junitxml=${LOG_PATH}/${test_dir}/${test_name}.xml" fi - echo Running: python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} - ret_code=$? + echo Running: pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + USE_PY3=0 + for i in `cat python3_test_files.txt` + do + USE_PY3=`expr match ${test_script} ${i}` + [[ ${USE_PY3} != 0 ]] && break + done + if [ ${USE_PY3} != 0 ]; then + echo Activate Python3 venv + source /var/AzDevOps/env-python3/bin/activate + fi + pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} + ret_code=$? + if [ ${USE_PY3} != 0 ]; then + echo Deactivate Python3 venv + deactivate + fi # Clear pytest cache for the first run if [[ -n ${CACHE_CLEAR} ]]; then From 28e63216395efd167d3a1ca096009a073f90b7bd Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Tue, 8 Aug 2023 21:34:08 +0000 Subject: [PATCH 12/13] Revert "Revert "Change run_tests.sh to use python3 unconditionally (#8988)"" This reverts commit 87ad5dbde3f118b7e4a59d60e6b8bc906326b818. --- tests/python3_test_files.txt | 357 +---------------------------------- tests/run_tests.sh | 46 ++--- 2 files changed, 17 insertions(+), 386 deletions(-) diff --git a/tests/python3_test_files.txt b/tests/python3_test_files.txt index 04c7a3e8c5..0702cb5bfb 100644 --- a/tests/python3_test_files.txt +++ b/tests/python3_test_files.txt @@ -1,356 +1 @@ -acl/custom_acl_table/test_custom_acl_table.py -acl/null_route/test_null_route_helper.py -acl/test_acl.py -acl/test_acl_outer_vlan.py -acl/test_stress_acl.py -arp/test_arp_dualtor.py -arp/test_arp_extended.py -arp/test_arpall.py -arp/test_neighbor_mac.py -arp/test_neighbor_mac_noptf.py -arp/test_stress_arp.py -arp/test_tagged_arp.py -arp/test_unknown_mac.py -arp/test_wr_arp.py -autorestart/test_container_autorestart.py -bfd/test_bfd.py -bgp/test_bgp_allow_list.py -bgp/test_bgp_bbr.py -bgp/test_bgp_bounce.py -bgp/test_bgp_dual_asn.py -bgp/test_bgp_fact.py -bgp/test_bgp_gr_helper.py -bgp/test_bgp_multipath_relax.py -bgp/test_bgp_session_flap.py -bgp/test_bgp_slb.py -bgp/test_bgp_speaker.py -bgp/test_bgp_update_timer.py -bgp/test_bgpmon.py -bgp/test_traffic_shift.py -cacl/test_cacl_application.py -cacl/test_cacl_function.py -cacl/test_ebtables_application.py -configlet/test_add_rack.py -console/test_console_availability.py -console/test_console_driver.py -console/test_console_loopback.py -console/test_console_reversessh.py -console/test_console_udevrule.py -container_checker/test_container_checker.py -container_hardening/test_container_hardening.py -copp/test_copp.py -crm/test_crm.py -dash/test_dash_vnet.py -decap/test_decap.py -dhcp_relay/test_dhcp_pkt_fwd.py -dhcp_relay/test_dhcp_relay.py -dhcp_relay/test_dhcpv6_relay.py -disk/test_disk_exhaustion.py -dns/test_dns_resolv_conf.py -drop_packets/test_configurable_drop_counters.py -drop_packets/test_drop_counters.py -dualtor/test_ipinip.py -dualtor/test_orch_stress.py -dualtor/test_orchagent_active_tor_downstream.py -dualtor/test_orchagent_mac_move.py -dualtor/test_orchagent_slb.py -dualtor/test_orchagent_standby_tor_downstream.py -dualtor/test_standby_tor_upstream_mux_toggle.py -dualtor/test_tor_ecn.py -dualtor/test_tunnel_memory_leak.py -dualtor_io/test_grpc_server_failure.py -dualtor_io/test_heartbeat_failure.py -dualtor_io/test_link_drop.py -dualtor_io/test_link_failure.py -dualtor_io/test_normal_op.py -dualtor_io/test_tor_bgp_failure.py -dualtor_io/test_tor_failure.py -dualtor_mgmt/test_dualtor_bgp_update_delay.py -dualtor_mgmt/test_grpc_periodical_sync.py -dualtor_mgmt/test_ingress_drop.py -dualtor_mgmt/test_server_failure.py -dualtor_mgmt/test_toggle_mux.py -dut_console/test_console_baud_rate.py -dut_console/test_escape_character.py -dut_console/test_idle_timeout.py -ecmp/inner_hashing/test_inner_hashing.py -ecmp/inner_hashing/test_inner_hashing_lag.py -ecmp/inner_hashing/test_wr_inner_hashing.py -ecmp/inner_hashing/test_wr_inner_hashing_lag.py -ecmp/test_fgnhg.py -everflow/test_everflow_ipv6.py -everflow/test_everflow_per_interface.py -everflow/test_everflow_testbed.py -fdb/test_fdb.py -fdb/test_fdb_flush.py -fdb/test_fdb_mac_expire.py -fdb/test_fdb_mac_move.py -fib/test_fib.py -generic_config_updater/test_aaa.py -generic_config_updater/test_bgp_prefix.py -generic_config_updater/test_bgp_speaker.py -generic_config_updater/test_bgpl.py -generic_config_updater/test_cacl.py -generic_config_updater/test_dhcp_relay.py -generic_config_updater/test_eth_interface.py -generic_config_updater/test_incremental_qos.py -generic_config_updater/test_ipv6.py -generic_config_updater/test_lo_interface.py -generic_config_updater/test_mmu_dynamic_threshold_config_update.py -generic_config_updater/test_monitor_config.py -generic_config_updater/test_ntp.py -generic_config_updater/test_pfcwd_interval.py -generic_config_updater/test_portchannel_interface.py -generic_config_updater/test_syslog.py -generic_config_updater/test_vlan_interface.py -gnmi/test_gnmi.py -gnmi/test_gnmi_appldb.py -gnmi/test_gnmi_configdb.py -http/test_http_copy.py -iface_loopback_action/test_iface_loopback_action.py -iface_namingmode/test_iface_namingmode.py -ip/test_ip_packet.py -ipfwd/test_dip_sip.py -ipfwd/test_dir_bcast.py -ipfwd/test_mtu.py -ipfwd/test_nhop_group.py -ixia/ecn/test_dequeue_ecn.py -ixia/ecn/test_red_accuracy.py -ixia/ixanvl/test_bgp_conformance.py -ixia/pfc/test_global_pause.py -ixia/pfc/test_pfc_congestion.py -ixia/pfc/test_pfc_pause_lossless.py -ixia/pfc/test_pfc_pause_lossy.py -ixia/pfcwd/test_pfcwd_a2a.py -ixia/pfcwd/test_pfcwd_basic.py -ixia/pfcwd/test_pfcwd_burst_storm.py -ixia/pfcwd/test_pfcwd_m2o.py -ixia/pfcwd/test_pfcwd_runtime_traffic.py -ixia/test_ixia_traffic.py -ixia/test_tgen.py -k8s/test_config_reload.py -k8s/test_disable_flag.py -k8s/test_join_available_master.py -lldp/test_lldp.py -log_fidelity/test_bgp_shutdown.py -macsec/test_controlplane.py -macsec/test_dataplane.py -macsec/test_deployment.py -macsec/test_fault_handling.py -macsec/test_interop_protocol.py -macsec/test_interop_wan_isis.py -mclag/test_mclag_l3.py -memory_checker/test_memory_checker.py -monit/test_monit_status.py -mpls/test_mpls.py -mvrf/test_mgmtvrf.py -nat/test_dynamic_nat.py -nat/test_static_nat.py -ntp/test_ntp.py -override_config_table/test_override_config_table.py -passw_hardening/test_passw_hardening.py -pc/test_lag_2.py -pc/test_lag_member.py -pc/test_po_cleanup.py -pc/test_po_update.py -pc/test_po_voq.py -pfc_asym/test_pfc_asym.py -pfcwd/test_pfc_config.py -pfcwd/test_pfcwd_all_port_storm.py -pfcwd/test_pfcwd_function.py -pfcwd/test_pfcwd_timer_accuracy.py -pfcwd/test_pfcwd_warm_reboot.py -platform_tests/api/test_chassis.py -platform_tests/api/test_chassis_fans.py -platform_tests/api/test_component.py -platform_tests/api/test_fan_drawer.py -platform_tests/api/test_fan_drawer_fans.py -platform_tests/api/test_module.py -platform_tests/api/test_psu.py -platform_tests/api/test_psu_fans.py -platform_tests/api/test_sfp.py -platform_tests/api/test_thermal.py -platform_tests/api/test_watchdog.py -platform_tests/broadcom/test_ser.py -platform_tests/cli/test_show_chassis_module.py -platform_tests/cli/test_show_platform.py -platform_tests/counterpoll/test_counterpoll_watermark.py -platform_tests/daemon/test_chassisd.py -platform_tests/daemon/test_fancontrol.py -platform_tests/daemon/test_ledd.py -platform_tests/daemon/test_pcied.py -platform_tests/daemon/test_psud.py -platform_tests/daemon/test_syseepromd.py -platform_tests/fwutil/test_fwutil.py -platform_tests/link_flap/test_cont_link_flap.py -platform_tests/link_flap/test_link_flap.py -platform_tests/mellanox/test_check_sfp_eeprom.py -platform_tests/mellanox/test_check_sfp_presence.py -platform_tests/mellanox/test_check_sfp_using_ethtool.py -platform_tests/mellanox/test_check_sysfs.py -platform_tests/mellanox/test_hw_management_service.py -platform_tests/mellanox/test_psu_power_threshold.py -platform_tests/mellanox/test_reboot_cause.py -platform_tests/mellanox/test_thermal_control.py -platform_tests/sfp/test_sfpshow.py -platform_tests/sfp/test_sfputil.py -platform_tests/sfp/test_show_intf_xcvr.py -platform_tests/test_advanced_reboot.py -platform_tests/test_auto_negotiation.py -platform_tests/test_cont_warm_reboot.py -platform_tests/test_cpu_memory_usage.py -platform_tests/test_first_time_boot_password_change/test_first_time_boot_password_change.py -platform_tests/test_link_down.py -platform_tests/test_memory_exhaustion.py -platform_tests/test_platform_info.py -platform_tests/test_port_toggle.py -platform_tests/test_power_budget_info.py -platform_tests/test_reboot.py -platform_tests/test_reload_config.py -platform_tests/test_sensors.py -platform_tests/test_sequential_restart.py -platform_tests/test_service_warm_restart.py -platform_tests/test_thermal_state_db.py -platform_tests/test_xcvr_info_in_db.py -portstat/test_portstat.py -process_monitoring/test_critical_process_monitoring.py -qos/test_buffer.py -qos/test_buffer_traditional.py -qos/test_pfc_counters.py -qos/test_pfc_pause.py -qos/test_qos_masic.py -qos/test_qos_sai.py -qos/test_tunnel_qos_remap.py -radv/test_radv_ipv6_ra.py -radv/test_radv_restart.py -read_mac/test_read_mac_metadata.py -restapi/test_restapi.py -restapi/test_restapi_vxlan_ecmp.py -route/test_default_route.py -route/test_route_flap.py -route/test_route_flow_counter.py -route/test_route_perf.py -route/test_static_route.py -sai_qualify/test_brcm_t0.py -sai_qualify/test_community.py -sai_qualify/test_sai_ptf.py -sai_qualify/test_sai_ptf_warm_reboot.py -sai_qualify/test_sai_t0_warm_reboot.py -scp/test_scp_copy.py -sflow/test_sflow.py -show_techsupport/test_auto_techsupport.py -show_techsupport/test_techsupport.py -show_techsupport/test_techsupport_no_secret.py -snappi/bgp/test_bgp_convergence_performance.py -snappi/bgp/test_bgp_local_link_failover.py -snappi/bgp/test_bgp_remote_link_failover.py -snappi/bgp/test_bgp_rib_in_capacity.py -snappi/bgp/test_bgp_rib_in_convergence.py -snappi/bgp/test_bgp_scalability.py -snappi/ecn/test_dequeue_ecn_with_snappi.py -snappi/ecn/test_red_accuracy_with_snappi.py -snappi/lacp/test_add_remove_link_from_dut.py -snappi/lacp/test_add_remove_link_physically.py -snappi/lacp/test_lacp_timers_effect.py -snappi/pfc/test_global_pause_with_snappi.py -snappi/pfc/test_pfc_pause_lossless_with_snappi.py -snappi/pfc/test_pfc_pause_lossy_with_snappi.py -snappi/pfc/test_pfc_pause_response_with_snappi.py -snappi/pfcwd/test_pfcwd_a2a_with_snappi.py -snappi/pfcwd/test_pfcwd_basic_with_snappi.py -snappi/pfcwd/test_pfcwd_burst_storm_with_snappi.py -snappi/pfcwd/test_pfcwd_m2o_with_snappi.py -snappi/pfcwd/test_pfcwd_runtime_traffic_with_snappi.py -snappi/reboot/test_cold_reboot.py -snappi/reboot/test_fast_reboot.py -snappi/reboot/test_soft_reboot.py -snappi/reboot/test_warm_reboot.py -snappi/test_snappi.py -snmp/test_snmp_cpu.py -snmp/test_snmp_default_route.py -snmp/test_snmp_fdb.py -snmp/test_snmp_interfaces.py -snmp/test_snmp_lldp.py -snmp/test_snmp_loopback.py -snmp/test_snmp_memory.py -snmp/test_snmp_pfc_counters.py -snmp/test_snmp_phy_entity.py -snmp/test_snmp_psu.py -snmp/test_snmp_queue.py -snmp/test_snmp_v2mib.py -span/test_port_mirroring.py -ssh/test_ssh_ciphers.py -ssh/test_ssh_default_password.py -ssh/test_ssh_limit.py -ssh/test_ssh_stress.py -stress/test_stress_routes.py -sub_port_interfaces/test_show_subinterface.py -sub_port_interfaces/test_sub_port_interfaces.py -sub_port_interfaces/test_sub_port_l2_forwarding.py -syslog/test_logrotate.py -syslog/test_syslog.py -syslog/test_syslog_rate_limit.py -syslog/test_syslog_source_ip.py -system_health/test_system_health.py -system_health/test_system_status.py -tacacs/test_accounting.py -tacacs/test_authorization.py -tacacs/test_jit_user.py -tacacs/test_ro_disk.py -tacacs/test_ro_user.py -tacacs/test_rw_user.py -telemetry/test_events.py -telemetry/test_telemetry.py -test_features.py -test_interfaces.py -test_nbr_health.py -test_posttest.py -test_pretest.py -test_procdockerstatsd.py -test_vs_chassis_setup.py -testbed_setup/test_add_property_spytest_junit_xml.py -testbed_setup/test_gen_spy_testbed.py -testbed_setup/test_populate_fdb.py -upgrade_path/test_upgrade_path.py -vlan/test_autostate_disabled.py -vlan/test_host_vlan.py -vlan/test_vlan.py -vlan/test_vlan_ping.py -voq/test_voq_disrupts.py -voq/test_voq_init.py -voq/test_voq_intfs.py -voq/test_voq_ipfwd.py -voq/test_voq_nbr.py -vrf/test_vrf.py -vrf/test_vrf_attr.py -vxlan/test_vnet_route_leak.py -vxlan/test_vnet_vxlan.py -vxlan/test_vxlan_crm.py -vxlan/test_vxlan_decap.py -vxlan/test_vxlan_ecmp.py -wan/isis/test_isis_authentication.py -wan/isis/test_isis_csnp_interval.py -wan/isis/test_isis_database.py -wan/isis/test_isis_dynamic_hostname.py -wan/isis/test_isis_ecmp.py -wan/isis/test_isis_hello_interval.py -wan/isis/test_isis_hello_pad.py -wan/isis/test_isis_holdtime.py -wan/isis/test_isis_intf_passive.py -wan/isis/test_isis_level_capacity.py -wan/isis/test_isis_log_adjacency_change.py -wan/isis/test_isis_lsp_fragment.py -wan/isis/test_isis_lsp_gen_interval.py -wan/isis/test_isis_lsp_lifetime.py -wan/isis/test_isis_lsp_refresh.py -wan/isis/test_isis_metric_wide.py -wan/isis/test_isis_neighbor.py -wan/isis/test_isis_overload_bit.py -wan/isis/test_isis_redistribute.py -wan/isis/test_isis_spf_default_interval.py -wan/isis/test_isis_spf_ietf_interval.py -wan/lacp/test_wan_lacp.py -wan/lacp/test_wan_lag_member.py -wan/lacp/test_wan_lag_min_link.py -wan/lldp/test_wan_lldp.py -wan/traffic_test/test_traffic.py +all diff --git a/tests/run_tests.sh b/tests/run_tests.sh index 976f4a5ceb..f3cc2cdd31 100755 --- a/tests/run_tests.sh +++ b/tests/run_tests.sh @@ -45,14 +45,14 @@ function get_dut_from_testbed_file() { DUT_NAME=${ARRAY[9]//[\[\] ]/} elif [[ $TESTBED_FILE == *.yaml ]]; then - content=$(python -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") + content=$(python3 -c "from __future__ import print_function; import yaml; print('+'.join(str(tb) for tb in yaml.safe_load(open('$TESTBED_FILE')) if '$TESTBED_NAME'==tb['conf-name']))") if [[ -z ${content} ]]; then echo "Unable to find testbed '$TESTBED_NAME' in testbed file '$TESTBED_FILE'" show_help_and_exit 4 fi IFS=$'+' read -r -a tb_lines <<< $content tb_line=${tb_lines[0]} - DUT_NAME=$(python -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") + DUT_NAME=$(python3 -c "from __future__ import print_function; tb=eval(\"$tb_line\"); print(\",\".join(tb[\"dut\"]))") fi fi } @@ -130,7 +130,7 @@ function setup_test_options() # for the scenario of specifying test scripts using pattern like `subfolder/test_*.py`. The pattern will be # expanded to matched test scripts by bash. Among the expanded scripts, we may want to skip a few. Then we can # explicitly specify the script to be skipped. - ignores=$(python -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") + ignores=$(python3 -c "print('|'.join('''$SKIP_FOLDERS'''.split()))") if [[ -z ${TEST_CASES} ]]; then # When TEST_CASES is not specified, find all the possible scripts, ignore the scripts under $SKIP_FOLDERS all_scripts=$(find ./ -name 'test_*.py' | sed s:^./:: | grep -vE "^(${ignores})") @@ -143,18 +143,18 @@ function setup_test_options() fi # Ignore the scripts specified in $SKIP_SCRIPTS if [[ x"${TEST_INPUT_ORDER}" == x"True" ]]; then - TEST_CASES=$(python -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") + TEST_CASES=$(python3 -c "print('\n'.join([testcase for testcase in list('''$all_scripts'''.split()) if testcase not in set('''$SKIP_SCRIPTS'''.split())]))") else - TEST_CASES=$(python -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) + TEST_CASES=$(python3 -c "print('\n'.join(set('''$all_scripts'''.split()) - set('''$SKIP_SCRIPTS'''.split())))" | sort) fi # Check against $INCLUDE_FOLDERS, filter out test cases not in the specified folders FINAL_CASES="" - includes=$(python -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") + includes=$(python3 -c "print('|'.join('''$INCLUDE_FOLDERS'''.split()))") for test_case in ${TEST_CASES}; do FINAL_CASES="${FINAL_CASES} $(echo ${test_case} | grep -E "^(${includes})")" done - TEST_CASES=$(python -c "print('\n'.join('''${FINAL_CASES}'''.split()))") + TEST_CASES=$(python3 -c "print('\n'.join('''${FINAL_CASES}'''.split()))") if [[ -z $TEST_CASES ]]; then echo "No test case to run based on conditions of '-c', '-I' and '-S'. Please check..." @@ -264,22 +264,22 @@ function pre_post_extra_params() function prepare_dut() { echo "=== Preparing DUT for subsequent tests ===" - echo Running: pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest - pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest + python3 -m pytest ${PYTEST_UTIL_OPTS} ${PRET_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m pretest } function cleanup_dut() { echo "=== Cleaning up DUT after tests ===" - echo Running: pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest - pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + echo Running: python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest + python3 -m pytest ${PYTEST_UTIL_OPTS} ${POST_LOGGING_OPTIONS} ${UTIL_TOPOLOGY_OPTIONS} $(pre_post_extra_params) -m posttest } function run_group_tests() { echo "=== Running tests in groups ===" - echo Running: pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear + echo Running: python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + python3 -m pytest ${TEST_CASES} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} --cache-clear } function run_individual_tests() @@ -300,23 +300,9 @@ function run_individual_tests() TEST_LOGGING_OPTIONS="--log-file ${LOG_PATH}/${test_dir}/${test_name}.log --junitxml=${LOG_PATH}/${test_dir}/${test_name}.xml" fi - echo Running: pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} - USE_PY3=0 - for i in `cat python3_test_files.txt` - do - USE_PY3=`expr match ${test_script} ${i}` - [[ ${USE_PY3} != 0 ]] && break - done - if [ ${USE_PY3} != 0 ]; then - echo Activate Python3 venv - source /var/AzDevOps/env-python3/bin/activate - fi - pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} - ret_code=$? - if [ ${USE_PY3} != 0 ]; then - echo Deactivate Python3 venv - deactivate - fi + echo Running: python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} + python3 -m pytest ${test_script} ${PYTEST_COMMON_OPTS} ${TEST_LOGGING_OPTIONS} ${TEST_TOPOLOGY_OPTIONS} ${EXTRA_PARAMETERS} ${CACHE_CLEAR} + ret_code=$? # Clear pytest cache for the first run if [[ -n ${CACHE_CLEAR} ]]; then From 21281b980ff5d5c84897790fb030974cd67905aa Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Tue, 8 Aug 2023 21:34:34 +0000 Subject: [PATCH 13/13] Add test_snmp_link_local_ip test to multi-asic VS PR checker. Signed-off-by: Suvarna Meenakshi --- .azure-pipelines/pr_test_scripts.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.azure-pipelines/pr_test_scripts.yaml b/.azure-pipelines/pr_test_scripts.yaml index 4188aa26b1..b5624c4094 100644 --- a/.azure-pipelines/pr_test_scripts.yaml +++ b/.azure-pipelines/pr_test_scripts.yaml @@ -118,6 +118,7 @@ multi-asic-t1-lag: - bgp/test_bgp_fact.py - bgp/test_bgp_update_timer.py - snmp/test_snmp_default_route.py + - snmp/test_snmp_link_local_ip.py - snmp/test_snmp_loopback.py - snmp/test_snmp_pfc_counters.py - snmp/test_snmp_queue.py