]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: vstart wrapper helper for unittests
authorLoic Dachary <loic@dachary.org>
Mon, 16 Dec 2013 16:13:27 +0000 (17:13 +0100)
committerLoic Dachary <loic@dachary.org>
Tue, 17 Dec 2013 16:46:23 +0000 (17:46 +0100)
Primarily useful to run scripts from qa/workunits as part of make check.

vstart_wrapper.sh starts a vstart.sh cluster, runs the command given in
argument and tearsdown cluster when it completes.

The vstart_wrapped_tests.sh script contains the list of scripts that
need the vstart_wrapper.sh to run. It would not be necessary if automake
allowed passing argument to tests scripts. It also adds markers to the
output to facilitate searching the output because it can be very verbose.

This wrapper is kept simple and will probably evolve into something more
sophisticated depending on the scripts being added to
vstart_wrapper_tests.sh. There are numerous options, ranging from
parsing the yaml from ceph-qa-suite to figure out the configuration
cluster to converting the same yaml into a puppet manifest that is
applied locally or even driving OpenStack instances to avoid messing
with the local machine. But this would probably be overkill at this
point.

Signed-off-by: Loic Dachary <loic@dachary.org>
src/test/Makefile.am
src/test/vstart_wrapped_tests.sh [new file with mode: 0755]
src/test/vstart_wrapper.sh [new file with mode: 0755]

index e543fd759cc18a04c7e0d987f2eedfbbd673b392..3cd531ef67421fea4cb29fca65292698f418d8a1 100644 (file)
@@ -234,7 +234,8 @@ bin_DEBUGPROGRAMS += ceph_bench_log
 
 check_SCRIPTS += \
        unittest_bufferlist.sh \
-       test/encoding/check-generated.sh
+       test/encoding/check-generated.sh \
+       test/vstart_wrapped_tests.sh
 
 # target to build but not run the unit tests
 unittests:: $(check_PROGRAMS)
diff --git a/src/test/vstart_wrapped_tests.sh b/src/test/vstart_wrapped_tests.sh
new file mode 100755 (executable)
index 0000000..02f582e
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+echo "Run unit tests that need a cluster, using vstart.sh"
+while read line ; do
+  echo "================ START ================"
+  echo "$line"
+  echo "======================================="
+  test/vstart_wrapper.sh $line
+  echo "================ STOP ================="  
+done <<EOF
+EOF
diff --git a/src/test/vstart_wrapper.sh b/src/test/vstart_wrapper.sh
new file mode 100755 (executable)
index 0000000..b9e1772
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright (C) 2013 Cloudwatt <libre.licensing@cloudwatt.com>
+#
+# Author: Loic Dachary <loic@dachary.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Library Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Library Public License for more details.
+#
+function vstart_teardown()
+{
+    ./stop.sh
+}
+
+function vstart_setup()
+{
+    rm -fr dev out
+    mkdir -p dev
+    trap "vstart_teardown ; rm -f $TMPFILE" EXIT
+    export LC_ALL=C # some tests are vulnerable to i18n
+    MON=1 OSD=3 ./vstart.sh -n -X -l mon osd
+    export PATH=.:$PATH
+    export CEPH_CONF=ceph.conf
+}
+
+function main()
+{
+    if [[ $(pwd) =~ /src$ ]] && [ -d .libs ] && [ -d pybind ] ; then
+        vstart_setup
+    else
+        trap "rm -f $TMPFILE" EXIT
+    fi
+    
+    "$@"
+}
+
+main "$@"