From d51c9a6d5056e8c5670bdadcd08b798e0423f04c Mon Sep 17 00:00:00 2001 From: Suvarna Meenakshi Date: Thu, 3 Aug 2023 23:12:33 +0000 Subject: [PATCH] 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