def test_iso_http_basic_a2(self): # 下发配置 fun.send(rbmExc, message.addhttp_front['AddCustomAppPolicy'], FrontDomain, base_path) fun.send(rbmExc, message.addhttp_back['AddCustomAppPolicy'], BackDomain, base_path) fun.wait_data('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') fun.nginx_worker('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') fun.wait_data('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') fun.nginx_worker('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') # 检查配置下发是否成功 for key in self.case2_step1: re = fun.wait_data(self.case2_step1[key][0], 'FrontDut', self.case2_step1[key][1], '配置', 100) print(re) assert self.case2_step1[key][1] in re for key in self.case2_step11: re = fun.wait_data(self.case2_step11[key][0], 'FrontDut', self.case2_step11[key][1], '配置', 100) print(re) assert self.case2_step11[key][1] in re # 发送get请求,验证get请求是否正常 print('请求地址为{}'.format(http_url)) content = http_check.http_get(http_url) print('验证隔离下的get请求内容为:{}'.format(content)) # 发送get请求,验证隔离下的http策略下载一个10M大小的文件 print('下载的服务器地址为{}'.format(self.downfile_url)) result = http_check.http_download(self.downfile_url, self.downlocalPath) assert result == 1
def test_iso_tcp_large_file_a1(self): # 下发配置 fun.send(rbmExc, message.addtcp_front['AddCustomAppPolicy'], FrontDomain, base_path) fun.send(rbmExc, message.addtcp_back['AddCustomAppPolicy'], BackDomain, base_path) fun.wait_data('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') front_res = fun.nginx_worker('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process', name='前置机nginx进程') assert front_res == 1 fun.wait_data('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') back_res = fun.nginx_worker('ps -ef |grep nginx', 'BackDut', 'nginx: worker process', name='后置机nginx进程') assert back_res == 1 # 检查配置下发是否成功 for key in self.case1_step1: re = fun.wait_data(self.case1_step1[key][0], 'FrontDut', self.case1_step1[key][1], '配置', 100) print(re) assert self.case1_step1[key][1] in re for key in self.case1_step11: re = fun.wait_data(self.case1_step11[key][0], 'FrontDut', self.case1_step11[key][1], '配置', 100) print(re) assert self.case1_step11[key][1] in re # 发送get请求,验证隔离下的http策略下载一个10G大小的文件 print('下载的服务器地址为{}'.format(self.downfile_url)) result = http_check.http_download(self.downfile_url, self.downlocalPath) assert result == 1 # 检查下载目录下是否有文件生成,若有,则检查文件大小是否正常 # 判断文件大小是否是10G file_size = os.path.getsize(self.downlocalPath) file_size = file_size / float(1024 * 1024) # 将单位转化为M assert 9500.0 <= file_size <= 10050.0 # 移除策略,清空环境 fun.send(rbmExc, message.deltcp_front['DelCustomAppPolicy'], FrontDomain, base_path) fun.send(rbmExc, message.deltcp_back['DelCustomAppPolicy'], BackDomain, base_path) fun.wait_data('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') fdel_res = fun.nginx_worker('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process', name='前置机nginx进程') assert fdel_res == 1 fun.wait_data('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') bdel_res = fun.nginx_worker('ps -ef |grep nginx', 'BackDut', 'nginx: worker process', name='后置机nginx进程') assert bdel_res == 1 # 检查策略移除是否成功 for key in self.case1_step1: re = fun.wait_data(self.case1_step1[key][0], 'FrontDut', self.case1_step1[key][1], '配置', 100, flag='不存在') print(re) assert self.case1_step1[key][1] not in re
def test_iso_http_basic_a2(self): # 下发配置 fun.send(rbmExc, message.addhttp_front['AddCustomAppPolicy'], FrontDomain, base_path) fun.send(rbmExc, message.addhttp_back['AddCustomAppPolicy'], BackDomain, base_path) fun.wait_data('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') front_res = fun.nginx_worker('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process', name='前置机nginx进程') assert front_res == 1 fun.wait_data('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') back_res = fun.nginx_worker('ps -ef |grep nginx', 'BackDut', 'nginx: worker process', name='后置机nginx进程') assert back_res == 1 # 检查配置下发是否成功 for key in self.case2_step1: re = fun.wait_data(self.case2_step1[key][0], 'FrontDut', self.case2_step1[key][1], '配置', 100) print(re) assert self.case2_step1[key][1] in re for key in self.case2_step11: re = fun.wait_data(self.case2_step11[key][0], 'FrontDut', self.case2_step11[key][1], '配置', 100) print(re) assert self.case2_step11[key][1] in re # 发送get请求,验证get请求是否正常 print('请求地址为{}'.format(http_url)) content = http_check.http_get(http_url) print('验证隔离下的get请求内容为:{}'.format(content)) # 发送get请求,验证隔离下的http策略下载一个10M大小的文件 print('下载的服务器地址为{}'.format(self.downfile_url)) result = http_check.http_download(self.downfile_url, self.downlocalPath) assert result == 1 #判断文件大小是否是10M file_size = os.path.getsize(self.downlocalPath) file_size = file_size / float(1024 * 1024) #将单位转化为M assert 9.5 <= file_size <= 10.5 # 移除策略,清空环境 fun.send(rbmExc, message.delhttp_front['DelCustomAppPolicy'], FrontDomain, base_path) fun.send(rbmExc, message.delhttp_back['DelCustomAppPolicy'], BackDomain, base_path) fun.wait_data('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process') fdel_res = fun.nginx_worker('ps -ef |grep nginx', 'FrontDut', 'nginx: worker process', name='前置机nginx进程') assert fdel_res == 1 fun.wait_data('ps -ef |grep nginx', 'BackDut', 'nginx: worker process') bdel_res = fun.nginx_worker('ps -ef |grep nginx', 'BackDut', 'nginx: worker process', name='后置机nginx进程') assert bdel_res == 1 # 检查策略移除是否成功 for key in self.case2_step1: re = fun.wait_data(self.case2_step1[key][0], 'FrontDut', self.case2_step1[key][1], '配置', 100, flag='不存在') print(re) assert self.case2_step1[key][1] not in re