Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test car models: fix random hanging #1055

Merged
merged 5 commits into from Feb 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 20 additions & 14 deletions selfdrive/test/test_car_models.py
Expand Up @@ -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 = {

Expand Down Expand Up @@ -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

Expand All @@ -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 = []
Expand Down
13 changes: 7 additions & 6 deletions tools/replay/unlogger.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down