Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fa2e84caa80053db…
Commit: fa2e84caa80053dbc5a8b42d2d3e2e1492736243
Parent: f96c310eea7e4f6a6cc567e2f5b52a2d1f5f4c90
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sun Jun 29 17:37:35 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:19 2015 +0100
NIX: Re-work VM monitoring.
---
nix/default.nix | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index c73ec29..19df6e8 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -1,3 +1,4 @@
+# -*- mode: nix; indent-tabs-mode: nil -*-
{ nixpkgs ? <nixpkgs>, lvm2Src, release ? false,
rawhide32 ? "" , rawhide64 ? "" ,
fc20_32_updates ? "", fc20_64_updates ? "",
@@ -72,34 +73,42 @@ let
counter=0
rm -f j.current j.last t.current t.last
while true; do
+ if ! test -f pid; then
+ counter=0
+ sleep 60
+ continue
+ fi
+
cat xchg/results-ndev/journal xchg/results-udev/journal > j.current 2> /dev/null
cat xchg/results-ndev/timestamp xchg/results-udev/timestamp > t.current 2> /dev/null
- # the journal didn't change for 10 minutes, kill the VM
- if diff j.current j.last > /dev/null 2> /dev/null; then
+ if diff j.current j.last >& /dev/null; then
counter=$(($counter + 1));
else
counter=0
fi
- if test $counter -eq 10 || diff t.current t.last > /dev/null 2> /dev/null; then
- kill $1
- sleep 3600 # wait for the parent to kill us
+ if test $counter -eq 10 || diff t.current t.last >& /dev/null; then
+ echo
+ echo "VM got stuck; timestamps: $(cat t.current) $(cat t.last), counter = $counter."
+ echo "last journal entry: $(tail -n 1 j.current), previously $(tail -n 1 j.last)"
+ kill -- -$(cat pid)
fi
sleep 60
- mv j.current j.last
- mv t.current t.last
+ mv j.current j.last >& /dev/null
+ mv t.current t.last >& /dev/null
done
}
- for i in seq 1 20; do # we allow up to 20 VM restarts
+ monitor &
+
+ for i in `seq 1 20`; do # we allow up to 20 VM restarts
${vmtools.qemu}/bin/qemu-img create -f qcow2 /dev/shm/testdisk.img 4G
setsid bash -e ${vmtools.vmRunCommand (vmtools.qemuCommandLinux kernel)} &
pid=$!
- sleep 60 # give the VM some time to get up and running
- monitor $pid &
- mon=$!
+ sleep 180 # give the VM some time to get up and running
+ echo $pid > pid # monitor go
wait $pid || true
- kill $mon
+ rm -f pid # disarm the monitor process
# if we have any new results, stash them
mv xchg/results-*'/'*.txt $out/test-results/ || true
@@ -109,7 +118,7 @@ let
break
fi
- sleep 5 # wait for the VM to clean up before starting up a new one
+ sleep 10 # wait for the VM to clean up before starting up a new one
done
cat xchg/results-ndev/list xchg/results-udev/list > $out/test-results/list || true
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2b6f9152ccbc74ab…
Commit: 2b6f9152ccbc74ab4c599089dc6bf0ae43ccd123
Parent: 285db7a240229e17fabaaf03ad9febd90afe8a8e
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Sat Jun 28 11:16:22 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:19 2015 +0100
NIX: Adapt to the append-based test journal.
---
nix/default.nix | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index 9b466ba..843440e 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -16,7 +16,7 @@ let
#!/bin/bash
export PATH=/usr/bin:/bin:/usr/sbin:/sbin
- # we always run in a fresh image, so need to install everything again
+ # we always run in a fresh image, so need to install everything again
ls ${build}/rpms/*/*.rpm | grep -v sysvinit | xargs rpm -Uvh # */
rpm -Uv ${pkgs.fetchurl {
url = "http://archives.fedoraproject.org/pub/archive/fedora/linux/updates/16/i386/…";
@@ -72,8 +72,9 @@ let
monitor() {
set +e
counter=0
+ rm -f j.current j.last t.current t.last
while true; do
- cat xchg/results-ndev/journal* xchg/results-udev/journal* > j.current 2> /dev/null
+ cat xchg/results-ndev/journal xchg/results-udev/journal > j.current 2> /dev/null
cat xchg/results-ndev/timestamp xchg/results-udev/timestamp > t.current 2> /dev/null
# the journal didn't change for 10 minutes, kill the VM
if diff j.current j.last > /dev/null 2> /dev/null; then
@@ -95,6 +96,7 @@ let
${vmtools.qemu}/bin/qemu-img create -f qcow2 /dev/shm/testdisk.img 4G
setsid bash -e ${vmtools.vmRunCommand (vmtools.qemuCommandLinux kernel)} &
pid=$!
+ sleep 60 # give the VM some time to get up and running
monitor $pid &
mon=$!
@@ -112,8 +114,7 @@ let
sleep 5 # wait for the VM to clean up before starting up a new one
done
- # (ab)use the journals in case the lists weren't actually written yet
- cat xchg/results-ndev/journal xchg/results-udev/journal > $out/test-results/list || true
+ cat xchg/results-ndev/list xchg/results-udev/list > $out/test-results/list || true
'';
};
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=285db7a240229e17…
Commit: 285db7a240229e17fabaaf03ad9febd90afe8a8e
Parent: dcf5182a96c7eb65fe5d61ce5ceea9ba5bf7a3f2
Author: Petr Rockai <prockai(a)redhat.com>
AuthorDate: Fri Jun 27 23:09:30 2014 +0200
Committer: Petr Rockai <prockai(a)redhat.com>
CommitterDate: Thu Feb 5 13:47:19 2015 +0100
NIX: Implement a smarter VM monitoring loop.
---
nix/default.nix | 48 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 38 insertions(+), 10 deletions(-)
diff --git a/nix/default.nix b/nix/default.nix
index bd3d969..9b466ba 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -61,30 +61,58 @@ let
builder = pkgs.writeScript "vm-test" ''
#!${pkgs.bash}/bin/bash
. $stdenv/setup
- set -x
export QEMU_OPTS="-drive file=/dev/shm/testdisk.img,if=virtio -m 256M"
- export KERNEL_OPTS="log_buf_len=131072"
+ export KERNEL_OPTS="log_buf_len=131072 loglevel=1"
export mountDisk=1
mkdir -p $out/test-results $out/nix-support
touch $out/nix-support/failed
- # give it 9x 20 minutes, i.e. about 3 hours
- for i in seq 1 9; do
+ monitor() {
+ set +e
+ counter=0
+ while true; do
+ cat xchg/results-ndev/journal* xchg/results-udev/journal* > j.current 2> /dev/null
+ cat xchg/results-ndev/timestamp xchg/results-udev/timestamp > t.current 2> /dev/null
+ # the journal didn't change for 10 minutes, kill the VM
+ if diff j.current j.last > /dev/null 2> /dev/null; then
+ counter=$(($counter + 1));
+ else
+ counter=0
+ fi
+ if test $counter -eq 10 || diff t.current t.last > /dev/null 2> /dev/null; then
+ kill $1
+ sleep 3600 # wait for the parent to kill us
+ fi
+ sleep 60
+ mv j.current j.last
+ mv t.current t.last
+ done
+ }
+
+ for i in seq 1 20; do # we allow up to 20 VM restarts
${vmtools.qemu}/bin/qemu-img create -f qcow2 /dev/shm/testdisk.img 4G
setsid bash -e ${vmtools.vmRunCommand (vmtools.qemuCommandLinux kernel)} &
pid=$!
- ( sleep 1200 ; kill -- -$pid ) &
- if wait $pid; then
- rm -f $out/nix-support/failed
+ monitor $pid &
+ mon=$!
+
+ wait $pid || true
+ kill $mon
+
+ # if we have any new results, stash them
+ mv xchg/results-*'/'*.txt $out/test-results/ || true
+
+ if test -n "$(cat xchg/in-vm-exit)"; then # the VM is done
+ test 0 -eq "$(cat xchg/in-vm-exit)" && rm -f $out/nix-support/failed
break
fi
- mv xchg/results-*'/'*.txt $out/test-results/
- sleep 5
+
+ sleep 5 # wait for the VM to clean up before starting up a new one
done
- # use journals in case the lists weren't actually written yet
+ # (ab)use the journals in case the lists weren't actually written yet
cat xchg/results-ndev/journal xchg/results-udev/journal > $out/test-results/list || true
'';
};