def State_change004(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、模拟pad下发自动驾驶指令)' '//5s内状态机仍为锁车态') communication_control_pub(container, mode='vehicle_state', state='auto') # 等待5s time.sleep(5) # 上位机为维护锁车态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') # 下位机为锁车态 state_machine = chassis_state_change_echo(container) if state_machine != 0: raise Exception('状态机预期为锁车,实际为%d' % state_machine)
def State_change005(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、下发解锁命令)' '//状态机切换为维护空闲') communication_control_pub(container, mode='vehicle_state', state='unlock') # 查看状态机状态为维护空闲 if state_machine_state_echo(container) != 1: raise Exception('当前状态不为维护空闲') logging.info('2、下发上锁命令)' '//状态机切换为维护锁车') communication_control_pub(container, mode='vehicle_state', state='lock') # 查看状态机状态为维护空闲 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车')
def State_change001(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、维护锁车时发生不可使用故障' '//上位机进入故障态,下位机进入故障态') # 注入platform_datacollect_sensor_state故障,id65541 fault_inject_pub(container,65541,1) # 上位机10s内进入维护故障 for i in range(10): if state_machine_state_echo(container) != 3: time.sleep(2) else: break if i == 9: raise Exception('上位机未进入故障态') # 下位机进入故障 state_machine = chassis_state_change_echo(container) if state_machine != 4: raise Exception('状态机预期为故障,实际为%d' %state_machine) # 查看产生对应告警 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'sensor_state collect failed' or alarm_info['type'] != '0': raise Exception('告警不正确') # 取消故障注入 fault_inject_pub(container,65541,0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'sensor_state collect failed' or alarm_info['type'] != '1': raise Exception('告警不正确') # 上位机恢复为维护锁车态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') # 下位机进入锁车态 state_machine = chassis_state_change_echo(container) if state_machine != 0: raise Exception('状态机预期为锁车,实际为%d' %state_machine)
def State_change015(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') logging.info('2、模拟pad下发解锁命令' '//上位机进入运营就绪态') communication_control_pub(container, mode='vehicle_state', state='unlock') if state_machine_state_echo(container) != 5: raise Exception('当前状态不为维护锁车')
def State_change017(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') logging.info('2、注入platform_datacollect_ultrasound故障ID 65540' '//上位机进入运营故障态,下位机进入故障态,告警ultrasound collect failed正确') fault_inject_pub(container, 65540, 1) # 上位机20s内进入维护故障 for i in range(10): if state_machine_state_echo(container) != 8: time.sleep(2) else: break if i == 9: raise Exception('上位机未进入故障态') # 下位机进入故障 state_machine = chassis_state_change_echo(container) if state_machine != 4: raise Exception('状态机预期为故障,实际为%d' % state_machine) # 查看产生对应告警 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'ultrasound collect failed' or alarm_info[ 'type'] != '0': raise Exception('告警不正确') # 取消故障注入 fault_inject_pub(container, 65540, 0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['type'] != '1': raise Exception('故障未取消')
def State_change016(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') logging.info('2、注入platform_datacollect_imu故障ID 65538' '//10s内产生正确告警imu collect failed正确,上位机仍为运营锁车态,下位机仍为锁车态') fault_inject_pub(container, 65538, 1) time.sleep(20) # 查看产生对应告警 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'imu collect failed' or alarm_info[ 'type'] != '0': raise Exception('告警不正确') # 查看上位机状态机状态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') # 下位机仍为锁车态 state_machine = chassis_state_change_echo(container) if state_machine != 0: raise Exception('状态机预期为锁车,实际为%d' % state_machine) # 恢复故障 fault_inject_pub(container, 65538, 0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'imu collect failed' or alarm_info[ 'type'] != '1': raise Exception('告警不正确')
def State_change003(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、注入不可自动驾驶故障(数据采集错误,故障ID 65537)' '//状态机状态10秒内不改变') # 注入platform_datacollect_odom故障,id 65537 fault_inject_pub(container, 65537, 1) # 20s内查看产生对应告警 for i in range(5): alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'odom collect failed' or alarm_info[ 'type'] != '0': time.sleep(5) else: break if i == 4: raise Exception('未产生对应告警') # 上位机仍为维护锁车态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') # 下位机为锁车态 state_machine = chassis_state_change_echo(container) if state_machine != 0: raise Exception('状态机预期为锁车,实际为%d' % state_machine) # 取消故障注入 fault_inject_pub(container, 65537, 0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'odom collect failed' or alarm_info[ 'type'] != '1': raise Exception('告警不正确')
def State_change002(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式,下位机进入锁车态') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') # 下位机进入锁车态 state_machine = chassis_state_change_echo(container) if state_machine != 0: raise Exception('状态机预期为锁车,实际为%d' % state_machine) # 恢复为维护模式 communication_control_pub(container, mode='vehicle_mode', state='maintenance') if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车')
def State_change025(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') logging.info('2、下发解锁命令)' '//状态机切换为运营就绪') communication_control_pub(container, mode='vehicle_state', state='unlock') # 查看状态机状态为运营就绪 if state_machine_state_echo(container) != 5: raise Exception('当前状态不为运营就绪') logging.info('3、切换自动驾驶模式' '//上位机状态机为自动驾驶') communication_control_pub(container, mode='vehicle_state', state='auto') # 查看状态机状态为自动驾驶 if state_machine_state_echo(container) != 7: raise Exception('当前状态不为自动驾驶') logging.info('4、注入不可使用故障(数据采集错误,故障ID 65541)' '//状态机切换为运营故障态') # 注入platform_datacollect_sensor_state故障,id65541 fault_inject_pub(container,65541,1) # 上位机20s内进入运营故障 for i in range(10): if state_machine_state_echo(container) != 8: time.sleep(2) else: break if i == 9: raise Exception('上位机未进入故障态') # 下位机进入故障 state_machine = chassis_state_change_echo(container) if state_machine != 4: raise Exception('状态机预期为故障,实际为%d' %state_machine) # 取消故障注入 fault_inject_pub(container,65541,0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'sensor_state collect failed' or alarm_info['type'] != '1': raise Exception('告警不正确')
def State_change022(): logging.info('前置步骤:所有docker均已启动。roscore已运行。已屏蔽所有影响状态机的告警,状态机状态为维护锁车。') tx2 = TX2.TX2(ip) containers = tx2.Containers() container = tx2.Containers()['chassis_serial'] tx2.Images() if len(containers) != 11: raise Exception('docker未全部启动') if not Exec_Run.Exec(container).roscore_check(): raise Exception('roscore未自动启动') # 影响状态机告警为空 if self_check_service(container): raise Exception('存在影响状态机的告警') # 查看上位机状态机状态 if state_machine_state_echo(container) != 0: raise Exception('当前状态不为维护锁车') logging.info('1、切换运营模式' '//上位机进入运营锁车模式') communication_control_pub(container, mode='vehicle_mode', state='operation') # 上位机为运营锁车态 if state_machine_state_echo(container) != 4: raise Exception('当前状态不为运营锁车') logging.info('2、下发解锁命令)' '//状态机切换为运营就绪') communication_control_pub(container, mode='vehicle_state', state='unlock') # 查看状态机状态为运营就绪 if state_machine_state_echo(container) != 5: raise Exception('当前状态不为运营就绪') logging.info('3、注入不可自动驾驶故障(数据采集错误,故障ID 65537)' '//状态机状态10秒内不改变') # 注入platform_datacollect_odom故障,id 65537 fault_inject_pub(container,65537,1) # 10s内状态机不进入故障 time.sleep(10) # 查看产生对应告警 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'odom collect failed' or alarm_info['type'] != '0': raise Exception('告警不正确') # 上位机仍为运营就绪态 if state_machine_state_echo(container) != 5: raise Exception('当前状态不为运营就绪态') # 下位机为就绪态 state_machine = chassis_state_change_echo(container) if state_machine != 1: raise Exception('状态机预期为就绪,实际为%d' %state_machine) # 取消故障注入 fault_inject_pub(container,65537,0) # 查看告警取消的信息 alarm_info = communication_alarm_echo(container) if alarm_info['content'] != 'odom collect failed' or alarm_info['type'] != '1': raise Exception('告警不正确')