Skip to content

Commit

Permalink
jenkins: improve overall robustness (#23117)
Browse files Browse the repository at this point in the history
* test onroad: more reliable log finding

* Update selfdrive/test/test_onroad.py

* write continue.sh in device setup

* clone

* try different delimeter

* try this instead

* fix keys path

* executable

* remove orphaned lock
  • Loading branch information
adeebshihadeh committed Dec 5, 2021
1 parent 8a4ab7f commit 7c291a1
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def phone(String ip, String step_label, String cmd) {
withCredentials([file(credentialsId: 'id_rsa', variable: 'key_file')]) {
def ssh_cmd = """
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'EOF'
ssh -tt -o StrictHostKeyChecking=no -i ${key_file} 'comma@${ip}' /usr/bin/bash <<'END'
set -e
Expand Down Expand Up @@ -29,7 +29,7 @@ cd ${env.TEST_DIR} || true
${cmd}
exit 0
EOF"""
END"""

sh script: ssh_cmd, label: step_label
}
Expand Down
31 changes: 30 additions & 1 deletion selfdrive/test/setup_device_ci.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/usr/bin/bash -e
#!/usr/bin/bash

set -e

if [ -z "$SOURCE_DIR" ]; then
echo "SOURCE_DIR must be set"
Expand All @@ -24,8 +26,35 @@ if [ -f "/EON" ]; then
rm -rf /data/safe_staging
fi

export KEYS_PATH="/usr/comma/setup_keys"
export CONTINUE_PATH="/data/continue.sh"
if [ -f "/EON" ]; then
export KEYS_PATH="/data/data/com.termux/files/home/setup_keys"
export CONTINUE_PATH="/data/data/com.termux/files/continue.sh"
fi
tee $CONTINUE_PATH << EOF
#!/usr/bin/bash
PARAMS_ROOT="/data/params/d"
while true; do
mkdir -p \$PARAMS_ROOT
cp $KEYS_PATH \$PARAMS_ROOT/GithubSshKeys
echo -n 1 > \$PARAMS_ROOT/SshEnabled
sleep 1m
done
sleep infinity
EOF
chmod +x $CONTINUE_PATH

# set up environment
if [ ! -d "$SOURCE_DIR" ]; then
git clone https://github.com/commaai/openpilot.git $SOURCE_DIR
fi
cd $SOURCE_DIR

rm -f .git/index.lock
git reset --hard
git fetch
find . -maxdepth 1 -not -path './.git' -not -name '.' -not -name '..' -exec rm -rf '{}' \;
Expand Down
25 changes: 13 additions & 12 deletions selfdrive/test/test_onroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,21 +138,18 @@ def setUpClass(cls):
cls.lr = list(LogReader(os.path.join(segs[-1], "rlog.bz2")))
return

# setup env
os.environ['REPLAY'] = "1"
os.environ['SKIP_FW_QUERY'] = "1"
os.environ['FINGERPRINT'] = "TOYOTA COROLLA TSS2 2019"

params = Params()
params.clear_all()
set_params_enabled()

# Make sure athena isn't running
Params().delete("DongleId")
Params().delete("AthenadPid")
os.system("pkill -9 -f athena")

logger_root = Path(ROOT)
initial_segments = set()
if logger_root.exists():
initial_segments = set(Path(ROOT).iterdir())

# start manager and run openpilot for a minute
try:
manager_path = os.path.join(BASEDIR, "selfdrive/manager/manager.py")
Expand All @@ -164,15 +161,19 @@ def setUpClass(cls):
sm.update(1000)

# make sure we get at least two full segments
route = None
cls.segments = []
with Timeout(300, "timed out waiting for logs"):
while route is None:
route = params.get("CurrentRoute", encoding="utf-8")
time.sleep(0.1)

while len(cls.segments) < 3:
new_paths = set()
if logger_root.exists():
new_paths = set(logger_root.iterdir()) - initial_segments
segs = [p for p in new_paths if "--" in str(p)]
segs = set()
if Path(ROOT).exists():
segs = set(Path(ROOT).glob(f"{route}--*"))
cls.segments = sorted(segs, key=lambda s: int(str(s).rsplit('--')[-1]))
time.sleep(5)
time.sleep(2)

finally:
proc.terminate()
Expand Down

0 comments on commit 7c291a1

Please sign in to comment.