WIP: ci: use debvm (#72899) #15

Draft
ecazenave wants to merge 1 commits from wip/72899-debvm into main
2 changed files with 22 additions and 2 deletions

4
Jenkinsfile vendored
View File

@ -7,14 +7,14 @@ pipeline {
stage('Unit Tests (bullseye)') {
steps {
catchError(stageResult: 'FAILURE') {
sh 'sudo ./test-nspawn bullseye'
sh './test-debvm bookworm'
}
}
}
stage('Unit Tests (bookworm)') {
steps {
catchError(stageResult: 'FAILURE') {
sh 'sudo ./test-nspawn bookworm'
sh './test-debvm trixie'
}
}
}

20
test-debvm Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh -ex
# USAGE : ./test-debvm bookworm
if [ $1 = bookworm ] || [ $1 = trixie ]
then
SUITE=$1
debvm-create --release=$SUITE --size=10G --sshkey=$HOME/.ssh/id_rsa.pub -- --include=ca-certificates,gnupg2,linux-image-generic,locales-all,postgresql,sudo,git,ansible,make --hook-dir=/usr/share/mmdebstrap/hooks/9pmount --mode=unshare
debvm-run -g --sshport 2222 -- -daemonize -display none -virtfs "local,path=.,mount_tag=publik-devinst,security_model=none"
debvm-waitssh 2222
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 2222 root@localhost "cd /media/publik-devinst;./test-debvm run-tests"
kill `ps ax | grep "qemu-system-x86_64" | awk 'NR==1{print $1}'`
rm rootfs.ext4
elif [ $1 = 'run-tests' ]
then
adduser --disabled-password --gecos "" testuser
usermod -a -G sudo testuser
echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
PORT=`pg_lsclusters | tail -n1 | awk '{ print $3 }'`
su testuser -l -c 'cd /media/publik-devinst; ansible-playbook -e "postgresql_port=$PORT" -i inventory.yml install.yml'
fi