def upgrade_to_old_version(): # 向低版本升级测试 to_log('向低版本升级测试') # 获取升级前的设备属性 a0 = get_device_attribute(data_for_upgradeTest['deviceNo']) to_log('升级前版本号为:' + a0.get('sys.software.version', '')) # 发送升级命令 send_upgrade_cmd(data_for_upgradeTest['deviceNo'], p1.get('id', '')) time.sleep(10) # 检查升级过程是否完成 for ii in range(240): a1 = get_device_attribute(data_for_upgradeTest['deviceNo']) if a1.get('time', '1') != a0.get('time', ''): break # 升级完成后获取设备属性 a2 = get_device_attribute(data_for_upgradeTest['deviceNo']) to_log('升级后版本号为:' + a2.get('sys.software.version', '')) # 断言升级是否成功 if a0.get('sys.software.version', '') != a2.get('sys.software.version', ''): to_log('向低版本升级测试PASS\n') return True else: to_log('向低版本升级测试Failed\n') return False
def check_network_config_if_success( want_time, device_no=data_for_networkTest.get('deviceNo')): import time from dmSupport import get_device_attribute from to_log import to_log flag = False try: for i in range(int(want_time / 5)): # 获取系统当前时间 ts = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time())) # 获取设备属性 da = get_device_attribute(device_no) # 修正时间 ct = ts[:-4] + str(int(ts[-4]) + 1) if da.get('time', 'failed')[:-3] == ts[:-3] or da.get( 'time', 'failed')[:-3] == ct: flag = True break except: to_log('检查网络配置模块异常, 请确认输入的时间是否为5的整数倍') return flag
# 生成LAN+静态IP网络配置二维码 lan_mode(ip=data_for_networkTest.get('ip'), mask=data_for_networkTest.get('mask'), gw=data_for_networkTest.get('gw'), dns=data_for_networkTest.get('dns')) # 配网时间 time.sleep(5) if check_network_config_if_success(120): # 获取系统当前时间 nowTimestamp = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time())) # 获取设备属性 da = get_device_attribute(data_for_networkTest.get('deviceNo')) # 修正时间 correction_time = nowTimestamp[:-4] + str(int(nowTimestamp[-4]) + 1) if da.get('time', 'failed')[:-3] == nowTimestamp[:-3] or da.get( 'time', 'failed')[:-3] == correction_time: if da.get('persist.net.type') == 'eth' and da.get( 'persist.net.dhcp') == 'false': to_log('LAN+静态IP网络配置测试Pass\n') to_log('配网方式:' + da.get('persist.net.type', '')) to_log('DHCP:' + da.get('persist.net.dhcp', '')) to_log('IP:' + da.get('sys.net.ip', '')) to_log('MASK:' + da.get('persist.net.mask', '')) to_log('GW:' + da.get('persist.net.gw', '')) to_log('DNS:' + da.get('persist.net.dns1', '')) to_log('MAC:' + da.get('system.net.wifi.mac', '') + '\n')
to_log('***网络配置成功率测试***') for i in range(configuration['netConfigTestTime']): # 配网 driver.get('file:///' + configuration['filePath'] + 'netPass.png') # 识别时间 time.sleep(1) # 打开空白图片 driver.get('file:///' + configuration['filePath'] + 'blank.png') # 配网时间 time.sleep(15) # 获取系统当前时间 nowTimestamp = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time())) to_log(nowTimestamp) # 获取设备属性上传时间 dmTimestamp1 = get_device_attribute(configuration['networkDeviceNo']).get('time', '获取时间失败') to_log(dmTimestamp1) if nowTimestamp[:-3] == dmTimestamp1[:-3]: to_log('第' + str(i + 1) + '配网成功 ^_^') passCount += 1 else: to_log('第' + str(i + 1) + '配网失败 -_-') failCount += 1 # 断网 driver.get('file:///' + configuration['filePath'] + 'netFail.png') # 识别时间 time.sleep(1) # 打开空白图片 driver.get('file:///' + configuration['filePath'] + 'blank.png') # 配网时间
# coding=utf-8 import time from to_log import to_log from configFile import configuration from dmSupport import get_device_attribute, send_upgrade_cmd passCount = 0 failCount = 0 to_log('***升级成功率测试***') for i in range(20): # 获取升级前的设备属性 a0 = get_device_attribute(configuration['upgradeDeviceNo']) to_log('第' + str(i + 1) + '次升级前版本为:' + a0.get('sys.software.version', '')) # 下发升级(4.0.38:153/4.0.38.4:172) if a0.get('sys.software.version', '') == '4.0.38': send_upgrade_cmd(configuration['upgradeDeviceNo'], '172') elif a0.get('sys.software.version', '') == '': to_log('获取设备属性失败!') else: send_upgrade_cmd(configuration['upgradeDeviceNo'], '153') time.sleep(15) # 升级过程等待20min,期间每个5秒获取一次设备属性 # 如果最后一次属性上传时间与上次上传时间相等,则升级过程结束 for ii in range(240): a1 = get_device_attribute(configuration['upgradeDeviceNo']) if a1.get('time', '') != a0.get('time', ''): break # 升级完成后获取设备属性
to_log('升级后版本号为:' + a2.get('sys.software.version', '')) # 断言升级是否成功 if a0.get('sys.software.version', '') != a2.get('sys.software.version', ''): to_log('向低版本升级测试PASS\n') return True else: to_log('向低版本升级测试Failed\n') return False if upgrade_to_old_version(): # 低版本向当前版升级测试 to_log('低版本向当前版升级测试') # 获取升级前的设备属性 a3 = get_device_attribute(data_for_upgradeTest['deviceNo']) to_log('升级前版本号为:' + a3.get('sys.software.version', '')) # 发送升级命令 send_upgrade_cmd(data_for_upgradeTest['deviceNo'], p2.get('id', '')) time.sleep(10) # 检查升级过程是否完成 for ii in range(240): a4 = get_device_attribute(data_for_upgradeTest['deviceNo']) if a3.get('time', '') != a4.get('time', ''): break # 升级完成后获取设备属性 a5 = get_device_attribute(data_for_upgradeTest['deviceNo']) to_log('升级后版本号为:' + a5.get('sys.software.version', '')) # 断言升级是否成功 if a3.get('sys.software.version', '') != a5.get('sys.software.version', ''):
with open('issueTest.log', "r+", encoding='UTF-8', errors='ignore') as f: content = f.read() f.seek(0, 0) f.write( time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())) + ": " + str_info + '\n' + content) f.close() print(str_info) # A5下发稳定性测试1: 2126 # A5下发稳定性测试2: 2127 count = 0 for i in range(10): device_att = get_device_attribute('4113180400131017') if '下发稳定性测试1' in device_att.get('send.test1', ''): issue_user_defined_config('2127', '2767390', '4113180400131017') time.sleep(10) count += 1 temp0 = get_device_attribute('4113180400131017') if '下发稳定性测试2' in temp0.get('send.test1', ''): to_log('第' + str(count) + '次下发成功^_^') else: to_log('第' + str(count) + '次下发成功-_-') elif '下发稳定性测试2' in device_att.get('send.test1', ''): issue_user_defined_config('2126', '2767390', '4113180400131017') time.sleep(10) count += 1 temp1 = get_device_attribute('4113180400131017') if '下发稳定性测试1' in temp1.get('send.test1', ''):
to_log('***网络配置成功率测试***', file='4gModeTest.log') for i in range(500): # 配网 driver.get('file:///D:/script/flushbonding/4gMode.png') # 识别时间 time.sleep(1) # 打开空白图片 driver.get('file:///D:/script/flushbonding/blank.png') # 日本4G卡配网时间35s,DM设备状态变更2min time.sleep(125) # 获取系统当前时间 nowTimestamp = time.strftime('%Y-%m-%d %H-%M-%S', time.localtime(time.time())) # 获取设备属性 da = get_device_attribute('4140190200100062') # 修正时间 correction_time = nowTimestamp[:-4] + str(int(nowTimestamp[-4]) + 1) if da.get('time', 'failed')[:-3] == nowTimestamp[:-3] or da.get('time', 'failed')[:-3] == correction_time: to_log('第' + str(i + 1) + '配网成功 ^_^', file='4gModeTest.log') passCount += 1 else: to_log('第' + str(i + 1) + '配网失败 -_-', file='4gModeTest.log') failCount += 1 # 断网 driver.get('file:///D:/script/flushbonding/lanMode.png') # 识别时间 time.sleep(1) # 打开空白图片