add test-nspawn and Jenkinsfile (#21758)

This commit is contained in:
Christophe Siraut 2019-10-03 12:58:37 +02:00
parent 7fa64db161
commit 9b2ca13078
2 changed files with 48 additions and 0 deletions

23
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,23 @@
@Library('eo-jenkins-lib@master') import eo.Utils
pipeline {
agent any
stages {
stage('Unit Tests') {
steps {
sh 'sudo ./test-nspawn buster'
}
}
}
post {
always {
script {
utils = new Utils()
utils.mail_notify(currentBuild, env, 'ci+jenkins-publik-devinst@entrouvert.org')
}
}
success {
cleanWs()
}
}
}

25
test-nspawn Executable file
View File

@ -0,0 +1,25 @@
#!/bin/sh
set -ex
if [ $1 = 'buster' ]
then
suite=$1
image=publik-devinst-$suite
fs=/var/lib/machines/$image
test -d $fs || (cd /var/lib/machines && debootstrap --include=systemd-container $suite $image http://deb.debian.org/debian/)
rsync -a --delete . $fs/opt/publik-devinst
sudo systemd-nspawn -x -D $fs /opt/publik-devinst/test-nspawn run-tests
elif [ $1 = 'run-tests' ]
then
apt update
apt install -y wget ca-certificates gnupg2 git ansible postgresql sudo python python-psycopg2 python3
adduser --disabled-password --gecos "" testuser
usermod -a -G sudo testuser
echo 'testuser ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
chown -R testuser /opt/publik-devinst
/usr/bin/wget https://deb.entrouvert.org/entrouvert.gpg
apt-key add entrouvert.gpg
apt update
/etc/init.d/postgresql start
su testuser -l -c 'cd /opt/publik-devinst; ansible-playbook -i inventory.yml -e "{postgresql_port: 5433}" install.yml'
fi