def setup_class(self): # print('test start') self.session = Init.BS_SESSION self.base_info = Init.BASE_INFO self.console_host = self.base_info['bsHost'] self.workspace_id = self.base_info['ctyunAcctId'] self.head_json = self.base_info['headers_json'] self.today = CreateLogData().day_time self.now = CreateLogData().now_time self.head_form = self.base_info['headers_form']
def setup_class(self): # print('test start') self.session = Init.CTYUN_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['ctyunHost'] self.workspaceId = self.base_info['ctyun_workspaceid'] self.log = CreateLogData() self.get_domain_list = self.log.get_ctyun_domain_list(self.console_host, self.workspaceId) # 接口 self.fbrData_url = self.console_host + self.log_info['fbrData'] self.ispList_url = self.console_host + self.log_info['ispList'] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_data = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_001 = {"data": {"workspaceId": self.workspaceId, "productType": ['001'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_003 = {"data": {"workspaceId": self.workspaceId, "productType": ['003'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_004 = {"data": {"workspaceId": self.workspaceId, "productType": ['004'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_005 = {"data": {"workspaceId": self.workspaceId, "productType": ['005'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "startTime": self.day_time, "endTime": self.now_time}} self.single_domain = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": [random.choice(self.get_domain_list)], "startTime": self.day_time, "endTime": self.now_time}} self.date_data_yesterday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time}} self.date_data_sevenday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.sevenday_time, "endTime": self.now_time}} self.date_data_month = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.month_time, "endTime": self.now_time}}
def test_CDN_240872(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' # 只能刷新已启用的域名 used_domain_list = CreateLogData().get_used_domain_list() directory_list = ['/images/', '/text/', '/pdf/'] valuse_list = [] for temp in used_domain_list: valuse_list.append(temp + directory_list[0]) valuse_list.append(temp + directory_list[1]) valuse_list.append(temp + directory_list[2]) payload = { "data": { "workspaceId": self.workspace_id, "values": valuse_list, "domain": "", "task_type": "2" } } print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200
def __init__(self, session, host, workspaceid): self.domain_info = Init.DOMAIN_INFO self.base_info = Init.BASE_INFO self.session = session self.host = host self.workspaceId = workspaceid self.log = CreateLogData()
def setup_class(self): now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) day_time = int(time.mktime(datetime.now().date().timetuple())) now_time = get_unix_time(now) # print('test start') self.session = Init.CONSOLE_SESSION self.base_info = Init.BASE_INFO self.console_host = self.base_info['host'] self.workspace_id = self.base_info['workspaceid'] self.head_json = self.base_info['headers_json'] self.today = day_time self.now = now_time self.head_form = self.base_info['headers_form'] # 提取工作区对应的域名列表 self.log = CreateLogData() self.get_domain_list = self.log.get_available_domain_list()
def setup_class(self): print('test start') self.v1_info = Init.V1_INFO self.base_info = Init.V1_BASE_INFO self.host = self.base_info["host"] self.ctyunacctid = self.base_info["ctyunAcctId"] self.domain = self.base_info["domain"] self.log = CreateLogData() self.seven = self.log.sevenday_time self.month = self.log.month_time self.today = self.log.month_time self.now = self.log.now_time
def setup_class(self): now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # today = time.strftime("%Y-%m-%d", time.localtime()) # sevenday = (date.today() + timedelta(days=-6)).strftime("%Y-%m-%d %H:%M:%S") # month = (date.today() + timedelta(days=-29)).strftime("%Y-%m-%d %H:%M:%S") now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) day_time = int(time.mktime(datetime.now().date().timetuple())) now_time = get_unix_time(now) # print('test start') self.session = Init.BS_SESSION self.base_info = Init.BASE_INFO self.console_host = self.base_info['bsHost'] self.workspace_id = self.base_info['ctyunAcctId'] self.head_json = self.base_info['headers_json'] self.today = day_time self.now = now_time self.head_form = self.base_info['headers_form'] # 提取工作区对应的域名列表 self.log = CreateLogData() self.get_domain_list = self.log.get_bs_used_domain_list(self.console_host,self.workspace_id) self.get_fan_domain=self.log.get_bs_all_domain(self.console_host,self.workspace_id)
def setup_class(self): print('test start') self.base_info = Init.BASE_INFO self.domain_info = Init.DOMAIN_INFO self.createDomain = CreateDomain() self.assert_common = Assert() self.session = Init.CONSOLE_SESSION self.bs_session = Init.BS_SESSION console_host = self.base_info['host'] workspace_id = self.base_info['workspaceid'] self.verifyDomain_url = console_host + self.domain_info['verifyDomain'] self.check_domain_url = console_host + self.domain_info['detailDomain'] self.domain_list = CreateLogData().get_domain_list()
class Test_BS_Log_dataList(): def setup_class(self): # print('test start') self.session = Init.BS_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['bsHost'] self.workspaceId = self.base_info['ctyunAcctId'] self.log = CreateLogData() self.get_domain_list = self.log.get_bs_domain_list(self.workspaceId) # 接口 self.fbrData_url = self.console_host + self.log_info['fbrData'] self.ispList_url = self.console_host + self.log_info['ispList'] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_data = { "data": { "workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time } } self.cp_data_001 = { "data": { "workspaceId": self.workspaceId, "productType": ['001'], "isp": [], "province": [], "domain": self.log.get_bs_cp_domain(self.console_host, self.workspaceId, '001'), "startTime": self.day_time, "endTime": self.now_time } } self.cp_data_003 = { "data": { "workspaceId": self.workspaceId, "productType": ['003'], "isp": [], "province": [], "domain": self.log.get_bs_cp_domain(self.console_host, self.workspaceId, '003'), "startTime": self.day_time, "endTime": self.now_time } } self.cp_data_004 = { "data": { "workspaceId": self.workspaceId, "productType": ['004'], "isp": [], "province": [], "domain": self.log.get_bs_cp_domain(self.console_host, self.workspaceId, '004'), "startTime": self.day_time, "endTime": self.now_time } } self.cp_data_005 = { "data": { "workspaceId": self.workspaceId, "productType": ['005'], "isp": [], "province": [], "domain": self.log.get_bs_cp_domain(self.console_host, self.workspaceId, '005'), "startTime": self.day_time, "endTime": self.now_time } } self.single_domain = { "data": { "workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": [random.choice(self.get_domain_list)], "startTime": self.day_time, "endTime": self.now_time } } self.date_data_yesterday = { "data": { "workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time } } self.date_data_sevenday = { "data": { "workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.sevenday_time, "endTime": self.now_time } } self.date_data_month = { "data": { "workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.month_time, "endTime": self.now_time } } def teardown_class(self): # 做清数据,退出登录等 self.session.close() print('-------------------test end-------------------') @allure.story(' 单个域名查询用户省份分析数据') def test_CDN_243660(self): url = self.fbrData_url payload = self.single_domain response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 单个域名查询用户运营商分析数据') def test_CDN_243661(self): url = self.ispList_url payload = self.single_domain response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 视频直播产品查询 用户省份分析数据') def test_CDN_243662(self): url = self.fbrData_url payload = self.cp_data_004 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 视频直播产品查询 用户运营商分析数据') def test_CDN_243663(self): url = self.ispList_url payload = self.cp_data_004 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 视频点播产品查询 用户省份分析数据') def test_CDN_243664(self): url = self.fbrData_url payload = self.cp_data_005 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 视频点播产品查询 用户运营商分析数据') def test_CDN_243665(self): url = self.ispList_url payload = self.cp_data_005 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 下载加速产品查询 用户省份分析数据') def test_CDN_243666(self): url = self.fbrData_url payload = self.cp_data_003 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 下载加速产品查询 用户运营商分析数据') def test_CDN_243667(self): url = self.ispList_url payload = self.cp_data_003 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 静态加速产品查询 用户省份分析数据') def test_CDN_243668(self): url = self.fbrData_url payload = self.cp_data_001 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 静态加速产品查询 用户运营商分析数据') def test_CDN_243669(self): url = self.ispList_url payload = self.cp_data_001 response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 默认查询 用户省份分析数据') def test_CDN_243670(self): url = self.fbrData_url payload = self.default_data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' 默认查询 用户运营商分析数据') def test_CDN_243671(self): url = self.ispList_url payload = self.default_data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3
class Test_Vip_Refresh(): def setup_class(self): now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) day_time = int(time.mktime(datetime.now().date().timetuple())) now_time = get_unix_time(now) # print('test start') self.session = Init.CONSOLE_SESSION self.base_info = Init.BASE_INFO self.console_host = self.base_info['host'] self.workspace_id = self.base_info['workspaceid'] self.head_json = self.base_info['headers_json'] self.today = day_time self.now = now_time self.head_form = self.base_info['headers_form'] # 提取工作区对应的域名列表 self.log = CreateLogData() self.get_domain_list = self.log.get_available_domain_list() def teardown_class(self): # 做清数据,退出登录等 self.session.close() print('-------------------test end-------------------') @allure.story('refresh/ListRefreshTask 接口1') def test_CDN_240863(self): temp = self.console_host + '/cdn/gw/refresh/ListRefreshTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&task_type=1&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert 'create_time' in response.text assert 'total' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('refresh/ListRefreshTask 接口2') def test_CDN_240864(self): temp = self.console_host + '/cdn/gw/refresh/ListRefreshTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&task_type=2&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'create_time' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('preload/ListPreloadTaskk 接口') def test_CDN_240865(self): temp = self.console_host + '/cdn/gw/preload/ListPreloadTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert 'total' in response.text assert response.elapsed.total_seconds() < 3 # @pytest.mark.skip(reason="调试") # 跳过该测试 # @pytest.mark.repeat(50) @allure.story('CreateRefreshTask 接口') def test_CDN_240866(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = "http://" + random.choice(self.get_domain_list) # domain='http://zzzzz.baidu.com' # 可能随机到泛域名,泛域名是无法刷新的,可以替换成任意字母即可 if '*' in domain: domain = str(domain).replace('*', 'abc') payload = { "data": { "workspaceId": self.workspace_id, "values": [domain], "domain": "", "task_type": "1" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 接口2') def test_CDN_240867(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = "http://" + random.choice(self.get_domain_list) domain_https = "https://" + random.choice(self.get_domain_list) value = [] # 可能随机到泛域名,泛域名是无法刷新的,可以替换成任意字母即可 if '*' in domain: domain = str(domain).replace('*', 'abc') if '*' in domain_https: domain_https = str(domain_https).replace('*', 'abc') value.append(domain_https) value.append(domain) payload = { "data": { "workspaceId": self.workspace_id, "values": value, "domain": "", "task_type": "1" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 接口2') def test_CDN_240868(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' # 只能刷新已启用的域名 used_domain_list = self.get_domain_list value = [] headers = ["http://", "https://"] for item in used_domain_list: if '*' not in item: value.append(random.choice(headers) + item) payload = { "data": { "workspaceId": self.workspace_id, "values": value, "domain": "", "task_type": "1" } } print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text # assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷泛域名') def test_CDN_241649(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": { "workspaceId": self.workspace_id, "values": ['http://*.baidu.com'], "domain": "", "task_type": "1" } } print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 # assert 'core.ok' in response.text assert '请求参数错误' in response.text # assert 'value_error.url.scheme' in response.text @allure.story('CreateRefreshTask 刷泛域名目录') def test_CDN_241650(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": { "workspaceId": self.workspace_id, "values": ["http://*.baidu.com/images/"], "domain": "", "task_type": "2" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert '请求参数错误' in response.text assert 'value_error' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷没有操作权限的URL') def test_CDN_240869(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": { "workspaceId": self.workspace_id, "values": ["http://www.hehehe.com"], "domain": "", "task_type": "1" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' not in response.text assert '填写内容有误,请核对添加的域名' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷目录') def test_CDN_240870(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = "http://" + random.choice(self.get_domain_list) if '*' in domain: domain = str(domain).replace('*', 'abc') payload = { "data": { "workspaceId": self.workspace_id, "values": [domain + "/images/"], "domain": "", "task_type": "2" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷多个目录') def test_CDN_240871(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = "http://" + random.choice(self.get_domain_list) + "/images/" domain_https = "https://" + random.choice( self.get_domain_list) + "/gal.text/" value = [] if '*' in domain: domain = str(domain).replace('*', 'abc') if '*' in domain_https: domain_https = str(domain_https).replace('*', 'abc') value.append(domain_https) value.append(domain) payload = { "data": { "workspaceId": self.workspace_id, "values": value, "domain": "", "task_type": "2" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask,刷新大量目录 ') def test_CDN_240872(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' # 只能刷新已启用的域名 used_domain_list = CreateLogData().get_used_domain_list() directory_list = ['/images/', '/text/', '/pdf/'] valuse_list = [] for temp in used_domain_list: valuse_list.append(temp + directory_list[0]) valuse_list.append(temp + directory_list[1]) valuse_list.append(temp + directory_list[2]) payload = { "data": { "workspaceId": self.workspace_id, "values": valuse_list, "domain": "", "task_type": "2" } } print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 # assert '请求参数错误' in response.text # assert '100006' in response.text # 由于刷新的目录太多,所有肯定超过3秒,这条不验证 # assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷没有操作权限的目录') def test_CDN_240873(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": { "workspaceId": self.workspace_id, "values": ["http://www.hehehe.com/text/"], "domain": "", "task_type": "2" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' not in response.text assert '填写内容有误,请核对添加的域名' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('domain/CheckPrivilege 刷不存在的URL') def test_CDN_241653(self): url = self.console_host + '/cdn/gw/domain/CheckPrivilege' payload = { "data": { "workspaceId": self.workspace_id, "values": ["http://www.baidu55555.com"], "do": "c_refresh" } } # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert '"list":[{"enable":"false","on":"www.baidu55555.com"}]' in str( response.text) # assert '填写内容有误,请核对添加的域名' in response.text assert response.elapsed.total_seconds() < 3
def setup_class(self): # print('test start') self.session = Init.CTYUN_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['ctyunHost'] self.workspaceId = self.base_info['ctyun_workspaceid'] self.log = CreateLogData() self.get_domain_list = self.log.get_ctyun_domain_list( self.console_host, self.workspaceId) # 接口 self.uri_url = self.console_host + self.log_info['ListTopUri'] self.referer_url = self.console_host + self.log_info['ListTopReferer'] self.domain_url = self.console_host + self.log_info['ListTopDomain'] self.ip_url = self.console_host + self.log_info['ListTopIp'] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.before_yesterday = self.log.before_yesterday self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_uri_hit_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.default_uri_miss_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.default_referer_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "flow" } } self.default_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.default_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.uri_hit_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "httpCode": [], "productCode": ["001"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "httpCode": [], "productCode": ["001"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "productCode": ["001"], "sortedBy": "flow" } } self.domain_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "productCode": ["001"], "sortedBy": "flow" } } self.ip_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "provinceCode": ["001"], "sortedBy": "flow" } } self.uri_hit_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["003"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["003"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "productCode": ["003"], "sortedBy": "flow" } } self.domain_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "productCode": ["003"], "sortedBy": "flow" } } self.ip_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "provinceCode": ["003"], "sortedBy": "flow" } } self.uri_hit_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["004"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "httpCode": [], "productCode": ["004"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "productCode": ["004"], "sortedBy": "flow" } } self.domain_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "productCode": ["004"], "sortedBy": "flow" } } self.ip_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "provinceCode": ["004"], "sortedBy": "flow" } } self.uri_hit_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "httpCode": [], "productCode": ["005"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "httpCode": [], "productCode": ["005"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "productCode": ["005"], "sortedBy": "flow" } } self.domain_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "productCode": ["005"], "sortedBy": "flow" } } self.ip_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "provinceCode": ["005"], "sortedBy": "flow" } } self.uri_hit_httpcode_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [random.choice(httpCode)], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_httpcode_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [random.choice(httpCode)], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.uri_hit_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "request" } } self.uri_miss_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "request" } } self.referer_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "request" } } self.domain_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "request" } } self.ip_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "request" } } self.ip_province_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [random.choice(province)], "sortedBy": "request" } } self.today_uri_hit_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.today_uri_miss_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.today_referer_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "flow" } } self.today_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.today_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.seven_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.sevenday_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.senven_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.sevenday_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.month_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.month_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.month_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.month_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } }
class Test_Ctyun_Top(object): def setup_class(self): # print('test start') self.session = Init.CTYUN_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['ctyunHost'] self.workspaceId = self.base_info['ctyun_workspaceid'] self.log = CreateLogData() self.get_domain_list = self.log.get_ctyun_domain_list( self.console_host, self.workspaceId) # 接口 self.uri_url = self.console_host + self.log_info['ListTopUri'] self.referer_url = self.console_host + self.log_info['ListTopReferer'] self.domain_url = self.console_host + self.log_info['ListTopDomain'] self.ip_url = self.console_host + self.log_info['ListTopIp'] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.before_yesterday = self.log.before_yesterday self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_uri_hit_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.default_uri_miss_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.default_referer_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "flow" } } self.default_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.default_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.uri_hit_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "httpCode": [], "productCode": ["001"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "httpCode": [], "productCode": ["001"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "productCode": ["001"], "sortedBy": "flow" } } self.domain_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "productCode": ["001"], "sortedBy": "flow" } } self.ip_data_001 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "top": 100, "provinceCode": ["001"], "sortedBy": "flow" } } self.uri_hit_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["003"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["003"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "productCode": ["003"], "sortedBy": "flow" } } self.domain_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "productCode": ["003"], "sortedBy": "flow" } } self.ip_data_003 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "provinceCode": ["003"], "sortedBy": "flow" } } self.uri_hit_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "top": 100, "httpCode": [], "productCode": ["004"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "httpCode": [], "productCode": ["004"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "productCode": ["004"], "sortedBy": "flow" } } self.domain_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "productCode": ["004"], "sortedBy": "flow" } } self.ip_data_004 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "top": 100, "provinceCode": ["004"], "sortedBy": "flow" } } self.uri_hit_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "httpCode": [], "productCode": ["005"], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "httpCode": [], "productCode": ["005"], "status": "MISS", "sortedBy": "flow" } } self.referer_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "productCode": ["005"], "sortedBy": "flow" } } self.domain_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "productCode": ["005"], "sortedBy": "flow" } } self.ip_data_005 = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "top": 100, "provinceCode": ["005"], "sortedBy": "flow" } } self.uri_hit_httpcode_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [random.choice(httpCode)], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.uri_miss_httpcode_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [random.choice(httpCode)], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.uri_hit_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "request" } } self.uri_miss_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "request" } } self.referer_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "request" } } self.domain_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "request" } } self.ip_request_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "request" } } self.ip_province_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.yesterday_time, "endTime": self.day_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [random.choice(province)], "sortedBy": "request" } } self.today_uri_hit_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "HIT", "sortedBy": "flow" } } self.today_uri_miss_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "httpCode": [], "productCode": [], "status": "MISS", "sortedBy": "flow" } } self.today_referer_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "productCode": [], "sortedBy": "flow" } } self.today_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.today_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.day_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.seven_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.sevenday_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.senven_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.sevenday_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } self.month_domain_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.month_time, "endTime": self.now_time, "domain": self.get_domain_list, "productCode": [], "sortedBy": "flow" } } self.month_ip_data = { "data": { "workspaceId": self.workspaceId, "startTime": self.month_time, "endTime": self.now_time, "domain": self.get_domain_list, "top": 100, "provinceCode": [], "sortedBy": "flow" } } def teardown_class(self): # 做清数据,退出登录等 self.session.close() print('-------------------test end-------------------') @allure.story("默认查询热门URL") def test_CDN_251619(self): url = self.uri_url payload = self.default_uri_hit_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("默认查询热门URL(回源)") def test_CDN_251620(self): url = self.uri_url payload = self.default_uri_miss_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("默认查询热门Referer") def test_CDN_251621(self): url = self.referer_url payload = self.default_referer_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("默认查询域名排行") def test_CDN_251622(self): url = self.domain_url payload = self.default_domain_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("默认查询TOP客户端IP") def test_CDN_251623(self): url = self.ip_url payload = self.default_ip_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("静态加速产品下查询热门URL") def test_CDN_251624(self): url = self.uri_url payload = self.uri_hit_data_001 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("静态加速产品下查询热门URL(回源)") def test_CDN_251625(self): url = self.uri_url payload = self.uri_miss_data_001 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("静态加速产品下查询热门Referer") def test_CDN_251626(self): url = self.referer_url payload = self.referer_data_001 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("静态加速产品下查询域名排行") def test_CDN_251627(self): url = self.domain_url payload = self.domain_data_001 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("静态加速产品下查询TOP客户端IP") def test_CDN_251628(self): url = self.ip_url payload = self.ip_data_001 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("下载加速产品下查询热门URL") def test_CDN_251629(self): url = self.uri_url payload = self.uri_hit_data_003 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("下载加速产品下查询热门URL(回源)") def test_CDN_251630(self): url = self.uri_url payload = self.uri_miss_data_003 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("下载加速产品下查询热门Referer") def test_CDN_251631(self): url = self.referer_url payload = self.referer_data_003 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("下载加速产品下查询域名排行") def test_CDN_251632(self): url = self.domain_url payload = self.domain_data_003 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("下载加速产品下查询TOP客户端IP") def test_CDN_251633(self): url = self.ip_url payload = self.ip_data_003 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频点播加速产品下查询热门URL") def test_CDN_251634(self): url = self.uri_url payload = self.uri_hit_data_004 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频点播加速产品下查询热门URL(回源)") def test_CDN_251635(self): url = self.uri_url payload = self.uri_miss_data_004 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频点播加速产品下查询Referer") def test_CDN_251636(self): url = self.referer_url payload = self.referer_data_004 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频点播加速产品下查询域名排行") def test_CDN_251637(self): url = self.domain_url payload = self.domain_data_004 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频点播加速产品下查询TOP客户端IP") def test_CDN_251638(self): url = self.ip_url payload = self.ip_data_004 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频直播加速产品下查询热门URL") def test_CDN_251639(self): url = self.uri_url payload = self.uri_hit_data_005 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频直播加速产品下查询热门URL(回源)") def test_CDN_251640(self): url = self.uri_url payload = self.uri_miss_data_005 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频直播加速产品下查询Referer") def test_CDN_251641(self): url = self.referer_url payload = self.referer_data_005 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频直播加速产品下查询域名排行") def test_CDN_251642(self): url = self.domain_url payload = self.domain_data_005 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("视频直播加速产品下查询TOP客户端IP") def test_CDN_251643(self): url = self.ip_url payload = self.ip_data_005 response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("状态码查询热门URL") def test_CDN_251644(self): url = self.uri_url payload = self.uri_hit_httpcode_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("状态码查询热门URL(回源)") def test_CDN_251645(self): url = self.uri_url payload = self.uri_miss_httpcode_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("访问次数维度查询热门URL") def test_CDN_251646(self): url = self.uri_url payload = self.uri_hit_request_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("访问次数维度查询热门URL(回源)") def test_CDN_251647(self): url = self.uri_url payload = self.uri_miss_request_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("访问次数维度查询热门Referer") def test_CDN_251648(self): url = self.referer_url payload = self.referer_request_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("访问次数维度查询域名排行") def test_CDN_251649(self): url = self.domain_url payload = self.domain_request_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("访问次数维度查询TOP客户端IP") def test_CDN_251650(self): url = self.ip_url payload = self.ip_request_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("通过地区查询TOP客户端IP") def test_CDN_251651(self): url = self.ip_url payload = self.ip_province_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询今天的热门URL") def test_CDN_251652(self): url = self.uri_url payload = self.today_uri_hit_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询今天的热门URL(回源)") def test_CDN_251653(self): url = self.uri_url payload = self.today_uri_miss_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topuri 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询今天的热门Referer") def test_CDN_251654(self): url = self.referer_url payload = self.today_referer_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topreferer 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询今天的域名排行") def test_CDN_251655(self): url = self.domain_url payload = self.today_domain_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询今天的TOP客户端IP") def test_CDN_251656(self): url = self.ip_url payload = self.today_ip_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询7天的域名排行") def test_CDN_251657(self): url = self.domain_url payload = self.seven_domain_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story("查询7天的TOP客户端IP") def test_CDN_251658(self): url = self.ip_url payload = self.senven_ip_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 # @pytest.mark.skip("响应超时") # 跳过该测试 @allure.story("查询30天的域名排行") def test_CDN_251659(self): url = self.domain_url payload = self.month_domain_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topdomain 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 10 # @pytest.mark.skip("响应超时") # 跳过该测试 @allure.story("查询30天的TOP客户端IP") def test_CDN_251660(self): url = self.ip_url payload = self.month_ip_data response = self.session.post(url, json=payload, timeout=10) print("-------------------查询 topip 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 10
def setup_class(self): # print('test start') self.session = Init.CTYUN_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['ctyunHost'] self.workspaceId = self.base_info['ctyun_workspaceid'] self.log = CreateLogData() self.get_domain_list = self.log.get_ctyun_domain_list(self.console_host, self.workspaceId) # 接口 self.flow_url = self.console_host + self.log_info['dataList'] self.miss_dataList_url = self.console_host + self.log_info['missDataList'] self.req_url = self.console_host + self.log_info['requestDataList'] self.hit_url = self.console_host + self.log_info['hit'] self.httpcode_url = self.console_host + self.log_info['httpcode'] self.pvuv_url = self.console_host + self.log_info["pvuv"] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.before_yesterday = self.log.before_yesterday self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_data = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_001 = {"data": {"workspaceId": self.workspaceId, "productType": ['001'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_003 = {"data": {"workspaceId": self.workspaceId, "productType": ['003'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_004 = {"data": {"workspaceId": self.workspaceId, "productType": ['004'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_005 = {"data": {"workspaceId": self.workspaceId, "productType": ['005'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_1 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [1], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_2 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [2], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_3 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [3], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_4 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [4], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_5 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [5], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_6 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [6], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_100 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [100], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} isp_list = [1, 2, 3, 4, 5, 6, 100] self.isp_data_random = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [random.choice(isp_list)], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.province_data_1 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [random.choice(province)], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.province_data_2 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [random.choice(province)], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time}} self.date_yesterday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time}} self.date_compare = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.before_yesterday, "endTime": self.yesterday_time}} self.date_sevenday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.sevenday_time, "endTime": self.now_time}} self.date_month = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.month_time, "endTime": self.now_time}} self.default_pvuv = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time, "ignore": "domain"}} self.random_domain_pvuv = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": [random.choice(self.get_domain_list)], "startTime": self.day_time, "endTime": self.now_time, "ignore": "domain"}}
class Test_Ctyun_Log_Query(): def setup_class(self): # print('test start') self.session = Init.CTYUN_SESSION self.base_info = Init.BASE_INFO self.log_info = Init.LOG_INFO self.console_host = self.base_info['ctyunHost'] self.workspaceId = self.base_info['ctyun_workspaceid'] self.log = CreateLogData() self.get_domain_list = self.log.get_ctyun_domain_list(self.console_host, self.workspaceId) # 接口 self.flow_url = self.console_host + self.log_info['dataList'] self.miss_dataList_url = self.console_host + self.log_info['missDataList'] self.req_url = self.console_host + self.log_info['requestDataList'] self.hit_url = self.console_host + self.log_info['hit'] self.httpcode_url = self.console_host + self.log_info['httpcode'] self.pvuv_url = self.console_host + self.log_info["pvuv"] # 日期类 self.day_time = self.log.day_time self.yesterday_time = self.log.yesterday_time self.before_yesterday = self.log.before_yesterday self.sevenday_time = self.log.sevenday_time self.month_time = self.log.month_time self.now_time = self.log.now_time # 查询数据 self.default_data = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_001 = {"data": {"workspaceId": self.workspaceId, "productType": ['001'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '001'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_003 = {"data": {"workspaceId": self.workspaceId, "productType": ['003'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '003'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_004 = {"data": {"workspaceId": self.workspaceId, "productType": ['004'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '004'), "startTime": self.day_time, "endTime": self.now_time}} self.cp_data_005 = {"data": {"workspaceId": self.workspaceId, "productType": ['005'], "isp": [], "province": [], "domain": self.log.get_ctyun_cp_domain(self.console_host, self.workspaceId, '005'), "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_1 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [1], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_2 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [2], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_3 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [3], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_4 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [4], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_5 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [5], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_6 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [6], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.isp_data_100 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [100], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} isp_list = [1, 2, 3, 4, 5, 6, 100] self.isp_data_random = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [random.choice(isp_list)], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.province_data_1 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [random.choice(province)], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time}} self.province_data_2 = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [random.choice(province)], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time}} self.date_yesterday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.yesterday_time, "endTime": self.now_time}} self.date_compare = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.before_yesterday, "endTime": self.yesterday_time}} self.date_sevenday = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.sevenday_time, "endTime": self.now_time}} self.date_month = {"data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.month_time, "endTime": self.now_time}} self.default_pvuv = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": self.get_domain_list, "startTime": self.day_time, "endTime": self.now_time, "ignore": "domain"}} self.random_domain_pvuv = { "data": {"workspaceId": self.workspaceId, "productType": [], "isp": [], "province": [], "domain": [random.choice(self.get_domain_list)], "startTime": self.day_time, "endTime": self.now_time, "ignore": "domain"}} def teardown_class(self): # 做清数据,退出登录等 self.session.close() print('-------------------test end-------------------') @allure.story(' dataList 接口1') def test_CDN_246237(self): url = self.flow_url payload = self.default_data # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246239(self): url = self.miss_dataList_url payload = self.default_data # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246238(self): url = self.req_url payload = self.default_data # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246241(self): url = self.hit_url payload = self.default_data # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246240(self): url = self.httpcode_url payload = self.default_data # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246242(self): url = self.flow_url payload = self.date_yesterday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246243(self): url = self.miss_dataList_url payload = self.date_yesterday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246244(self): url = self.req_url payload = self.date_yesterday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246246(self): url = self.hit_url payload = self.date_yesterday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246245(self): url = self.httpcode_url payload = self.date_yesterday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246247(self): url = self.flow_url payload = self.date_sevenday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246248(self): url = self.miss_dataList_url payload = self.date_sevenday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246249(self): url = self.req_url payload = self.date_sevenday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246251(self): url = self.hit_url payload = self.date_sevenday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246250(self): url = self.httpcode_url payload = self.date_sevenday # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246252(self): url = self.flow_url payload = self.cp_data_001 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246252(self): url = self.miss_dataList_url payload = self.cp_data_001 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246254(self): url = self.req_url payload = self.cp_data_001 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246256(self): url = self.hit_url payload = self.cp_data_001 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246255(self): url = self.httpcode_url payload = self.cp_data_001 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246257(self): url = self.flow_url payload = self.cp_data_003 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246258(self): url = self.miss_dataList_url payload = self.cp_data_003 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246259(self): url = self.req_url payload = self.cp_data_003 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246261(self): url = self.hit_url payload = self.cp_data_003 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246260(self): url = self.httpcode_url payload = self.cp_data_003 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246267(self): url = self.flow_url payload = self.cp_data_004 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246268(self): url = self.miss_dataList_url payload = self.cp_data_004 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246269(self): url = self.req_url payload = self.cp_data_004 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246271(self): url = self.hit_url payload = self.cp_data_004 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246270(self): url = self.httpcode_url payload = self.cp_data_004 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246262(self): url = self.flow_url payload = self.cp_data_005 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246263(self): url = self.miss_dataList_url payload = self.cp_data_005 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246264(self): url = self.req_url payload = self.cp_data_005 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246266(self): url = self.hit_url payload = self.cp_data_005 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246265(self): url = self.httpcode_url payload = self.cp_data_005 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246272(self): url = self.flow_url payload = self.isp_data_random # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246273(self): url = self.miss_dataList_url payload = self.isp_data_random # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246274(self): url = self.req_url payload = self.isp_data_random # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246276(self): url = self.hit_url payload = self.isp_data_random # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246275(self): url = self.httpcode_url payload = self.isp_data_random # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246277(self): url = self.flow_url payload = self.province_data_1 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246278(self): url = self.miss_dataList_url payload = self.province_data_2 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246279(self): url = self.req_url payload = self.province_data_1 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246281(self): url = self.hit_url payload = self.province_data_2 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246280(self): url = self.httpcode_url payload = self.province_data_1 # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1,默认数据对比') def test_CDN_246282(self): url = self.flow_url payload = self.date_compare # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 默认数据对比') def test_CDN_246283(self): url = self.miss_dataList_url payload = self.date_compare # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' dataList 接口1') def test_CDN_246284(self): url = self.flow_url payload = self.date_month # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 dataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' missDataList 接口1') def test_CDN_246285(self): url = self.miss_dataList_url payload = self.date_month # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 missDataList 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' req_url 接口1') def test_CDN_246286(self): url = self.req_url payload = self.date_month # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 req_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' hit_url 接口1') def test_CDN_246288(self): url = self.hit_url payload = self.date_month # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 hit_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(' httpcode_url 接口1') def test_CDN_246287(self): url = self.httpcode_url payload = self.date_month # url = temp + data response = self.session.request("GET", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 httpcode_url 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story(" GetPvUv 接口1 默认数据查询") def test_CDN_265357(self): url = self.pvuv_url payload = self.default_pvuv response = self.session.post(url, json=payload, verify=False, timeout=10) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text @allure.story(" GetPvUv 接口1 单域名查询") def test_CDN_265358(self): url = self.pvuv_url payload = self.random_domain_pvuv response = self.session.post(url, json=payload, verify=False, timeout=10) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text @allure.story(" GetPvUv 接口1 查询昨天的PV/UV") def test_CDN_265359(self): url = self.pvuv_url self.date_yesterday["data"]["ignore"] = "domain" payload = self.date_yesterday response = self.session.post(url, json=payload, verify=False, timeout=10) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text @allure.story(" GetPvUv 接口1 查询近7天的PV/UV") def test_CDN_265360(self): url = self.pvuv_url self.date_sevenday["data"]["ignore"] = "domain" payload = self.date_sevenday response = self.session.post(url, json=payload, verify=False, timeout=10) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text @allure.story(" GetPvUv 接口1 查询近30天的PV/UV") def test_CDN_265361(self): url = self.pvuv_url self.date_month["data"]["ignore"] = "domain" payload = self.date_month response = self.session.post(url, json=payload, verify=False, timeout=10) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text @pytest.mark.skipif(Init.ENV == "ITE", reason="测试环境可能无数据,暂不执行") @allure.story(" 小时粒度,PV峰值/总量正确 ") def test_CDN_270975(self): payload = self.default_pvuv response = self.session.post(self.pvuv_url, json=payload, verify=False, timeout=10) content = json.loads(response.text) hours = content["data"]["hours"] pvCount = [hour["pvCount"] for hour in hours] totalPv = 0 for i in range(0, len(pvCount)): # pv总量 totalPv += pvCount[i] # pv峰值 maxPv = max(pvCount) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + self.pvuv_url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert totalPv == content["data"]["totalPv"] assert maxPv == content["data"]["maxPv"] @pytest.mark.skipif(Init.ENV == "ITE", reason="测试环境可能无数据,暂不执行") @allure.story(" 小时粒度,UV峰值/总量正确 ") def test_CDN_270976(self): payload = self.default_pvuv response = self.session.post(self.pvuv_url, json=payload, verify=False, timeout=10) content = json.loads(response.text) hours = content["data"]["hours"] uvCount = [hour["uvCount"] for hour in hours] totalUv = 0 for i in range(0, len(uvCount)): # pv总量 totalUv += uvCount[i] # pv峰值 maxUv = max(uvCount) print(totalUv, maxUv) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + self.pvuv_url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert totalUv == content["data"]["totalUv"] assert maxUv == content["data"]["maxUv"] @pytest.mark.skipif(Init.ENV == "ITE", reason="测试环境可能无数据,暂不执行") @allure.story(" 天粒度,PV峰值/总量正确 ") def test_CDN_270977(self): self.date_sevenday["data"]["ignore"] = "domain" payload = self.date_sevenday response = self.session.post(self.pvuv_url, json=payload, verify=False, timeout=10) content = json.loads(response.text) hours = content["data"]["daily"] pvCount = [hour["pvCount"] for hour in hours] totalPv = 0 for i in range(0, len(pvCount)): # Pv总量 totalPv += pvCount[i] # Pv峰值 maxPv = max(pvCount) print(totalPv, maxPv) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + self.pvuv_url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert totalPv == content["data"]["totalPv"] assert maxPv == content["data"]["maxPv"] @pytest.mark.skipif(Init.ENV == "ITE", reason="测试环境可能无数据,暂不执行") @allure.story(" 天粒度,UV峰值/总量正确 ") def test_CDN_27098(self): self.date_sevenday["data"]["ignore"] = "domain" payload = self.date_sevenday response = self.session.post(self.pvuv_url, json=payload, verify=False, timeout=10) content = json.loads(response.text) hours = content["data"]["daily"] uvCount = [hour["uvCount"] for hour in hours] totalUv = 0 for i in range(0, len(uvCount)): # Uv总量 totalUv += uvCount[i] # Uv峰值 maxUv = max(uvCount) print(totalUv, maxUv) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + self.pvuv_url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert totalUv == content["data"]["totalUv"] assert maxUv == content["data"]["maxUv"] @pytest.mark.skipif(Init.ENV == "ITE", reason="测试环境可能无数据,暂不执行") @allure.story(" 天粒度,近30天的PV总量大于UV总量 ") def test_CDN_271055(self): # Pv:业务访问量, Uv:独立客户访问量 self.date_month["data"]["ignore"] = "domain" payload = self.date_month response = self.session.post(self.pvuv_url, json=payload, verify=False, timeout=10) content = json.loads(response.text) totalPv = content["data"]["totalPv"] totalUv = content["data"]["totalUv"] print(totalPv, totalUv) print("-------------------查询 GetPvUv 接口-------------------") print('请求url: ' + self.pvuv_url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: Pv总量大于Uv总量") assert response.status_code == 200 assert 'core.ok' in response.text assert totalPv > totalUv
class Test_Bs_Refresh(): def setup_class(self): now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) # today = time.strftime("%Y-%m-%d", time.localtime()) # sevenday = (date.today() + timedelta(days=-6)).strftime("%Y-%m-%d %H:%M:%S") # month = (date.today() + timedelta(days=-29)).strftime("%Y-%m-%d %H:%M:%S") now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) day_time = int(time.mktime(datetime.now().date().timetuple())) now_time = get_unix_time(now) # print('test start') self.session = Init.BS_SESSION self.base_info = Init.BASE_INFO self.console_host = self.base_info['bsHost'] self.workspace_id = self.base_info['ctyunAcctId'] self.head_json = self.base_info['headers_json'] self.today = day_time self.now = now_time self.head_form = self.base_info['headers_form'] # 提取工作区对应的域名列表 self.log = CreateLogData() self.get_domain_list = self.log.get_bs_used_domain_list(self.console_host,self.workspace_id) self.get_fan_domain=self.log.get_bs_all_domain(self.console_host,self.workspace_id) def teardown_class(self): # 做清数据,退出登录等 self.session.close() print('-------------------test end-------------------') @allure.story('refresh/ListRefreshTask 接口1') def test_CDN_243732(self): temp = self.console_host + '/cdn/gw/refresh/ListRefreshTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&task_type=1&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'create_time' in response.text assert 'total' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('refresh/ListRefreshTask 接口2') def test_CDN_243733(self): temp = self.console_host + '/cdn/gw/refresh/ListRefreshTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&task_type=2&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'create_time' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('preload/ListPreloadTaskk 接口') def test_CDN_243734(self): temp = self.console_host + '/cdn/gw/preload/ListPreloadTask' data = '?workspaceId=' + self.workspace_id + '&page=1&page_size=10&pageSize=10&start_time=' + str( self.today) + '&end_time=' + str(self.now) + '' payload = {} url = temp + data response = self.session.request("POST", url, data=payload, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert 'total' in response.text assert response.elapsed.total_seconds() < 3 # @pytest.mark.skip(reason="调试") # 跳过该测试 # @pytest.mark.repeat(50) @allure.story('CreateRefreshTask 接口') def test_CDN_243735(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_domain_list) payload = { "data": {"workspaceId": self.workspace_id, "values": [domain], "domain": "", "task_type": "1"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 接口2') def test_CDN_243736(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_domain_list) domain_s = random.choice(self.get_domain_list) value = [] value.append(domain) value.append(domain_s) payload = { "data": {"workspaceId": self.workspace_id, "values": value, "domain": "", "task_type": "1"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 接口2') def test_CDN_243737(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' # 只能刷新已启用的域名 used_domain_list = self.get_domain_list payload = { "data": {"workspaceId": self.workspace_id, "values": used_domain_list, "domain": "", "task_type": "1"}} print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text # assert 'secrets' in response.text # assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷泛域名') def test_CDN_243738(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_fan_domain) payload = { "data": {"workspaceId": self.workspace_id, "values": [domain], "domain": "", "task_type": "1"}} print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 # assert 'core.ok' in response.text assert '请求参数错误' in response.text # assert 'value_error.url.scheme' in response.text @allure.story('CreateRefreshTask 刷泛域名目录') def test_CDN_243739(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_fan_domain) + "/images/" payload = { "data": {"workspaceId": self.workspace_id, "values": [domain], "domain": "", "task_type": "2"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert '请求参数错误' in response.text assert 'value_error' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷没有操作权限的URL') def test_CDN_243740(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": {"workspaceId": self.workspace_id, "values": ["http://www.hehehe.com"], "domain": "", "task_type": "1"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' not in response.text assert '填写内容有误,请核对添加的域名' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷目录') def test_CDN_243741(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_domain_list) + "/images/" payload = { "data": {"workspaceId": self.workspace_id, "values": [domain], "domain": "", "task_type": "2"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷多个目录') def test_CDN_243742(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' domain = random.choice(self.get_domain_list) + "/images/" domain_s = random.choice(self.get_domain_list) + "/gal.text/" value = [] value.append(domain) value.append(domain_s) payload = { "data": {"workspaceId": self.workspace_id, "values": value, "domain": "", "task_type": "2"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask,刷新大量目录 ') def test_CDN_243743(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' # 只能刷新已启用的域名 used_domain_list = self.get_domain_list directory_list = ['/images/', '/text/', '/pdf/'] valuse_list = [] for temp in used_domain_list: valuse_list.append(temp + directory_list[0]) valuse_list.append(temp + directory_list[1]) valuse_list.append(temp + directory_list[2]) payload = { "data": {"workspaceId": self.workspace_id, "values": valuse_list, "domain": "", "task_type": "2"}} print(type(payload), payload) response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert '请求参数错误' in response.text assert '100006' in response.text # 由于刷新的目录太多,所有肯定超过3秒,这条不验证 # assert response.elapsed.total_seconds() < 3 @allure.story('CreateRefreshTask 刷没有操作权限的目录') def test_CDN_243744(self): url = self.console_host + '/cdn/gw/refresh/CreateRefreshTask' payload = { "data": {"workspaceId": self.workspace_id, "values": ["http://www.hehehe.com/text/"], "domain": "", "task_type": "2"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert 'core.ok' not in response.text assert '填写内容有误,请核对添加的域名' in response.text assert response.elapsed.total_seconds() < 3 @allure.story('domain/CheckPrivilege 刷不存在的URL') def test_CDN_243745(self): url = self.console_host + '/cdn/gw/domain/CheckPrivilege' payload = { "data": {"workspaceId": self.workspace_id, "values": ["http://www.baidu55555.com"], "do": "c_refresh"}} # url = temp + data response = self.session.request("POST", url, data=json.dumps(payload), verify=False, timeout=10) print("-------------------查询 CreateRefreshTask 接口-------------------") print('请求url: ' + url) print("请求data: " + str(payload)) print("返回: " + response.text) print("重点验证:" " expect: 返回码与响应时间") assert response.status_code == 200 assert '"list":[{"enable":"false","on":"www.baidu55555.com"}]' in str(response.text) assert response.elapsed.total_seconds() < 3