def erspan_pre_config_verify(): """ Author: Lakshminarayana D ([email protected]) Using this pre config at module level. So, applicable for all test cases which includes in this module. :return: True or False """ retval = True # Displaying ip route table for dut in (vars.D1, vars.D2): st.log("Displaying routes on device {}....".format(dut)) ip.show_ip_route(dut) # Veification of acl policy and table match = [{'policy_name': data.acl_table_name}] if not acl_dscp.verify(vars.D1, 'policy', verify_list=match): st.log("acl policy verification failed") retval = False # Verification of Monitor session if not mirror.verify_session(vars.D1, session_name=data.session_name, src_ip=data.ip_D1T1P1, dst_ip=data.ip_T1D2P1, gre_type=data.gre_type, dscp=data.dscp, ttl=data.ttl, queue=data.queue, status="active"): st.log("Failed to create mirror session '{}' ".format(data.session_name)) retval = False return retval
def test_ft_erspan_config_upload_save_reload_reboot(): """ Author: Prudviraj kristipati ([email protected]) Verify that ERSPAN configuration is stored to config_db file, after config save & reload and save & reboot. :return: """ mirror.delete_session(vars.D1, data.session_name) mirror_args = {"session_name": data.session_name, "src_ip": data.ip_D1T1P1, "dst_ip": data.ip_T1D2P1, "gre_type": data.gre_type, "dscp": data.dscp, "ttl": data.ttl, "queue": data.queue} retval = mirror.create_session_table(vars.D1, **mirror_args) if not retval: st.log("Failed to create mirror session using json file.") st.report_fail("mirror_session_fail", data.session_name) if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"): st.log("Failed to show mirror session details in running config.") st.report_fail("test_case_failure_message", "Failed to display mirror session details in running-config.") reboot_obj.config_save_reload(vars.D1) if not mirror.verify_session(vars.D1, **mirror_args): st.log("Failed to show mirror session details after reload.") st.report_fail("mirror_session_fail", data.session_name + "after config save and reload") if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"): st.log("Failed to show mirror session details in running config after reload.") st.report_fail("test_case_failure_message", "Failed to display mirror session details in running-config after config save and reload") st.reboot(vars.D1) if not mirror.verify_session(vars.D1, **mirror_args): st.log("failed to show mirror session details after reboot.") st.report_fail("mirror_session_fail", data.session_name + "after save and reboot") if not sconf.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"): st.log("failed to show mirror session details in running config after reboot.") st.report_fail("test_case_failure_message", "Failed to display mirror session details in running-config after save and reboot") st.report_pass("test_case_passed")
def mirror_action_verify(): mirror_args = { "session_name": data.session_name, "gre_type": data.gre_type, "dscp": data.dscp, "ttl": data.ttl, "queue": data.queue, "src_ip": data.source_ip, "dst_ip": data.destination_ip } if not mirror.verify_session(vars.D1, **mirror_args): st.log("failed to show mirror session details after reboot.") st.report_fail("operation_failed") if not sconf_obj.verify_running_config(vars.D1, "MIRROR_SESSION", "Mirror_Ses", "dst_ip", "15.1.1.2"): st.log( "failed to show mirror session details in running config after reboot." ) st.report_fail("operation_failed")
def erspan_pre_config_verify(): """ Author: Anil Kumar Kacharla<*****@*****.**> Using this pre config at module level. So, applicable for all test cases which includes in this module. :return: None """ retval = True # Displaying ip route table for dut in (data.dut1, data.dut2): st.log("Displaying routes on device {}....".format(dut)) ip.show_ip_route(dut) # Verification of ACL Table if not acl_dscp.verify(data.dut1, 'policy', verify_list=[{ "policy_name": data.acl_table_name }]): st.log("Failed to create ACL policy '{}' ".format(data.acl_table_name)) retval = False # Verification of Monitor session if not mirror.verify_session(data.dut1, session_name=data.session_name, src_ip=data.ip_D1T1P1, dst_ip=data.ip_T1D2P1, gre_type=data.gre_type, dscp=data.dscp, ttl=data.ttl, queue=data.queue, status="active"): st.log("Failed to create mirror session '{}' ".format( data.session_name)) retval = False return retval
def port_mirror_verify(): if not mirror.verify_session(vars.D1, mirror_type=data.mirror_type, session_name=data.session_name_port): st.report_fail("mirror_session_verification_failed")
def test_ft_erspan_basic_functionality(): """ Author: Sesha Koilkonda ([email protected]) TC1 FtOpSoSyErspanFn019: Verify that maximum number of mirror sessions are created. TC2 FtOpSoSyErspanFn015: Verify that multiple mirror sessions can be created and assigned to rules from the same ACL. TC3 FtOpSoSyErspanFn011: Verify that ERSPAN is working as expected and intended traffic is mirrored to remote interface from multiple interfaces. Notes from dev: Only 1 Mirror ACL configuration is supported as of now. maximum Acl rules that can be configured in mirror sesssion(s) is 3. :return: """ ip_add_src, ip_add_dst = data.ip_T1D1P1, data.ip_T1D2P1 max_sessions, data.mask = 4, '32' tc_fail = 0 acl_dscp.config_classifier_table(vars.D1, enable='create', match_type="fields", class_name=data.acl_rule) acl_dscp.config_classifier_table(vars.D1, enable='yes', class_criteria='--src-ip', class_name=data.acl_rule, criteria_value="{}/{}".format(ip_add_src, data.mask), match_type="fields") acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='add', policy_type=data.type, class_name=data.acl_rule, priority_value=data.priority, description=data.description) acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='update',policy_type=data.type, class_name=data.acl_rule, priority_option='--mirror-session', priority_value=data.session_name) #Configure the maximum supported mirror sessions(Session1 alreday created as part of module config.) for ele in range(1, max_sessions): _, ip_add_src = ip.increment_ip_addr("{}/{}".format(ip_add_src.split('/')[0], data.mask), "host") _, ip_add_dst = ip.increment_ip_addr("{}/{}".format(ip_add_dst.split('/')[0], data.mask), "host") if ele == 2: _, ip_add_src = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P2, data.mask), "host") mirror_args = {'session_name': data.session_name + str(ele),'src_ip': ip_add_src.split('/')[0], 'dst_ip': ip_add_dst.split('/')[0], 'dscp':'50', 'ttl':'60', 'gre_type':'0x88ee', 'queue':data.queue} mirror.create_session(vars.D1, **mirror_args) if not mirror.verify_session(vars.D1, **mirror_args): st.log("failed to configure the mirror session: {} ".format(data.session_name + str(ele))) tc_fail = 1 acl_dscp.config_classifier_table(vars.D1, enable='create', match_type="fields", class_name=data.acl_rule+ str(ele)) acl_dscp.config_classifier_table(vars.D1, enable='yes', class_criteria='--src-ip', match_type="fields", class_name=data.acl_rule + str(ele), criteria_value="{}".format(ip_add_src)) acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='add', policy_type=data.type, class_name=data.acl_rule+str(ele),priority_value=int(data.priority) + ele, description=data.description) acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='update',policy_type=data.type, class_name=data.acl_rule+str(ele), priority_option='--mirror-session', priority_value=data.session_name + str(ele)) # Traffic validations for the mirror sessions. ip_add_src, ip_add_dst, tg_src = data.ip_T1D1P1, data.ip_T1D1P2, 'tg_ph_1' for ele in range(0, max_sessions): if ele == 2: _, ip_add_src = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P2.split('/')[0], data.mask), "host") _, ip_add_dst = ip.increment_ip_addr("{}/{}".format(data.ip_D1T1P1.split('/')[0], data.mask), "host") tg_src = 'tg_ph_2' retval = send_traffic(capture_values=[ip_add_dst], capture_fields=['dst_ip'], ip_src_addr= ip_add_src.split('/')[0], ip_dst_addr= ip_add_dst.split('/')[0], tg_src_port=tg_src) if not retval[0]: st.log('Traffic validation failed for the mirror session combination: source_ip {} , destination_ip {}'.format(ip_add_src,ip_add_dst)) tc_fail = ele _, ip_add_src = ip.increment_ip_addr("{}/{}".format(ip_add_src.split('/')[0], data.mask), "host") #Unconfigration part for ele in range(1, max_sessions): acl_dscp.config_flow_update_table(vars.D1, policy_name=data.acl_table_name, flow='del', policy_type=data.type, class_name=data.acl_rule + str(ele)) acl_dscp.config_classifier_table(dut=vars.D1, enable="del", class_name=data.acl_rule+str(ele)) mirror.delete_session(vars.D1, data.session_name + str(ele)) if tc_fail == 1: st.report_fail("mirror_session_fail", "") elif tc_fail == 2: st.report_fail("traffic_verification_fail", "packet count") st.report_pass("test_case_passed")