Skip to content

Commit

Permalink
Let backup handle docker name different than master
Browse files Browse the repository at this point in the history
Signed-off-by: Corentin LABBE <[email protected]>
  • Loading branch information
montjoie committed Jan 8, 2025
1 parent 106a7c2 commit a71508b
Show file tree
Hide file tree
Showing 4 changed files with 89 additions and 3 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,27 @@ jobs:
run: cd output/local && docker compose up -d
- name: Wait for LAVA 2023.10 to be started
run: sh .github/workflows/wait-for-docker.sh
test-backup:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: install lavacli
run: sudo apt-get -y install lavacli
- name: test valid and invalid usage of backup.sh
run: |
./backup.sh -n && exit 1
./backup.sh -h || exit 1
./backup.sh --help || exit 1
- run: ./lavalab-gen.py boards-ci-testbackup.yaml
- name: Build lava-docker
run: cd output/local && docker compose build
- name: Launch lava-docker
run: cd output/local && docker compose up -d
- name: Wait for LAVA to be started
run: sh .github/workflows/wait-for-docker.sh central
- name: Run backup
run: ./backup.sh -n central
- name: Check backup
run: |
pwd
ls -l backup-latest
11 changes: 9 additions & 2 deletions .github/workflows/wait-for-docker.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
#!/bin/sh

DOCKERNAME=master
if [ ! -z "$1" ];then
DOCKERNAME=$1
echo "DEBUG: master name is $DOCKERNAME"
fi

cd output/local

TIMEOUT=0
Expand All @@ -24,12 +30,13 @@ do
fi
docker compose logs --tail=60
docker ps > /tmp/alldocker
grep -q master /tmp/alldocker
grep -q $DOCKERNAME /tmp/alldocker
if [ $? -ne 0 ];then
echo "=========================================="
echo "=========================================="
echo "=========================================="
echo "ERROR: master died"
echo "ERROR: master $DOCKERNAME died"
docker ps
docker compose logs
exit 1
fi
Expand Down
31 changes: 30 additions & 1 deletion backup.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,46 @@
#!/bin/sh

DOCKERNAME=master
BACKUP_DIR="backup-$(date +%Y%m%d_%H%M)"
# use /tmp by default on host (this is used by tar)
TMPDIR=${TMPDIR:-/tmp}
export TMPDIR

usage() {
echo "$0 [-h|--help] [-n dockername]"
}

while [ $# -ge 1 ]
do
case $1 in
-h)
usage
exit 0
;;
--help)
usage
exit 0
;;
-n)
shift
DOCKERNAME=$1
shift
;;
*)
usage
exit 1
;;
esac
done

mkdir -p $TMPDIR

mkdir $BACKUP_DIR
cp boards.yaml $BACKUP_DIR

DOCKERID=$(docker ps |grep master | cut -d' ' -f1)
DOCKERID=$(docker ps |grep "$DOCKERNAME" | cut -d' ' -f1)
if [ -z "$DOCKERID" ];then
echo "ERROR: unable to find docker named $DOCKERNAME"
exit 1
fi

Expand Down
26 changes: 26 additions & 0 deletions boards-ci-testbackup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
masters:
- name: central
host: local
users:
- name: admin
token: tokenforci
password: passwordforci
superuser: true
staff: true
tokens:
- username: admin
token: dfjdfkfkdjfkdsjfslforci
description: no description

slaves:
- name: lab-ci-0
host: local
remote_master: central
remote_user: admin
use_overlay_server: false
use_tftp: false

boards:
- name: qemu-01
type: qemu

0 comments on commit a71508b

Please sign in to comment.