From 77eb3e2b5bba2831d03f555a8499b01027ea9daa Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sat, 4 Jun 2016 10:48:06 -0400 Subject: [PATCH] tests: Introduce "vmcheck" This is infrastructure that's oriented around Vagrant, we do builds inside the target VM (actually inside a Docker container), but then directly `make install DESTDIR=/host/`. The goal here is to have a convenient workflow for: - dev -> hand testing - dev -> run destructive tests Closes: #303 Approved by: jlebon --- Vagrantfile | 8 +++++- tests/vmcheck/Dockerfile.builder | 13 +++++++++ tests/vmcheck/Makefile | 17 ++++++++++++ tests/vmcheck/README.md | 30 +++++++++++++++++++++ tests/vmcheck/atomic-centos-continuous.repo | 4 +++ tests/vmcheck/host-install.sh | 12 +++++++++ tests/vmcheck/setup.yml | 18 +++++++++++++ 7 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/vmcheck/Dockerfile.builder create mode 100644 tests/vmcheck/Makefile create mode 100644 tests/vmcheck/README.md create mode 100644 tests/vmcheck/atomic-centos-continuous.repo create mode 100755 tests/vmcheck/host-install.sh create mode 100644 tests/vmcheck/setup.yml diff --git a/Vagrantfile b/Vagrantfile index 3028dc8a..09d88ab0 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -10,5 +10,11 @@ Vagrant.configure(2) do |config| config.vm.box = "centos/atomic-host" config.vm.hostname = "centosah-dev" - config.vm.synced_folder ".", "/srv/vagrant", disabled: true + + config.vm.provision "ansible" do |ansible| + ansible.playbook = "tests/vmcheck/setup.yml" + ansible.host_key_checking = false + ansible.extra_vars = { ansible_ssh_user: 'vagrant' } + ansible.raw_ssh_args = ['-o ControlMaster=no'] + end end diff --git a/tests/vmcheck/Dockerfile.builder b/tests/vmcheck/Dockerfile.builder new file mode 100644 index 00000000..53e3c121 --- /dev/null +++ b/tests/vmcheck/Dockerfile.builder @@ -0,0 +1,13 @@ +FROM centos/tools +ADD atomic-centos-continuous.repo /etc/yum.repos.d/atomic-centos-continuous.repo +RUN yum -y install yum-plugin-priorities sudo && \ + yum -y install bash bzip2 coreutils cpio diffutils system-release findutils gawk gcc gcc-c++ \ + grep gzip info make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip util-linux \ + which xz python gcc \ + && yum-builddep -y rpm-ostree +RUN groupadd -g 1000 vagrant && useradd -u 1000 -g vagrant -G wheel vagrant +RUN echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers +ADD host-install.sh /usr/local/bin/host-install +LABEL RUN "/usr/bin/docker run --privileged -ti -v /var/home:/home -v /etc:/host/etc -v /usr:/host/usr \${IMAGE}" +USER vagrant +WORKDIR /home/vagrant/sync diff --git a/tests/vmcheck/Makefile b/tests/vmcheck/Makefile new file mode 100644 index 00000000..9ca00dbb --- /dev/null +++ b/tests/vmcheck/Makefile @@ -0,0 +1,17 @@ +all: + echo "Targets: buildimg build install" + +buildimg: + sudo docker build -t rpm-ostree-builder -f Dockerfile.builder . + +runbuilder=sudo /usr/bin/docker run --privileged -ti -v /var/home:/home -v /etc:/host/etc -v /usr:/host/usr rpm-ostree-builder + +build: + $(runbuilder) /bin/sh -c 'if ! test -f configure; then env NOCONFIGURE=1 ./autogen.sh; fi' + $(runbuilder) /bin/sh -c 'if ! test -f Makefile; then ./configure --prefix=/usr --libdir=/usr/lib64; fi' + $(runbuilder) /bin/sh -c make -j 4 + +install: build + $(runbuilder) sudo /usr/local/bin/host-install + + diff --git a/tests/vmcheck/README.md b/tests/vmcheck/README.md new file mode 100644 index 00000000..a362cf48 --- /dev/null +++ b/tests/vmcheck/README.md @@ -0,0 +1,30 @@ +Using vmcheck +============= + +One time setup: + +``` +host$ vagrant up +host$ vagrant ssh +vm$ sudo rpm-ostree rebase centos-atomic-continuous:centos-atomic-host/7/x86_64/devel/continuous +vm$ systemctl reboot +``` + +Edit source code on the host system; to synchronize, use: + +``` +vagrant rsync +``` + +To build and install into the VM: + +``` + +host$ vagrant ssh +vm$ cd ~/sync/tests/vmcheck +vm$ make build +vm$ make install +vm$ systemctl restart rpm-ostreed +``` + + diff --git a/tests/vmcheck/atomic-centos-continuous.repo b/tests/vmcheck/atomic-centos-continuous.repo new file mode 100644 index 00000000..f243396a --- /dev/null +++ b/tests/vmcheck/atomic-centos-continuous.repo @@ -0,0 +1,4 @@ +[atomic-centos-continuous] +baseurl=https://ci.centos.org/artifacts/sig-atomic/rdgo/centos-continuous/build +gpgcheck=0 +priority=1 diff --git a/tests/vmcheck/host-install.sh b/tests/vmcheck/host-install.sh new file mode 100755 index 00000000..d9410e90 --- /dev/null +++ b/tests/vmcheck/host-install.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -xeuo pipefail +eval $(findmnt /host/usr -o OPTIONS -P) +(IFS=,; + for x in ${OPTIONS}; do + if test ${x} == "ro"; then + mount -o remount,rw /host/usr + break + fi + done) +make install DESTDIR=/host/ + diff --git a/tests/vmcheck/setup.yml b/tests/vmcheck/setup.yml new file mode 100644 index 00000000..165d6fcd --- /dev/null +++ b/tests/vmcheck/setup.yml @@ -0,0 +1,18 @@ +--- +- hosts: all + become: yes + tasks: + - command: ostree remote add --set=gpg-verify=false centos-atomic-continuous https://ci.centos.org/artifacts/sig-atomic/rdgo/centos-continuous/ostree/repo/ + args: + creates: /etc/ostree/remotes.d/centos-atomic-continuous.conf + + - command: docker inspect rpm-ostree-builder + failed_when: False + changed_when: False + register: inspect + + - name: build buildimg + command: make buildimg + args: + chdir: sync/tests/vmcheck + when: inspect.rc != 0