Skip to content
Permalink
Browse files

test car models: fix random hanging (#1055)

* debug print

* unlogger doesn't need fcamera.hevc

* only need the rlog

* tiemout for log downloading

* try again after timeout
  • Loading branch information
quillford committed Feb 6, 2020
1 parent 0728e57 commit 30dffb486aa04b892fb442315620c82cf5592e3f
Showing with 27 additions and 20 deletions.
  1. +20 −14 selfdrive/test/test_car_models.py
  2. +7 −6 tools/replay/unlogger.py
@@ -38,20 +38,24 @@ def wait_for_sockets(socks, timeout=10.0):
recvd.append(s)
return recvd

def get_route_logs(route_name):
for log_f in ["rlog.bz2", "fcamera.hevc"]:
log_path = os.path.join("/tmp", "%s--0--%s" % (route_name.replace("|", "_"), log_f))
def get_route_log(route_name):
log_path = os.path.join("/tmp", "%s--0--%s" % (route_name.replace("|", "_"), "rlog.bz2"))

if not os.path.isfile(log_path):
log_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/0/%s" % (route_name.replace("|", "/"), log_f)
r = requests.get(log_url)
if not os.path.isfile(log_path):
log_url = "https://commadataci.blob.core.windows.net/openpilotci/%s/0/%s" % (route_name.replace("|", "/"), "rlog.bz2")

if r.status_code == 200:
with open(log_path, "wb") as f:
f.write(r.content)
else:
print("failed to download test log %s" % route_name)
sys.exit(-1)
# if request fails, try again once and let it throw exception if fails again
try:
r = requests.get(log_url, timeout=15)
except:
r = requests.get(log_url, timeout=15)

if r.status_code == 200:
with open(log_path, "wb") as f:
f.write(r.content)
else:
print("failed to download test log %s" % route_name)
sys.exit(-1)

routes = {

@@ -490,7 +494,9 @@ def get_route_logs(route_name):
results = {}
for route, checks in routes.items():
if route not in non_public_routes:
get_route_logs(route)
print("GETTING ROUTE LOGS")
get_route_log(route)
print("DONE GETTING ROUTE LOGS")
elif "UNLOGGER_PATH" not in os.environ:
continue

@@ -512,7 +518,7 @@ def get_route_logs(route_name):
unlogger_cmd = [os.path.join(BASEDIR, os.environ['UNLOGGER_PATH']), route]
else:
unlogger_cmd = [os.path.join(BASEDIR, 'tools/replay/unlogger.py'), route, '/tmp']
unlogger = subprocess.Popen(unlogger_cmd + ['--disable', 'frame,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl,carEvents,carParams', '--no-interactive'], preexec_fn=os.setsid)
unlogger = subprocess.Popen(unlogger_cmd + ['--disable', 'frame,encodeIdx,plan,pathPlan,liveLongitudinalMpc,radarState,controlsState,liveTracks,liveMpc,sendcan,carState,carControl,carEvents,carParams', '--no-interactive'], preexec_fn=os.setsid)

print("Check sockets")
extra_socks = []
@@ -68,7 +68,7 @@ def run(self, commands_address, data_address, pub_types):
while True:
while poller.poll(0.) or route is None:
cookie, cmd = commands_socket.recv_pyobj()
route = self._process_commands(cmd, route)
route = self._process_commands(cmd, route, pub_types)

# **** get message ****
self._read_logs(cookie, pub_types)
@@ -121,18 +121,19 @@ def _send_logs(self, data_socket):
data_socket.send_pyobj((cookie, typ, msg.logMonoTime, route_time), flags=zmq.SNDMORE)
data_socket.send(smsg.to_bytes(), copy=False)

def _process_commands(self, cmd, route):
def _process_commands(self, cmd, route, pub_types):
seek_to = None
if route is None or (isinstance(cmd, SetRoute) and route.name != cmd.name):
seek_to = cmd.start_time
route = Route(cmd.name, cmd.data_dir)
self._lr = MultiLogIterator(route.log_paths(), wraparound=True)
if self._frame_reader is not None:
self._frame_reader.close()
# reset frames for a route
self._frame_id_lookup = {}
self._frame_reader = RouteFrameReader(
route.camera_paths(), None, self._frame_id_lookup, readahead=True)
if "frame" in pub_types or "encodeIdx" in pub_types:
# reset frames for a route
self._frame_id_lookup = {}
self._frame_reader = RouteFrameReader(
route.camera_paths(), None, self._frame_id_lookup, readahead=True)

# always reset this on a seek
if isinstance(cmd, SeekRelativeTime):

0 comments on commit 30dffb4

Please sign in to comment.
You can’t perform that action at this time.