mavsdk_tests: remove waitforgz helper, add sleep

This is an attempt to workaround the gz spawn timeout in CI.
Let's just hard-code a sleep before spawning the model.
This commit is contained in:
Julian Oes 2020-04-08 15:13:18 +02:00
parent 0a7cde4819
commit 54fe3c5fd5
3 changed files with 6 additions and 39 deletions

View File

@ -9,6 +9,7 @@ import psutil # type: ignore
import signal
import subprocess
import sys
import time
from logger_helper import color, colorize
import process_helper as ph
from typing import Any, Dict, List, NoReturn, TextIO, Optional
@ -382,14 +383,6 @@ class Tester:
self.verbose)
self.active_runners.append(gzserver_runner)
waitforgz_runner = ph.WaitforgzRunner(
os.getcwd(),
log_dir,
test['model'],
case,
self.verbose)
self.active_runners.append(waitforgz_runner)
gzmodelspawn_runner = ph.GzmodelspawnRunner(
os.getcwd(),
log_dir,
@ -428,6 +421,11 @@ class Tester:
.format(runner.name))
break
# Workaround to prevent gz not being able to communicate
# with gzserver
if runner.name == "gzserver":
time.sleep(10)
if abort:
self.stop_runners()
sys.exit(1)

View File

@ -6,7 +6,6 @@ import os
import atexit
import subprocess
import threading
import pathlib
import errno
from typing import Any, Dict, List, TextIO, Optional
@ -31,7 +30,6 @@ class Runner:
self.start_time = time.time()
self.log_dir = log_dir
self.log_filename = ""
self.wait_until_complete = False
self.stop_thread: Any[threading.Event] = None
def set_log_filename(self, log_filename: str) -> None:
@ -62,11 +60,6 @@ class Runner:
self.stop_thread = threading.Event()
self.thread = threading.Thread(target=self.process_output)
self.thread.start()
if self.wait_until_complete:
timeout_s = 10.0
if self.wait(timeout_s) != 0:
raise TimeoutError("Command '{}' not completed within {}"
.format(self.cmd, timeout_s))
def process_output(self) -> None:
assert self.process.stdout is not None
@ -211,24 +204,6 @@ class GzserverRunner(Runner):
self.env[var] = os.environ[var]
class WaitforgzRunner(Runner):
def __init__(self,
workspace_dir: str,
log_dir: str,
model: str,
case: str,
verbose: bool):
super().__init__(log_dir, model, case, verbose)
self.name = "waitforgz"
self.cwd = workspace_dir
self.env = {"PATH": os.environ['PATH'],
"HOME": os.environ['HOME']}
script_dir = pathlib.Path(__file__).parent.absolute()
self.cmd = os.path.join(script_dir, "waitforgz.sh")
self.args = []
self.wait_until_complete = True
class GzmodelspawnRunner(Runner):
def __init__(self,
workspace_dir: str,
@ -252,7 +227,6 @@ class GzmodelspawnRunner(Runner):
self.model + "/" + self.model + ".sdf",
"--model-name", self.model,
"-x", "1.01", "-y", "0.98", "-z", "0.83"]
self.wait_until_complete = True
class GzclientRunner(Runner):

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
while gz stats -d 0 2>&1 | grep -q "An instance of Gazebo is not running."; do
echo "Gazebo not running yet ..."
done