diff options
| author | zhaokun <[email protected]> | 2024-11-27 13:57:08 +0800 |
|---|---|---|
| committer | zhaokun <[email protected]> | 2024-11-27 13:57:08 +0800 |
| commit | 25c74d14007dd0800d8a5da6bc7722d0615fe653 (patch) | |
| tree | 16fa4a86ca237070251ea5fbb28681c6fb927e36 | |
| parent | 2ad5ddd548f21b2ae90b2181c045cb06102044c7 (diff) | |
| parent | cb24695f76b6d53644152981c56d82011591e607 (diff) | |
merge
670 files changed, 11885 insertions, 5765 deletions
diff --git a/support/api_utils/create_profiles.py b/support/api_utils/create_profiles.py index dda7354e3..bbd0e20d3 100644 --- a/support/api_utils/create_profiles.py +++ b/support/api_utils/create_profiles.py @@ -74,7 +74,7 @@ class CreateProfiles: profile_uuids_temp_dict = {} profile_uuids_temp_dict["type"] = profile_type profile_uuids_temp_dict["uuid"] = record_uuids - profile_uuids_temp_dict["name"] = policy_configuration["action_parameter"]["record_profile"]["name"] + profile_uuids_temp_dict["name"] = record_profile["record_profile"]["name"] profile_uuids_list.append(profile_uuids_temp_dict) record_profile["record_profile"] = record_uuids elif "traffic_mirroring" in policy_configuration["action_parameter"].keys(): diff --git a/support/api_utils/query_rule_log.py b/support/api_utils/query_rule_log.py index cf033a47e..6ea0a58d9 100644 --- a/support/api_utils/query_rule_log.py +++ b/support/api_utils/query_rule_log.py @@ -93,7 +93,7 @@ class QueryRuleLog: log_condition_dict["intervals"].append(start_time + '/' + end_time) log_condition_dict['vsys'] = self.parameter["vsys"] if self.is_attribute_name_exsit("ATTR_SUBSCRIBER_ID") == True: - log_filter = f"vsys_id in ({int(self.parameter["vsys"])}) AND subscriber_id='{self.parameter['test_subcriber_id']}' AND has({log_query_rule_type}, '{rule_uuid})'" + log_filter = f"vsys_id in ({int(self.parameter['vsys'])}) AND subscriber_id='{self.parameter['test_subcriber_id']}' AND has({log_query_rule_type}, '{rule_uuid}')" log_condition_dict['filter'] = log_filter else: if self.traffic_generation["tool"] == "trex": @@ -101,12 +101,12 @@ class QueryRuleLog: attack_type = "Custom Network Attack" log_condition_dict['filter'] = f"destination_ip='{traffic_generation['servers_start_ip']}'AND attack_type='{attack_type}'" else: - log_filter = f"vsys_id in ({int(self.parameter["vsys"])}) AND client_ip={traffic_generation['clients_start_ip']} AND has({log_query_rule_type}, '{rule_uuid}')" + log_filter = f"vsys_id in ({int(self.parameter['vsys'])}) AND client_ip={traffic_generation['clients_start_ip']} AND has({log_query_rule_type}, '{rule_uuid}')" log_condition_dict['filter'] = log_filter log_condition_dict['filter'] = log_condition_dict['filter'].replace(f"client_ip={traffic_generation['clients_start_ip']}",f"client_ip='{traffic_generation['clients_start_ip']}'") else: # log_filter = f"client_ip={self.parameter['test_pc_ip']} AND has({log_query_rule_type}, '{rule_uuid}')" - log_filter = f"vsys_id in ({int(self.parameter["vsys"])}) AND client_ip={self.parameter['test_pc_ip']} AND has({log_query_rule_type}, '{rule_uuid}')" + log_filter = f"vsys_id in ({int(self.parameter['vsys'])}) AND client_ip={self.parameter['test_pc_ip']} AND has({log_query_rule_type}, '{rule_uuid}')" log_condition_dict['filter'] = log_filter log_condition_dict['filter'] = log_condition_dict['filter'].replace(f"client_ip={self.parameter['test_pc_ip']}", f"client_ip='{self.parameter['test_pc_ip']}'") dsl_dict["dsl"] = log_condition_dict @@ -119,6 +119,7 @@ class QueryRuleLog: "query_jobs":[{"id": job_id,"query_option":"list"}], "vsys":int(self.parameter["vsys"]),"limit":20,"offset":0 } + time.sleep(2) response = requests.post(url, headers=headers, json=query_list_dict, verify=False) assert response.status_code == 200 log_list = json.loads(response.text) @@ -188,8 +189,8 @@ class QueryRuleLog: else: temp_log_result_list.append(True) elif query_field_key in {"monitor_mirrored_pkts", "monitor_mirrored_bytes"}: - actual_bytes_value = self.traffic_result['result']['total_bytes'] - actual_pkts_value = self.traffic_result['result']["total_packets"] + actual_bytes_value = self.traffic_result['total_bytes'] + actual_pkts_value = self.traffic_result["total_packets"] mirror_bytes_value = 0 mirror_pkts_value = 0 application = self.get_application_from_configration() diff --git a/support/packet_generator/dns_player.py b/support/packet_generator/dns_player.py index 72168f50a..cee1beeee 100644 --- a/support/packet_generator/dns_player.py +++ b/support/packet_generator/dns_player.py @@ -4,7 +4,7 @@ from datetime import datetime import dns.resolver class DnsPlayer: - def send_dns_query(self, traffic_data, script_type, debug_flag): + def send_dns_query(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send dns traffic for effect verification.", flush=True) if "command" in traffic_data: p = subprocess.Popen(traffic_data["command"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") diff --git a/support/packet_generator/doh_player.py b/support/packet_generator/doh_player.py index 422cfc32f..a2f118ed7 100644 --- a/support/packet_generator/doh_player.py +++ b/support/packet_generator/doh_player.py @@ -6,7 +6,7 @@ import dns.message import dns.name class DohPlayer: - def send_doh_query(self, traffic_data, script_type, debug_flag): + def send_doh_query(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send doh query for effect verification.", flush=True) domain = traffic_data["domain"] diff --git a/support/packet_generator/ftp_player.py b/support/packet_generator/ftp_player.py index 32cf0b1bd..48492f027 100644 --- a/support/packet_generator/ftp_player.py +++ b/support/packet_generator/ftp_player.py @@ -4,7 +4,7 @@ from datetime import datetime from ftplib import FTP class FtpPlayer: - def send_ftp_traffic(self, traffic_data, script_type, debug_flag): + def send_ftp_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send ftp traffic for effect verification.", flush=True) if "command" in traffic_data: p = subprocess.Popen(traffic_data["command"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") diff --git a/support/packet_generator/gre_over_gre_player.py b/support/packet_generator/gre_over_gre_player.py index 763c06928..680f7f4db 100644 --- a/support/packet_generator/gre_over_gre_player.py +++ b/support/packet_generator/gre_over_gre_player.py @@ -12,7 +12,7 @@ from scapy.layers.inet import IP, TCP from datetime import datetime class GreOverGrePlayer: - def send_gre_over_gre_traffic(self, traffic_data, script_type, debug_flag): + def send_gre_over_gre_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send gre over gre traffic for effect verification.", flush=True) try: pcap = traffic_data["pcap_name"] + ".pcap" diff --git a/support/packet_generator/http_player.py b/support/packet_generator/http_player.py index 57e1dccc3..fea2da298 100644 --- a/support/packet_generator/http_player.py +++ b/support/packet_generator/http_player.py @@ -4,7 +4,7 @@ from datetime import datetime import requests class HttpPlayer: - def send_http_traffic(self, traffic_data, script_type, debug_flag): + def send_http_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send http traffic for effect verification.", flush=True) if "command" in traffic_data: p = subprocess.Popen(traffic_data["command"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") diff --git a/support/packet_generator/mail_player.py b/support/packet_generator/mail_player.py index 3e7a3ac51..3a4f1904c 100644 --- a/support/packet_generator/mail_player.py +++ b/support/packet_generator/mail_player.py @@ -10,7 +10,7 @@ from email.header import Header from email import encoders class MailPlayer: - def send_mail_traffic(self, traffic_data, script_type, debug_flag): + def send_mail_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send mail traffic for effect verification.", flush=True) if "command" in traffic_data: p = subprocess.Popen(traffic_data["command"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") diff --git a/support/packet_generator/mpls_one_label_player.py b/support/packet_generator/mpls_one_label_player.py index 6a8f6c0ad..bde84220e 100644 --- a/support/packet_generator/mpls_one_label_player.py +++ b/support/packet_generator/mpls_one_label_player.py @@ -12,7 +12,7 @@ from scapy.layers.inet import IP, TCP from datetime import datetime class MplsOneLabelPlayer: - def send_mpls_one_label_traffic(self, traffic_data, script_type, debug_flag): + def send_mpls_one_label_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send mpls traffic for effect verification.", flush=True) try: pcap = traffic_data["pcap_name"] + ".pcap" diff --git a/support/packet_generator/quic_player.py b/support/packet_generator/quic_player.py index 6acb61413..6ead323ba 100644 --- a/support/packet_generator/quic_player.py +++ b/support/packet_generator/quic_player.py @@ -5,7 +5,7 @@ from datetime import datetime from aioquic.quic.configuration import QuicConfiguration from aioquic.asyncio.protocol import QuicConnectionProtocol -async def send_quic_traffic(traffic_data, script_type, debug_flag): +async def send_quic_traffic(traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send quic traffic for effect verification.", flush=True) configuration = QuicConfiguration(is_client=True) # protocol = QuicConnectionProtocol("quic") diff --git a/support/packet_generator/ssl_player.py b/support/packet_generator/ssl_player.py index c8796caa0..da0f5e762 100644 --- a/support/packet_generator/ssl_player.py +++ b/support/packet_generator/ssl_player.py @@ -7,7 +7,7 @@ from scapy.all import * from scapy.layers.inet import TCP class SSLPlayer: - def send_ssl_traffic(self, traffic_data, script_type, debug_flag): + def send_ssl_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send ssl traffic for effect verification.", flush=True) if "command" in traffic_data: p = subprocess.Popen(traffic_data["command"], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8") diff --git a/support/packet_generator/traffic_generator.py b/support/packet_generator/traffic_generator.py index c2047e6e1..da94829ec 100644 --- a/support/packet_generator/traffic_generator.py +++ b/support/packet_generator/traffic_generator.py @@ -49,7 +49,7 @@ class TrafficGenerator: if parse_boolean == False: json_data = {} json_data = response.text - result = json_data + result = json_data["result"] else: if traffic_generation["tool"] == "http": print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Simulate http traffic.", flush=True) @@ -133,13 +133,8 @@ class TrafficGenerator: try: if self.traffic_generation["tool"] == "trex": return True, "" - debug = "local" - if debug == "local": - traffic_result_temp = traffic_result["result"] - else: - traffic_result_temp = traffic_result expected_result_temp = verification["excepted_traffic_result"] - result = all(word in traffic_result_temp for word in expected_result_temp) + result = all(word in traffic_result for word in expected_result_temp) #if not result: # print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], 'DEBUG:excepted_traffic_result:{};expected_result_temp:{};traffic_result_temp:{}'.format(result, expected_result_temp, traffic_result_temp), flush=True) if result == True: diff --git a/support/packet_generator/unordered_tcp_player.py b/support/packet_generator/unordered_tcp_player.py index 958a33868..fa74b19de 100644 --- a/support/packet_generator/unordered_tcp_player.py +++ b/support/packet_generator/unordered_tcp_player.py @@ -12,7 +12,7 @@ from scapy.layers.inet import IP, TCP from datetime import datetime class UnorderedTcpPlayer: - def send_unordered_tcp_traffic(self, traffic_data, script_type, debug_flag): + def send_unordered_tcp_traffic(self, traffic_data): print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to send tcp out of order traffic for effect verification.", flush=True) try: pcap = traffic_data["pcap_name"] + ".pcap" diff --git a/support/ui_utils/element_position/map_element_position_library.py b/support/ui_utils/element_position/map_element_position_library.py index 6823f6972..92e6e8814 100644 --- a/support/ui_utils/element_position/map_element_position_library.py +++ b/support/ui_utils/element_position/map_element_position_library.py @@ -1215,9 +1215,18 @@ object_subscriberid_object_element_position = { "objectPage_okButton_posXpath": subscriberidObjectPage_okButton_posXpath, "objectPage_okButton_warningYes_posXpath": subscriberidObjectPage_okButton_warningYes_posXpath }, + "edit":{ + "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath, + "objectPage_addItem_posXpath": subscriberidobjectPage_addItem_posXpath, + "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath, + "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath, + "objectPage_inputItem_posXpath": subscriberidObjectPage_inputItem_posXpath, + "objectPage_button_saveItem_posXpath": subscriberidPage_button_saveItem_posXpath, + "objectPage_okButton_posXpath": subscriberidObjectPage_okButton_posXpath, + }, "search": { "objectListPage_searchLabel_posXpath": subscriberidObjectListPage_searchLabel_posXpath, - "objectListPage_searchLabel_selectName_posXpath": subscriberidObjectListPage_searchLabel_selectName_posXpath, + "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath, "objectListPage_tableTbody_posXpath": subscriberidObjectListPage_tableTbody_posXpath, "objectListPage_search_input_posXpath": subscriberidObjectListPage_search_input_posXpath, "objectListPage_search_dropDown_item_posXpath": subscriberidObjectListPage_search_dropDown_item_posXpath, @@ -1251,9 +1260,21 @@ object_keywords_object_element_position = { "objectPage_okButton_warningYes_posXpath": keywordsObjectPage_okButton_warningYes_posXpath, "ObjectPage_sameItem_addItem_posXpath": urlObjectPage_sameItem_addItem_posXpath, }, + "edit": { + "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath, + "objectPage_addItem_posXpath": keywordsobjectPage_addItem_posXpath, + "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath, + "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath, + "objectPage_inputItem_posXpath": keywordsObjectPage_inputItem_posXpath, + "objectPage_button_saveItem_posXpath": keywordsObjectPage_button_saveItem_posXpath, + "objectPage_okButton_posXpath": keywordsObjectPage_okButton_posXpath, + "ObjectPage_sameItem_addItem_posXpath": keywordsObjectPage_sameItem_addItem_posXpath, + "ObjectPage_sameItem_inputItem_posXpath":keywordsObjectPage_sameItem_inputItem_posXpath + }, "search": { "objectListPage_searchLabel_posXpath": keywordsObjectListPage_searchLabel_posXpath, "objectListPage_searchLabel_selectName_posXpath": keywordsObjectListPage_searchLabel_selectName_posXpath, + "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath, "objectListPage_tableTbody_posXpath": keywordsObjectListPage_tableTbody_posXpath, "objectListPage_search_input_posXpath": keywordsObjectListPage_search_input_posXpath, "objectListPage_search_dropDown_item_posXpath": keywordsObjectListPage_search_dropDown_item_posXpath, @@ -1261,7 +1282,7 @@ object_keywords_object_element_position = { }, "delete": { "objectListPage_allSelect_posXpath": keywordsObjectListPage_allSelect_posXpath, - "objectListPage_deleteButton_posId": keywordsObjectListPage_deleteButton_posId, + "objectListPage_deleteButton_posXpath": keywordsObjectListPage_deleteButton_posXpath, "objectListPage_deleteButton_warningYes_posXpath": keywordsObjectListPage_deleteButton_warningYes_posXpath } } @@ -1382,7 +1403,7 @@ object_imsi_object_element_position = { }, "delete": { "objectListPage_allSelect_posXpath": imsiObjectListPage_allSelect_posXpath, - "objectListPage_deleteButton_posId": imsiObjectListPage_deleteButton_posId, + "objectListPage_deleteButton_posId": imsiObjectListPage_deleteButton_posXpath, "objectListPage_deleteButton_warningYes_posXpath": imsiObjectListPage_deleteButton_warningYes_posXpath } } @@ -1413,7 +1434,7 @@ object_phone_number_object_element_position = { }, "delete": { "objectListPage_allSelect_posXpath": imsiObjectListPage_allSelect_posXpath, - "objectListPage_deleteButton_posId": imsiObjectListPage_deleteButton_posId, + "objectListPage_deleteButton_posId": imsiObjectListPage_deleteButton_posXpath, "objectListPage_deleteButton_warningYes_posXpath": imsiObjectListPage_deleteButton_warningYes_posXpath } } @@ -1439,11 +1460,20 @@ object_mobile_identity_object_element_position = { "objectPage_okButton_warningYes_posXpath": imsiObjectPage_okButton_warningYes_posXpath, "ObjectPage_sameItem_addItem_posXpath": phoneNumberobjectPage_sameItem_addItem_posXpath, "ObjectPage_sameItem_inputItem_posXpath":phoneNumberObjectPage_sameItem_inputItem_posXpath - + }, + "edit": { + "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath, + "objectPage_addItem_posXpath": imsiobjectPage_addItem_posXpath, + "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath, + "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath, + "objectPage_inputItem_posXpath": imsiObjectPage_inputItem_posXpath, + "objectPage_button_saveItem_posXpath": imsiObjectPage_button_saveItem_posXpath, + "objectPage_okButton_posXpath": imsiObjectPage_okButton_posXpath, }, "search": { "objectListPage_searchLabel_posXpath": imsiObjectListPage_searchLabel_posXpath, "objectListPage_searchLabel_selectName_posXpath": imsiObjectListPage_searchLabel_selectName_posXpath, + "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath, "objectListPage_tableTbody_posXpath": imsiObjectListPage_tableTbody_posXpath, "objectListPage_search_input_posXpath": imsiObjectListPage_search_input_posXpath, "objectListPage_search_dropDown_item_posXpath": imsiObjectListPage_search_dropDown_item_posXpath, @@ -1451,7 +1481,7 @@ object_mobile_identity_object_element_position = { }, "delete": { "objectListPage_allSelect_posXpath": imsiObjectListPage_allSelect_posXpath, - "objectListPage_deleteButton_posId": imsiObjectListPage_deleteButton_posId, + "objectListPage_deleteButton_posXpath": imsiObjectListPage_deleteButton_posXpath, "objectListPage_deleteButton_warningYes_posXpath": imsiObjectListPage_deleteButton_warningYes_posXpath } } @@ -1474,9 +1504,18 @@ object_apn_object_element_position = { "objectPage_okButton_posXpath": apnObjectPage_okButton_posXpath, "objectPage_okButton_warningYes_posXpath": apnObjectPage_okButton_warningYes_posXpath }, + "edit": { + "ObjectListPage_editButton_posXpath": ipObjectListPage_editButton_posXpath, + "objectPage_addItem_posXpath": subscriberidobjectPage_addItem_posXpath, + "ObjectPage_edit_item_posXpath": ipObjectPage_edit_item_posXpath, + "ObjectPage_search_item_posXpath": ipObjectPage_search_item_posXpath, + "objectPage_inputItem_posXpath": subscriberidObjectPage_inputItem_posXpath, + "objectPage_button_saveItem_posXpath": subscriberidPage_button_saveItem_posXpath, + "objectPage_okButton_posXpath": subscriberidObjectPage_okButton_posXpath, + }, "search": { "objectListPage_searchLabel_posXpath": apnObjectListPage_searchLabel_posXpath, - "objectListPage_searchLabel_selectName_posXpath": apnObjectListPage_searchLabel_selectName_posXpath, + "objectListPage_searchLabel_selectID_posXpath": objectListPage_search_select_Id_posXpath, "objectListPage_tableTbody_posXpath": apnObjectListPage_tableTbody_posXpath, "objectListPage_search_input_posXpath": apnObjectListPage_search_input_posXpath, "objectListPage_search_dropDown_item_posXpath": apnObjectListPage_search_dropDown_item_posXpath, diff --git a/support/ui_utils/element_position/object_element_position.py b/support/ui_utils/element_position/object_element_position.py index ad2697077..99af9aaec 100644 --- a/support/ui_utils/element_position/object_element_position.py +++ b/support/ui_utils/element_position/object_element_position.py @@ -140,7 +140,7 @@ mobile_identitiesObjectListPage_createButton_posXpath = '//span[@class="action-c mobile_identitiesObjectListPage_dropDown_createButton_posXpath = "//ul[@class='base-Popper-root MuiMenu-root Mui-expanded MuiMenu-variantOutlined MuiMenu-colorNeutral MuiMenu-sizeMd css-1iuehdr']//li[1]" # 从下拉菜单中选择Mobile Identity imsiObjectListPage_searchLabel_posXpath = ipObjectListPage_searchLabel_posId = "//div[@class='MuiAutocomplete-wrapper MuiAutocomplete-multiple css-1h1ala5']//input" # 查询框id imsiObjectListPage_searchLabel_selectName_posXpath = '//li[@id="2-_FilteredSearch_ElRow_Objects_mobile_identity_Home_App_anonymousComponent"]' # 查询Name -imsiObjectListPage_deleteButton_posId = "//div[@class='flex justify-start items-center mr-[20px]']//span[text()='Delete']" +imsiObjectListPage_deleteButton_posXpath = "//div[@class='flex justify-start items-center mr-[20px]']//span[text()='Delete']" imsiObjectListPage_deleteButton_warningYes_posXpath = ipObjectListPage_deleteButton_warningYes_posXpath imsiObjectListPage_allSelect_posXpath = objectListPage_allSelect_posXpath imsiObjectListPage_search_input_posXpath = objectListPage_search_input_posXpath @@ -312,7 +312,7 @@ urlObjectListPage_deleteButton_warningYes_posXpath = httpSignatureObjectListPage # keywords keywordsObjectListPage_createButton_posXpath = '//span[@class="action-create inline-flex mr-[8px] "]/button' -keywordsObjectListPage_deleteButton_posId = '//*[@class="action-delete inline-flex mr-[8px] "]' +keywordsObjectListPage_deleteButton_posXpath = '//*[@class="action-delete inline-flex mr-[8px] "]' keywordsObjectListPage_deleteButton_warningYes_posXpath = httpSignatureObjectListPage_deleteButton_warningYes_posXpath # httpSignatureObjectListPage_deleteButton_warningNo_posCss keywordsObjectListPage_dropDown_createButton_posXpath = '//li[@class="MuiMenuItem-root MuiMenuItem-colorNeutral MuiMenuItem-variantPlain keyword-item css-1rt9hnn"]' @@ -331,6 +331,8 @@ keywordsObjectPage_item_value_plus_posXpath = '//*[@class="customRow css-863uk6" keywordsObjectPage_button_saveItem_posXpath = '//*[@class="flex flex-row items-center"]//i[@class="operate-icon iconfont icon-save"]' keywordsObjectPage_okButton_posXpath = '//*[@class="form-action bg-[--color-background] flex justify-center py-[12px] absolute bottom-0 w-full"]//button[1]' keywordsObjectPage_okButton_warningYes_posXpath = "//button[@class='el-button el-button--default el-button--small el-button--primary operation-confirm']//span" +keywordsObjectPage_sameItem_addItem_posXpath = '//*[@class="pl-[40px] pt-[0!important]"]//i[@class="iconfont icon-Create1 font-[700]"]' +keywordsObjectPage_sameItem_inputItem_posXpath = "(//div[@class='form-list-row css-xpbhx9']//div[@class='MuiBox-root css-0']//input[@class='MuiInput-input css-1u0jcuo'])[last()]" # account accountObjectListPage_createButton_posXpath = '//span[@class="action-create inline-flex mr-[8px] "]/button' diff --git a/support/ui_utils/objects/create_objects_example.py b/support/ui_utils/objects/create_objects_example.py index 777a54c81..16fe1ad09 100644 --- a/support/ui_utils/objects/create_objects_example.py +++ b/support/ui_utils/objects/create_objects_example.py @@ -48,7 +48,7 @@ class CreateObjects: object_type = object["type"] element_position_library = get_element_position(object_type) page_jump_element_position = element_position_library["page_jump"] - create_element_position = element_position_library["create"] + creation_element_position = element_position_library["create"] # 页面跳转 page_jump = PageJump(self.driver) page_jump.jump_sub_object_page(page_jump_element_position) @@ -58,27 +58,27 @@ class CreateObjects: object_type = object["type"] # 点击creat time.sleep(8) - self.driver.find_element(By.XPATH, create_element_position["objectListPage_createButton_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectListPage_createButton_posXpath"]).click() time.sleep(1) if object_type not in ["application","tunnel"]: - self.driver.find_element(By.XPATH,create_element_position["objectListPage_dropDown_createButton_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectListPage_dropDown_createButton_posXpath"]).click() time.sleep(1) # 输入name object_name = object["name"] - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputName_posXpath"]).send_keys(object_name) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputName_posXpath"]).send_keys(object_name) # 添加item """ if object_type == "http_signature": for i in range(len(object["items"])): - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_item_key_dropDown_posXpath"]).click() - temp_element_position = create_element_position["objectPage_item_key_dropDown_select_posXpath"].format(replaceValue=object["items"][i]["item_key"]) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_item_key_dropDown_posXpath"]).click() + temp_element_position = creation_element_position["objectPage_item_key_dropDown_select_posXpath"].format(replaceValue=object["items"][i]["item_key"]) self.driver.find_element(By.XPATH, temp_element_position).click() - temp_element_position = create_element_position["objectPage_item_value_select_posXpath"].format(replaceValue=object["items"][i]["item_value"]) + temp_element_position = creation_element_position["objectPage_item_value_select_posXpath"].format(replaceValue=object["items"][i]["item_value"]) self.driver.find_element(By.XPATH, temp_element_position).click() # 如果有range,则需要点击range if "range" in object["items"][i] and len(object["items"][i]["range"]) > 0: - self.driver.find_element(By.XPATH, create_element_position["objectPage_item_value_select_posXpath"].format(replaceValue="Range")).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_item_value_select_posXpath"].format(replaceValue="Range")).click() if object["items"][i]["item_operation"] == "add": # 直接 新增 模式 if "->" in object["items"][i]["value"][0]: # -> 存在,需要拆分 item_value_str = object["items"][i]["value"][0].split("->")[0].strip() @@ -94,28 +94,28 @@ class CreateObjects: item_values = [object["items"][i]["item_value"]] for j, item_value in enumerate(item_values): # 遍历添加 multi substr,第一个元素不用点击 + 图标 item_value = item_value.strip() - temp_element_position = create_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=1) + temp_element_position = creation_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=1) if j == 0: self.driver.find_element(By.XPATH, temp_element_position).send_keys(item_value) else: - self.driver.find_element(By.XPATH,create_element_position["objectPage_item_value_plus_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_item_value_plus_posXpath"]).click() self.driver.find_element(By.XPATH, temp_element_position).send_keys(item_value) # 如果有range,需要输入 offset depth if "range" in object["items"][i] and len(object["items"][i]["range"]) > 0: offset = object["items"][i]["range"][j]["offset"] depth = object["items"][i]["range"][j]["depth"] - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=2), find_after_wait_time=0.5).send_keys(offset) - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=3), find_after_wait_time=0.5).send_keys(depth) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=2), find_after_wait_time=0.5).send_keys(offset) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j+1, replaceValueInput=3), find_after_wait_time=0.5).send_keys(depth) - self.driver.find_element(By.XPATH, create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_button_saveItem_posXpath"]).click() el""" if object_type in ["keyword", "http_signature"]: for i in range(len(object["items"])): - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() - # temp_element_position = create_element_position["objectPage_item_value_select_posXpath"].format(replaceValue=object["items"][i]["expression"]) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() + # temp_element_position = creation_element_position["objectPage_item_value_select_posXpath"].format(replaceValue=object["items"][i]["expression"]) # self.driver.find_element(By.XPATH, temp_element_position).click() if object["items"][i]["op"] == "add": # 直接 新增 模式 if "->" in object["items"][i]["expression"]: # -> 存在,需要拆分 @@ -132,22 +132,22 @@ class CreateObjects: item_values = [object["items"][i]["expression"]] for j, item_value in enumerate(item_values): # 遍历添加 multi substr,第一个元素不用点击 + 图标 item_value = item_value.strip() - temp_element_position = create_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j + 1) + temp_element_position = creation_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j + 1) if j == 0: for char in str(item_value): self.driver.find_element(By.XPATH, temp_element_position).send_keys(char) time.sleep(0.1) else: - self.driver.find_element(By.XPATH, create_element_position["objectPage_item_value_plus_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_item_value_plus_posXpath"]).click() for char in str(item_value): self.driver.find_element(By.XPATH, temp_element_position).send_keys(char) time.sleep(0.1) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type in ["url", "account", "phone_number", "fqdn", "subscriberid", "apn"]: if object_type == "phone_number": - self.driver.find_element(By.XPATH,create_element_position["objectPage_phnoeNumberType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_phnoeNumberType_posXpath"]).click() for i in range(len(object["items"])): # - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() if object["items"][i]["op"] == "add": # 直接 新增 模式 if "->" in object["items"][i]["expression"]: # -> 存在,需要拆分 item_value_str = object["items"][i]["expression"].split("->")[0].strip() @@ -165,17 +165,17 @@ class CreateObjects: item_value = item_value.strip() if j == 0: # 适配24.10 版本,需要逐个字符输入 - input_field = self.driver.find_element(By.XPATH, create_element_position["objectPage_inputItem_posXpath"]) + input_field = self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputItem_posXpath"]) for char in str(item_value): input_field.send_keys(char) time.sleep(0.1) else: - self.driver.find_element(By.XPATH, create_element_position["ObjectPage_sameItem_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["ObjectPage_sameItem_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value) + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type == "flag": for i in range(len(object["items"])): # - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() if object["items"][i]["op"] == "add": # 直接 新增 模式 for key_flag in object["items"][i]["flag"]: if key_flag == "Bulky" and object["items"][i]["flag"][key_flag] == True: @@ -210,56 +210,56 @@ class CreateObjects: self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[16]").click() elif key_flag == "Tunneling" and object["items"][i]["flag"][key_flag] == True: self.driver.find_element(By.XPATH, "//*[@class='flag-object-flag']//span[17]").click() - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type == "interval": for i in range(len(object["items"])): data_int = object["items"][i]["interval"].split("-") - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() # 点击“+”按钮 + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() # 点击“+”按钮 # 在空内容的输入框中,输入新增的数据 - self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_lowBoundary_posXpath"]).send_keys(eval(str(data_int))[0]) # 于item 下low_boundary value输入框键入item_value - self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_upBoundary_posXpath"]).send_keys(eval(str(data_int))[1]) # 于item 下up_boundary value输入框键入item_value - self.driver.find_element(By.XPATH, create_element_position["objectPage_button_saveItem_posXpath"]).click() # 点击保存按钮 + self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_lowBoundary_posXpath"]).send_keys(eval(str(data_int))[0]) # 于item 下low_boundary value输入框键入item_value + self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_upBoundary_posXpath"]).send_keys(eval(str(data_int))[1]) # 于item 下up_boundary value输入框键入item_value + self.driver.find_element(By.XPATH, creation_element_position["objectPage_button_saveItem_posXpath"]).click() # 点击保存按钮 elif object_type == "application": - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputLongName_posXpath"]).send_keys(object["application"]["app_longname"]) # input long name - # self.driver.find_element(By.XPATH, create_element_position[""]).send_keys("Your description") # input description - self.driver.find_element(By.XPATH, create_element_position["objectPage_select_category_dropwmn_posXpath"]).click() # category - self.driver.find_element(By.XPATH, create_element_position["objectPage_category_xpath"].format(replaceValue=object["application"]["app_properties"]["category"])).click() # - self.driver.find_element(By.XPATH, create_element_position["objectPage_select_subcategory_dropwmn_posXpath"]).click() # subcategory - self.driver.find_element(By.XPATH, create_element_position["objectPage_sub_category_xpath"].format(replaceValue=object["application"]["app_properties"]["subcategory"])).click() # - self.driver.find_element(By.XPATH, create_element_position["objectPage_select_content_dropwmn_posXpath"]).click() # content - self.driver.find_element(By.XPATH, create_element_position["objectPage_content_xpath"].format(replaceValue=object["application"]["app_properties"]["content"])).click() # - self.driver.find_element(By.XPATH, create_element_position["objectPage_select_risk_dropwmn_posXpath"]).click() # risk 0 - self.driver.find_element(By.XPATH, create_element_position["objectPage_risi_xpath"].format(replaceValue=object["application"]["app_properties"]["risk"])).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_characteristics_xpath"].format(replaceValue=object["application"]["app_properties"]["characteristics"])).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputLongName_posXpath"]).send_keys(object["application"]["app_longname"]) # input long name + # self.driver.find_element(By.XPATH, creation_element_position[""]).send_keys("Your description") # input description + self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_category_dropwmn_posXpath"]).click() # category + self.driver.find_element(By.XPATH, creation_element_position["objectPage_category_xpath"].format(replaceValue=object["application"]["app_properties"]["category"])).click() # + self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_subcategory_dropwmn_posXpath"]).click() # subcategory + self.driver.find_element(By.XPATH, creation_element_position["objectPage_sub_category_xpath"].format(replaceValue=object["application"]["app_properties"]["subcategory"])).click() # + self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_content_dropwmn_posXpath"]).click() # content + self.driver.find_element(By.XPATH, creation_element_position["objectPage_content_xpath"].format(replaceValue=object["application"]["app_properties"]["content"])).click() # + self.driver.find_element(By.XPATH, creation_element_position["objectPage_select_risk_dropwmn_posXpath"]).click() # risk 0 + self.driver.find_element(By.XPATH, creation_element_position["objectPage_risi_xpath"].format(replaceValue=object["application"]["app_properties"]["risk"])).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_characteristics_xpath"].format(replaceValue=object["application"]["app_properties"]["characteristics"])).click() #添加signature - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_create_signature_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_create_signature_posXpath"]).click() for m in range(len(object["app_surrogates"])): app_surrogates= object["app_surrogates"][m] for i in range(len(app_surrogates["signature_sequence"])): app_signature= app_surrogates["signature_sequence"][i] - self.driver.find_element(By.XPATH,create_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"]) - self.driver.find_element(By.XPATH, create_element_position["signature_add_artibutem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["signature_inputName_posXpath"]).send_keys(app_signature["signature"]["name"]) + self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibutem_posXpath"]).click() for j in range(len(app_signature["signature"]["and_conditions"])): app_and_condition= app_signature["signature"]["and_conditions"][j] - self.driver.find_element(By.XPATH, create_element_position["signature_condition_select_up_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["signature_condition_select_up_posXpath"]).click() if app_and_condition["negate_option"] == False: - self.driver.find_element(By.XPATH, create_element_position["signature_new_condition__posXpath"]).click() - else:self.driver.find_element(By.XPATH, create_element_position["signature_new_not_condition__posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["signature_add_artibute_button_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["signature_new_condition__posXpath"]).click() + else:self.driver.find_element(By.XPATH, creation_element_position["signature_new_not_condition__posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["signature_add_artibute_button_posXpath"]).click() for n in range(len(app_and_condition["or_conditions"])): app_or_condition= app_and_condition["or_conditions"][n] self.driver.find_element(By.XPATH,"//li[@class = 'MuiTreeItem-root css-105mfs8']//div[text()='common']").click() - self.driver.find_element(By.XPATH,create_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click() + self.driver.find_element(By.XPATH,creation_element_position["signature_artibute_protocols"].format(replaceValue=app_or_condition["attribute_name"])).click() self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click() - self.driver.find_element(By.XPATH,create_element_position["attribute_add_object_posXpath"]).click() - self.driver.find_element(By.XPATH,create_element_position["objectPage_create_signature_posXpath"]+"[2]").click() + self.driver.find_element(By.XPATH,creation_element_position["attribute_add_object_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_create_signature_posXpath"]+"[2]").click() common_object_element_position = get_element_position(app_or_condition["type"]) self.create_common_objects(app_or_condition,common_object_element_position) - self.driver.find_element(By.XPATH,create_element_position["objectPage_okButton_posXpath"]+"[4]").click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[4]").click() self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[4]//button[text()='Cancel']").click() - self.driver.find_element(By.XPATH,create_element_position["objectPage_okButton_posXpath"]+"[3]").click() - self.driver.find_element(By.XPATH,create_element_position["objectPage_okButton_posXpath"]+"[2]").click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[3]").click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[2]").click() self.driver.find_element(By.XPATH,"(//div[@class='MuiDrawer-content css-10lcz44'])[1]//button[text()='Cancel']").click() elif object_type == "tunnel": if len(object["tunnel"]["and_conditions"]) == 1: @@ -268,95 +268,95 @@ class CreateObjects: tunnel_endition_a = object["tunnel"]["and_conditions"][0] tunnel_endition_b = object["tunnel"]["and_conditions"][1] - self.driver.find_element(By.XPATH, create_element_position["objectPage_edit_tunnel_type_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_edit_tunnel_type_posXpath"]).click() if object["tunnel"]["action_parameter"]["type"] == "IP": - self.driver.find_element(By.XPATH, create_element_position["objectListPage_type_ip_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectListPage_type_ip_posXpath"]).click() elif object["tunnel"]["action_parameter"]["type"] == "GRE": - self.driver.find_element(By.XPATH, create_element_position["objectListPage_type_gre_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectListPage_type_gre_posXpath"]).click() for i in range(len(tunnel_endition_a["or_conditions"])): - self.driver.find_element(By.XPATH,create_element_position["objectPage_endition_a_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_side_slic_create_button_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_endition_a_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_side_slic_create_button_posXpath"]).click() common_object_element_position = get_element_position(tunnel_endition_a["or_conditions"][i]["type"]) self.create_common_objects(tunnel_endition_a["or_conditions"][i],common_object_element_position) - self.driver.find_element(By.XPATH,create_element_position["objectPage_okButton_posXpath"]+"[2]").click() - self.driver.find_element(By.XPATH,create_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"]+"[2]").click() + self.driver.find_element(By.XPATH,creation_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click() if len(object["tunnel"]["and_conditions"]) == 2: - self.driver.find_element(By.XPATH,create_element_position["objectPage_endition_b_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH,create_element_position["objectPage_endition_b_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_side_slic_create_button_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_endition_b_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_endition_b_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_side_slic_create_button_posXpath"]).click() for i in range(len(tunnel_endition_b["or_conditions"])): self.create_common_objects(tunnel_endition_b["or_conditions"][i], common_object_element_position) - self.driver.find_element(By.XPATH,create_element_position["objectPage_okButton_posXpath"] + "[2]").click() - self.driver.find_element(By.XPATH,create_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_okButton_posXpath"] + "[2]").click() + self.driver.find_element(By.XPATH,creation_element_position["ObjectPage_side_slic_Cancel_posXpath"]).click() elif object_type == "port": for i in range(len(object["items"])): if object["items"][i]["op"] == "add": - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() # 适配24.10 版本,需要逐个字符输入 send_data = object["items"][i]["interval"] - input_field = self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_posXpath"]) + input_field = self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_posXpath"]) for char in str(send_data): input_field.send_keys(char) time.sleep(0.1) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type == "ip_learning": - self.driver.find_element(By.XPATH,create_element_position["objectPage_ipLearningType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_ipLearningType_posXpath"]).click() if object["op"] == "add": for i in range(0,len(object["learning_plan"]["fqdn_ip_learning_plan"]["from_fqdns"])): - self.driver.find_element(By.XPATH,create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_addItem_posXpath"]).click() send_data = object["learning_plan"]["fqdn_ip_learning_plan"]["from_fqdns"][i] - input_field = self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_posXpath"]) + input_field = self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_posXpath"]) for char in str(send_data): input_field.send_keys(char) time.sleep(0.1) - self.driver.find_element(By.XPATH, create_element_position["objectPage_button_saveItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_learnFromProtocols_up_select_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_learnFromProtocols_up_select_posXpath"]).click() if object["learning_plan"]["fqdn_ip_learning_plan"]["from_protocol"] == "HTTP": - self.driver.find_element(By.XPATH,create_element_position["objectPage_learnFromProtocols_http_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_learnFromProtocols_http_posXpath"]).click() elif object["learning_plan"]["fqdn_ip_learning_plan"]["from_protocol"] == "SSL": - self.driver.find_element(By.XPATH,create_element_position["objectPage_learnFromProtocols_ssl_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_learnFromProtocols_ssl_posXpath"]).click() # self.driver.find_element(By.XPATH, ip_addressObjectPage_button_IP_learn_from_protocols_up_posXpath).click() - self.driver.find_element(By.XPATH, create_element_position["objectPage_agingTimes_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["aging_time"] ) - self.driver.find_element(By.XPATH,create_element_position["objectPage_voteClients_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["vote_client_num"]) - self.driver.find_element(By.XPATH,create_element_position["objectPage_learnedIPLimits_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["goal_upper_limit"]) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_agingTimes_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["aging_time"] ) + self.driver.find_element(By.XPATH,creation_element_position["objectPage_voteClients_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["vote_client_num"]) + self.driver.find_element(By.XPATH,creation_element_position["objectPage_learnedIPLimits_posXpath"]).send_keys(object["learning_plan"]["fqdn_ip_learning_plan"]["goal_upper_limit"]) else: for i in range(len(object["items"])): if object_type == "ip": - self.driver.find_element(By.XPATH,create_element_position["objectPage_ipType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_ipType_posXpath"]).click() send_data = object["items"][i]["ip"] if object_type == "imsi": - self.driver.find_element(By.XPATH,create_element_position["objectPage_imsiType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_imsiType_posXpath"]).click() send_data = object["items"][i]["expression"] elif object_type == "imei": - self.driver.find_element(By.XPATH,create_element_position["objectPage_imeiType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_imeiType_posXpath"]).click() send_data = object["items"][i]["expression"] if object["items"][i]["op"] == "add": - self.driver.find_element(By.XPATH,create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_addItem_posXpath"]).click() # 适配24.10 版本,需要逐个字符输入 - input_field = self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_posXpath"]) + input_field = self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_posXpath"]) for char in str(send_data): input_field.send_keys(char) time.sleep(0.1) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() if "statistics_option" in object.keys(): # 如果修改Object的统计参数则进行操作 statistics_option_temp = object["statistics_option"] time.sleep(1) - if statistics_option_temp in {"None", "Brief", "Elaborate"}: - self.driver.find_element(By.XPATH,create_element_position["objectPage_statistics_select_posXpath"]).click() - element_dropdown_item = self.driver.find_element(By.XPATH, create_element_position["objectPage_statistics_select_option_posXpath"].format(statistics_option_temp)) + if statistics_option_temp in {"brief", "elaborate"}: + self.driver.find_element(By.XPATH,creation_element_position["objectPage_statistics_select_posXpath"]).click() + element_dropdown_item = self.driver.find_element(By.XPATH, creation_element_position["objectPage_statistics_select_option_posXpath"].format(statistics_option_temp)) # 移动元素到页面,在执行点击 self.driver.execute_script("arguments[0].scrollIntoView();", element_dropdown_item) self.driver.execute_script("arguments[0].click();", element_dropdown_item) # 确认创建 - self.driver.find_element(By.XPATH, create_element_position["objectPage_okButton_posXpath"]).click() - # self.driver.find_element(By.XPATH, create_element_position["objectPage_okButton_warningYes_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_okButton_posXpath"]).click() + # self.driver.find_element(By.XPATH, creation_element_position["objectPage_okButton_warningYes_posXpath"]).click() return 200 except Exception as e: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "When creating object, the exception error: ", str(e), flush=True) @@ -365,79 +365,79 @@ class CreateObjects: def create_objects_group(self, object, object_type, object_element_position): page_jump_element_position = object_element_position["page_jump"] - create_element_position = object_element_position["create"] + creation_element_position = object_element_position["create"] try: # 页面跳转 page_jump = PageJump(self.driver) page_jump.jump_sub_object_page(page_jump_element_position) # 点击create group - self.driver.find_element(By.ID, create_element_position["objectListPage_createButton_posId"]).click() + self.driver.find_element(By.ID, creation_element_position["objectListPage_createButton_posId"]).click() if object_type == "ApplicationGroup": pass else: - self.driver.find_element(By.ID, create_element_position[ + self.driver.find_element(By.ID, creation_element_position[ "objectListPage_dropDown_createGroupButton_posId".format(object_type)]).click() # 输入name object_name = object["name"] - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputName_posXpath"]).send_keys( + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputName_posXpath"]).send_keys( object_name) # 切换type if object["select_type"] == True: - self.driver.find_element(By.ID, create_element_position[ + self.driver.find_element(By.ID, creation_element_position[ "groupObjectPage_selectType{}_posId".format(object_type)]).click() # 点subordinate的+ self.driver.find_element(By.XPATH, - create_element_position["groupObjectPage_addSubordinate_posXpath"]).click() + creation_element_position["groupObjectPage_addSubordinate_posXpath"]).click() # 添加subordinate group_subordinate_data = object["group_subordinate"] if len(group_subordinate_data) != 0: for x in range(len(group_subordinate_data)): time.sleep(0.5) - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_searchSubordinate{}_posXpath".format(object_type)]).send_keys( group_subordinate_data[x]["name"]) - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_searchSubordinate{}_posXpath".format(object_type)]).send_keys(Keys.ENTER) - temp_element_position = create_element_position[ + temp_element_position = creation_element_position[ "groupObjectPage_selectSubordinate{}_posXpath".format(object_type)].format( replaceValue=group_subordinate_data[x]["name"]) self.driver.find_element(By.XPATH, temp_element_position).click() - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_closeSubordinate{}_posXpath".format(object_type)]).click() if len(group_subordinate_data) > 1 and x < len(group_subordinate_data) - 1: - self.driver.find_element(By.ID, create_element_position[ + self.driver.find_element(By.ID, creation_element_position[ "groupObjectPage_addSubordinateObject_posId"]).click() # 判断是否存在exclude group_exclude_data = object["group_exclude"] if len(group_exclude_data) != 0: # 使能exclude self.driver.find_element(By.XPATH, - create_element_position["groupObjectPage_enableExclude_posXpath"]).click() + creation_element_position["groupObjectPage_enableExclude_posXpath"]).click() # 点exclude的+ self.driver.find_element(By.XPATH, - create_element_position["groupObjectPage_addExclude_posXpath"]).click() + creation_element_position["groupObjectPage_addExclude_posXpath"]).click() # 添加exclude group_exclude_data = object["group_exclude"] for y in range(len(group_exclude_data)): time.sleep(0.5) - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_searchExclude{}_posXpath".format(object_type)]).send_keys( group_exclude_data[y]["name"]) - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_searchExclude{}_posXpath".format(object_type)]).send_keys(Keys.ENTER) - temp_element_position = create_element_position[ + temp_element_position = creation_element_position[ "groupObjectPage_selectExclude{}_posXpath".format(object_type)].format( replaceValue=group_exclude_data[y]["name"]) self.driver.find_element(By.XPATH, temp_element_position).click() - self.driver.find_element(By.XPATH, create_element_position[ + self.driver.find_element(By.XPATH, creation_element_position[ "groupObjectPage_closeExclude{}_posXpath".format(object_type)]).click() if len(group_exclude_data) > 1 and y < len(group_exclude_data) - 1: - self.driver.find_element(By.ID, create_element_position[ + self.driver.find_element(By.ID, creation_element_position[ "groupObjectPage_addExcludeObject_posId"]).click() # 确认创建 - self.driver.find_element(By.XPATH, create_element_position["objectPage_okButton_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_okButton_posXpath"]).click() self.driver.find_element(By.XPATH, - create_element_position["objectPage_okButton_warningYes_posXpath"]).click() + creation_element_position["objectPage_okButton_warningYes_posXpath"]).click() return 200 except Exception as e: # print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], f"Exception: {e}", file=sys.stderr, flush=True) @@ -446,15 +446,15 @@ class CreateObjects: def create_objects_by_side_slide(self,object,common_object_element_position): object_type = object["type"] - create_element_position = common_object_element_position["create"] + creation_element_position = common_object_element_position["create"] self.driver.find_element(By.XPATH,'//ul[@class="base-Popper-root MuiMenu-root Mui-expanded MuiMenu-variantOutlined MuiMenu-colorNeutral MuiMenu-sizeMd css-131n2dh"]/li[1]').click() object_name = object["name"] - self.driver.find_element(By.XPATH, create_element_position["objectPage_inputName_posXpath"]).send_keys(object_name) + self.driver.find_element(By.XPATH, creation_element_position["objectPage_inputName_posXpath"]).send_keys(object_name) if object_type in ["url", "account", "phone_number", "fqdn", "subscriberid", "apn"]: if object_type == "phone_number": - self.driver.find_element(By.XPATH,create_element_position["objectPage_phnoeNumberType_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_phnoeNumberType_posXpath"]).click() for i in range(len(object["items"])): # - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() if object["items"][i]["op"] == "add": # 直接 新增 模式 if "->" in object["items"][i]["expression"]: # -> 存在,需要拆分 item_value_str = object["items"][i]["expression"].split("->")[0].strip() @@ -473,23 +473,23 @@ class CreateObjects: if j == 0: # 适配24.10 版本,需要逐个字符输入 input_field = self.driver.find_element(By.XPATH, - create_element_position["objectPage_inputItem_posXpath"]) + creation_element_position["objectPage_inputItem_posXpath"]) for char in str(item_value): input_field.send_keys(char) time.sleep(0.1) else: - self.driver.find_element(By.XPATH, create_element_position["ObjectPage_sameItem_addItem_posXpath"]).click() - self.driver.find_element(By.XPATH, create_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["ObjectPage_sameItem_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value) + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type == "ip": for i in range(len(object["items"])): if object["items"][i]["op"] == "add": - self.driver.find_element(By.XPATH, create_element_position["objectPage_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, creation_element_position["objectPage_addItem_posXpath"]).click() # 适配24.10 版本,需要逐个字符输入 - input_field = self.driver.find_element(By.XPATH,create_element_position["objectPage_inputItem_posXpath"]) + input_field = self.driver.find_element(By.XPATH,creation_element_position["objectPage_inputItem_posXpath"]) for char in str(object["items"][i]["ip"]): input_field.send_keys(char) time.sleep(0.1) - self.driver.find_element(By.XPATH,create_element_position["objectPage_button_saveItem_posXpath"]).click() + self.driver.find_element(By.XPATH,creation_element_position["objectPage_button_saveItem_posXpath"]).click() diff --git a/support/ui_utils/objects/delete_objects_example.py b/support/ui_utils/objects/delete_objects_example.py index 9f1964d7d..fa9122626 100644 --- a/support/ui_utils/objects/delete_objects_example.py +++ b/support/ui_utils/objects/delete_objects_example.py @@ -16,7 +16,7 @@ class DeleteObjects: try: for object in objects_tuple: element_position_library = get_element_position(object["type"]) - delete_element_position = element_position_library["delete"] + deletion_element_position = element_position_library["delete"] page_jump_element_position = element_position_library["page_jump"] search_element_position = element_position_library["search"] page_jump = PageJump(self.driver) @@ -30,8 +30,8 @@ class DeleteObjects: time.sleep(2) self.driver.find_element(By.XPATH, '(//input[@aria-label="Select row"])[1]').click() #点击删除按钮 - self.driver.find_element(By.XPATH, delete_element_position["objectListPage_deleteButton_posXpath"]).click() - self.driver.find_element(By.XPATH,delete_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click() + self.driver.find_element(By.XPATH, deletion_element_position["objectListPage_deleteButton_posXpath"]).click() + self.driver.find_element(By.XPATH,deletion_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click() time.sleep(3) return 200 except Exception as e: @@ -39,11 +39,11 @@ class DeleteObjects: return 400 def delete_sub_object(self,object_element_position,first_row_checkbox_element): - delete_element_position = object_element_position["delete"] + deletion_element_position = object_element_position["delete"] try: first_row_checkbox_element.click() - self.driver.find_element(By.ID, delete_element_position["objectListPage_deleteButton_posId"]).click() - self.driver.find_element(By.XPATH,delete_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click() + self.driver.find_element(By.ID, deletion_element_position["objectListPage_deleteButton_posId"]).click() + self.driver.find_element(By.XPATH,deletion_element_position["objectListPage_deleteButton_warningYes_posXpath"]).click() time.sleep(3) return 200 except Exception as e: diff --git a/support/ui_utils/objects/edit_objects_example.py b/support/ui_utils/objects/edit_objects_example.py index 5a2c663bb..75fe6235a 100644 --- a/support/ui_utils/objects/edit_objects_example.py +++ b/support/ui_utils/objects/edit_objects_example.py @@ -34,23 +34,26 @@ class EditObjects: self.driver.find_element(By.XPATH, edit_element_position["ObjectListPage_editButton_posXpath"]).click() object_type = object["type"] if object_type in ["keyword", "http_signature"]: - for i in range(len(object["items"])): - self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click() # temp_element_position = edit_element_position["objectPage_item_value_select_posXpath"].format(replaceValue=object["items"][i]["expression"]) # self.driver.find_element(By.XPATH, temp_element_position).click() - if object["items"][i]["op"] == "add": # 直接 新增 模式 - if "->" in object["items"][i]["expression"]: # -> 存在,需要拆分 - item_value_str = object["items"][i]["expression"].split("->")[0].strip() - else: # -> 不存在,直接取值 - item_value_str = object["items"][i]["expression"].strip() + if src_item == "": # 直接 新增 模式 + self.driver.find_element(By.XPATH,edit_element_position["objectPage_addItem_posXpath"]).click() + item_value_str = new_item.strip() # 匹配多个multiple substrings 类型 if "&" in item_value_str: # & 含有多个 and multiple substrings item_values = item_value_str.split("&") else: item_values = [item_value_str] else: # 修改模式,未完成 - # print("todo modify moudle ...") - item_values = [object["items"][i]["expression"]] + self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_search_item_posXpath"]).send_keys(src_item + Keys.ENTER) + self.driver.find_element(By.XPATH,edit_element_position["ObjectPage_edit_item_posXpath"]).click() + input_field = self.driver.find_element(By.XPATH, edit_element_position["objectPage_inputItem_posXpath"].format(replaceValue=1)) + input_field.send_keys(Keys.CONTROL, 'a') # 或使用 Keys.COMMAND 在 macOS + input_field.send_keys(Keys.DELETE) + if "&" in new_item: # & 含有多个 and multiple substrings + item_values = new_item.split("&") + else: + item_values = [new_item] for j, item_value in enumerate(item_values): # 遍历添加 multi substr,第一个元素不用点击 + 图标 item_value = item_value.strip() temp_element_position = edit_element_position["objectPage_inputItem_posXpath"].format(replaceValue=j + 1) @@ -59,15 +62,10 @@ class EditObjects: self.driver.find_element(By.XPATH, temp_element_position).send_keys(char) time.sleep(0.1) else: - self.driver.find_element(By.XPATH, edit_element_position["objectPage_item_value_plus_posXpath"]).click() - for char in str(item_value): - self.driver.find_element(By.XPATH, temp_element_position).send_keys(char) - time.sleep(0.1) + self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_addItem_posXpath"]).click() + self.driver.find_element(By.XPATH, edit_element_position["ObjectPage_sameItem_inputItem_posXpath"]).send_keys(item_value) self.driver.find_element(By.XPATH,edit_element_position["objectPage_button_saveItem_posXpath"]).click() elif object_type in ["url", "account", "phone_number", "fqdn", "subscriberid", "apn"]: - if object_type == "phone_number": - self.driver.find_element(By.XPATH,edit_element_position["objectPage_phnoeNumberType_posXpath"]).click() - if src_item == "": # 编辑 新增 模式 self.driver.find_element(By.XPATH, edit_element_position["objectPage_addItem_posXpath"]).click() item_value_str = new_item @@ -278,7 +276,7 @@ class EditObjects: # 如果修改Object的统计参数则进行操作 statistics_option_temp = object["statistics_option"] time.sleep(1) - if statistics_option_temp in {"None", "Brief", "Elaborate"}: + if statistics_option_temp in {"brief", "elaborate"}: self.driver.find_element(By.XPATH,edit_element_position["objectPage_statistics_select_posXpath"]).click() element_dropdown_item = self.driver.find_element(By.XPATH, edit_element_position["objectPage_statistics_select_option_posXpath"].format(statistics_option_temp)) # 移动元素到页面,在执行点击 diff --git a/support/ui_utils/objects/search_objects_example.py b/support/ui_utils/objects/search_objects_example.py index edc27542a..7067f4bf1 100644 --- a/support/ui_utils/objects/search_objects_example.py +++ b/support/ui_utils/objects/search_objects_example.py @@ -142,7 +142,7 @@ class SearchObjects: self.driver.find_element(By.XPATH, '//div[text()="Name"]').click() object_uuid = self.driver.find_element(By.XPATH, '//div[@aria-rowindex="2"]//div[@data-field="uuid"]').text object_description = self.driver.find_element(By.XPATH,'//div[@aria-rowindex="2"]//div[@data-field="description"]').text - object_uuids_temp_dict["type"] = object["type"] + object_uuids_temp_dict["type"] = object_type object_uuids_temp_dict["uuid"] = object_uuid object_uuids_temp_dict["name"] = object["name"] object_uuids_temp_dict["description"] = object_description diff --git a/tests/manipulation/man_deny_srcip_subid_sub_fqdn_sub_url_http_sub_reqheader_by_ua_resheader_ct_sub_reqbody_sub_resbody.py b/tests/manipulation/man_deny_srcip_subid_sub_fqdn_sub_url_http_sub_reqheader_by_ua_resheader_ct_sub_reqbody_sub_resbody.py index 03e4ab8f7..3b8042bd8 100644 --- a/tests/manipulation/man_deny_srcip_subid_sub_fqdn_sub_url_http_sub_reqheader_by_ua_resheader_ct_sub_reqbody_sub_resbody.py +++ b/tests/manipulation/man_deny_srcip_subid_sub_fqdn_sub_url_http_sub_reqheader_by_ua_resheader_ct_sub_reqbody_sub_resbody.py @@ -51,23 +51,6 @@ def run(parameter): "negate_option": False, "or_conditions": [ { - "attribute_name": "ATTR_SUBSCRIBER_ID", - "name": "manipulation_subid", - "type": "subscriberid", - "statistics_option": "none", - "member_type": "item", - "items": [ - { - "op": "add", - "expr_type": "and", - "expression": "^{}$".format(parameter["test_subcriber_id"]) - }] - }] - }, - { - "negate_option": False, - "or_conditions": [ - { "attribute_name": "ATTR_APP_ID", "type": "application", "items": ["http"] diff --git a/tests/manipulation/man_edit_element_srcip_http_substr_url_whole_file_mark_logall.py b/tests/manipulation/man_edit_element_srcip_http_substr_url_whole_file_mark_logall.py index 25535e557..961c60f89 100644 --- a/tests/manipulation/man_edit_element_srcip_http_substr_url_whole_file_mark_logall.py +++ b/tests/manipulation/man_edit_element_srcip_http_substr_url_whole_file_mark_logall.py @@ -122,9 +122,7 @@ def run(parameter): "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "http_host", "query_value": "open.node.com"}, - {"query_field_key": "decoded_as", "query_value": "HTTP"}, - {"query_field_key": "http_request_body", "query_value": True}, - {"query_field_key": "http_response_body", "query_value": True} + {"query_field_key": "decoded_as", "query_value": "HTTP"} ] } diff --git a/tests/manipulation/man_monitor_srcip_http_logall.py b/tests/manipulation/man_monitor_srcip_http_logall.py index 6831f1a14..97dd12bc0 100644 --- a/tests/manipulation/man_monitor_srcip_http_logall.py +++ b/tests/manipulation/man_monitor_srcip_http_logall.py @@ -70,9 +70,7 @@ def run(parameter): "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "http_host", "query_value": "open.node.com"}, - {"query_field_key": "decoded_as", "query_value": "HTTP"}, - {"query_field_key": "http_request_body", "query_value": True}, - {"query_field_key": "http_response_body", "query_value": True} + {"query_field_key": "decoded_as", "query_value": "HTTP"} ] } diff --git a/tests/manipulation/man_monitor_srcip_http_substr_reqbody_selectmorelog.py b/tests/manipulation/man_monitor_srcip_http_substr_reqbody_selectmorelog.py index 7f5967326..6c8a38047 100644 --- a/tests/manipulation/man_monitor_srcip_http_substr_reqbody_selectmorelog.py +++ b/tests/manipulation/man_monitor_srcip_http_substr_reqbody_selectmorelog.py @@ -88,13 +88,9 @@ def run(parameter): "expected_log": [ {"query_field_key": "http_host", "query_value": "open.node.com"}, {"query_field_key": "decoded_as", "query_value": "HTTP"}, - {"query_field_key": "decoded_as", "query_value": "HTTP"}, {"query_field_key": "client_ip", "query_value": parameter["test_pc_ip"]}, - {"query_field_key": "server_ip", "query_value": "open.node.com"}, - {"query_field_key": "server_fqdn", "query_value": "open.node.com"}, {"query_field_key": "ip_protocol", "query_value": "tcp"}, {"query_field_key": "http_url", "query_value": "open.node.com:1443/go"}, - {"query_field_key": "http_request_line", "query_value": "POST open.node.com:1443/go HTTP/1.1"}, {"query_field_key": "http_response_line", "query_value": "HTTP/1.1 200 OK"} ] } diff --git a/tests/manipulation/man_monitor_srcip_subid_sub_fqdn_http_sub_url_sub_reqheader_by_ua_resheader_by_ct_reqbodyr_esbody.py b/tests/manipulation/man_monitor_srcip_subid_sub_fqdn_http_sub_url_sub_reqheader_by_ua_resheader_by_ct_reqbodyr_esbody.py index 3eec7a1ef..c528b2f71 100644 --- a/tests/manipulation/man_monitor_srcip_subid_sub_fqdn_http_sub_url_sub_reqheader_by_ua_resheader_by_ct_reqbodyr_esbody.py +++ b/tests/manipulation/man_monitor_srcip_subid_sub_fqdn_http_sub_url_sub_reqheader_by_ua_resheader_by_ct_reqbodyr_esbody.py @@ -77,23 +77,6 @@ def run(parameter): "negate_option": False, "or_conditions": [ { - "attribute_name": "ATTR_SERVER_FQDN", - "name": "manipulation_fqdn", - "type": "fqdn", - "statistics_option": "none", - "member_type": "item", - "items": [ - { - "op": "add", - "expr_type": "and", - "expression": "open.node.com" - }] - }] - }, - { - "negate_option": False, - "or_conditions": [ - { "attribute_name": "ATTR_HTTP_URL", "name": "manipulation_url", "type": "url", diff --git a/tests/manipulation/man_redirect_srcip_http_2item_in_url_302.py b/tests/manipulation/man_redirect_srcip_http_2item_in_url_302.py index 411bc7f52..e606b004e 100644 --- a/tests/manipulation/man_redirect_srcip_http_2item_in_url_302.py +++ b/tests/manipulation/man_redirect_srcip_http_2item_in_url_302.py @@ -69,6 +69,11 @@ def run(parameter): { "op": "add", "expr_type": "and", + "expression": "baidu" + }, + { + "op": "add", + "expr_type": "and", "expression": "google" }] }] diff --git a/tests/manipulation/man_replace_srcip_http_substr_url_search_in_request_body_logall.py b/tests/manipulation/man_replace_srcip_http_substr_url_search_in_request_body_logall.py index aa9c9e677..c7b4079ea 100644 --- a/tests/manipulation/man_replace_srcip_http_substr_url_search_in_request_body_logall.py +++ b/tests/manipulation/man_replace_srcip_http_substr_url_search_in_request_body_logall.py @@ -98,9 +98,7 @@ def run(parameter): "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "http_host", "query_value": "open.node.com"}, - {"query_field_key": "decoded_as", "query_value": "HTTP"}, - {"query_field_key": "http_request_body", "query_value": True}, - {"query_field_key": "http_response_body", "query_value": True} + {"query_field_key": "decoded_as", "query_value": "HTTP"} ] } diff --git a/tests/manipulation/test.py b/tests/manipulation/test.py index 62d1570a5..a37526aa3 100644 --- a/tests/manipulation/test.py +++ b/tests/manipulation/test.py @@ -41,10 +41,19 @@ def local_run(): all_list = os.listdir() man_list = [] # 要执行的测试文件名称 + tmp_no = ["pre_reqheader", "xly_reqheader", "suff_reqheader", "pre_resheader", "xly_resheader", "pre_resheader", "doh"] for i in all_list: if "man_" in i: i_1 = i[:-3] - man_list.append(i_1) + # 临时过滤掉不执行header的其它匹配 + flag_1 = 0 + for j in range(len(tmp_no)): + if tmp_no[j] in i_1: + flag_1 = 1 + break + if flag_1 == 0: + man_list.append(i_1) + n = 1 sum_all = len(man_list) @@ -962,10 +971,10 @@ if __name__ == '__main__': file_endswith = ".py" # 本地运行所有用例 - #local_run() + local_run() # 对比MS工具 - diff_ms(ms_json_path=ms_json_path, case_directory_path=case_directory_path, file_startwith=file_startwith, file_endswith=file_endswith) + # diff_ms(ms_json_path=ms_json_path, case_directory_path=case_directory_path, file_startwith=file_startwith, file_endswith=file_endswith) # 生成excle使用数据工具 #get_excel_formate_from_case(case_directory_path=case_directory_path, file_startwith=file_startwith, file_endswith=file_endswith) diff --git a/tests/monitor/monit_apn_dns.py b/tests/monitor/monit_apn_dns.py index 246c90eb9..130bc4968 100644 --- a/tests/monitor/monit_apn_dns.py +++ b/tests/monitor/monit_apn_dns.py @@ -110,11 +110,7 @@ def run(parameter): # 获取当前时间 utc_tz = pytz.timezone('UTC') current_utc_time = datetime.now(utc_tz) - # # 减去 10 秒 - # adjusted_time = current_utc_time - timedelta(seconds=25) - # start_time = adjusted_time.strftime('%Y-%m-%dT%H:%M:%SZ') start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') - print(start_time) # 触发流量 traffic_result = generator.run(policy_configuration, traffic_generation) @@ -170,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_apn_ftp.py b/tests/monitor/monit_apn_ftp.py index f9332bd7a..d8fb3fa71 100644 --- a/tests/monitor/monit_apn_ftp.py +++ b/tests/monitor/monit_apn_ftp.py @@ -165,9 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_apn_http.py b/tests/monitor/monit_apn_http.py index 68dcaab1b..75e0034bc 100644 --- a/tests/monitor/monit_apn_http.py +++ b/tests/monitor/monit_apn_http.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_apn_mail.py b/tests/monitor/monit_apn_mail.py index e1089998b..9355c624d 100644 --- a/tests/monitor/monit_apn_mail.py +++ b/tests/monitor/monit_apn_mail.py @@ -177,9 +177,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_apn_ssl.py b/tests/monitor/monit_apn_ssl.py index 7f75bec0f..b14fcf7ce 100644 --- a/tests/monitor/monit_apn_ssl.py +++ b/tests/monitor/monit_apn_ssl.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip.py b/tests/monitor/monit_extip.py index a30301762..f9db2c550 100644 --- a/tests/monitor/monit_extip.py +++ b/tests/monitor/monit_extip.py @@ -157,9 +157,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip_dns.py b/tests/monitor/monit_extip_dns.py index 0d0b6fefa..1a3f815b6 100644 --- a/tests/monitor/monit_extip_dns.py +++ b/tests/monitor/monit_extip_dns.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip_fqdn_http.py b/tests/monitor/monit_extip_fqdn_http.py index 1831fca8f..fc48fde1d 100644 --- a/tests/monitor/monit_extip_fqdn_http.py +++ b/tests/monitor/monit_extip_fqdn_http.py @@ -188,9 +188,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip_ftp.py b/tests/monitor/monit_extip_ftp.py index a309f1503..1df0b6b99 100644 --- a/tests/monitor/monit_extip_ftp.py +++ b/tests/monitor/monit_extip_ftp.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip_mail.py b/tests/monitor/monit_extip_mail.py index 6cf3ba968..393056347 100644 --- a/tests/monitor/monit_extip_mail.py +++ b/tests/monitor/monit_extip_mail.py @@ -177,9 +177,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_extip_ssl.py b/tests/monitor/monit_extip_ssl.py index 6ed75e83a..3247946e8 100644 --- a/tests/monitor/monit_extip_ssl.py +++ b/tests/monitor/monit_extip_ssl.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_fqdn_ipproto_tcp_dns_verify_miss.py b/tests/monitor/monit_fqdn_ipproto_tcp_dns_verify_miss.py index 68ec26b34..c82613294 100644 --- a/tests/monitor/monit_fqdn_ipproto_tcp_dns_verify_miss.py +++ b/tests/monitor/monit_fqdn_ipproto_tcp_dns_verify_miss.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_fqdn_ipproto_tcp_http.py b/tests/monitor/monit_fqdn_ipproto_tcp_http.py index a93ddeeaf..ab7ee8950 100644 --- a/tests/monitor/monit_fqdn_ipproto_tcp_http.py +++ b/tests/monitor/monit_fqdn_ipproto_tcp_http.py @@ -194,9 +194,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_fqdn_ipproto_udp_tcp_icmp_http.py b/tests/monitor/monit_fqdn_ipproto_udp_tcp_icmp_http.py index e69ae2e24..fe4fae7d1 100644 --- a/tests/monitor/monit_fqdn_ipproto_udp_tcp_icmp_http.py +++ b/tests/monitor/monit_fqdn_ipproto_udp_tcp_icmp_http.py @@ -198,9 +198,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imei_dns.py b/tests/monitor/monit_imei_dns.py index cce5fa0cc..188bb01b4 100644 --- a/tests/monitor/monit_imei_dns.py +++ b/tests/monitor/monit_imei_dns.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imei_ftp.py b/tests/monitor/monit_imei_ftp.py index ae1b69352..6a5b4475f 100644 --- a/tests/monitor/monit_imei_ftp.py +++ b/tests/monitor/monit_imei_ftp.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imei_http.py b/tests/monitor/monit_imei_http.py index b85d7feed..1f4530987 100644 --- a/tests/monitor/monit_imei_http.py +++ b/tests/monitor/monit_imei_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imei_mail.py b/tests/monitor/monit_imei_mail.py index 66a1cc2a4..72e430c1e 100644 --- a/tests/monitor/monit_imei_mail.py +++ b/tests/monitor/monit_imei_mail.py @@ -178,9 +178,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imei_ssl.py b/tests/monitor/monit_imei_ssl.py index 78e1aa9cd..ada485b7e 100644 --- a/tests/monitor/monit_imei_ssl.py +++ b/tests/monitor/monit_imei_ssl.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imsi_dns.py b/tests/monitor/monit_imsi_dns.py index f93262655..79f69b7bd 100644 --- a/tests/monitor/monit_imsi_dns.py +++ b/tests/monitor/monit_imsi_dns.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imsi_ftp.py b/tests/monitor/monit_imsi_ftp.py index fd59ebadd..9ef25b686 100644 --- a/tests/monitor/monit_imsi_ftp.py +++ b/tests/monitor/monit_imsi_ftp.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imsi_http.py b/tests/monitor/monit_imsi_http.py index 91bbbff3d..2047a2ca4 100644 --- a/tests/monitor/monit_imsi_http.py +++ b/tests/monitor/monit_imsi_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imsi_mail.py b/tests/monitor/monit_imsi_mail.py index 74d16b1c3..805cc1317 100644 --- a/tests/monitor/monit_imsi_mail.py +++ b/tests/monitor/monit_imsi_mail.py @@ -178,9 +178,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_imsi_ssl.py b/tests/monitor/monit_imsi_ssl.py index 72d665041..2e9d8017e 100644 --- a/tests/monitor/monit_imsi_ssl.py +++ b/tests/monitor/monit_imsi_ssl.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip.py b/tests/monitor/monit_intip.py index ffd903f97..8e3d78347 100644 --- a/tests/monitor/monit_intip.py +++ b/tests/monitor/monit_intip.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_dns.py b/tests/monitor/monit_intip_dns.py index 11c831a25..b6f6eac62 100644 --- a/tests/monitor/monit_intip_dns.py +++ b/tests/monitor/monit_intip_dns.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_extip.py b/tests/monitor/monit_intip_extip.py index 1b4c007be..e0fffd629 100644 --- a/tests/monitor/monit_intip_extip.py +++ b/tests/monitor/monit_intip_extip.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_fqdn_http.py b/tests/monitor/monit_intip_fqdn_http.py index 35aed410e..84e82f600 100644 --- a/tests/monitor/monit_intip_fqdn_http.py +++ b/tests/monitor/monit_intip_fqdn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_ftp.py b/tests/monitor/monit_intip_ftp.py index 74a007b72..6b26faeb5 100644 --- a/tests/monitor/monit_intip_ftp.py +++ b/tests/monitor/monit_intip_ftp.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_intport_extip_extport.py b/tests/monitor/monit_intip_intport_extip_extport.py index 6aa6c882e..39967c001 100644 --- a/tests/monitor/monit_intip_intport_extip_extport.py +++ b/tests/monitor/monit_intip_intport_extip_extport.py @@ -208,9 +208,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_mail.py b/tests/monitor/monit_intip_mail.py index ecb304fb4..a47e2f414 100644 --- a/tests/monitor/monit_intip_mail.py +++ b/tests/monitor/monit_intip_mail.py @@ -177,9 +177,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intip_ssl.py b/tests/monitor/monit_intip_ssl.py index b59c915a7..4af40176a 100644 --- a/tests/monitor/monit_intip_ssl.py +++ b/tests/monitor/monit_intip_ssl.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_intport_extport.py b/tests/monitor/monit_intport_extport.py index 4b93ebbf8..757173ac2 100644 --- a/tests/monitor/monit_intport_extport.py +++ b/tests/monitor/monit_intport_extport.py @@ -189,9 +189,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_neg_srcip_http_hit_no.py b/tests/monitor/monit_neg_srcip_http_hit_no.py index c3106fa1a..87a5a6e45 100644 --- a/tests/monitor/monit_neg_srcip_http_hit_no.py +++ b/tests/monitor/monit_neg_srcip_http_hit_no.py @@ -54,6 +54,24 @@ def run(parameter): "items": ["http"] } ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_SERVER_FQDN", + "type": "fqdn", + "member_type": "item", + "name": "monitor_test_node", + "items": [ + { + "op": "add", + "expr_type": "and", + "expression": "open.node.com", + } + ] + } + ], } ], "action_parameter": { @@ -163,9 +181,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_neg_srcip_http_hit_yes.py b/tests/monitor/monit_neg_srcip_http_hit_yes.py index a37ee78b2..e4e6e28db 100644 --- a/tests/monitor/monit_neg_srcip_http_hit_yes.py +++ b/tests/monitor/monit_neg_srcip_http_hit_yes.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_neg_srcip_ssl_hit_no.py b/tests/monitor/monit_neg_srcip_ssl_hit_no.py index 1df3c5638..f87b503ff 100644 --- a/tests/monitor/monit_neg_srcip_ssl_hit_no.py +++ b/tests/monitor/monit_neg_srcip_ssl_hit_no.py @@ -54,7 +54,25 @@ def run(parameter): "items": ["ssl"] } ] - } + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_SERVER_FQDN", + "type": "fqdn", + "member_type": "item", + "name": "monitor_test_youtube", + "items": [ + { + "op": "add", + "expr_type": "and", + "expression": "youtube.com" + } + ] + } + ], + }, ], "action_parameter": { "packet_capture": { @@ -163,9 +181,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_neg_srcip_ssl_hit_yes.py b/tests/monitor/monit_neg_srcip_ssl_hit_yes.py index 98112461d..f756ad243 100644 --- a/tests/monitor/monit_neg_srcip_ssl_hit_yes.py +++ b/tests/monitor/monit_neg_srcip_ssl_hit_yes.py @@ -72,7 +72,7 @@ def run(parameter): ] } ], - }, + } ], "action_parameter": { "packet_capture": { @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_pn_dns.py b/tests/monitor/monit_pn_dns.py index a06330de2..a1333723c 100644 --- a/tests/monitor/monit_pn_dns.py +++ b/tests/monitor/monit_pn_dns.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_pn_ftp.py b/tests/monitor/monit_pn_ftp.py index 3be102e87..8b89fd25f 100644 --- a/tests/monitor/monit_pn_ftp.py +++ b/tests/monitor/monit_pn_ftp.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_pn_http.py b/tests/monitor/monit_pn_http.py index 2b8848c24..f998840c8 100644 --- a/tests/monitor/monit_pn_http.py +++ b/tests/monitor/monit_pn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_pn_mail.py b/tests/monitor/monit_pn_mail.py index 789ba8760..8cd9bde0d 100644 --- a/tests/monitor/monit_pn_mail.py +++ b/tests/monitor/monit_pn_mail.py @@ -178,9 +178,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_pn_ssl.py b/tests/monitor/monit_pn_ssl.py index fcd13fd81..4516c1866 100644 --- a/tests/monitor/monit_pn_ssl.py +++ b/tests/monitor/monit_pn_ssl.py @@ -168,9 +168,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_src_library_http.py b/tests/monitor/monit_src_library_http.py index d537a3c23..58c2e24d2 100644 --- a/tests/monitor/monit_src_library_http.py +++ b/tests/monitor/monit_src_library_http.py @@ -211,9 +211,9 @@ def run(parameter): if library_tuple: api_client.delete_libraries(library_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_appgroup_ssl.py b/tests/monitor/monit_srcip_appgroup_ssl.py index 6cd26b19c..db43a6c42 100644 --- a/tests/monitor/monit_srcip_appgroup_ssl.py +++ b/tests/monitor/monit_srcip_appgroup_ssl.py @@ -1,147 +1,212 @@ import os import sys from support.ui_utils.element_position.map_element_position_library import replace_paras -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) -from support.common_utils.create_policy import CreatePolicy -from support.report_update import ReportUpdate -from support.ui_utils.element_position.map_element_position_library import * +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +import time +import pytz from datetime import datetime +from support.ui_utils.workpath import workdir +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * +from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} + # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "monitor", - "rule_name": "monitor_app_group", - "rule_action": "monitor", - "rule_type": "create", - "condition": { - "source_ip": [ - { - "name": "monitor_source_ip", - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ - { - "item_operation": "add", - "item_type": "ipv4", - "item_value": parameter['test_pc_ip'], - }, - ] - } - ], - "source_port": [], - "destination_ip": [], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "monitor_contain_ssl_exclude_http", - "group_subordinate": [ - { - "name": "ssl" - } - ], - "group_exclude": [ - { - "name": "http" - } - ], - "select_type": "False", - "object_type":"application_group" - } - ], - "server_fqdn": [], - "protocol_filed":[], - #"sub_action_override": True, - "sub_action": [], - "packet_capture": [] - }, - "is_mirror":"off", - "expected_return": "skype", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "ssl_sni", "query_value": "www.skype.com"}], - "traffic": { - "protocol": "ssl", - "type": "curl", - "command": "curl -L https://www.skype.com/" + policy_configuration = { + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "sub_type": "ip", + "name": "monitor_source_ip", + "items": [ + { + "op": "add", + "ip": parameter["test_pc_ip"], + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "statistics_option": "brief", + "name": "monitor_application_group", + "included_sub_object_uuids": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["ssl"], + } + ], + "excluded_sub_object_uuids": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["mail"], + } + ] + } + ], + } + ], + "action_parameter": { + "packet_capture": { + "enable": 0 + }, + "traffic_mirroring": { + "enable": 0 + } }, - "token": "" + "name": os.path.splitext(os.path.basename(__file__))[0], + "log_option": "metadata", + "action": "monitor", + "type": "monitor", + "is_enabled": 1 } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - return result + traffic_generation = { + "tool": "ssl", # or trex/http + "command": "curl -L https://www.skype.com/" + } + + verification_result = { + "excepted_traffic_result": "skype", + "expected_metric": {"hits": "many"}, + "expected_log": [ + {"query_field_key": "ssl_sni", "query_value": "www.skype.com"} + ] + } + + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", "") + if len(api_error) > 0: + return api_error + + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, + traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境并删除配置 - if isinstance(create, CreatePolicy): - create.clean_up() - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) - if __name__ == '__main__': parameter = { - "username": "guoqiuya", - "password": "Guoqiuya123@@", - "test_pc_ip": "192.168.64.105", - "test_subcriber_id": "test490", + "username": "zhaokun", + "password": "zhaokun1", + "test_pc_ip": "192.168.64.87", + "test_subcriber_id": "test6776", "api_server": "http://192.168.44.72", - "debug_flag": "local", - "is_log": 1, + "initiation_method": "api", "env": "tsgx", - "script_type": "api", - "vsys_id": 1, - "root_path": "C:/Users/guoqiuya/Desktop/code/test_924/tsg_test", - "path": "C:/Users/guoqiuya/Desktop/code/test_924/tsg_test/tests/ui", - "module_name": "manipulation", + "vsys": 5, + "root_path": workdir, + "path": workdir + "/tests", + "module_name": "monitor", "test_case_name": os.path.basename(__file__)[:-3] } parameter = replace_paras(parameter) - parameter = replace_paras(parameter) run(parameter) - """ - # 在测试文件的当前路径执行如下命令执行测试用例: - pytest –cache-clear -v pytest_json.py --alluredir ./allure - - # 执行如下命令生成测试报告(自动打开浏览器): - allure serve allure - """
\ No newline at end of file diff --git a/tests/monitor/monit_srcip_appgroup_ssl_verify_exclude_app.py b/tests/monitor/monit_srcip_appgroup_ssl_verify_exclude_app.py index a4dbb0071..3111e088e 100644 --- a/tests/monitor/monit_srcip_appgroup_ssl_verify_exclude_app.py +++ b/tests/monitor/monit_srcip_appgroup_ssl_verify_exclude_app.py @@ -1,148 +1,210 @@ import os import sys from support.ui_utils.element_position.map_element_position_library import replace_paras -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) -from support.common_utils.create_policy import CreatePolicy -from support.report_update import ReportUpdate -from support.ui_utils.element_position.map_element_position_library import * +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +import time +import pytz from datetime import datetime +from support.ui_utils.workpath import workdir +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * +from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} + # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "monitor", - "rule_name": "monitor_app_group_verify_exclude", - "rule_action": "monitor", - "rule_type": "create", - "condition": { - "source_ip": [ - { - "name": "monitor_source_ip", - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ - { - "item_operation": "add", - "item_type": "ipv4", - "item_value": parameter['test_pc_ip'], - }, - ] - } - ], - "source_port": [], - "destination_ip": [], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "monitor_contain_ssl_exclude_http", - "group_subordinate": [ - { - "name": "ssl" - } - ], - "group_exclude": [ - { - "name": "http" - } - ], - "select_type": "False", - "object_type":"application_group" - } - ], - "server_fqdn": [], - "protocol_filed":[], - #"sub_action_override": True, - "sub_action": [], - "packet_capture": [] + policy_configuration = { + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "sub_type": "ip", + "name": "monitor_source_ip", + "items": [ + { + "op": "add", + "ip": parameter["test_pc_ip"], + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "statistics_option": "brief", + "name": "monitor_application_group", + "included_sub_object_uuids": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["ssl"], + } + ], + "excluded_sub_object_uuids": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"], + } + ] + } + ], + } + ], + "action_parameter": { + "packet_capture": { + "enable": 0 + }, + "traffic_mirroring": { + "enable": 0 + } }, - "is_mirror":"off", - "expected_return": "yumi", - "counters": {"hits": 0}, - "log_query_param": [], - "traffic": { - "protocol": "http", - "type": "curl", - "command": "curl -kv http://www.yumi.com" - }, - "token": "" + "name": os.path.splitext(os.path.basename(__file__))[0], + "log_option": "metadata", + "action": "monitor", + "type": "monitor", + "is_enabled": 1 + } + + traffic_generation = { + "tool": "ssl", # or trex/http + "command": "curl -kv http://www.yumi.com" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() + verification_result = { + "excepted_traffic_result": "yumi", + "expected_metric": {"hits": 0}, + "expected_log": [] + } + + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", "") + if len(api_error) > 0: + return api_error + + # 等待下发配置生效 + time.sleep(3) - return result + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, + traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境并删除配置 - if isinstance(create, CreatePolicy): - create.clean_up() - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) - if __name__ == '__main__': parameter = { - "username": "guoqiuya", - "password": "Guoqiuya123@@", - "test_pc_ip": "192.168.64.105", - "test_subcriber_id": "test490", + "username": "zhaokun", + "password": "zhaokun1", + "test_pc_ip": "192.168.64.87", + "test_subcriber_id": "test6776", "api_server": "http://192.168.44.72", - "debug_flag": "local", - "is_log": 1, + "initiation_method": "api", "env": "tsgx", - "script_type": "api", - "vsys_id": 1, - "root_path": "C:/Users/guoqiuya/Desktop/code/test_924/tsg_test", - "path": "C:/Users/guoqiuya/Desktop/code/test_924/tsg_test/tests/ui", - "module_name": "manipulation", + "vsys": 5, + "root_path": workdir, + "path": workdir + "/tests", + "module_name": "monitor", "test_case_name": os.path.basename(__file__)[:-3] } parameter = replace_paras(parameter) - parameter = replace_paras(parameter) run(parameter) - """ - # 在测试文件的当前路径执行如下命令执行测试用例: - pytest –cache-clear -v pytest_json.py --alluredir ./allure - - # 执行如下命令生成测试报告(自动打开浏览器): - allure serve allure - """
\ No newline at end of file diff --git a/tests/monitor/monit_srcip_dns_mirror_off.py b/tests/monitor/monit_srcip_dns_mirror_off.py index 7bb46c727..2560bf146 100644 --- a/tests/monitor/monit_srcip_dns_mirror_off.py +++ b/tests/monitor/monit_srcip_dns_mirror_off.py @@ -165,10 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - # duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_mirror_on.py b/tests/monitor/monit_srcip_dns_mirror_on.py index c8d74f4ac..3f682a2ec 100644 --- a/tests/monitor/monit_srcip_dns_mirror_on.py +++ b/tests/monitor/monit_srcip_dns_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_pre_qname.py b/tests/monitor/monit_srcip_dns_pre_qname.py index c7a63c261..1f26362c3 100644 --- a/tests/monitor/monit_srcip_dns_pre_qname.py +++ b/tests/monitor/monit_srcip_dns_pre_qname.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_pre_qname_mirror_on.py b/tests/monitor/monit_srcip_dns_pre_qname_mirror_on.py index b1ab69264..8938e918a 100644 --- a/tests/monitor/monit_srcip_dns_pre_qname_mirror_on.py +++ b/tests/monitor/monit_srcip_dns_pre_qname_mirror_on.py @@ -198,9 +198,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_pre_qname_profile_on.py b/tests/monitor/monit_srcip_dns_pre_qname_profile_on.py index b3c72b0a0..bad54cdbc 100644 --- a/tests/monitor/monit_srcip_dns_pre_qname_profile_on.py +++ b/tests/monitor/monit_srcip_dns_pre_qname_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_profile_on.py b/tests/monitor/monit_srcip_dns_profile_on.py index ba1479aeb..0a0c1d062 100644 --- a/tests/monitor/monit_srcip_dns_profile_on.py +++ b/tests/monitor/monit_srcip_dns_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_sub_qname.py b/tests/monitor/monit_srcip_dns_sub_qname.py index 1c15ead7c..d4f886d08 100644 --- a/tests/monitor/monit_srcip_dns_sub_qname.py +++ b/tests/monitor/monit_srcip_dns_sub_qname.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_suff_qname.py b/tests/monitor/monit_srcip_dns_suff_qname.py index 3976d7da1..b0f0359a1 100644 --- a/tests/monitor/monit_srcip_dns_suff_qname.py +++ b/tests/monitor/monit_srcip_dns_suff_qname.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dns_xly_qname.py b/tests/monitor/monit_srcip_dns_xly_qname.py index 1c7ac5244..0fd7f4920 100644 --- a/tests/monitor/monit_srcip_dns_xly_qname.py +++ b/tests/monitor/monit_srcip_dns_xly_qname.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dst_ranport.py b/tests/monitor/monit_srcip_dst_ranport.py index 41e2255da..9fd97af8d 100644 --- a/tests/monitor/monit_srcip_dst_ranport.py +++ b/tests/monitor/monit_srcip_dst_ranport.py @@ -172,9 +172,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dst_singleport.py b/tests/monitor/monit_srcip_dst_singleport.py index 39c393ca9..ce57f7468 100644 --- a/tests/monitor/monit_srcip_dst_singleport.py +++ b/tests/monitor/monit_srcip_dst_singleport.py @@ -173,9 +173,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dstip_dns_pkt_on.py b/tests/monitor/monit_srcip_dstip_dns_pkt_on.py index 4eb356535..a0563aef1 100644 --- a/tests/monitor/monit_srcip_dstip_dns_pkt_on.py +++ b/tests/monitor/monit_srcip_dstip_dns_pkt_on.py @@ -188,9 +188,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dstip_ftp_pkt_on.py b/tests/monitor/monit_srcip_dstip_ftp_pkt_on.py index 9c54628ff..86be1344c 100644 --- a/tests/monitor/monit_srcip_dstip_ftp_pkt_on.py +++ b/tests/monitor/monit_srcip_dstip_ftp_pkt_on.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dstip_http_mirror_off.py b/tests/monitor/monit_srcip_dstip_http_mirror_off.py index a46095525..97704dcf1 100644 --- a/tests/monitor/monit_srcip_dstip_http_mirror_off.py +++ b/tests/monitor/monit_srcip_dstip_http_mirror_off.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_dstip_mail_pkt_on.py b/tests/monitor/monit_srcip_dstip_mail_pkt_on.py index 7bf72ee56..d51f2aa6e 100644 --- a/tests/monitor/monit_srcip_dstip_mail_pkt_on.py +++ b/tests/monitor/monit_srcip_dstip_mail_pkt_on.py @@ -196,9 +196,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ext_ranport.py b/tests/monitor/monit_srcip_ext_ranport.py index e997e2282..3019b579b 100644 --- a/tests/monitor/monit_srcip_ext_ranport.py +++ b/tests/monitor/monit_srcip_ext_ranport.py @@ -172,9 +172,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ext_singleport.py b/tests/monitor/monit_srcip_ext_singleport.py index 4f56bcc38..c18ecdb0e 100644 --- a/tests/monitor/monit_srcip_ext_singleport.py +++ b/tests/monitor/monit_srcip_ext_singleport.py @@ -172,9 +172,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_facebook.py b/tests/monitor/monit_srcip_facebook.py index 93098696a..f613e6a0b 100644 --- a/tests/monitor/monit_srcip_facebook.py +++ b/tests/monitor/monit_srcip_facebook.py @@ -165,9 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_dns.py b/tests/monitor/monit_srcip_flag_dns.py index d573bee6c..4603c8da5 100644 --- a/tests/monitor/monit_srcip_flag_dns.py +++ b/tests/monitor/monit_srcip_flag_dns.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_dns_pre_qname.py b/tests/monitor/monit_srcip_flag_dns_pre_qname.py index 657dff149..8f12403c8 100644 --- a/tests/monitor/monit_srcip_flag_dns_pre_qname.py +++ b/tests/monitor/monit_srcip_flag_dns_pre_qname.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_ftp.py b/tests/monitor/monit_srcip_flag_ftp.py index 3afdb066f..ced5bf579 100644 --- a/tests/monitor/monit_srcip_flag_ftp.py +++ b/tests/monitor/monit_srcip_flag_ftp.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_ftp_multi_uri.py b/tests/monitor/monit_srcip_flag_ftp_multi_uri.py index 5e59070c4..d3bfa6a67 100644 --- a/tests/monitor/monit_srcip_flag_ftp_multi_uri.py +++ b/tests/monitor/monit_srcip_flag_ftp_multi_uri.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_ftp_sub_content_sub_uri_sub_account.py b/tests/monitor/monit_srcip_flag_ftp_sub_content_sub_uri_sub_account.py index 44c820e27..e5e3e09bb 100644 --- a/tests/monitor/monit_srcip_flag_ftp_sub_content_sub_uri_sub_account.py +++ b/tests/monitor/monit_srcip_flag_ftp_sub_content_sub_uri_sub_account.py @@ -241,9 +241,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_http.py b/tests/monitor/monit_srcip_flag_http.py index deca5cd91..ba2ca27fc 100644 --- a/tests/monitor/monit_srcip_flag_http.py +++ b/tests/monitor/monit_srcip_flag_http.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_http_pre_url_sub_reheader_by_ua_multi_resheader_by_ct.py b/tests/monitor/monit_srcip_flag_http_pre_url_sub_reheader_by_ua_multi_resheader_by_ct.py index d8463655e..0f8f04789 100644 --- a/tests/monitor/monit_srcip_flag_http_pre_url_sub_reheader_by_ua_multi_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_flag_http_pre_url_sub_reheader_by_ua_multi_resheader_by_ct.py @@ -238,9 +238,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_mail.py b/tests/monitor/monit_srcip_flag_mail.py index 2524b65fb..735f17d52 100644 --- a/tests/monitor/monit_srcip_flag_mail.py +++ b/tests/monitor/monit_srcip_flag_mail.py @@ -194,9 +194,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_mail_pre_subject_pre_from_pre_to_account.py b/tests/monitor/monit_srcip_flag_mail_pre_subject_pre_from_pre_to_account.py index 807bd66e4..4967e50dc 100644 --- a/tests/monitor/monit_srcip_flag_mail_pre_subject_pre_from_pre_to_account.py +++ b/tests/monitor/monit_srcip_flag_mail_pre_subject_pre_from_pre_to_account.py @@ -266,9 +266,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_flag_ssl.py b/tests/monitor/monit_srcip_flag_ssl.py index 435d912f3..4b5dc7b16 100644 --- a/tests/monitor/monit_srcip_flag_ssl.py +++ b/tests/monitor/monit_srcip_flag_ssl.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_hex_content.py b/tests/monitor/monit_srcip_ftp_hex_content.py index 6d63fd8f8..ecac899fb 100644 --- a/tests/monitor/monit_srcip_ftp_hex_content.py +++ b/tests/monitor/monit_srcip_ftp_hex_content.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_mirror_off.py b/tests/monitor/monit_srcip_ftp_mirror_off.py index 14fd35c58..b570421f5 100644 --- a/tests/monitor/monit_srcip_ftp_mirror_off.py +++ b/tests/monitor/monit_srcip_ftp_mirror_off.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_mirror_on.py b/tests/monitor/monit_srcip_ftp_mirror_on.py index 4f07a6b52..f6199adc9 100644 --- a/tests/monitor/monit_srcip_ftp_mirror_on.py +++ b/tests/monitor/monit_srcip_ftp_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_multi_account.py b/tests/monitor/monit_srcip_ftp_multi_account.py index 77ef9ed70..ebb98d15a 100644 --- a/tests/monitor/monit_srcip_ftp_multi_account.py +++ b/tests/monitor/monit_srcip_ftp_multi_account.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_multi_account_mirror_on.py b/tests/monitor/monit_srcip_ftp_multi_account_mirror_on.py index f09e728dd..7165cd949 100644 --- a/tests/monitor/monit_srcip_ftp_multi_account_mirror_on.py +++ b/tests/monitor/monit_srcip_ftp_multi_account_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_multi_account_profile_on.py b/tests/monitor/monit_srcip_ftp_multi_account_profile_on.py index 05ca940cf..4fdacfa2a 100644 --- a/tests/monitor/monit_srcip_ftp_multi_account_profile_on.py +++ b/tests/monitor/monit_srcip_ftp_multi_account_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_multi_content.py b/tests/monitor/monit_srcip_ftp_multi_content.py index 2a413c16b..7b6d7e9eb 100644 --- a/tests/monitor/monit_srcip_ftp_multi_content.py +++ b/tests/monitor/monit_srcip_ftp_multi_content.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_multi_uri.py b/tests/monitor/monit_srcip_ftp_multi_uri.py index d51ff40cb..e7f5beb96 100644 --- a/tests/monitor/monit_srcip_ftp_multi_uri.py +++ b/tests/monitor/monit_srcip_ftp_multi_uri.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_pre_account.py b/tests/monitor/monit_srcip_ftp_pre_account.py index 0e4ad1ea6..062977f73 100644 --- a/tests/monitor/monit_srcip_ftp_pre_account.py +++ b/tests/monitor/monit_srcip_ftp_pre_account.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_pre_content.py b/tests/monitor/monit_srcip_ftp_pre_content.py index 038e21c11..75f8de05f 100644 --- a/tests/monitor/monit_srcip_ftp_pre_content.py +++ b/tests/monitor/monit_srcip_ftp_pre_content.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_pre_uri.py b/tests/monitor/monit_srcip_ftp_pre_uri.py index 96761f20d..9d4186167 100644 --- a/tests/monitor/monit_srcip_ftp_pre_uri.py +++ b/tests/monitor/monit_srcip_ftp_pre_uri.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_profile_on.py b/tests/monitor/monit_srcip_ftp_profile_on.py index 5ff0f25f8..68f9198ef 100644 --- a/tests/monitor/monit_srcip_ftp_profile_on.py +++ b/tests/monitor/monit_srcip_ftp_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_account.py b/tests/monitor/monit_srcip_ftp_sub_account.py index 5b0b3db27..29b4e4d16 100644 --- a/tests/monitor/monit_srcip_ftp_sub_account.py +++ b/tests/monitor/monit_srcip_ftp_sub_account.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_account_sub_content.py b/tests/monitor/monit_srcip_ftp_sub_account_sub_content.py index 914da5cb2..ff1f95a51 100644 --- a/tests/monitor/monit_srcip_ftp_sub_account_sub_content.py +++ b/tests/monitor/monit_srcip_ftp_sub_account_sub_content.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_account_sub_uri.py b/tests/monitor/monit_srcip_ftp_sub_account_sub_uri.py index c3dd579f2..0e3a79db3 100644 --- a/tests/monitor/monit_srcip_ftp_sub_account_sub_uri.py +++ b/tests/monitor/monit_srcip_ftp_sub_account_sub_uri.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_content.py b/tests/monitor/monit_srcip_ftp_sub_content.py index 3627383df..6fbea6ef2 100644 --- a/tests/monitor/monit_srcip_ftp_sub_content.py +++ b/tests/monitor/monit_srcip_ftp_sub_content.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_content_sub_uri.py b/tests/monitor/monit_srcip_ftp_sub_content_sub_uri.py index 1806f0eb7..9acb03439 100644 --- a/tests/monitor/monit_srcip_ftp_sub_content_sub_uri.py +++ b/tests/monitor/monit_srcip_ftp_sub_content_sub_uri.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_content_sub_uri_sub_account.py b/tests/monitor/monit_srcip_ftp_sub_content_sub_uri_sub_account.py index e200b5f58..8d48342eb 100644 --- a/tests/monitor/monit_srcip_ftp_sub_content_sub_uri_sub_account.py +++ b/tests/monitor/monit_srcip_ftp_sub_content_sub_uri_sub_account.py @@ -220,9 +220,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_sub_uri.py b/tests/monitor/monit_srcip_ftp_sub_uri.py index 56b305e73..a86f0d6a2 100644 --- a/tests/monitor/monit_srcip_ftp_sub_uri.py +++ b/tests/monitor/monit_srcip_ftp_sub_uri.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_suff_account.py b/tests/monitor/monit_srcip_ftp_suff_account.py index b6b7fa4f2..d31cd4d87 100644 --- a/tests/monitor/monit_srcip_ftp_suff_account.py +++ b/tests/monitor/monit_srcip_ftp_suff_account.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_suff_content.py b/tests/monitor/monit_srcip_ftp_suff_content.py index d7db80cd8..38a98b09a 100644 --- a/tests/monitor/monit_srcip_ftp_suff_content.py +++ b/tests/monitor/monit_srcip_ftp_suff_content.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_suff_uri.py b/tests/monitor/monit_srcip_ftp_suff_uri.py index 400d9f62a..0ac6de31e 100644 --- a/tests/monitor/monit_srcip_ftp_suff_uri.py +++ b/tests/monitor/monit_srcip_ftp_suff_uri.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_xly_account.py b/tests/monitor/monit_srcip_ftp_xly_account.py index 275061f3a..452176ca8 100644 --- a/tests/monitor/monit_srcip_ftp_xly_account.py +++ b/tests/monitor/monit_srcip_ftp_xly_account.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ftp_xly_uri.py b/tests/monitor/monit_srcip_ftp_xly_uri.py index 2ede51f9c..dae90d460 100644 --- a/tests/monitor/monit_srcip_ftp_xly_uri.py +++ b/tests/monitor/monit_srcip_ftp_xly_uri.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_fqdn_pkt_on.py b/tests/monitor/monit_srcip_http_fqdn_pkt_on.py index f3265ce14..cf47590d5 100644 --- a/tests/monitor/monit_srcip_http_fqdn_pkt_on.py +++ b/tests/monitor/monit_srcip_http_fqdn_pkt_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_hex_reqbody.py b/tests/monitor/monit_srcip_http_hex_reqbody.py index da4c651ab..befecccdb 100644 --- a/tests/monitor/monit_srcip_http_hex_reqbody.py +++ b/tests/monitor/monit_srcip_http_hex_reqbody.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_hex_reqheader_by_ua.py b/tests/monitor/monit_srcip_http_hex_reqheader_by_ua.py index 348070aeb..3a56c3619 100644 --- a/tests/monitor/monit_srcip_http_hex_reqheader_by_ua.py +++ b/tests/monitor/monit_srcip_http_hex_reqheader_by_ua.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_hex_resbody.py b/tests/monitor/monit_srcip_http_hex_resbody.py index db39e6c30..da2985426 100644 --- a/tests/monitor/monit_srcip_http_hex_resbody.py +++ b/tests/monitor/monit_srcip_http_hex_resbody.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_hex_resheader_by_ct.py b/tests/monitor/monit_srcip_http_hex_resheader_by_ct.py index c63a6b4a7..53bc60f35 100644 --- a/tests/monitor/monit_srcip_http_hex_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_hex_resheader_by_ct.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_mirror_on.py b/tests/monitor/monit_srcip_http_mirror_on.py index 681892c7d..648fed17b 100644 --- a/tests/monitor/monit_srcip_http_mirror_on.py +++ b/tests/monitor/monit_srcip_http_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_reqbody.py b/tests/monitor/monit_srcip_http_multi_reqbody.py index 44858b497..5e3f08bbe 100644 --- a/tests/monitor/monit_srcip_http_multi_reqbody.py +++ b/tests/monitor/monit_srcip_http_multi_reqbody.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_reqheader_by_ua.py b/tests/monitor/monit_srcip_http_multi_reqheader_by_ua.py index 7749c66ec..ec0ff5e79 100644 --- a/tests/monitor/monit_srcip_http_multi_reqheader_by_ua.py +++ b/tests/monitor/monit_srcip_http_multi_reqheader_by_ua.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_resbody_log_all.py b/tests/monitor/monit_srcip_http_multi_resbody_log_all.py index cc6668ece..7a1e5ff6b 100644 --- a/tests/monitor/monit_srcip_http_multi_resbody_log_all.py +++ b/tests/monitor/monit_srcip_http_multi_resbody_log_all.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_resbody_log_metadata.py b/tests/monitor/monit_srcip_http_multi_resbody_log_metadata.py index 2e8130e94..1f3dd4bd3 100644 --- a/tests/monitor/monit_srcip_http_multi_resbody_log_metadata.py +++ b/tests/monitor/monit_srcip_http_multi_resbody_log_metadata.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_resheader_by_ct.py b/tests/monitor/monit_srcip_http_multi_resheader_by_ct.py index c42eee3f2..d5ce5383d 100644 --- a/tests/monitor/monit_srcip_http_multi_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_multi_resheader_by_ct.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_multi_url.py b/tests/monitor/monit_srcip_http_multi_url.py index b355fd5ed..3a9c9cea0 100644 --- a/tests/monitor/monit_srcip_http_multi_url.py +++ b/tests/monitor/monit_srcip_http_multi_url.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_no.py b/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_no.py index afee555f1..0d65ade17 100644 --- a/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_no.py +++ b/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_no.py @@ -181,9 +181,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_yes.py b/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_yes.py index ce94bf93a..cb97134e1 100644 --- a/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_yes.py +++ b/tests/monitor/monit_srcip_http_neg_substr_fqdn_hit_yes.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_pre_reqheader_by_ua.py b/tests/monitor/monit_srcip_http_pre_reqheader_by_ua.py index f8ca692fe..8d991aaf2 100644 --- a/tests/monitor/monit_srcip_http_pre_reqheader_by_ua.py +++ b/tests/monitor/monit_srcip_http_pre_reqheader_by_ua.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_pre_resheader_by_ct.py b/tests/monitor/monit_srcip_http_pre_resheader_by_ct.py index 3ce69ecd0..aafb7e265 100644 --- a/tests/monitor/monit_srcip_http_pre_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_pre_resheader_by_ct.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_pre_url.py b/tests/monitor/monit_srcip_http_pre_url.py index 9b8a5c166..676e42286 100644 --- a/tests/monitor/monit_srcip_http_pre_url.py +++ b/tests/monitor/monit_srcip_http_pre_url.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_pre_url_sub_reqheader_by_ua_multi_resheader_by_ct.py b/tests/monitor/monit_srcip_http_pre_url_sub_reqheader_by_ua_multi_resheader_by_ct.py index f8292fde7..17eb96124 100644 --- a/tests/monitor/monit_srcip_http_pre_url_sub_reqheader_by_ua_multi_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_pre_url_sub_reqheader_by_ua_multi_resheader_by_ct.py @@ -222,9 +222,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_profile_on.py b/tests/monitor/monit_srcip_http_profile_on.py index f0bdd0d5e..3749594a9 100644 --- a/tests/monitor/monit_srcip_http_profile_on.py +++ b/tests/monitor/monit_srcip_http_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqbody.py b/tests/monitor/monit_srcip_http_sub_reqbody.py index 3e263a1b9..f576fd476 100644 --- a/tests/monitor/monit_srcip_http_sub_reqbody.py +++ b/tests/monitor/monit_srcip_http_sub_reqbody.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqbody_sub_resbody.py b/tests/monitor/monit_srcip_http_sub_reqbody_sub_resbody.py index d025e10e9..cdc651777 100644 --- a/tests/monitor/monit_srcip_http_sub_reqbody_sub_resbody.py +++ b/tests/monitor/monit_srcip_http_sub_reqbody_sub_resbody.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua.py b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua.py index d44b2d51d..0aac04004 100644 --- a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua.py +++ b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_mirror_on.py b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_mirror_on.py index ae1bcf68c..2a5724ac6 100644 --- a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_mirror_on.py +++ b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_profile_on.py b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_profile_on.py index 08f36cd0e..f9e2b7845 100644 --- a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_profile_on.py +++ b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_sub_reqbody.py b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_sub_reqbody.py index 978a16eeb..5984a35d0 100644 --- a/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_sub_reqbody.py +++ b/tests/monitor/monit_srcip_http_sub_reqheader_by_ua_sub_reqbody.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_resbody.py b/tests/monitor/monit_srcip_http_sub_resbody.py index dc843203f..10a2862f8 100644 --- a/tests/monitor/monit_srcip_http_sub_resbody.py +++ b/tests/monitor/monit_srcip_http_sub_resbody.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_resheader_by_ct.py b/tests/monitor/monit_srcip_http_sub_resheader_by_ct.py index c42eee3f2..d5ce5383d 100644 --- a/tests/monitor/monit_srcip_http_sub_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_sub_resheader_by_ct.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_mirror_on.py b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_mirror_on.py index 161d61a0b..bbc0be1f7 100644 --- a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_mirror_on.py +++ b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_mirror_on.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_profile_on.py b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_profile_on.py index 1de612db6..9ddb7f38a 100644 --- a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_profile_on.py +++ b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_profile_on.py @@ -205,9 +205,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_sub_resbody.py b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_sub_resbody.py index 4b51786d6..bfcc4548c 100644 --- a/tests/monitor/monit_srcip_http_sub_resheader_by_ct_sub_resbody.py +++ b/tests/monitor/monit_srcip_http_sub_resheader_by_ct_sub_resbody.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_url.py b/tests/monitor/monit_srcip_http_sub_url.py index 90d3872db..c4929eb73 100644 --- a/tests/monitor/monit_srcip_http_sub_url.py +++ b/tests/monitor/monit_srcip_http_sub_url.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_url_mirror_on.py b/tests/monitor/monit_srcip_http_sub_url_mirror_on.py index d9c8ae787..c6992daef 100644 --- a/tests/monitor/monit_srcip_http_sub_url_mirror_on.py +++ b/tests/monitor/monit_srcip_http_sub_url_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_url_profile_on.py b/tests/monitor/monit_srcip_http_sub_url_profile_on.py index 7c2b372c2..f00fe45cc 100644 --- a/tests/monitor/monit_srcip_http_sub_url_profile_on.py +++ b/tests/monitor/monit_srcip_http_sub_url_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_sub_url_sub_reqbody_sub_respbody.py b/tests/monitor/monit_srcip_http_sub_url_sub_reqbody_sub_respbody.py index a09d3c2e3..89ebbe44c 100644 --- a/tests/monitor/monit_srcip_http_sub_url_sub_reqbody_sub_respbody.py +++ b/tests/monitor/monit_srcip_http_sub_url_sub_reqbody_sub_respbody.py @@ -219,9 +219,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_suff_resheader_by_ct.py b/tests/monitor/monit_srcip_http_suff_resheader_by_ct.py index abc30cd4b..e5ce78fd5 100644 --- a/tests/monitor/monit_srcip_http_suff_resheader_by_ct.py +++ b/tests/monitor/monit_srcip_http_suff_resheader_by_ct.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_suff_url.py b/tests/monitor/monit_srcip_http_suff_url.py index 24000bc01..7ddc1122f 100644 --- a/tests/monitor/monit_srcip_http_suff_url.py +++ b/tests/monitor/monit_srcip_http_suff_url.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_xly_resheader_by_ua.py b/tests/monitor/monit_srcip_http_xly_resheader_by_ua.py index ec62af6a2..351c2b6dd 100644 --- a/tests/monitor/monit_srcip_http_xly_resheader_by_ua.py +++ b/tests/monitor/monit_srcip_http_xly_resheader_by_ua.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_http_xly_url.py b/tests/monitor/monit_srcip_http_xly_url.py index db62806a1..b3a2da0ce 100644 --- a/tests/monitor/monit_srcip_http_xly_url.py +++ b/tests/monitor/monit_srcip_http_xly_url.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_https_fqdn_pkt_on.py b/tests/monitor/monit_srcip_https_fqdn_pkt_on.py index 691a71cf2..2b96fb1d5 100644 --- a/tests/monitor/monit_srcip_https_fqdn_pkt_on.py +++ b/tests/monitor/monit_srcip_https_fqdn_pkt_on.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_https_mirror_off.py b/tests/monitor/monit_srcip_https_mirror_off.py index 199c2acc8..2d5d6330c 100644 --- a/tests/monitor/monit_srcip_https_mirror_off.py +++ b/tests/monitor/monit_srcip_https_mirror_off.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_https_mirror_on.py b/tests/monitor/monit_srcip_https_mirror_on.py index 6f70386b4..96d8025a3 100644 --- a/tests/monitor/monit_srcip_https_mirror_on.py +++ b/tests/monitor/monit_srcip_https_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_https_profile_on.py b/tests/monitor/monit_srcip_https_profile_on.py index f9b7ab4a9..3816db3f2 100644 --- a/tests/monitor/monit_srcip_https_profile_on.py +++ b/tests/monitor/monit_srcip_https_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_int_ranport.py b/tests/monitor/monit_srcip_int_ranport.py index 2d1c85301..1def86cf9 100644 --- a/tests/monitor/monit_srcip_int_ranport.py +++ b/tests/monitor/monit_srcip_int_ranport.py @@ -172,9 +172,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ipproto_udp_dns.py b/tests/monitor/monit_srcip_ipproto_udp_dns.py index b3976bf77..26f73d4eb 100644 --- a/tests/monitor/monit_srcip_ipproto_udp_dns.py +++ b/tests/monitor/monit_srcip_ipproto_udp_dns.py @@ -176,9 +176,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ipproto_udp_http_verify_miss.py b/tests/monitor/monit_srcip_ipproto_udp_http_verify_miss.py index 0b5e96304..a232ca978 100644 --- a/tests/monitor/monit_srcip_ipproto_udp_http_verify_miss.py +++ b/tests/monitor/monit_srcip_ipproto_udp_http_verify_miss.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_library_fqdn_https.py b/tests/monitor/monit_srcip_library_fqdn_https.py index 67adbe20e..8797523f3 100644 --- a/tests/monitor/monit_srcip_library_fqdn_https.py +++ b/tests/monitor/monit_srcip_library_fqdn_https.py @@ -197,9 +197,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_hex_attachment_content.py b/tests/monitor/monit_srcip_mail_hex_attachment_content.py index d2a5b71fd..e6e4c1d23 100644 --- a/tests/monitor/monit_srcip_mail_hex_attachment_content.py +++ b/tests/monitor/monit_srcip_mail_hex_attachment_content.py @@ -190,9 +190,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_hex_attachment_name.py b/tests/monitor/monit_srcip_mail_hex_attachment_name.py index 53201548b..e1a29d563 100644 --- a/tests/monitor/monit_srcip_mail_hex_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_hex_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_mirror_off.py b/tests/monitor/monit_srcip_mail_mirror_off.py index 8d3cb43f6..3349825aa 100644 --- a/tests/monitor/monit_srcip_mail_mirror_off.py +++ b/tests/monitor/monit_srcip_mail_mirror_off.py @@ -176,9 +176,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_mirror_on.py b/tests/monitor/monit_srcip_mail_mirror_on.py index 10cfa9539..b680b39d6 100644 --- a/tests/monitor/monit_srcip_mail_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_account.py b/tests/monitor/monit_srcip_mail_multi_account.py index 4376a993d..7abd8c5bb 100644 --- a/tests/monitor/monit_srcip_mail_multi_account.py +++ b/tests/monitor/monit_srcip_mail_multi_account.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_account_mirror_on.py b/tests/monitor/monit_srcip_mail_multi_account_mirror_on.py index adf834810..0e8e5cd3f 100644 --- a/tests/monitor/monit_srcip_mail_multi_account_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_multi_account_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_account_profile_on.py b/tests/monitor/monit_srcip_mail_multi_account_profile_on.py index c8fb01c3a..b432a8c2a 100644 --- a/tests/monitor/monit_srcip_mail_multi_account_profile_on.py +++ b/tests/monitor/monit_srcip_mail_multi_account_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_attachment_content.py b/tests/monitor/monit_srcip_mail_multi_attachment_content.py index 8db1e33b4..79007b37e 100644 --- a/tests/monitor/monit_srcip_mail_multi_attachment_content.py +++ b/tests/monitor/monit_srcip_mail_multi_attachment_content.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_attachment_name.py b/tests/monitor/monit_srcip_mail_multi_attachment_name.py index 13cca7810..b3b7f6d68 100644 --- a/tests/monitor/monit_srcip_mail_multi_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_multi_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_content.py b/tests/monitor/monit_srcip_mail_multi_content.py index ef38a9442..0fcf629f2 100644 --- a/tests/monitor/monit_srcip_mail_multi_content.py +++ b/tests/monitor/monit_srcip_mail_multi_content.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_from.py b/tests/monitor/monit_srcip_mail_multi_from.py index 0c36df7b2..c002d016e 100644 --- a/tests/monitor/monit_srcip_mail_multi_from.py +++ b/tests/monitor/monit_srcip_mail_multi_from.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_from_mirror_on.py b/tests/monitor/monit_srcip_mail_multi_from_mirror_on.py index c8cfcd904..7238d4811 100644 --- a/tests/monitor/monit_srcip_mail_multi_from_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_multi_from_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_from_profile_on.py b/tests/monitor/monit_srcip_mail_multi_from_profile_on.py index de106611b..cddc64a7f 100644 --- a/tests/monitor/monit_srcip_mail_multi_from_profile_on.py +++ b/tests/monitor/monit_srcip_mail_multi_from_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_subject.py b/tests/monitor/monit_srcip_mail_multi_subject.py index 8eea11d95..1a4681349 100644 --- a/tests/monitor/monit_srcip_mail_multi_subject.py +++ b/tests/monitor/monit_srcip_mail_multi_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_subject_mirror_on.py b/tests/monitor/monit_srcip_mail_multi_subject_mirror_on.py index 514442b9c..4aba3bee2 100644 --- a/tests/monitor/monit_srcip_mail_multi_subject_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_multi_subject_mirror_on.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_subject_profile_on.py b/tests/monitor/monit_srcip_mail_multi_subject_profile_on.py index b5f093d6c..5089db9e1 100644 --- a/tests/monitor/monit_srcip_mail_multi_subject_profile_on.py +++ b/tests/monitor/monit_srcip_mail_multi_subject_profile_on.py @@ -205,9 +205,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_to.py b/tests/monitor/monit_srcip_mail_multi_to.py index c94c051a3..73b15cf50 100644 --- a/tests/monitor/monit_srcip_mail_multi_to.py +++ b/tests/monitor/monit_srcip_mail_multi_to.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_to_mirror_on.py b/tests/monitor/monit_srcip_mail_multi_to_mirror_on.py index 10bee3847..ab55e6d80 100644 --- a/tests/monitor/monit_srcip_mail_multi_to_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_multi_to_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_multi_to_profile_on.py b/tests/monitor/monit_srcip_mail_multi_to_profile_on.py index 6b62fa1ef..e870fbeac 100644 --- a/tests/monitor/monit_srcip_mail_multi_to_profile_on.py +++ b/tests/monitor/monit_srcip_mail_multi_to_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_account.py b/tests/monitor/monit_srcip_mail_pre_account.py index d7a80ecaa..178543597 100644 --- a/tests/monitor/monit_srcip_mail_pre_account.py +++ b/tests/monitor/monit_srcip_mail_pre_account.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_account_mirror_on.py b/tests/monitor/monit_srcip_mail_pre_account_mirror_on.py index 9408c1931..646b57bc4 100644 --- a/tests/monitor/monit_srcip_mail_pre_account_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_pre_account_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_account_profile_on.py b/tests/monitor/monit_srcip_mail_pre_account_profile_on.py index e76057ba7..400c81c8a 100644 --- a/tests/monitor/monit_srcip_mail_pre_account_profile_on.py +++ b/tests/monitor/monit_srcip_mail_pre_account_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_attachment_content.py b/tests/monitor/monit_srcip_mail_pre_attachment_content.py index eff4de8df..f0e5cb5e9 100644 --- a/tests/monitor/monit_srcip_mail_pre_attachment_content.py +++ b/tests/monitor/monit_srcip_mail_pre_attachment_content.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_attachment_name.py b/tests/monitor/monit_srcip_mail_pre_attachment_name.py index c0b4f8819..15327c438 100644 --- a/tests/monitor/monit_srcip_mail_pre_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_pre_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_content.py b/tests/monitor/monit_srcip_mail_pre_content.py index 6786d98a6..e29023813 100644 --- a/tests/monitor/monit_srcip_mail_pre_content.py +++ b/tests/monitor/monit_srcip_mail_pre_content.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_from.py b/tests/monitor/monit_srcip_mail_pre_from.py index 82acb6467..abb43c653 100644 --- a/tests/monitor/monit_srcip_mail_pre_from.py +++ b/tests/monitor/monit_srcip_mail_pre_from.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject.py b/tests/monitor/monit_srcip_mail_pre_subject.py index 35f4ab502..ee39f366b 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject.py +++ b/tests/monitor/monit_srcip_mail_pre_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_account.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_account.py index 6676d66b5..933cb5511 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_account.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_account.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_from.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_from.py index c5b1d47db..aef059d87 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_from.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_from.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_account.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_account.py index 88792f0ff..fbb6bb475 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_account.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_account.py @@ -233,9 +233,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to.py index 4de943d8d..2502dbd1b 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to.py @@ -233,9 +233,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to_pre_account.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to_pre_account.py index fcfe75be4..d2345ccf9 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to_pre_account.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_from_pre_to_pre_account.py @@ -256,9 +256,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_to.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_to.py index 0853b6cf1..c926b1557 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_to.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_to.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_subject_pre_to_pre_account.py b/tests/monitor/monit_srcip_mail_pre_subject_pre_to_pre_account.py index daaf8a19d..279eb72af 100644 --- a/tests/monitor/monit_srcip_mail_pre_subject_pre_to_pre_account.py +++ b/tests/monitor/monit_srcip_mail_pre_subject_pre_to_pre_account.py @@ -233,9 +233,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_pre_to.py b/tests/monitor/monit_srcip_mail_pre_to.py index 4d8a06a45..0f35b4494 100644 --- a/tests/monitor/monit_srcip_mail_pre_to.py +++ b/tests/monitor/monit_srcip_mail_pre_to.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_profile_on.py b/tests/monitor/monit_srcip_mail_profile_on.py index e0b1e2112..a1b23118d 100644 --- a/tests/monitor/monit_srcip_mail_profile_on.py +++ b/tests/monitor/monit_srcip_mail_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_account.py b/tests/monitor/monit_srcip_mail_sub_account.py index 42ff5e244..004036d0d 100644 --- a/tests/monitor/monit_srcip_mail_sub_account.py +++ b/tests/monitor/monit_srcip_mail_sub_account.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_account_sub_from.py b/tests/monitor/monit_srcip_mail_sub_account_sub_from.py index 2998234a2..735bd2391 100644 --- a/tests/monitor/monit_srcip_mail_sub_account_sub_from.py +++ b/tests/monitor/monit_srcip_mail_sub_account_sub_from.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_account_sub_from_sub_to.py b/tests/monitor/monit_srcip_mail_sub_account_sub_from_sub_to.py index d9716c79a..fae9ed93e 100644 --- a/tests/monitor/monit_srcip_mail_sub_account_sub_from_sub_to.py +++ b/tests/monitor/monit_srcip_mail_sub_account_sub_from_sub_to.py @@ -232,9 +232,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_account_sub_to.py b/tests/monitor/monit_srcip_mail_sub_account_sub_to.py index 13d45313a..f1ad4a7e7 100644 --- a/tests/monitor/monit_srcip_mail_sub_account_sub_to.py +++ b/tests/monitor/monit_srcip_mail_sub_account_sub_to.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_content.py b/tests/monitor/monit_srcip_mail_sub_attachment_content.py index d29bfbbd9..2fb933969 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_content.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_content.py @@ -190,9 +190,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_content_mirror_on.py b/tests/monitor/monit_srcip_mail_sub_attachment_content_mirror_on.py index 0b6c2b43d..ee7d927fa 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_content_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_content_mirror_on.py @@ -38,7 +38,7 @@ def run(parameter): "items": [ { "op": "add", - "ip": "10.64.224.7", + "ip": "10.64.224.3", "interval": "0-65535" } ] @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_content_profile_on.py b/tests/monitor/monit_srcip_mail_sub_attachment_content_profile_on.py index 3d7f56b8a..95b438a21 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_content_profile_on.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_content_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_content_sub_content.py b/tests/monitor/monit_srcip_mail_sub_attachment_content_sub_content.py index 4dbcc3176..a6b5ab6ac 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_content_sub_content.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_content_sub_content.py @@ -208,9 +208,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name.py b/tests/monitor/monit_srcip_mail_sub_attachment_name.py index b29d465a7..dc279aca8 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name_mirror_on.py b/tests/monitor/monit_srcip_mail_sub_attachment_name_mirror_on.py index f5a080fb2..2238bb4f2 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name_mirror_on.py @@ -38,7 +38,7 @@ def run(parameter): "items": [ { "op": "add", - "ip": "10.64.224.7", + "ip": "10.64.224.3", "interval": "0-65535" } ] @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name_profile_on.py b/tests/monitor/monit_srcip_mail_sub_attachment_name_profile_on.py index 23e29a854..0b1446148 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name_profile_on.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content.py b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content.py index 0931ae0a0..fdb9a94d3 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content.py @@ -209,9 +209,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content_sub_content.py b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content_sub_content.py index 1c38bad33..0f929259c 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content_sub_content.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_attachment_content_sub_content.py @@ -227,9 +227,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_content.py b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_content.py index c4b71bcd3..406c20f4a 100644 --- a/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_content.py +++ b/tests/monitor/monit_srcip_mail_sub_attachment_name_sub_content.py @@ -209,9 +209,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_content.py b/tests/monitor/monit_srcip_mail_sub_content.py index 75a4d03f2..8337b2f01 100644 --- a/tests/monitor/monit_srcip_mail_sub_content.py +++ b/tests/monitor/monit_srcip_mail_sub_content.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_content_mirror_on.py b/tests/monitor/monit_srcip_mail_sub_content_mirror_on.py index fffd18b83..8cda749b7 100644 --- a/tests/monitor/monit_srcip_mail_sub_content_mirror_on.py +++ b/tests/monitor/monit_srcip_mail_sub_content_mirror_on.py @@ -192,9 +192,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_content_profile_on.py b/tests/monitor/monit_srcip_mail_sub_content_profile_on.py index e959ddc39..83f87ca07 100644 --- a/tests/monitor/monit_srcip_mail_sub_content_profile_on.py +++ b/tests/monitor/monit_srcip_mail_sub_content_profile_on.py @@ -204,9 +204,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_from.py b/tests/monitor/monit_srcip_mail_sub_from.py index 3afde4f92..ef15f815f 100644 --- a/tests/monitor/monit_srcip_mail_sub_from.py +++ b/tests/monitor/monit_srcip_mail_sub_from.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_from_sub_to.py b/tests/monitor/monit_srcip_mail_sub_from_sub_to.py index 8de9c8a0b..d3102b63e 100644 --- a/tests/monitor/monit_srcip_mail_sub_from_sub_to.py +++ b/tests/monitor/monit_srcip_mail_sub_from_sub_to.py @@ -214,9 +214,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_subject.py b/tests/monitor/monit_srcip_mail_sub_subject.py index 7bc49e49d..28ce3f1e1 100644 --- a/tests/monitor/monit_srcip_mail_sub_subject.py +++ b/tests/monitor/monit_srcip_mail_sub_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_sub_to.py b/tests/monitor/monit_srcip_mail_sub_to.py index 6af96100c..ad2f0cce3 100644 --- a/tests/monitor/monit_srcip_mail_sub_to.py +++ b/tests/monitor/monit_srcip_mail_sub_to.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_suff_account.py b/tests/monitor/monit_srcip_mail_suff_account.py index c730363bb..cfb113de9 100644 --- a/tests/monitor/monit_srcip_mail_suff_account.py +++ b/tests/monitor/monit_srcip_mail_suff_account.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_suff_attachment_name.py b/tests/monitor/monit_srcip_mail_suff_attachment_name.py index aa5a480e9..491d59d44 100644 --- a/tests/monitor/monit_srcip_mail_suff_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_suff_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_suff_from.py b/tests/monitor/monit_srcip_mail_suff_from.py index 5a90476d5..fd70e4f19 100644 --- a/tests/monitor/monit_srcip_mail_suff_from.py +++ b/tests/monitor/monit_srcip_mail_suff_from.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_suff_subject.py b/tests/monitor/monit_srcip_mail_suff_subject.py index 1ffa77966..5afbe921a 100644 --- a/tests/monitor/monit_srcip_mail_suff_subject.py +++ b/tests/monitor/monit_srcip_mail_suff_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_suff_to.py b/tests/monitor/monit_srcip_mail_suff_to.py index b94310e65..52ef05ce2 100644 --- a/tests/monitor/monit_srcip_mail_suff_to.py +++ b/tests/monitor/monit_srcip_mail_suff_to.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_xly_account.py b/tests/monitor/monit_srcip_mail_xly_account.py index 8d6bf3d1e..557450688 100644 --- a/tests/monitor/monit_srcip_mail_xly_account.py +++ b/tests/monitor/monit_srcip_mail_xly_account.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_xly_attachment_name.py b/tests/monitor/monit_srcip_mail_xly_attachment_name.py index 98f14b19f..37c8de994 100644 --- a/tests/monitor/monit_srcip_mail_xly_attachment_name.py +++ b/tests/monitor/monit_srcip_mail_xly_attachment_name.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_xly_from.py b/tests/monitor/monit_srcip_mail_xly_from.py index 86685d394..8acbc282e 100644 --- a/tests/monitor/monit_srcip_mail_xly_from.py +++ b/tests/monitor/monit_srcip_mail_xly_from.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_xly_subject.py b/tests/monitor/monit_srcip_mail_xly_subject.py index a5b4e3c8c..c5a67d926 100644 --- a/tests/monitor/monit_srcip_mail_xly_subject.py +++ b/tests/monitor/monit_srcip_mail_xly_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mail_xly_to.py b/tests/monitor/monit_srcip_mail_xly_to.py index 40f84500c..e208aef69 100644 --- a/tests/monitor/monit_srcip_mail_xly_to.py +++ b/tests/monitor/monit_srcip_mail_xly_to.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_mirror_on.py b/tests/monitor/monit_srcip_mirror_on.py index 254c91113..c5b791a3a 100644 --- a/tests/monitor/monit_srcip_mirror_on.py +++ b/tests/monitor/monit_srcip_mirror_on.py @@ -164,9 +164,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_pre_fqdn_http.py b/tests/monitor/monit_srcip_pre_fqdn_http.py index 7d9ba09a6..a0e05c7c7 100644 --- a/tests/monitor/monit_srcip_pre_fqdn_http.py +++ b/tests/monitor/monit_srcip_pre_fqdn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_pre_fqdn_https.py b/tests/monitor/monit_srcip_pre_fqdn_https.py index 3c93034b2..22e71a2d6 100644 --- a/tests/monitor/monit_srcip_pre_fqdn_https.py +++ b/tests/monitor/monit_srcip_pre_fqdn_https.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_pre_fqdn_quic.py b/tests/monitor/monit_srcip_pre_fqdn_quic.py index bc6fe2896..6cb3f1b4f 100644 --- a/tests/monitor/monit_srcip_pre_fqdn_quic.py +++ b/tests/monitor/monit_srcip_pre_fqdn_quic.py @@ -186,9 +186,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_pre_fqdn_ssl.py b/tests/monitor/monit_srcip_pre_fqdn_ssl.py index 3c93034b2..22e71a2d6 100644 --- a/tests/monitor/monit_srcip_pre_fqdn_ssl.py +++ b/tests/monitor/monit_srcip_pre_fqdn_ssl.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_profile_on.py b/tests/monitor/monit_srcip_profile_on.py index 50a87e1e2..82a974e80 100644 --- a/tests/monitor/monit_srcip_profile_on.py +++ b/tests/monitor/monit_srcip_profile_on.py @@ -176,9 +176,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_quic_fqdn_pkt_on.py b/tests/monitor/monit_srcip_quic_fqdn_pkt_on.py index b348cf671..ed8165c01 100644 --- a/tests/monitor/monit_srcip_quic_fqdn_pkt_on.py +++ b/tests/monitor/monit_srcip_quic_fqdn_pkt_on.py @@ -186,9 +186,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_quic_mirror_off.py b/tests/monitor/monit_srcip_quic_mirror_off.py index 434caf720..94e1608b7 100644 --- a/tests/monitor/monit_srcip_quic_mirror_off.py +++ b/tests/monitor/monit_srcip_quic_mirror_off.py @@ -167,9 +167,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_quic_mirror_on.py b/tests/monitor/monit_srcip_quic_mirror_on.py index 402c3c649..64d259c27 100644 --- a/tests/monitor/monit_srcip_quic_mirror_on.py +++ b/tests/monitor/monit_srcip_quic_mirror_on.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_quic_profile_on.py b/tests/monitor/monit_srcip_quic_profile_on.py index e7b6d2a2d..88ac911b5 100644 --- a/tests/monitor/monit_srcip_quic_profile_on.py +++ b/tests/monitor/monit_srcip_quic_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_skype.py b/tests/monitor/monit_srcip_skype.py index 901a26ab2..d3bca3a2b 100644 --- a/tests/monitor/monit_srcip_skype.py +++ b/tests/monitor/monit_srcip_skype.py @@ -165,9 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_src_ranport.py b/tests/monitor/monit_srcip_src_ranport.py index 6661fafca..6a9be34c9 100644 --- a/tests/monitor/monit_srcip_src_ranport.py +++ b/tests/monitor/monit_srcip_src_ranport.py @@ -172,9 +172,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_srcport_dstport.py b/tests/monitor/monit_srcip_srcport_dstport.py index e68a1a672..48e898101 100644 --- a/tests/monitor/monit_srcip_srcport_dstport.py +++ b/tests/monitor/monit_srcip_srcport_dstport.py @@ -189,9 +189,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_false.py b/tests/monitor/monit_srcip_ssl_ech_false.py index c2fa2b761..c29a6d27f 100644 --- a/tests/monitor/monit_srcip_ssl_ech_false.py +++ b/tests/monitor/monit_srcip_ssl_ech_false.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_false_mirror_on.py b/tests/monitor/monit_srcip_ssl_ech_false_mirror_on.py index 97608df30..d45cb8694 100644 --- a/tests/monitor/monit_srcip_ssl_ech_false_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_ech_false_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_false_profile_on.py b/tests/monitor/monit_srcip_ssl_ech_false_profile_on.py index 4ef7b0371..5045a1409 100644 --- a/tests/monitor/monit_srcip_ssl_ech_false_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_ech_false_profile_on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_true.py b/tests/monitor/monit_srcip_ssl_ech_true.py index b673e5c83..9605c403c 100644 --- a/tests/monitor/monit_srcip_ssl_ech_true.py +++ b/tests/monitor/monit_srcip_ssl_ech_true.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_true_mirror_on.py b/tests/monitor/monit_srcip_ssl_ech_true_mirror_on.py index 566c5aa0f..af558fe2a 100644 --- a/tests/monitor/monit_srcip_ssl_ech_true_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_ech_true_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_ech_true_profile_on.py b/tests/monitor/monit_srcip_ssl_ech_true_profile_on.py index ecdf8014d..f29ac5c22 100644 --- a/tests/monitor/monit_srcip_ssl_ech_true_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_ech_true_profile_on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_false.py b/tests/monitor/monit_srcip_ssl_esni_false.py index a61054858..06295a59b 100644 --- a/tests/monitor/monit_srcip_ssl_esni_false.py +++ b/tests/monitor/monit_srcip_ssl_esni_false.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_false_ech_false.py b/tests/monitor/monit_srcip_ssl_esni_false_ech_false.py index b3382c2a9..911d92a89 100644 --- a/tests/monitor/monit_srcip_ssl_esni_false_ech_false.py +++ b/tests/monitor/monit_srcip_ssl_esni_false_ech_false.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_false_ech_true.py b/tests/monitor/monit_srcip_ssl_esni_false_ech_true.py index e5dc3ff08..0dcfeec14 100644 --- a/tests/monitor/monit_srcip_ssl_esni_false_ech_true.py +++ b/tests/monitor/monit_srcip_ssl_esni_false_ech_true.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_false_mirror_on.py b/tests/monitor/monit_srcip_ssl_esni_false_mirror_on.py index 1a55a8a91..df82a3b31 100644 --- a/tests/monitor/monit_srcip_ssl_esni_false_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_esni_false_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_false_profile_on.py b/tests/monitor/monit_srcip_ssl_esni_false_profile_on.py index 1d563b219..b7ddc00a8 100644 --- a/tests/monitor/monit_srcip_ssl_esni_false_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_esni_false_profile_on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_true.py b/tests/monitor/monit_srcip_ssl_esni_true.py index 1a80b005d..4092fafe3 100644 --- a/tests/monitor/monit_srcip_ssl_esni_true.py +++ b/tests/monitor/monit_srcip_ssl_esni_true.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_true_ech_false.py b/tests/monitor/monit_srcip_ssl_esni_true_ech_false.py index 2d7c045ec..bb6a62bf0 100644 --- a/tests/monitor/monit_srcip_ssl_esni_true_ech_false.py +++ b/tests/monitor/monit_srcip_ssl_esni_true_ech_false.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_true_mirror_on.py b/tests/monitor/monit_srcip_ssl_esni_true_mirror_on.py index 967771e1d..d45ddf75c 100644 --- a/tests/monitor/monit_srcip_ssl_esni_true_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_esni_true_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_esni_true_profile_on.py b/tests/monitor/monit_srcip_ssl_esni_true_profile_on.py index 41c14595e..0bfee1872 100644 --- a/tests/monitor/monit_srcip_ssl_esni_true_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_esni_true_profile_on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_flag_substr_fqdn.py b/tests/monitor/monit_srcip_ssl_flag_substr_fqdn.py index 683d36e32..a082b43bd 100644 --- a/tests/monitor/monit_srcip_ssl_flag_substr_fqdn.py +++ b/tests/monitor/monit_srcip_ssl_flag_substr_fqdn.py @@ -201,9 +201,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_fqdn_pkt_on.py b/tests/monitor/monit_srcip_ssl_fqdn_pkt_on.py index 7400f548e..acc741d31 100644 --- a/tests/monitor/monit_srcip_ssl_fqdn_pkt_on.py +++ b/tests/monitor/monit_srcip_ssl_fqdn_pkt_on.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_mirror_off.py b/tests/monitor/monit_srcip_ssl_mirror_off.py index 38dfa10d7..daa049a81 100644 --- a/tests/monitor/monit_srcip_ssl_mirror_off.py +++ b/tests/monitor/monit_srcip_ssl_mirror_off.py @@ -166,9 +166,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_mirror_on.py b/tests/monitor/monit_srcip_ssl_mirror_on.py index efc169775..4e05c9315 100644 --- a/tests/monitor/monit_srcip_ssl_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_mirror_on.py @@ -174,9 +174,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false.py b/tests/monitor/monit_srcip_ssl_nosni_false.py index c72982558..1a14a90bc 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false.py @@ -176,9 +176,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_false.py b/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_false.py index af4e67c01..56ce1617a 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_false.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_false.py @@ -203,9 +203,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_true.py b/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_true.py index 24e76d9e5..37d5f3395 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_true.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_esni_false_ech_true.py @@ -203,9 +203,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_mirror_on.py b/tests/monitor/monit_srcip_ssl_nosni_false_mirror_on.py index cd648cd57..5e2fc624a 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_profile__on.py b/tests/monitor/monit_srcip_ssl_nosni_false_profile__on.py index dc5df8c55..67d2dd237 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_profile__on.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_profile__on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_sub_cn.py b/tests/monitor/monit_srcip_ssl_nosni_false_sub_cn.py index a412293f3..5a9132c70 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_sub_cn.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_sub_cn.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_sub_san.py b/tests/monitor/monit_srcip_ssl_nosni_false_sub_san.py index f021dd9e1..9484d7775 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_sub_san.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_sub_san.py @@ -193,9 +193,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_false_sub_san_sub_cn.py b/tests/monitor/monit_srcip_ssl_nosni_false_sub_san_sub_cn.py index 450934daf..f7c05d832 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_false_sub_san_sub_cn.py +++ b/tests/monitor/monit_srcip_ssl_nosni_false_sub_san_sub_cn.py @@ -211,9 +211,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_true.py b/tests/monitor/monit_srcip_ssl_nosni_true.py index 0d000bc5d..cf061cffb 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_true.py +++ b/tests/monitor/monit_srcip_ssl_nosni_true.py @@ -176,9 +176,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_true_esni_true_ech_false.py b/tests/monitor/monit_srcip_ssl_nosni_true_esni_true_ech_false.py index b1b01560a..e62d3801b 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_true_esni_true_ech_false.py +++ b/tests/monitor/monit_srcip_ssl_nosni_true_esni_true_ech_false.py @@ -202,9 +202,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_true_mirror_on.py b/tests/monitor/monit_srcip_ssl_nosni_true_mirror_on.py index 751ec48d0..430ab341e 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_true_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_nosni_true_mirror_on.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_true_profile_on.py b/tests/monitor/monit_srcip_ssl_nosni_true_profile_on.py index 6134ac4b1..126d23cea 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_true_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_nosni_true_profile_on.py @@ -196,9 +196,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_nosni_true_sub_san_sub_cn_verify_miss.py b/tests/monitor/monit_srcip_ssl_nosni_true_sub_san_sub_cn_verify_miss.py index e267a8c26..e643f7221 100644 --- a/tests/monitor/monit_srcip_ssl_nosni_true_sub_san_sub_cn_verify_miss.py +++ b/tests/monitor/monit_srcip_ssl_nosni_true_sub_san_sub_cn_verify_miss.py @@ -209,9 +209,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_pre_cn.py b/tests/monitor/monit_srcip_ssl_pre_cn.py index a67714977..3c85403e2 100644 --- a/tests/monitor/monit_srcip_ssl_pre_cn.py +++ b/tests/monitor/monit_srcip_ssl_pre_cn.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_profile_on.py b/tests/monitor/monit_srcip_ssl_profile_on.py index aca29479c..bb507cbbc 100644 --- a/tests/monitor/monit_srcip_ssl_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_profile_on.py @@ -186,9 +186,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_cn.py b/tests/monitor/monit_srcip_ssl_sub_cn.py index d87a24134..2f70853a8 100644 --- a/tests/monitor/monit_srcip_ssl_sub_cn.py +++ b/tests/monitor/monit_srcip_ssl_sub_cn.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_cn_mirror_on.py b/tests/monitor/monit_srcip_ssl_sub_cn_mirror_on.py index 60860c7b2..b7a316b4a 100644 --- a/tests/monitor/monit_srcip_ssl_sub_cn_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_sub_cn_mirror_on.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_cn_profile_on.py b/tests/monitor/monit_srcip_ssl_sub_cn_profile_on.py index d0ab4d6fb..82dd0e6cd 100644 --- a/tests/monitor/monit_srcip_ssl_sub_cn_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_sub_cn_profile_on.py @@ -203,9 +203,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_cn_sub_san.py b/tests/monitor/monit_srcip_ssl_sub_cn_sub_san.py index 916105e50..86c5e5b12 100644 --- a/tests/monitor/monit_srcip_ssl_sub_cn_sub_san.py +++ b/tests/monitor/monit_srcip_ssl_sub_cn_sub_san.py @@ -200,9 +200,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_san.py b/tests/monitor/monit_srcip_ssl_sub_san.py index ab24d3fbd..ab8db147a 100644 --- a/tests/monitor/monit_srcip_ssl_sub_san.py +++ b/tests/monitor/monit_srcip_ssl_sub_san.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_san_mirror_on.py b/tests/monitor/monit_srcip_ssl_sub_san_mirror_on.py index 660ed3ed1..3b5587585 100644 --- a/tests/monitor/monit_srcip_ssl_sub_san_mirror_on.py +++ b/tests/monitor/monit_srcip_ssl_sub_san_mirror_on.py @@ -191,9 +191,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_sub_san_profile_on.py b/tests/monitor/monit_srcip_ssl_sub_san_profile_on.py index 51a1ba645..367122164 100644 --- a/tests/monitor/monit_srcip_ssl_sub_san_profile_on.py +++ b/tests/monitor/monit_srcip_ssl_sub_san_profile_on.py @@ -203,9 +203,9 @@ def run(parameter): if profile_tuple: api_client.delete_profiles(profile_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_suff_cn.py b/tests/monitor/monit_srcip_ssl_suff_cn.py index 07b1cad93..bc827a890 100644 --- a/tests/monitor/monit_srcip_ssl_suff_cn.py +++ b/tests/monitor/monit_srcip_ssl_suff_cn.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_suff_san.py b/tests/monitor/monit_srcip_ssl_suff_san.py index d3ed5103c..ed841e624 100644 --- a/tests/monitor/monit_srcip_ssl_suff_san.py +++ b/tests/monitor/monit_srcip_ssl_suff_san.py @@ -184,9 +184,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_ssl_xly_cn.py b/tests/monitor/monit_srcip_ssl_xly_cn.py index f3dc29cf7..e865bfe6d 100644 --- a/tests/monitor/monit_srcip_ssl_xly_cn.py +++ b/tests/monitor/monit_srcip_ssl_xly_cn.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_sub_fqdn_http.py b/tests/monitor/monit_srcip_sub_fqdn_http.py index 71456ac09..298ceaa0c 100644 --- a/tests/monitor/monit_srcip_sub_fqdn_http.py +++ b/tests/monitor/monit_srcip_sub_fqdn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_sub_fqdn_https.py b/tests/monitor/monit_srcip_sub_fqdn_https.py index af8ecb5d2..a77c2a45f 100644 --- a/tests/monitor/monit_srcip_sub_fqdn_https.py +++ b/tests/monitor/monit_srcip_sub_fqdn_https.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_sub_fqdn_quic.py b/tests/monitor/monit_srcip_sub_fqdn_quic.py index 3a12373af..20e92dd84 100644 --- a/tests/monitor/monit_srcip_sub_fqdn_quic.py +++ b/tests/monitor/monit_srcip_sub_fqdn_quic.py @@ -186,9 +186,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_sub_fqdn_ssl.py b/tests/monitor/monit_srcip_sub_fqdn_ssl.py index af8ecb5d2..a77c2a45f 100644 --- a/tests/monitor/monit_srcip_sub_fqdn_ssl.py +++ b/tests/monitor/monit_srcip_sub_fqdn_ssl.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_suff_fqdn_http.py b/tests/monitor/monit_srcip_suff_fqdn_http.py index d31cfef61..88c9ca105 100644 --- a/tests/monitor/monit_srcip_suff_fqdn_http.py +++ b/tests/monitor/monit_srcip_suff_fqdn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_suff_fqdn_https.py b/tests/monitor/monit_srcip_suff_fqdn_https.py index b9b4ca355..eefe475e4 100644 --- a/tests/monitor/monit_srcip_suff_fqdn_https.py +++ b/tests/monitor/monit_srcip_suff_fqdn_https.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_suff_fqdn_quic.py b/tests/monitor/monit_srcip_suff_fqdn_quic.py index 677dc1220..165b17b27 100644 --- a/tests/monitor/monit_srcip_suff_fqdn_quic.py +++ b/tests/monitor/monit_srcip_suff_fqdn_quic.py @@ -186,9 +186,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_suff_fqdn_ssl.py b/tests/monitor/monit_srcip_suff_fqdn_ssl.py index b9b4ca355..eefe475e4 100644 --- a/tests/monitor/monit_srcip_suff_fqdn_ssl.py +++ b/tests/monitor/monit_srcip_suff_fqdn_ssl.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_telegram.py b/tests/monitor/monit_srcip_telegram.py index 0de9b3757..faf112e3e 100644 --- a/tests/monitor/monit_srcip_telegram.py +++ b/tests/monitor/monit_srcip_telegram.py @@ -165,9 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_whatsapp.py b/tests/monitor/monit_srcip_whatsapp.py index 05294deb7..e25d6463e 100644 --- a/tests/monitor/monit_srcip_whatsapp.py +++ b/tests/monitor/monit_srcip_whatsapp.py @@ -165,9 +165,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_xly_fqdn_http.py b/tests/monitor/monit_srcip_xly_fqdn_http.py index 8ee90a8b2..840129d12 100644 --- a/tests/monitor/monit_srcip_xly_fqdn_http.py +++ b/tests/monitor/monit_srcip_xly_fqdn_http.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_xly_fqdn_https.py b/tests/monitor/monit_srcip_xly_fqdn_https.py index 7d3142257..2bfc65901 100644 --- a/tests/monitor/monit_srcip_xly_fqdn_https.py +++ b/tests/monitor/monit_srcip_xly_fqdn_https.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_xly_fqdn_quic.py b/tests/monitor/monit_srcip_xly_fqdn_quic.py index c42e18f27..6350d93d1 100644 --- a/tests/monitor/monit_srcip_xly_fqdn_quic.py +++ b/tests/monitor/monit_srcip_xly_fqdn_quic.py @@ -186,9 +186,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_srcip_xly_fqdn_ssl.py b/tests/monitor/monit_srcip_xly_fqdn_ssl.py index 7d3142257..2bfc65901 100644 --- a/tests/monitor/monit_srcip_xly_fqdn_ssl.py +++ b/tests/monitor/monit_srcip_xly_fqdn_ssl.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_dns_substr_qname.py b/tests/monitor/monit_subid_dns_substr_qname.py index cc9af76e7..127ad43fe 100644 --- a/tests/monitor/monit_subid_dns_substr_qname.py +++ b/tests/monitor/monit_subid_dns_substr_qname.py @@ -183,9 +183,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_ftp_substr_uri.py b/tests/monitor/monit_subid_ftp_substr_uri.py index 2c8011eed..42ec0ea3c 100644 --- a/tests/monitor/monit_subid_ftp_substr_uri.py +++ b/tests/monitor/monit_subid_ftp_substr_uri.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_ftp_substr_uri_substr_content_substr_account.py b/tests/monitor/monit_subid_ftp_substr_uri_substr_content_substr_account.py index 91f917531..19780824f 100644 --- a/tests/monitor/monit_subid_ftp_substr_uri_substr_content_substr_account.py +++ b/tests/monitor/monit_subid_ftp_substr_uri_substr_content_substr_account.py @@ -220,9 +220,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_http_substr_fqdn.py b/tests/monitor/monit_subid_http_substr_fqdn.py index 22ccb7aa6..6fa1a88ef 100644 --- a/tests/monitor/monit_subid_http_substr_fqdn.py +++ b/tests/monitor/monit_subid_http_substr_fqdn.py @@ -182,9 +182,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_http_substr_fqdn_substr_url_substr_reqheader_by_ua.py b/tests/monitor/monit_subid_http_substr_fqdn_substr_url_substr_reqheader_by_ua.py index 4b765eb5c..80f323660 100644 --- a/tests/monitor/monit_subid_http_substr_fqdn_substr_url_substr_reqheader_by_ua.py +++ b/tests/monitor/monit_subid_http_substr_fqdn_substr_url_substr_reqheader_by_ua.py @@ -219,9 +219,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_mail_substr_from_substr_to_substr_account.py b/tests/monitor/monit_subid_mail_substr_from_substr_to_substr_account.py index ab876b2fd..fdcb455b3 100644 --- a/tests/monitor/monit_subid_mail_substr_from_substr_to_substr_account.py +++ b/tests/monitor/monit_subid_mail_substr_from_substr_to_substr_account.py @@ -229,9 +229,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_mail_substr_subject.py b/tests/monitor/monit_subid_mail_substr_subject.py index de5f96c40..1c883fa9d 100644 --- a/tests/monitor/monit_subid_mail_substr_subject.py +++ b/tests/monitor/monit_subid_mail_substr_subject.py @@ -195,9 +195,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_account.py b/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_account.py index 37e7c1645..353e94fa9 100644 --- a/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_account.py +++ b/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_account.py @@ -230,9 +230,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_to.py b/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_to.py index d2fdc70ee..340afc3fa 100644 --- a/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_to.py +++ b/tests/monitor/monit_subid_mail_substr_subject_substr_from_substr_to.py @@ -230,9 +230,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_ssl_substr_fqdn.py b/tests/monitor/monit_subid_ssl_substr_fqdn.py index 7b2f09a4a..a172c6374 100644 --- a/tests/monitor/monit_subid_ssl_substr_fqdn.py +++ b/tests/monitor/monit_subid_ssl_substr_fqdn.py @@ -185,9 +185,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/monitor/monit_subid_ssl_substr_fqdn_substr_cn_substr_san.py b/tests/monitor/monit_subid_ssl_substr_fqdn_substr_cn_substr_san.py index 3b9d18e30..3cfa67f17 100644 --- a/tests/monitor/monit_subid_ssl_substr_fqdn_substr_cn_substr_san.py +++ b/tests/monitor/monit_subid_ssl_substr_fqdn_substr_cn_substr_san.py @@ -219,9 +219,9 @@ def run(parameter): if objects_tuple: api_client.delete_objects(objects_tuple) - # 统计脚本用时 - end_time = time.time() - duration = end_time - datetime.strptime(start_time, '%Y-%m-%dT%H:%M:%SZ').timestamp() + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], diff --git a/tests/object/test_temp/create_apn_object_temp.py b/tests/object/test_temp/create_apn_object_temp.py index 18baad183..745662fd7 100644 --- a/tests/object/test_temp/create_apn_object_temp.py +++ b/tests/object/test_temp/create_apn_object_temp.py @@ -16,39 +16,62 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ - { - "name": "test", - "type": "apn", - "member_type": "item", - "statistics_option": "", # random - "items": [ - { - "op": "add", - "expr_type": "and", - "expression": "acdcd$" - } - ] - } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, + object_configuration = [ + { + "name": "create_apn_object", + "type": "apn", + "member_type": "item", + "statistics_option": "", # random + "items": [ + { + "op": "add", + "expr_type": "and", + "expression": "acdcd$" + } + ] + } + ] - "audit_log": False # system - } + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_apn_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Search Object successful ") + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="testapn$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="acdcd$", new_item="^xrwom.fu$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + + return "" except Exception as e: exception_result = str(e) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True) @@ -56,22 +79,16 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/object/test_temp/create_ip_learning_objects_temp.py b/tests/object/test_temp/create_ip_learning_objects_temp.py index ec4499dbf..1644955c6 100644 --- a/tests/object/test_temp/create_ip_learning_objects_temp.py +++ b/tests/object/test_temp/create_ip_learning_objects_temp.py @@ -46,10 +46,15 @@ def run(parameter): if code != 200: return "Fail to create object." else: - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Create Object successful ") + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + search_type = { + "is_fuzzy": False, + "type": "", + } # 查询 - objects_tuple, code = ui_client.search_objects("create_ip_learing_object", object_configuration, "") + objects_tuple, code = ui_client.search_objects("create_ip_learing_object", object_configuration, search_type) objects_list = list(objects_tuple) if len(objects_list) == 0: return "Fail to get object uuid." @@ -58,8 +63,23 @@ def run(parameter): else: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ") - return "" + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="acdcd$", new_item="^xrwom.fu$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + return "" except Exception as e: exception_result = str(e) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True) @@ -69,7 +89,8 @@ def run(parameter): # 删除 if objects_tuple: ui_client.delete_objects(objects_tuple) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ") + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Delete Object successful ") # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() diff --git a/tests/object/test_temp/create_ip_object_temp.py b/tests/object/test_temp/create_ip_object_temp.py index 3c0312afe..f6cb3f788 100644 --- a/tests/object/test_temp/create_ip_object_temp.py +++ b/tests/object/test_temp/create_ip_object_temp.py @@ -21,7 +21,8 @@ def run(parameter): "type": "ip", "sub_type": "ip", "member_type": "item", - "statistics_option": "", # random + "description": "", + "statistics_option": "none", # random "items": [ { "op": "add", diff --git a/tests/object/test_temp/create_keyword_object_temp.py b/tests/object/test_temp/create_keyword_object_temp.py index 48f995356..d430c433d 100644 --- a/tests/object/test_temp/create_keyword_object_temp.py +++ b/tests/object/test_temp/create_keyword_object_temp.py @@ -16,10 +16,9 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ + object_configuration =[ { - "name": "test", + "name": "create_keyword_object", "type": "keyword", "member_type": "item", "statistics_option": "", # random @@ -31,23 +30,47 @@ def run(parameter): }, ], } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, - "audit_log": False # system - } + ] + + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_keyword_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ") + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="^ftp") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="^ftp", new_item="^abcd$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + + return "" except Exception as e: exception_result = str(e) @@ -56,15 +79,11 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time @@ -72,6 +91,7 @@ def run(parameter): "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/object/test_temp/create_mobile_imsi_object_temp.py b/tests/object/test_temp/create_mobile_imei_object.py index dace07d8e..b693885e8 100644 --- a/tests/object/test_temp/create_mobile_imsi_object_temp.py +++ b/tests/object/test_temp/create_mobile_imei_object.py @@ -16,10 +16,9 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ + object_configuration = [ { - "name": "test", + "name": "create_mobile_imei_object", "type": "mobile_identity", "sub_type": "imei", "member_type": "item", @@ -32,24 +31,50 @@ def run(parameter): } ], } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, - "audit_log": False # system - } + ] + + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_mobile_imei_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Search Object successful ") + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="^12312312321$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="^12312312321$", new_item="^523335986424$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + return "" except Exception as e: exception_result = str(e) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True) @@ -57,15 +82,11 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time @@ -73,6 +94,7 @@ def run(parameter): "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/object/test_temp/create_mobile_imsi_temp.py b/tests/object/test_temp/create_mobile_imsi_temp.py index 85f079e3a..a1c55eb51 100644 --- a/tests/object/test_temp/create_mobile_imsi_temp.py +++ b/tests/object/test_temp/create_mobile_imsi_temp.py @@ -16,10 +16,9 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ + object_configuration = [ { - "name": "test", + "name": "create_imsi_object", "type": "mobile_identity", "sub_type": "imsi", "member_type": "item", @@ -32,22 +31,50 @@ def run(parameter): } ], } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, - "audit_log": False # system - } + ] + + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_imsi_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Search Object successful ") + + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="^110035141486424$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="^12312312321", new_item="^65410035489794$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + + return "" except Exception as e: @@ -57,22 +84,16 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/object/test_temp/create_mobile_phone_number_temp.py b/tests/object/test_temp/create_mobile_phone_number_temp.py index 654f98ca9..64c9fcae5 100644 --- a/tests/object/test_temp/create_mobile_phone_number_temp.py +++ b/tests/object/test_temp/create_mobile_phone_number_temp.py @@ -16,10 +16,9 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ + object_configuration = [ { - "name": "test", + "name": "create_phone_number_object", "type": "mobile_identity", "sub_type": "phone_number", "member_type": "item", @@ -32,24 +31,47 @@ def run(parameter): } ] } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, - "audit_log": False # system - } + ] + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_phone_number_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ") + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="5986424$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="5986424$", new_item="^52333598") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Edit Object successful ") + return "" except Exception as e: exception_result = str(e) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True) @@ -57,22 +79,17 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/object/test_temp/create_sub_id_temp.py b/tests/object/test_temp/create_sub_id_temp.py index 10f4abe1a..7b8392de3 100644 --- a/tests/object/test_temp/create_sub_id_temp.py +++ b/tests/object/test_temp/create_sub_id_temp.py @@ -16,10 +16,9 @@ def run(parameter): script_start_time = time.time() #测试数据 - object_configuration = { - "or_conditions": [ + object_configuration = [ { - "name": "test", + "name": "create_sub_id_object", "type": "subscriberid", "member_type": "item", "statistics_option": "", # random @@ -31,25 +30,47 @@ def run(parameter): }, ] } - ], - "search": { - "is_fuzzy": False, - "type": "uuid" - }, + ] - "audit_log": False # system - } + ui_client = UIClient(parameter) # 创建 - ui_client = UIClient() - objects_tuple, ui_error = ui_client.create_objects(object_configuration) - if len(ui_error) > 0: - return ui_error + code = ui_client.create_objects(object_configuration) + if code != 200: + return "Fail to create object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "Create Object successful ") + + search_type = { + "is_fuzzy": False, + "type": "", + } + # 查询 + objects_tuple, code = ui_client.search_objects("create_sub_id_object", object_configuration, search_type) objects_list = list(objects_tuple) - if len(objects_list) > 0 and len(objects_list[0]["uuid"]) > 0: - return "" + if len(objects_list) == 0: + return "Fail to get object uuid." + if code != 200: + return "Fail to search object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Search Object successful ") + # 编辑 + # 如果src_item是空,则表示该item是新加 + code = ui_client.edit_objects(objects_tuple, src_item="", new_item="^addsubid$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + # 如果src_item是不是空,在item输入框,输入src_item,找到item,点击item的编辑按钮,删除src_item,输入new_item,点击保存按钮 + code = ui_client.edit_objects(objects_tuple, src_item="^test_subid$", new_item="^edit6628$") + if code != 200: + return "Fail to edit object." + else: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Edit Object successful ") + return "" except Exception as e: exception_result = str(e) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"When running test case, the exception error: ", str(e), flush=True) @@ -57,15 +78,10 @@ def run(parameter): finally: # 删除 - if parameter["initiation_method"] == "ui": - if objects_tuple is not None: - ui_client.delete_objects(parameter, objects_tuple, object_configuration["search"]) - # elif parameter["initiation_method"] == "api": - # if not objects_tuple: - # api_client.delete_rules(rules_tuple) - # if not objects_tuple: - # api_client.delete_objects(objects_tuple) - + if objects_tuple: + ui_client.delete_objects(objects_tuple) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3],"Delete Object successful ") + # ui_client.cleanup() # 统计脚本用时 script_end_time = time.time() duration = script_end_time - script_start_time @@ -73,6 +89,7 @@ def run(parameter): "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) diff --git a/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_mirror_bypass_vlan_none.py index 0ace9a6f8..c94425ba1 100644 --- a/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_mirror_bypass_vlan_none.py @@ -120,7 +120,7 @@ def run(parameter): } verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 0}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index cc84d748d..fe45613e2 100644 --- a/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_negate_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SOURCE_IP", @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 0}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_scrip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_scrip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py index 3028851b5..1b5a86cdf 100644 --- a/tests/service_chaining/sc_decrypted_scrip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_scrip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py index b53472168..63d6c6567 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py @@ -157,7 +157,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py index 835595c8c..8a9ec4709 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py @@ -151,7 +151,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py index a8e10d557..ec40b6d1c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py @@ -157,7 +157,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_iprange_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_iprange_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py index c144cb646..065d6e43d 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_iprange_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_iprange_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py @@ -151,7 +151,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_iprange_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_iprange_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py index cad0bf4ae..4aa256003 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_iprange_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_iprange_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py @@ -151,7 +151,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ext_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ext_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py index 86b73e4b0..112836b4c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ext_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ext_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py @@ -157,7 +157,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "example", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_mirror_bypass_vlan_none.py index 4c72da8a6..fed898981 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_mirror_bypass_vlan_none.py @@ -141,7 +141,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "ct.cn", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 03e60531f..fc4324bb6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -141,7 +141,7 @@ def run(parameter): } verification_result = { "excepted_traffic_result": "yumi", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py index 1edc9b27b..bc31505fd 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -138,7 +138,7 @@ def run(parameter): } verification_result = { "excepted_traffic_result": "baidu", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py index 906af1656..0495df7ba 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py @@ -139,7 +139,7 @@ def run(parameter): } verification_result = { "excepted_traffic_result": "baidu", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vlan_none.py index a7f6dd620..560f7e952 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vlan_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py index be673a4f0..a36e9e721 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_none.py index d8cfc04e2..3634328a3 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_activeip_none.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py index 2e3949007..b30357db6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py index 7b20ef388..68adbf02b 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_bfd.py index 89594da82..be6bb313f 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_none.py index 2011f5ccc..09ae999b2 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_block_vxlan_unavailableip_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_disabled_vxlan_activeip_bfd.py index 148f6773d..f7d723604 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_disabled_vxlan_activeip_bfd.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vlan_none.py index 4764ffbfd..18ce5c008 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vlan_none.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py index c47bf20f2..693041fdc 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py index 8b713bbd2..17b43bced 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_bfd.py index 7f9eb6e08..4d98bdf5c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py index 42a786e38..0af385b24 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py index 6f5837061..83b816c3f 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py index eee126f3b..ae0795ea7 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vlan_none.py index 44f308316..9a6a6e945 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vlan_none.py @@ -124,7 +124,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py index b2d9a68d7..43c9f3770 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py index ad2f43e9c..6ed26bcb9 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py index 833f191cc..c6819771d 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py index 5f197f875..80d181675 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py index 5747f9dbe..497f70e5d 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py index df35b14a4..8533daef0 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py index 5e3b152c5..677447dc8 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py index 1451b5140..9bc241f0a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py @@ -125,7 +125,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py index 33b9ef203..1d8809563 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py index 8d6367087..887cb7667 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py index c19942a91..f59cf81da 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py @@ -124,7 +124,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py index fb35053b9..0f34ad382 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py index d97402b36..67194082d 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py index f787548aa..6d6fdcb4a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py index 339529705..a721fea94 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py index cfe5466bc..af17f668a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_none.py index 0b1bee372..1ccab221b 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_activeip_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py index e27ef328c..043da118a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py index f1f1bb0ac..3f112ddd6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py index a5dbbc706..f29893c03 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py index 1b548ec0c..373823d5c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py index 2c004858e..e33f426d4 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py @@ -117,7 +117,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 8dc3dd756..4da9d235e 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -120,7 +120,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py index 28775aa40..b7c7b5038 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py index 53fe31b95..fec58d551 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py index df054cd5a..ca22d4e91 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py index e96fc323b..7b19f31c6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py index 67acba373..b076ea857 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py index 4ebd7279d..ffb1c8fd5 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py index 62d032d17..085fb18f6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_disabled_vxlan_activeip_bfd.py index 27a885178..27e0cb9cd 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_disabled_vxlan_activeip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py index 97465fa59..80305b001 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py index 583f0c219..74696c73b 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py index 394738eb3..268771931 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py index cdf15857f..9843e286e 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py index f4e777f6b..0a3510eee 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py index 6ebb3fa72..8080ad899 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_disabled_vxlan_activeip_bfd.py index efd9a0335..e74d55f9b 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_disabled_vxlan_activeip_bfd.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py index 44f474b3a..59789d9ba 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py @@ -124,7 +124,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py index 56a93abc0..88c73b5de 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py index 8b6c15462..8c61396c2 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py @@ -123,7 +123,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py index 53c546bec..d3819db88 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py @@ -124,7 +124,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py index a3275d47f..60f9ab81c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py @@ -121,7 +121,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py index 4edafb48c..692e19a89 100644 --- a/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py index 7bb7131d9..bb239fa85 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_compliance_risk_library_fqdn_ssl_mirror_block_vlan_none.py @@ -151,7 +151,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_geoip_asn_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_geoip_asn_library_fqdn_ssl_mirror_block_vlan_none.py index 37126af45..b887a41dd 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_geoip_asn_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_geoip_asn_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py index 0d81872ff..9ee9028d6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_geoip_city_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py index cd75bffdd..e6b765465 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_geoip_country_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py index a56c8ca2e..bb5ffb119 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_internet_service_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py index 92267c387..c4a11dc78 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_security_threat_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_int_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_int_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py index cbcc16d9c..00a10e836 100644 --- a/tests/service_chaining/sc_decrypted_srcip_int_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_int_website_classification_library_fqdn_ssl_mirror_block_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py index de0c9f6f0..8394e6746 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -141,7 +141,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 0}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index dcb7caa35..7bdc3c198 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -140,15 +140,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_mirror_bypass_vlan_none.py index 72afdd0c5..83cc67fcb 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_mirror_bypass_vlan_none.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_IMEI", @@ -142,15 +142,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 02b7247d6..465a40d71 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_imei_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -141,15 +141,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_mirror_bypass_vlan_none.py index 90a684408..832f1b47e 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_mirror_bypass_vlan_none.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_IMSI", @@ -142,15 +142,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 0c502ee2e..7eca114c3 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_IMSI", @@ -141,15 +141,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_mirror_bypass_vlan_none.py index c105092a4..595940d70 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -142,15 +142,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index ece183c33..4258ba5e1 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_PHONE_NUMBER", @@ -141,15 +141,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_mirror_bypass_vlan_none.py index 8d929a25a..7ada0dc1c 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_mirror_bypass_vlan_none.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SOURCE_PORT", @@ -112,8 +112,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", - "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py index 34aaf9daa..bc6b8d412 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SOURCE_PORT", @@ -111,8 +111,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", - "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_mirror_bypass_vlan_none.py index 6a4134e5b..62c031a15 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_mirror_bypass_vlan_none.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SUBSCRIBER_ID", @@ -140,15 +140,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test6494"}, - {"query_field_key": "imei", "query_value": "1234567801"}, - {"query_field_key": "imsi", "query_value": "43458960456"}, - {"query_field_key": "apn", "query_value": "www.lyautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678901"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index a753a9136..1943b85d5 100644 --- a/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_negate_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -49,7 +49,7 @@ def run(parameter): ] }, { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SUBSCRIBER_ID", @@ -139,7 +139,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vlan_none.py index b0582f991..d8c0a3022 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vlan_none.py @@ -103,7 +103,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vxlan_activeip_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vxlan_activeip_none.py index 0bfa5c991..a8a3f4157 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_block_vxlan_activeip_none.py @@ -101,7 +101,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_disabled_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_disabled_vlan_none.py index 0e8295506..2b1acea54 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_disabled_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_disabled_vlan_none.py @@ -100,7 +100,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_vlan_none.py index 544276211..0733f95f6 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_bypass_vlan_none.py @@ -102,7 +102,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_global_bypass_diff_device_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_global_bypass_diff_device_vlan_none.py index bdf6c57c3..5ab865a18 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_global_bypass_diff_device_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_global_bypass_diff_device_vlan_none.py @@ -102,7 +102,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_nearby_bypass_diff_device_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_nearby_bypass_diff_device_vlan_none.py index 26e6def49..bab6a270e 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_nearby_bypass_diff_device_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_nearby_bypass_diff_device_vlan_none.py @@ -102,7 +102,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py index 8b0d5d59f..26d6e2907 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py @@ -102,7 +102,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py index c1399fcfd..bbdfac4c5 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py @@ -103,7 +103,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py index fe06b1d3e..b93b43b54 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py index 7173c75c6..aaf4e7941 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py @@ -107,7 +107,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_bypass_vlan_none.py index b9015d02a..650e3f84e 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_mirror_redispatch_bypass_vlan_none.py @@ -107,7 +107,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "百度", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_bypass_vxlan_inactiveip_none.py index d03a958e5..34a1fa33a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_bypass_vxlan_inactiveip_none.py @@ -100,7 +100,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py index 2e3c54be9..ab7d4de46 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py @@ -105,7 +105,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py index 80d9a1127..3850588af 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py @@ -103,7 +103,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py index 04ad441d5..3c6f333de 100644 --- a/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py @@ -105,7 +105,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_mirror_bypass_vlan_none.py index 1956cb88c..fbcd5be9f 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_mirror_bypass_vlan_none.py @@ -140,7 +140,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index e721e489d..9757d56e4 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -139,7 +139,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [{"query_field_key": "sc_rsp_decrypted", "query_value": ""}] } diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_mirror_bypass_vlan_none.py index 75419aaa3..92132af3a 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index dd2990676..24ac5ff95 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_imei_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -172,7 +172,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_mirror_bypass_vlan_none.py index 0f36f8acf..950627538 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_mirror_bypass_vlan_none.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index f5b780e3b..c1b002f92 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_imsi_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_mirror_bypass_vlan_none.py index cc92314a9..a1ada941f 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index d4685ab44..853af4ee8 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_pn_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -171,7 +171,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_mirror_bypass_vlan_none.py index 7a1e52cd5..5e4b2c20d 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 8c3f9281f..8395484a3 100644 --- a/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_decrypted_srcip_subid_pn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "vip.com", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_decrypted", "query_value": ""}, {"query_field_key": "subscriber_id", "query_value": "test6494"}, diff --git a/tests/service_chaining/sc_raw_dstip_dstport_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_dstip_dstport_range_mirror_bypass_vlan_none.py index a37489c14..32be63dfd 100644 --- a/tests/service_chaining/sc_raw_dstip_dstport_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_dstip_dstport_range_mirror_bypass_vlan_none.py @@ -117,7 +117,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_dstip_dstport_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_dstip_dstport_range_steer_bypass_vxlan_activeip_bfd.py index eb9d73e32..131bc07c3 100644 --- a/tests/service_chaining/sc_raw_dstip_dstport_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_dstip_dstport_range_steer_bypass_vxlan_activeip_bfd.py @@ -116,7 +116,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_dstip_external_port_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_dstip_external_port_range_mirror_bypass_vlan_none.py index 9ac7b644b..a90bd98f5 100644 --- a/tests/service_chaining/sc_raw_dstip_external_port_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_dstip_external_port_range_mirror_bypass_vlan_none.py @@ -137,7 +137,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_dstip_external_port_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_dstip_external_port_range_steer_bypass_vxlan_activeip_bfd.py index 2318f2b44..1354a6cd6 100644 --- a/tests/service_chaining/sc_raw_dstip_external_port_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_dstip_external_port_range_steer_bypass_vxlan_activeip_bfd.py @@ -116,7 +116,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_imsi_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_imsi_fqdn_http_url_mirror_bypass_vlan_none.py index 28b232462..3fda6bdc3 100644 --- a/tests/service_chaining/sc_raw_imsi_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_imsi_fqdn_http_url_mirror_bypass_vlan_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 703bc4dc3..70c8a8309 100644 --- a/tests/service_chaining/sc_raw_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_multiple_port_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_multiple_port_steer_bypass_vxlan_activeip_bfd.py index b77f54cbb..bc2e3e84f 100644 --- a/tests/service_chaining/sc_raw_multiple_port_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_multiple_port_steer_bypass_vxlan_activeip_bfd.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py index 806904358..1965e39a7 100644 --- a/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_mirror_bypass_vlan_none.py @@ -128,19 +128,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 if parameter["initiation_method"] == "ui": diff --git a/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 51cfcdf53..ad37a01c8 100644 --- a/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_apn_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_APN", @@ -126,19 +126,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 if parameter["initiation_method"] == "ui": diff --git a/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_mirror_bypass_vlan_none.py index 5e9b80842..844ff62ee 100644 --- a/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_mirror_bypass_vlan_none.py @@ -147,19 +147,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 2e1611aee..58b8d0ff4 100644 --- a/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_imei_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -146,19 +146,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_mirror_bypass_vlan_none.py index 2376b0d1c..c1c872cd6 100644 --- a/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_mirror_bypass_vlan_none.py @@ -148,19 +148,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index bfe370fb5..4156ebaa5 100644 --- a/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_imsi_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_IMSI", @@ -146,19 +146,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_mirror_bypass_vlan_none.py index a0f93658e..67c4bb9ab 100644 --- a/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_mirror_bypass_vlan_none.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_GTP_PHONE_NUMBER", @@ -147,19 +147,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index dc89f95b7..af541e739 100644 --- a/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -146,19 +146,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py index 46bcd72f0..a0692b7c7 100644 --- a/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py @@ -150,14 +150,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 76b017689..1dd99ed84 100644 --- a/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -106,8 +106,8 @@ def run(parameter): "return_data": 1, "name": "steer_bypass_vxlan_activeip_bfd", "type": 1, - "load_balance_method": "hash-innermost-int-ip", - "load_balance_localization": "nearby", + "load_balance_method": "hash-innermost-int-ip", + "load_balance_localization": "nearby", "failure_action": "bypass", "service_func_profiles":[ { @@ -149,14 +149,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_mirror_bypass_vlan_none.py index 25b717a49..e92a6651a 100644 --- a/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_mirror_bypass_vlan_none.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SUBSCRIBER_ID", @@ -145,19 +145,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 3edffd6ad..e6ef01110 100644 --- a/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_negate_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -29,7 +29,7 @@ def run(parameter): "action": "service_chaining", "and_conditions": [ { - "negate_option": False, + "negate_option": True, "or_conditions": [ { "attribute_name": "ATTR_SUBSCRIBER_ID", @@ -144,19 +144,8 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", - "expected_log": [ - {"query_field_key": "sc_rsp_raw", "query_value": ""}, - {"query_field_key": "sent_pkts", "query_value": ""}, - {"query_field_key": "received_pkts", "query_value": ""}, - {"query_field_key": "sent_bytes", "query_value": ""}, - {"query_field_key": "received_bytes", "query_value": ""}, - {"query_field_key": "subscriber_id", "query_value": "test2425"}, - {"query_field_key": "imei", "query_value": "1234567802"}, - {"query_field_key": "imsi", "query_value": "43458960458"}, - {"query_field_key": "apn", "query_value": "www.lyrawautotest.com"}, - {"query_field_key": "phone_number", "query_value": "12345678902"} - ] + "expected_metric": {"hits": 0}, + "expected_log": [] } # 创建 diff --git a/tests/service_chaining/sc_raw_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 642f00d78..949b36d94 100644 --- a/tests/service_chaining/sc_raw_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_pn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_rtp_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_rtp_mirror_bypass_vlan_none.py index 58e69fcec..775bd906a 100644 --- a/tests/service_chaining/sc_raw_rtp_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_rtp_mirror_bypass_vlan_none.py @@ -92,7 +92,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""} ] diff --git a/tests/service_chaining/sc_raw_rtp_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_rtp_steer_bypass_vxlan_activeip_bfd.py index b578b94ac..0a36276ff 100644 --- a/tests/service_chaining/sc_raw_rtp_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_rtp_steer_bypass_vxlan_activeip_bfd.py @@ -91,7 +91,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""} ] diff --git a/tests/service_chaining/sc_raw_scrip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_scrip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py index f7c3c4f74..4ada4da1d 100644 --- a/tests/service_chaining/sc_raw_scrip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_scrip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py @@ -148,7 +148,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_compliance_risk_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_compliance_risk_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index cf7d50bcb..4bb95661d 100644 --- a/tests/service_chaining/sc_raw_src_compliance_risk_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_compliance_risk_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -182,7 +182,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_geoip_asn_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_geoip_asn_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index df59c9480..d3ceb7e74 100644 --- a/tests/service_chaining/sc_raw_src_geoip_asn_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_geoip_asn_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -181,7 +181,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_geoip_city_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_geoip_city_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index e6278ccc1..df60230bb 100644 --- a/tests/service_chaining/sc_raw_src_geoip_city_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_geoip_city_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_geoip_country_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_geoip_country_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 453a74a79..efe50ab82 100644 --- a/tests/service_chaining/sc_raw_src_geoip_country_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_geoip_country_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -180,7 +180,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_internet_service_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_internet_service_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index abc9f633b..3e51d37e9 100644 --- a/tests/service_chaining/sc_raw_src_internet_service_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_internet_service_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -182,7 +182,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 6d13e417e..1617026c2 100644 --- a/tests/service_chaining/sc_raw_src_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_security_threat_library_iprange_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_security_threat_library_iprange_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 980df2d23..c7589e99f 100644 --- a/tests/service_chaining/sc_raw_src_security_threat_library_iprange_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_security_threat_library_iprange_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_src_website_classification_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_src_website_classification_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 89071c0cf..0ace6a631 100644 --- a/tests/service_chaining/sc_raw_src_website_classification_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_src_website_classification_library_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -180,7 +180,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_compliance_risk_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_compliance_risk_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index da1fbf999..0d260e716 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_compliance_risk_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_compliance_risk_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_geoip_asn_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_geoip_asn_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 554a78daf..980a6aa98 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_geoip_asn_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_geoip_asn_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_geoip_city_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_geoip_city_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index d62a607f5..c1e29f208 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_geoip_city_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_geoip_city_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_geoip_country_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_geoip_country_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 19eefccf7..4f84318e4 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_geoip_country_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_geoip_country_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_internet_service_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_internet_service_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 7524de35f..45873e8b3 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_internet_service_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_internet_service_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index a977f27ad..a933100da 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_security_threat_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_security_threat_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index a591f556a..4a5c0aacb 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_security_threat_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_security_threat_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -175,7 +175,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dst_website_classification_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dst_website_classification_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index 3e757469c..46cded137 100644 --- a/tests/service_chaining/sc_raw_srcip_dst_website_classification_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dst_website_classification_library_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_dns_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_dns_mirror_bypass_vlan_none.py index a742ac6fd..d18f264d6 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_dns_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_dns_mirror_bypass_vlan_none.py @@ -132,7 +132,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_mirror_bypass_vlan_none.py index 76f849e76..923cb75cd 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_mirror_bypass_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_steer_bypass_vxlan_activeip_bfd.py index 4082c64c1..1a0f3c8da 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_dns_qname_steer_bypass_vxlan_activeip_bfd.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_dns_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_dns_steer_bypass_vxlan_activeip_bfd.py index 928f6a988..9fe278871 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_dns_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_dns_steer_bypass_vxlan_activeip_bfd.py @@ -131,7 +131,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_category_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_category_library_http_url_steer_bypass_vxlan_activeip_bfd.py index be2cad377..a2ec6d20e 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_category_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_category_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_geoip_city_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_geoip_city_library_http_url_steer_bypass_vxlan_activeip_bfd.py index 80b7a36a8..dd4b71dc5 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_geoip_city_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_geoip_city_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py index ea40beaa8..9fc647703 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_security_threat_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_security_threat_library_http_url_steer_bypass_vxlan_activeip_bfd.py index 8835b0e7b..f5cd38a86 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_security_threat_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_exact_fqdn_security_threat_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_http_url_steer_bypass_vxlan_activeip_bfd.py index d5337cd55..2211b8406 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_quic_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_quic_steer_bypass_vxlan_activeip_bfd.py index 54e2c4310..75e0398b0 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_quic_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_all_ipproto_quic_steer_bypass_vxlan_activeip_bfd.py @@ -160,7 +160,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_mirror_bypass_vlan_none.py index 1a65df32a..4b9bc796a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_mirror_bypass_vlan_none.py @@ -168,7 +168,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index a3706f569..1cd3dacdc 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -167,7 +167,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_mirror_bypass_vlan_none.py index 5b2ab3d18..4cb0cb563 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_mirror_bypass_vlan_none.py @@ -178,7 +178,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_steer_bypass_vxlan_activeip_bfd.py index 43557d3f9..c8351f7c3 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ipprototcp_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py index c61f8f765..945f28831 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -183,7 +183,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_mirror_bypass_vlan_none.py index 17b4dc673..87094524b 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_mirror_bypass_vlan_none.py @@ -167,7 +167,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py index 37b197796..e9db3ec9e 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_extport_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -166,7 +166,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py index df545c7bc..5f48880a6 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_mirror_bypass_vlan_none.py @@ -167,7 +167,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_steer_bypass_vxlan_activeip_bfd.py index df545c7bc..5f48880a6 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_negate_intport_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -167,7 +167,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_mirror_bypass_vlan_none.py index 77f42c2b6..2909b58fa 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_mirror_bypass_vlan_none.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_steer_bypass_vxlan_activeip_bfd.py index 556c365ed..5ca4ef460 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_quic_steer_bypass_vxlan_activeip_bfd.py @@ -148,7 +148,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_mirror_bypass_vlan_none.py index 136c21478..9789e3a22 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_mirror_bypass_vlan_none.py @@ -160,7 +160,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_steer_bypass_vxlan_activeip_bfd.py index 1021af574..639084518 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_false_steer_bypass_vxlan_activeip_bfd.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_mirror_bypass_vlan_none.py index f6224ae06..ef1e78162 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_mirror_bypass_vlan_none.py @@ -160,7 +160,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_steer_bypass_vxlan_activeip_bfd.py index 2f20ee5d5..75821d3fa 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_ech_true_steer_bypass_vxlan_activeip_bfd.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_mirror_bypass_vlan_none.py index e755b694a..c3d4e10d1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_mirror_bypass_vlan_none.py @@ -160,7 +160,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "trex", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_steer_bypass_vxlan_activeip_bfd.py index ca2dfd130..d2cab0b15 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_esni_false_steer_bypass_vxlan_activeip_bfd.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "trex", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py index 2ac4caa96..7f937730d 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_disabled_vxlan_activeip_bfd.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py index d98f99383..9be08ecde 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_bfd.py @@ -145,7 +145,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_none.py index 60ba46f63..f5544e470 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_activeip_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py index aee331f4a..356975934 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py index aae6534c5..577317fb5 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_block_vxlan_inactiveip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py index e1b26c8b8..ad28a8927 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py index a972d42e8..8455a67d3 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py index 8cbd5afc2..6523c879a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_activeip_none.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py index 1a9d6be29..aef17ce1b 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_inactiveip_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py index 144c268f2..b7d2a2ed7 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_bfd.py @@ -141,7 +141,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py index 411e5226e..ed87dea65 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_bypass_vxlan_unavailableip_none.py @@ -143,7 +143,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_global_bypass_diff_device_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_global_bypass_diff_device_vlan_none.py index e0c7d8219..a17405201 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_global_bypass_diff_device_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_global_bypass_diff_device_vlan_none.py @@ -148,7 +148,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_nearby_bypass_diff_device_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_nearby_bypass_diff_device_vlan_none.py index 322988c0b..b44ae5a4a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_nearby_bypass_diff_device_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_nearby_bypass_diff_device_vlan_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py index cf3591ee4..9b402ad75 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_disabled_vxlan_activeip_bfd.py @@ -152,7 +152,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vlan_none.py index 251c7baef..efea4196c 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vlan_none.py @@ -4,6 +4,7 @@ sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath( import time import pytz from datetime import datetime +from support.ui_utils.element_position.map_element_position_library import replace_paras from support.ui_utils.workpath import workdir from support.ui_utils.ui_client import UIClient from support.api_utils.api_client import APIClient @@ -41,7 +42,7 @@ def run(parameter): "items": [ { "op": "add", - "ip": "10.64.224.25", + "ip": "10.64.224.3", "interval": "0-65535" } ] @@ -153,7 +154,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, @@ -267,13 +268,14 @@ if __name__ == '__main__': "api_server": "http://192.168.44.72", "initiation_method": "api", "env": "tsgx", - "vsys_id": 11, + "vsys": 5, "is_log": 1, "root_path": "C:/automation_project/tsg_test", "path": "C:/automation_project/tsg_test/tests/ui", "module_name": "service_chaining", "test_case_name": "" } + parameter = replace_paras(parameter) run(parameter) """ # 在测试文件的当前路径执行如下命令执行测试用例: diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py index 4cb7e2f44..17818b457 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_bfd.py @@ -152,7 +152,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py index 0594f0b8a..f1c020a10 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_activeip_none.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py index 26c455337..dbd8f0f2a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_bfd.py @@ -152,7 +152,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py index ad877a22e..1f38779d5 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_inactiveip_none.py @@ -152,7 +152,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py index 212cb9073..3d5b3304f 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_bfd.py @@ -145,7 +145,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py index c67aaa1fc..09ed5d29b 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_block_vxlan_unavailableip_none.py @@ -152,7 +152,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py index 1dd966703..1086d2258 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_disabled_vxlan_activeip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py index 2a16f4625..35918f2d3 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vlan_none.py @@ -154,7 +154,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py index c44f64d4a..0254ef498 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py index a53e3e79f..ac874d306 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_activeip_none.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py index 4018bec5f..3c1237fda 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py index b4a2c1c2f..eb90d95e1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_inactiveip_none.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py index 75ef6d1c1..d628bc889 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_bfd.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py index 0c6e19f98..f33e650c9 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_mirror_redispatch_bypass_vxlan_unavailableip_none.py @@ -153,7 +153,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_mirror_bypass_vlan_none.py index 5926f7fb8..7ca91f24e 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_mirror_bypass_vlan_none.py @@ -160,7 +160,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_steer_bypass_vxlan_activeip_bfd.py index a20ac7a0f..3f2129095 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_no_sni_false_steer_bypass_vxlan_activeip_bfd.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py index 310b395e3..087c7d278 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_bfd.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_none.py index 854c4bdeb..144e346be 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_activeip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py index 967e28e5f..7b56bb6a7 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_bfd.py @@ -140,7 +140,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py index 5a47eda37..68833670a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_inactiveip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py index da31d5eb5..105e371de 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_bfd.py @@ -139,7 +139,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py index 7b3dea6f4..ca2ad4654 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_block_vxlan_unavailableip_none.py @@ -143,7 +143,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 66c18d036..0c27bba5c 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py index 2eef4327a..513bb9cf1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py index cc2980502..f44aacd3d 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_bfd.py @@ -140,7 +140,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py index fc28bfc8f..59c7b14e1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_inactiveip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py index aa26258f4..d1e1257e2 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_bfd.py @@ -137,7 +137,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py index 45c9c3ba0..507cc244e 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_bypass_vxlan_unavailableip_none.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py index 391da2b54..c8b617320 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py index 853dd755b..a1a60af89 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_activeip_none.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py index a119f5db2..4d97ea328 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_bfd.py @@ -143,7 +143,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py index cc28fd136..ef9db3894 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_inactiveip_none.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py index 61c823c26..0a5498b38 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py index fcda06409..183dea0d8 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_block_vxlan_unavailableip_none.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py index d77910bbf..d0850bb37 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py index c445255da..cf3a3f7eb 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_activeip_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py index ace9c7c14..6fffdfff4 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py index b91280a32..3b4e4762f 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_inactiveip_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py index 1a2ef188e..63ae19965 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_bfd.py @@ -146,7 +146,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py index b3e412d78..bf73c730c 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_fqdn_ssl_steer_redispatch_bypass_vxlan_unavailableip_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_mirror_bypass_vlan_none.py index 4ecbb094f..1344af48b 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_mirror_bypass_vlan_none.py @@ -147,7 +147,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_steer_bypass_vxlan_activeip_bfd.py index 9dc0e9606..f3c7eb3f3 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ftp_account_steer_bypass_vxlan_activeip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ipprototcp_ftp_account_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ipprototcp_ftp_account_steer_bypass_vxlan_activeip_bfd.py index 1ee0d2042..59cf265d5 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ipprototcp_ftp_account_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ipprototcp_ftp_account_steer_bypass_vxlan_activeip_bfd.py @@ -155,7 +155,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ipprotoudp_dns_qname_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ipprotoudp_dns_qname_steer_bypass_vxlan_activeip_bfd.py index e9f03afdc..842b56e2e 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ipprotoudp_dns_qname_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ipprotoudp_dns_qname_steer_bypass_vxlan_activeip_bfd.py @@ -159,7 +159,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_mirror_bypass_vlan_none.py index 59803acb3..11e3376f2 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_mirror_bypass_vlan_none.py @@ -186,7 +186,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_steer_bypass_vxlan_activeip_bfd.py index 44759a7a9..a87e5b22c 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mail_from_to_account_steer_bypass_vxlan_activeip_bfd.py @@ -180,7 +180,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mirror_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_mirror_block_vxlan_activeip_none.py index 1fe1caf1b..8f7a4cb4b 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mirror_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mirror_block_vxlan_activeip_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_disabled_vxlan_activeip_bfd.py index 9a0a173c4..3174b6376 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_disabled_vxlan_activeip_bfd.py @@ -116,7 +116,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_bfd.py index 433be475c..9f64ba0c1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_bfd.py @@ -116,7 +116,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_none.py index 97bc9c3ff..c1b217ec0 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_mirror_bypass_vxlan_activeip_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_multiple_port_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_multiple_port_mirror_bypass_vlan_none.py index 204f72a7f..9967f3282 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_multiple_port_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_multiple_port_mirror_bypass_vlan_none.py @@ -190,7 +190,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_mirror_bypass_vlan_none.py index ef23bc416..e50f6af13 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_mirror_bypass_vlan_none.py @@ -167,7 +167,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_steer_bypass_vxlan_activeip_bfd.py index f6c70f6de..fb7eaaf15 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_negate_dstport_dns_qname_steer_bypass_vxlan_activeip_bfd.py @@ -166,7 +166,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_mirror_bypass_vlan_none.py index d511bb3da..00ae85056 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_mirror_bypass_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index ee82369bd..8b6755c88 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_negate_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_openvpn_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_openvpn_mirror_bypass_vlan_none.py index d0cc72d9d..745d2b739 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_openvpn_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_openvpn_mirror_bypass_vlan_none.py @@ -132,7 +132,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_openvpn_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_openvpn_steer_bypass_vxlan_activeip_bfd.py index cf82f828e..c2a5e2fa8 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_openvpn_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_openvpn_steer_bypass_vxlan_activeip_bfd.py @@ -131,7 +131,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_quic_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_quic_mirror_bypass_vlan_none.py index 02accf0e6..33fb31809 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_quic_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_quic_mirror_bypass_vlan_none.py @@ -131,7 +131,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_quic_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_quic_steer_bypass_vxlan_activeip_bfd.py index 41ec03379..2bb325abb 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_quic_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_quic_steer_bypass_vxlan_activeip_bfd.py @@ -130,7 +130,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_rdp_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_rdp_mirror_bypass_vlan_none.py index 9ee68d66a..fdd0eb4f9 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_rdp_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_rdp_mirror_bypass_vlan_none.py @@ -132,7 +132,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_rdp_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_rdp_steer_bypass_vxlan_activeip_bfd.py index 4e49a48f7..76fb405ed 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_rdp_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_rdp_steer_bypass_vxlan_activeip_bfd.py @@ -131,7 +131,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_mirror_bypass_vlan_none.py index 97946f0a0..886db334a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_mirror_bypass_vlan_none.py @@ -142,7 +142,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_steer_bypass_vxlan_activeip_bfd.py index d7c2c8bdb..96e5420eb 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_esni_true_steer_bypass_vxlan_activeip_bfd.py @@ -141,7 +141,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vlan_none.py index 5a0f47fcf..1a5a1add9 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vlan_none.py @@ -130,7 +130,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_bfd.py index 3280b573c..3455c3ad7 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_bfd.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_none.py index 5f326d327..eea1a8a24 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_activeip_none.py @@ -128,7 +128,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_bfd.py index a3daf21e1..92a589aa6 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_bfd.py @@ -122,7 +122,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_none.py index 23f7186db..78c079aae 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_inactiveip_none.py @@ -129,7 +129,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_bfd.py index 03d2fb5f6..cc7fd93d0 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_none.py index 96aef28d0..aa4093f58 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_block_vxlan_unavailableip_none.py @@ -125,7 +125,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_disabled_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_disabled_vlan_none.py index 8fb1cc925..838e3822a 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_disabled_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_disabled_vlan_none.py @@ -130,7 +130,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_vlan_none.py index 35d4450b9..ce00e0842 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_mirror_bypass_vlan_none.py @@ -132,7 +132,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_mirror_bypass_vlan_none.py index bea8f999d..f250bb816 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_mirror_bypass_vlan_none.py @@ -142,7 +142,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_steer_bypass_vxlan_activeip_bfd.py index e5e0746b5..e636514bf 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_ssl_no_sni_true_steer_bypass_vxlan_activeip_bfd.py @@ -141,7 +141,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_disabled_vxlan_activeip_bfd.py index b1931d8c4..d153c17d5 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_disabled_vxlan_activeip_bfd.py @@ -115,7 +115,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_vxlan_activeip_bfd.py index 2e6a04db7..42820e307 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_steer_bypass_vxlan_activeip_bfd.py @@ -112,7 +112,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_compliance_risk_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_compliance_risk_library_http_url_steer_bypass_vxlan_activeip_bfd.py index 0d2faeacd..c31fe77be 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_compliance_risk_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_compliance_risk_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_geoip_asn_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_geoip_asn_library_http_url_steer_bypass_vxlan_activeip_bfd.py index 0b3144b9f..bdf4fffc1 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_geoip_asn_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_geoip_asn_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -183,7 +183,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_geoip_country_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_geoip_country_library_http_url_steer_bypass_vxlan_activeip_bfd.py index 68255b385..41732d811 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_geoip_country_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_geoip_country_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -177,7 +177,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_service_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_service_library_http_url_steer_bypass_vxlan_activeip_bfd.py index ef572af18..92f71829d 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_service_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_internet_service_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -176,7 +176,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py index f2f77a622..87f688ddd 100644 --- a/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstip_suff_fqdn_library_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -182,7 +182,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstport_external_port_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstport_external_port_steer_bypass_vxlan_activeip_bfd.py index 4b2ac568b..49c3b2692 100644 --- a/tests/service_chaining/sc_raw_srcip_dstport_external_port_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstport_external_port_steer_bypass_vxlan_activeip_bfd.py @@ -135,7 +135,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstport_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstport_mirror_bypass_vlan_none.py index 9da43e349..7f90b275f 100644 --- a/tests/service_chaining/sc_raw_srcip_dstport_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstport_mirror_bypass_vlan_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstport_range_external_port_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_dstport_range_external_port_range_mirror_bypass_vlan_none.py index 06fc31675..460931e47 100644 --- a/tests/service_chaining/sc_raw_srcip_dstport_range_external_port_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_dstport_range_external_port_range_mirror_bypass_vlan_none.py @@ -137,7 +137,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dstport_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_dstport_steer_bypass_vxlan_activeip_bfd.py index fea8c531a..f02df52f4 100644 --- a/tests/service_chaining/sc_raw_srcip_dstport_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dstport_steer_bypass_vxlan_activeip_bfd.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_dtsip_mirror_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_dtsip_mirror_bypass_vxlan_inactiveip_bfd.py index 022edf249..7469ff8aa 100644 --- a/tests/service_chaining/sc_raw_srcip_dtsip_mirror_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_dtsip_mirror_bypass_vxlan_inactiveip_bfd.py @@ -113,7 +113,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_fqdn_ipprototcp_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_fqdn_ipprototcp_ssl_steer_bypass_vxlan_activeip_bfd.py index 9b04a6923..0aa47f42e 100644 --- a/tests/service_chaining/sc_raw_srcip_fqdn_ipprototcp_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_fqdn_ipprototcp_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -137,7 +137,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py index 7196b7774..6e5b4c2f0 100644 --- a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_block_disabled_vxlan_activeip_bfd.py @@ -128,7 +128,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py index ac753b0ac..0263e52ac 100644 --- a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_bypass_disabled_vxlan_activeip_bfd.py @@ -127,7 +127,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py index 5561aca30..fde2a8c8c 100644 --- a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_global_bypass_diff_device_vxlan_activeip_bfd.py @@ -125,7 +125,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py index 69cd0ec60..ccb48bfe4 100644 --- a/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_fqdn_ssl_steer_nearby_bypass_diff_device_vxlan_activeip_bfd.py @@ -124,7 +124,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_internal_port_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_internal_port_range_mirror_bypass_vlan_none.py index 27aced842..855a5c353 100644 --- a/tests/service_chaining/sc_raw_srcip_internal_port_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_internal_port_range_mirror_bypass_vlan_none.py @@ -118,7 +118,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_internal_port_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_internal_port_range_steer_bypass_vxlan_activeip_bfd.py index bbb11978b..5763c79ed 100644 --- a/tests/service_chaining/sc_raw_srcip_internal_port_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_internal_port_range_steer_bypass_vxlan_activeip_bfd.py @@ -117,7 +117,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_bfd.py index ab3b6a08e..8a199d407 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_bfd.py @@ -101,7 +101,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_none.py index 9ca741638..4846f7166 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_inactiveip_none.py @@ -129,7 +129,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_bfd.py index bda3d1819..2afb209af 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_bfd.py @@ -101,7 +101,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_none.py index a9ad32da1..e4497d01c 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_block_vxlan_unavailableip_none.py @@ -101,7 +101,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_mirror_bypass_vxlan_unavailableip_bfd.py index 5fc0002d2..8840cb1f7 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_bypass_vxlan_unavailableip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_mirror_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_mirror_redispatch_block_vxlan_inactiveip_bfd.py index d6d7dd64e..f749f9d94 100644 --- a/tests/service_chaining/sc_raw_srcip_mirror_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_mirror_redispatch_block_vxlan_inactiveip_bfd.py @@ -104,7 +104,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_mirror_bypass_vlan_none.py index 0b2b2157e..7c3fe8e27 100644 --- a/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_mirror_bypass_vlan_none.py @@ -150,7 +150,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py index 56a9e4859..5cd556fd2 100644 --- a/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_negate_dstip_fqdn_ssl_steer_bypass_vxlan_activeip_bfd.py @@ -149,7 +149,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_negate_srcport_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcip_negate_srcport_range_mirror_bypass_vlan_none.py index 2970c5569..149c5f122 100644 --- a/tests/service_chaining/sc_raw_srcip_negate_srcport_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcip_negate_srcport_range_mirror_bypass_vlan_none.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py index 2970c5569..149c5f122 100644 --- a/tests/service_chaining/sc_raw_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_negate_srcport_range_steer_bypass_vxlan_activeip_bfd.py @@ -119,7 +119,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_bfd.py index cf47f6c6e..f93332d14 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_none.py b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_none.py index 3a92b9f72..ecaf71fb8 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_none.py +++ b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_inactiveip_none.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_bfd.py index a83b665a0..f4e9fc752 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_none.py index b1e33a00d..488a328fb 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_steer_block_vxlan_unavailableip_none.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_inactiveip_bfd.py index b84345fc0..2c4caa9bc 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_inactiveip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_bfd.py index 61b637162..c0d680a0e 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_bfd.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_none.py b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_none.py index c6af9d4df..1fa714676 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_none.py +++ b/tests/service_chaining/sc_raw_srcip_steer_bypass_vxlan_unavailableip_none.py @@ -99,7 +99,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_redispatch_block_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_redispatch_block_vxlan_inactiveip_bfd.py index 3383dcdac..d156bbb4b 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_redispatch_block_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_redispatch_block_vxlan_inactiveip_bfd.py @@ -102,7 +102,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcip_steer_redispatch_bypass_vxlan_inactiveip_bfd.py b/tests/service_chaining/sc_raw_srcip_steer_redispatch_bypass_vxlan_inactiveip_bfd.py index c0742c45e..6ad0e5bdb 100644 --- a/tests/service_chaining/sc_raw_srcip_steer_redispatch_bypass_vxlan_inactiveip_bfd.py +++ b/tests/service_chaining/sc_raw_srcip_steer_redispatch_bypass_vxlan_inactiveip_bfd.py @@ -103,7 +103,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcport_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcport_mirror_bypass_vlan_none.py index b7e7c8fd5..7fe8f46c6 100644 --- a/tests/service_chaining/sc_raw_srcport_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcport_mirror_bypass_vlan_none.py @@ -98,7 +98,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcport_range_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_srcport_range_mirror_bypass_vlan_none.py index 4f85e0614..b763d46dc 100644 --- a/tests/service_chaining/sc_raw_srcport_range_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_srcport_range_mirror_bypass_vlan_none.py @@ -98,7 +98,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcport_range_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcport_range_steer_bypass_vxlan_activeip_bfd.py index 887ab007f..9a188cd73 100644 --- a/tests/service_chaining/sc_raw_srcport_range_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcport_range_steer_bypass_vxlan_activeip_bfd.py @@ -105,7 +105,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_srcport_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_srcport_steer_bypass_vxlan_activeip_bfd.py index 5f5843f64..473138348 100644 --- a/tests/service_chaining/sc_raw_srcport_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_srcport_steer_bypass_vxlan_activeip_bfd.py @@ -93,7 +93,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_subid_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_subid_fqdn_http_url_mirror_bypass_vlan_none.py index aa0f592f5..58f0a5819 100644 --- a/tests/service_chaining/sc_raw_subid_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_subid_fqdn_http_url_mirror_bypass_vlan_none.py @@ -145,7 +145,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index d451b5b4f..a34873741 100644 --- a/tests/service_chaining/sc_raw_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_subid_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -144,7 +144,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_mirror_bypass_vlan_none.py b/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_mirror_bypass_vlan_none.py index 65bb629ca..6eef4892a 100644 --- a/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_mirror_bypass_vlan_none.py +++ b/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_mirror_bypass_vlan_none.py @@ -182,7 +182,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py b/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py index daa933df0..0e70ec19b 100644 --- a/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py +++ b/tests/service_chaining/sc_raw_subid_imei_apn_fqdn_http_url_steer_bypass_vxlan_activeip_bfd.py @@ -181,7 +181,7 @@ def run(parameter): verification_result = { "excepted_traffic_result": "", - "expected_metric": "", + "expected_metric": {"hits": 1}, "expected_log": [ {"query_field_key": "sc_rsp_raw", "query_value": ""}, {"query_field_key": "sent_pkts", "query_value": ""}, diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes.py index aafa2f2ee..699346452 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes.py @@ -94,7 +94,7 @@ def run(parameter): "table_type": "" }, "uuid": "", - "name": "RATE(Closed Sessions) Distributed by Time, Application", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes), BITRATE(Incoming Bytes) and BITRATE(Outgoing Bytes) Distributed by Time", "threshold": { "in_bytes": 0, "out_bytes": 0 @@ -103,20 +103,96 @@ def run(parameter): "dimensions": [ { "source_fields": [ - "app" + "__time" ], "function": { - "name": "", + "name": "DATETIME_FLOOR_WITH_FILL", "expression": "", "variables": [ ] }, - "label": "Application", + "label": "Time", "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" }, { "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_2", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + }, + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_3", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "" + } + }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "RATE(Incoming Bytes, Outgoing Bytes), RATE(Incoming Bytes) and RATE(Outgoing Bytes) Distributed by Time", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ "__time" ], "function": { @@ -134,7 +210,8 @@ def run(parameter): "metrics": [ { "source_fields": [ - "closed_sessions_for_this_rule" + "in_bytes", + "out_bytes" ], "function": { "name": "RATE", @@ -145,13 +222,45 @@ def run(parameter): }, "metric_type": "count", "metric_name": "count_1", - "label": "RATE(Closed Sessions)", - "unit": "sps" + "label": "RATE(Incoming Bytes, Outgoing Bytes)", + "unit": "Bps" + }, + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "RATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_2", + "label": "RATE(Incoming Bytes)", + "unit": "Bps" + }, + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "RATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_3", + "label": "RATE(Outgoing Bytes)", + "unit": "Bps" } ], "order_by": "", "source": "statistics_rule", - "series_limit": "5" + "series_limit": "" } }, { @@ -165,7 +274,7 @@ def run(parameter): "table_type": "" }, "uuid": "", - "name": "SUM(Closed Sessions) Distributed by Time, Application", + "name": "SUM(Incoming Bytes, Outgoing Bytes), SUM(Incoming Bytes) and SUM(Outgoing Bytes) Distributed by Time", "threshold": { "in_bytes": 0, "out_bytes": 0 @@ -174,38 +283,57 @@ def run(parameter): "dimensions": [ { "source_fields": [ - "app" + "__time" ], "function": { - "name": "", + "name": "DATETIME_FLOOR_WITH_FILL", "expression": "", "variables": [ ] }, - "label": "Application", + "label": "Time", "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "SUM", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "SUM(Incoming Bytes, Outgoing Bytes)", + "unit": "bytes" }, { "source_fields": [ - "__time" + "in_bytes" ], "function": { - "name": "DATETIME_FLOOR_WITH_FILL", + "name": "SUM", "expression": "", "variables": [ ] }, - "label": "Time", - "is_drill_down": 0 - } - ], - "limit": 65536, - "metrics": [ + "metric_type": "count", + "metric_name": "count_2", + "label": "SUM(Incoming Bytes)", + "unit": "bytes" + }, { "source_fields": [ - "closed_sessions_for_this_rule" + "out_bytes" ], "function": { "name": "SUM", @@ -215,14 +343,14 @@ def run(parameter): ] }, "metric_type": "count", - "metric_name": "count_1", - "label": "SUM(Closed Sessions)", - "unit": "sessions" + "metric_name": "count_3", + "label": "SUM(Outgoing Bytes)", + "unit": "bytes" } ], "order_by": "", "source": "statistics_rule", - "series_limit": "20" + "series_limit": "" } } ] @@ -343,7 +471,7 @@ def run(parameter): api_client.delete_profiles(profiles_tuple) if objects_tuple: api_client.delete_objects(objects_tuple) - # 脚本结束时间和耗时 + # 脚本结束时间和耗时 script_end_time = time.time() duration = script_end_time - script_start_time print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_app.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_app.py index 0dcd72366..ba0c5dc27 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_app.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_app.py @@ -1,200 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": null, + "page_y": null, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Application", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.15", + "id": "", + "display": { + "page_x": null, + "page_y": null, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Application", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": null, + "page_y": null, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Application", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["app"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.15", - "clients_end_ip": "10.64.224.15", - "servers_start_ip": "2.1.1.15", - "servers_end_ip": "2.1.1.15", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8 - {"applicatoin": "2407TCP","bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_appcategory.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_appcategory.py index 991bad1a1..b336b14d4 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_appcategory.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_appcategory.py @@ -1,200 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Application Category", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app_category" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application Category", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.15", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Application Category", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app_category" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application Category", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Application Category", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "app_category" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Application Category", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["app_category"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.15", - "clients_end_ip": "10.64.224.15", - "servers_start_ip": "2.1.1.15", - "servers_end_ip": "2.1.1.15", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8 - {"applicatoin": "2407TCP","bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_link_id.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_link_id.py index f65f4af96..c2fc5aa37 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_link_id.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_link_id.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client-to-Server Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client-to-Server Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client-to-Server Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "c2s_link_id" - ], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "0", - "min_out_size": "0" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.31", - "clients_end_ip": "10.64.224.31", - "servers_start_ip": "2.1.1.31", - "servers_end_ip": "2.1.1.31", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_ttl.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_ttl.py index b1e8b5e90..258747848 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_ttl.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c2s_ttl.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client-to-Server TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.17", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client-to-Server TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client-to-Server TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "c2s_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client-to-Server TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "c2s_ttl" - ], - "order_by": "bytes", - "row_limit": "50", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.17", - "clients_end_ip": "10.64.224.17", - "servers_start_ip": "2.1.1.17", - "servers_end_ip": "2.1.1.17", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8,此处为已经转换后的数据 - {"c2s_ttl": "64", "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_country.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_country.py index b6e7feb29..fb18a151b 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_country.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_country.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "client_country" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip.py index 97ca728f3..28e9f0724 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "client_ip" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip_object.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip_object.py index e9f16e950..a08e7527a 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip_object.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_ip_object.py @@ -1,201 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "statistics_option": "Brief", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.15", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["client_ip_object_list"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.15", - "clients_end_ip": "10.64.224.15", - "servers_start_ip": "2.1.1.15", - "servers_end_ip": "2.1.1.15", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8 - {"applicatoin": "2407TCP","bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_port.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_port.py index 6d47950dd..8dd2c6a33 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_port.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_c_port.py @@ -1,200 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Client Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.15", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Client Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Client Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "client_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Client Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["client_port"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.15", - "clients_end_ip": "10.64.224.15", - "servers_start_ip": "2.1.1.15", - "servers_end_ip": "2.1.1.15", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8 - {"applicatoin": "2407TCP","bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_decoded_as.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_decoded_as.py index 9cf089fe1..325c9aa19 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_decoded_as.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_decoded_as.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Decoded AS", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "decoded_as" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Decoded AS", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Decoded AS", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "decoded_as" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Decoded AS", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Decoded AS", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "decoded_as" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Decoded AS", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "decoded_as" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_device_group.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_device_group.py index 5c3ebfbd5..18b5c3f65 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_device_group.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_device_group.py @@ -1,197 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Device Group", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "device_group" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Device Group", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.20", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Device Group", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "device_group" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Device Group", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Device Group", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "device_group" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Device Group", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["device_group"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.20", - "clients_end_ip": "10.64.224.20", - "servers_start_ip": "2.1.1.20", - "servers_end_ip": "2.1.1.20", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_direction.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_direction.py index cbbc6cc94..a0d35b878 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_direction.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_direction.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Direction", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "direction" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Direction", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Direction", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "direction" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Direction", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Direction", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "direction" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Direction", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "direction" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_domain.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_domain.py index acde4ac67..a73e961f0 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_domain.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_domain.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server Domain", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_domain" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Domain", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server Domain", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_domain" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Domain", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server Domain", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_domain" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Domain", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "server_domain" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_flags.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_flags.py index b56876cd6..def46aaea 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_flags.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_flags.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Flags", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "flags" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Flags", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Flags", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "flags" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Flags", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Flags", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "flags" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Flags", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "flags" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_fqdn.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_fqdn.py index c1b818a6e..1a54f9297 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_fqdn.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_fqdn.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server FQDN", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_fqdn" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server FQDN", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server FQDN", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_fqdn" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server FQDN", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server FQDN", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_fqdn" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server FQDN", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "server_fqdn" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_http_host.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_http_host.py index e8ea19e75..329a0a138 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_http_host.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_http_host.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, HTTP Host", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "http_host" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "HTTP Host", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, HTTP Host", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "http_host" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "HTTP Host", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, HTTP Host", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "http_host" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "HTTP Host", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "http_host" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_link_id.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_link_id.py index 1dcb6258c..8dea08b1a 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_link_id.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_link_id.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server-to-Client Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server-to-Client Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server-to-Client Link ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_link_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client Link ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "s2c_link_id" - ], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "0", - "min_out_size": "0" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.31", - "clients_end_ip": "10.64.224.31", - "servers_start_ip": "2.1.1.31", - "servers_end_ip": "2.1.1.31", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_ttl.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_ttl.py index 994b2c570..105568f81 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_ttl.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s2c_ttl.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server-to-Client TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.17", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server-to-Client TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server-to-Client TTL", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "s2c_ttl" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server-to-Client TTL", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "s2c_ttl" - ], - "order_by": "bytes", - "row_limit": "50", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.17", - "clients_end_ip": "10.64.224.17", - "servers_start_ip": "2.1.1.17", - "servers_end_ip": "2.1.1.17", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8,此处为已经转换后的数据 - {"c2s_ttl": "64", "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_country.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_country.py index d44500529..ba46ad344 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_country.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_country.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server Country", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_country" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Country", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "server_country" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip.py index badb0c024..7e3c11d8d 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "server_ip" - ], - "order_by": "bytes", - "row_limit": "5", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip_object.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip_object.py index b33e15da1..940479ffb 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip_object.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_ip_object.py @@ -1,201 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "statistics_option": "Brief", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.15", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server IP Object List", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_ip_object_list" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server IP Object List", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": ["server_ip_object_list"], - "order_by": "bytes", - "row_limit": "15", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.15", - "clients_end_ip": "10.64.224.15", - "servers_start_ip": "2.1.1.15", - "servers_end_ip": "2.1.1.15", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [#如果Bytes Aggregate为:BITRATE则Bytes*8 - {"applicatoin": "2407TCP","bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_port.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_port.py index e654c0e49..6214b0383 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_port.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_s_port.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Server Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.19", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Server Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Server Port", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "server_port" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Server Port", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "server_port" - ], - "order_by": "bytes", - "row_limit": "5", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.19", - "clients_end_ip": "10.64.224.19", - "servers_start_ip": "2.1.1.19", - "servers_end_ip": "2.1.1.19", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"server_port": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sled_ip.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sled_ip.py index a3d2bc654..cac6359d6 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sled_ip.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sled_ip.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Sled IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "sled_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Sled IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Sled IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "sled_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Sled IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Sled IP", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "sled_ip" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Sled IP", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "sled_ip" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sub_id.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sub_id.py index 2fa6d235b..c9332e383 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sub_id.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_bytes_dim_sub_id.py @@ -1,202 +1,448 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes, Outgoing Bytes) Distributed by Time, Subscriber ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "subscriber_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Subscriber ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes", + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes, Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "20" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.3", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Incoming Bytes) Distributed by Time, Subscriber ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "subscriber_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Subscriber ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Incoming Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "15" + } }, + { + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "BITRATE(Outgoing Bytes) Distributed by Time, Subscriber ID", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "subscriber_id" + ], + "function": { + "name": "", + "expression": "", + "variables": [ + + ] + }, + "label": "Subscriber ID", + "is_drill_down": 0 + }, + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "out_bytes" + ], + "function": { + "name": "BITRATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "BITRATE(Outgoing Bytes)", + "unit": "bps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "10" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_bytes+out_bytes:BITRATE:bytes" - ], - "dimensions": [ - "subscriber_id" - ], - "order_by": "bytes", - "row_limit": "100", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.3", - "clients_end_ip": "10.64.224.3", - "servers_start_ip": "2.1.1.3", - "servers_end_ip": "2.1.1.3", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ # BITRATE=bytes*8 - {"s2c_link_id": 720, "bytes": 754864} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + if rules_tuple: + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ diff --git a/tests/statistics/stats_srcip_dstip_http_line_in_out_pkts.py b/tests/statistics/stats_srcip_dstip_http_line_in_out_pkts.py index bbe10bdc2..4f787b675 100644 --- a/tests/statistics/stats_srcip_dstip_http_line_in_out_pkts.py +++ b/tests/statistics/stats_srcip_dstip_http_line_in_out_pkts.py @@ -1,216 +1,414 @@ # -*- coding: UTF-8 -*- -import time import os import sys +import time +import pytz +from support.organize_config import OrganizeConfig from support.ui_utils.element_position.map_element_position_library import replace_paras - -sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))))) -import traceback -from datetime import datetime -from support.common_utils.create_policy import CreatePolicy +sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) +from support.ui_utils.ui_client import UIClient +from support.api_utils.api_client import APIClient +from support.packet_generator.traffic_generator import * from support.report_update import ReportUpdate def run(parameter): try: print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Begin to run test case: " + parameter["test_case_name"], flush=True) + # 参数初始化 - exception_result = "" - result = {} + result, exception_result = "", "" + test_summary = {} # 脚本启动时间 script_start_time = time.time() - # 测试数据 - test_data = { - "is_multi_priority": False, - "rule_num": 1, - "policy_type": "statistics", - "rule_name": parameter["test_case_name"], - "rule_action": "statistics", - "rule_type": "create", - "debug_flag": "local", - "test_subcriber_id": "test6489", - "script_type": "ui", - "condition": { - "source_ip": [ - { - "name": parameter["test_case_name"].replace("_dstip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ + policy_configuration = { + "name": parameter["test_case_name"], + "type": "statistics", + "action": "statistics", + "and_conditions": [ + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_dstip", "", 1), + "attribute_name": "ATTR_SOURCE_IP", + "type": "ip", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "10.64.224.31", + "interval": "1-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "name": parameter["test_case_name"].replace("_srcip", "", 1), + "attribute_name": "ATTR_DESTINATION_IP", + "type": "ip", + "sub_type": "ip", + "statistics_option": "none", + "member_type": "item", + "items": [ + { + "op": "add", + "ip": "2.1.1.9", + "interval": "0-65535" + } + ] + } + ] + }, + { + "negate_option": False, + "or_conditions": [ + { + "attribute_name": "ATTR_APP_ID", + "type": "application", + "items": ["http"] + } + ] + }, + ], + "action_parameter": { + "template_profile":{ + "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), + "uuid": "", + "dataview": { + "charts": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "10.64.224.31", + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "RATE(Incoming Packets, Outgoing Packets), RATE(Incoming Packets) and RATE(Outgoing Packets) Distributed by Time", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_pkts", + "out_pkts" + ], + "function": { + "name": "RATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "RATE(Incoming Packets, Outgoing Packets)", + "unit": "pps" + }, + { + "source_fields": [ + "in_pkts" + ], + "function": { + "name": "RATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_2", + "label": "RATE(Incoming Packets)", + "unit": "pps" + }, + { + "source_fields": [ + "out_pkts" + ], + "function": { + "name": "RATE", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_3", + "label": "RATE(Outgoing Packets)", + "unit": "pps" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "" + } }, - ] - } - ], - "source_port": [], - "destination_ip": [ - { - "name": parameter["test_case_name"].replace("_srcip", "", 1), - "object_type": "ip", - "select_type": False, - "negate": False, - "item": [ { - "item_operation": "add", - "item_type": "ipv4", - "item_value": "2.1.1.21", - }, + "id": "", + "display": { + "page_x": None, + "page_y": None, + "height": "", + "width": "", + "type": "line", + "table_type": "" + }, + "uuid": "", + "name": "SUM(Incoming Packets, Outgoing Packets), SUM(Incoming Packets) and SUM(Outgoing Packets) Distributed by Time", + "threshold": { + "in_bytes": 0, + "out_bytes": 0 + }, + "query": { + "dimensions": [ + { + "source_fields": [ + "__time" + ], + "function": { + "name": "DATETIME_FLOOR_WITH_FILL", + "expression": "", + "variables": [ + + ] + }, + "label": "Time", + "is_drill_down": 0 + } + ], + "limit": 65536, + "metrics": [ + { + "source_fields": [ + "in_pkts", + "out_pkts" + ], + "function": { + "name": "SUM", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_1", + "label": "SUM(Incoming Packets, Outgoing Packets)", + "unit": "packets" + }, + { + "source_fields": [ + "in_pkts" + ], + "function": { + "name": "SUM", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_2", + "label": "SUM(Incoming Packets)", + "unit": "packets" + }, + { + "source_fields": [ + "out_pkts" + ], + "function": { + "name": "SUM", + "expression": "", + "variables": [ + + ] + }, + "metric_type": "count", + "metric_name": "count_3", + "label": "SUM(Outgoing Packets)", + "unit": "packets" + } + ], + "order_by": "", + "source": "statistics_rule", + "series_limit": "" + } + } ] - }], - "destination_port": [], - "internal_ip": [], - "internal_port": [], - "external_ip": [], - "external_port": [], - "source_geography": [], - "destination_geography": [], - "sub_id": [], - "device": [], - "tunnel": [], - "tunnel_level": [], - "flag": [], - "application": [ - { - "name": "http", # - "object_type": "application", - "negate": False - } - ], - "server_fqdn": [ - ], - "protocol_filed": [], - "sub_action_override": True, - "sub_action": [ - ], - "packet_capture": [] - }, - "action_parameter": { - "statistics_template": [{ - "name": parameter["test_case_name"].replace("_srcip_dstip", "", 1), - "profile_type": "statistics_template", - "charts": [ - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_pkts:RATE:in pkts", - "out_pkts:RATE:out pkts", - "in_pkts+out_pkts:RATE:pkts" - ], - "dimensions": [], - "order_by": "", - "row_limit": "", - "min_in_size": "1", - "min_out_size": "1" - }, - { - "chart_name": "default name", - "visualization_type": "Line", - "metrics": [ - "in_pkts:SUM:in pkts", - "out_pkts:SUM:out pkts", - "in_pkts+out_pkts:SUM:pkts" - ], - "dimensions": [], - "order_by": "", - "row_limit": "", - "min_in_size": "1", - "min_out_size": "1" - } - ] - }] - }, - "expected_return": "reset", - "counters": {"hits": 1}, - "log_query_param": [{"query_field_key": "server_fqdn", "query_value": "www.yumi.com"}], - "traffic": { - "protocol": "", - "type": "trex", - "clients_start_ip": "10.64.224.21", - "clients_end_ip": "10.64.224.21", - "servers_start_ip": "2.1.1.21", - "servers_end_ip": "2.1.1.21", - "m": 1, - "d": 1, - "yaml_name": "test", - "pcap_name": "http_87pkts" + }, + "vsys": 1 + } }, - "statists_metric_results": [ - {"time": "2024-07-25T07:22:07Z", "out_pkts": 64, "pkts": 83, "in_pkts": 19} - ], - # "traffic": { - # "type": "trex", - # "clients_start_ip": "192.168.64.86", - # "clients_end_ip": "192.168.64.86", - # "servers_start_ip": "2.1.1.1", - # "servers_end_ip": "2.1.1.2", - # "m": 1, - # "d": 1, - # "yaml_name": "test", - # "pcap_name": "test_https" - # }, - # "traffic": { - # "type": "nslookup", - # "command": "nslookup www.facebook.com" - # }, - # "traffic": { - # "type": "wget", - # "command": "wget -q -O- http://open.node.com:180" - # }, - "token": "" + "is_enabled": 1, + "log_option": "metadata" } - # 测试用例实例化 - create = CreatePolicy(test_data, parameter) - result = create.create_policy() - # 脚本结束时间和耗时 - script_end_time = time.time() - duration = script_end_time - script_start_time - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], - "Finish test case: " + parameter["test_case_name"], flush=True) - return result + traffic_generation = { + "tool": "trex", # or trex/http + "clients_start_ip": "10.64.224.9", + "clients_end_ip": "10.64.224.9", + "servers_start_ip": "2.1.1.9", + "servers_end_ip": "2.1.1.9", + "m": 1, + "d": 1, + "yaml_name": "test", + "pcap_name": "http_87pkts" + } + + verification_result = { + "excepted_traffic_result": {"total_bytes": 94679, "total_bytes_received": 93284, "total_bytes_sent": 1395, "total_packets": 87, "total_packets_received": 65, "total_packets_sent": 22, "total_syn_pkt": 1}, + "expected_query": {"hits": 1}, + "expected_log": [ + {"query_field_key": "decoded_as", "query_value": "HTTP"}, + {"query_field_key": "server_fqdn", "query_value": "www.yumi.com"} + ] + } + # 创建 + if parameter["initiation_method"] == "ui": + ui_client = UIClient() + rules_tuple, ui_error = ui_client.create_rules(policy_configuration) + if len(ui_error) > 0: + return ui_error + elif parameter["initiation_method"] == "api": + api_client = APIClient(parameter) + organize_config = OrganizeConfig(parameter, policy_configuration, api_client.token,()) + organize_config.generate_random_ip(parameter, policy_configuration, traffic_generation) + + # {uuid, type}, i.e., {"12341-232-a21", "ip"} + objects_tuple, api_error = api_client.create_objects(policy_configuration) + if len(api_error) > 0: + return api_error + # 处理Profiles + profiles_tuple, api_error = api_client.create_profiles(policy_configuration) + if len(api_error) > 0: + return api_error + rules_tuple, api_error = api_client.create_rules(policy_configuration, objects_tuple, "", profiles_tuple) + if len(api_error) > 0: + return api_error + # 等待下发配置生效 + time.sleep(3) + + # 类实例化 + generator = TrafficGenerator() + + # 获取当前时间 + utc_tz = pytz.timezone('UTC') + current_utc_time = datetime.now(utc_tz) + start_time = current_utc_time.strftime('%Y-%m-%dT%H:%M:%SZ') + + # 触发流量 + traffic_result = generator.run(policy_configuration, traffic_generation) + + # 验证流量生成器的返回值是否符合策略执行的预期 + excepted_traffic_result, error = generator.result(verification_result, traffic_result) + if excepted_traffic_result == False: + return error + + # 验证tsg的日志是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + log_result = ui_client.query_rule_log(verification_result, rules_tuple, traffic_result) + elif parameter["initiation_method"] == "api": + log_result = api_client.query_rule_log(traffic_generation, verification_result, rules_tuple, start_time, traffic_result) + if log_result == True: + test_summary["log"] = "Pass." + elif log_result == False: + test_summary["log"] = "The failure reason: the returned log does not match the expected result." + elif log_result == None: + test_summary["log"] = "The failure reason: the returned log is empty." + elif len(log_result) > 0: + test_summary["log"] = log_result + + # 验证tsg的metric是否符合策略执行的预期 + if parameter["initiation_method"] == "ui": + metric_result = ui_client.query_rule_metric(verification_result, traffic_result) + elif parameter["initiation_method"] == "api": + metric_result = api_client.query_rule_metric(verification_result, rules_tuple, start_time, traffic_result) + if metric_result == True: + test_summary["metric"] = "Pass." + elif metric_result == False: + test_summary["metric"] = "The failure reason: the returned metric does not match the expected result." + elif metric_result == None: + test_summary["metric"] = "The failure reason: the returned metric is empty." + elif len(metric_result) > 0: + test_summary["metric"] = metric_result + #if rules_tuple: + # print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "DEBUG:Case:{},rule:{},log_result:{},excepted_traffic_result:{},metric_result:{}".format(os.path.basename(__file__)[:-3], list(rules_tuple)[0]["uuid"], log_result, excepted_traffic_result, metric_result), flush=True) + return test_summary except Exception as e: exception_result = str(e) - print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Error: ", e, - flush=True) - traceback.print_exc() - return "Error: " + str(e) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], + "When running test case, the exception error: ", str(e), flush=True) + return "When running test case, the exception error: " + str(e) finally: - # 清理环境 - if isinstance(create, CreatePolicy): - create.clean_up() + # 删除 + if parameter["initiation_method"] == "ui": + if rules_tuple: + ui_client.delete_rules(parameter, policy_configuration) + elif parameter["initiation_method"] == "api": + if rules_tuple: + api_client.delete_rules(rules_tuple) + if profiles_tuple: + api_client.delete_profiles(profiles_tuple) + if objects_tuple: + api_client.delete_objects(objects_tuple) + # 脚本结束时间和耗时 + script_end_time = time.time() + duration = script_end_time - script_start_time + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Duration of running the test case: ", "{:.3f}".format(duration), flush=True) + print(datetime.now().strftime("%Y-%m-%d %H:%M:%S"), str(datetime.now().microsecond)[:3], "Finish test case: " + parameter["test_case_name"], flush=True) + # 生成csv报告 update = ReportUpdate() update.write_result(parameter, result, exception_result) if __name__ == '__main__': parameter = { - "username": "zhaokun", "password": "zhaokun1", "test_pc_ip": "192.168.64.73", "api_server": "http://192.168.44.72", - "is_log": 1, + "is_log": 0, "env": "tsgx", - "vsys_id": 1, # 6 + "vsys": 1, # 6 "root_path": "D:/tsgcode/tsg_test", "path": "tsgcode/tsg_test/testcase/ui", "module_name": "statistics", "test_case_name": os.path.basename(__file__)[:-3], "debug_flag": "local", "test_subcriber_id": "test6489", - "script_type": "ui", + "initiation_method": "api", "policy_type": "statistics" - } + } parameter = replace_paras(parameter) run(parameter) """ |
