]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Test whether sample config generation works
authorEric Harney <eharney@redhat.com>
Tue, 18 Aug 2015 21:09:50 +0000 (17:09 -0400)
committerEric Harney <eharney@redhat.com>
Tue, 18 Aug 2015 21:31:01 +0000 (17:31 -0400)
Adds --checkonly to tools/config/check_uptodate.sh.

This allows verifying that a configuration file was
generated.

We have had a number of issues introduced which
have caused config file generation to fail since we
removed the sample config file check in the gate.
This does not add back checks to ensure that the file
has been updated, it only checks to ensure that it is
still possible to update the sample file.

Change-Id: I2e0e376fbdec5a1bb584c6739231649e1d0f5d8e

run_tests.sh
tools/config/check_uptodate.sh
tox.ini

index 09e22e8f285752b709873f07e3c3942eddd0d848..7d5a324480b5742429f707417fbc08b5896ca8b0 100755 (executable)
@@ -184,6 +184,7 @@ function run_pep8 {
   echo "Running flake8 ..."
   warn_on_flake8_without_venv
   bash -c "${wrapper} flake8"
+  ${wrapper} bash tools/config/check_uptodate.sh --checkonly
 }
 
 
index cf51c8caf0d6c923f2ca40dbe51645576acfa34b..89a4a3ec2d79459eee33c0578070b31ebd4fda7e 100755 (executable)
@@ -1,28 +1,44 @@
 #!/usr/bin/env bash
 
+CHECKONLY=0
+if [ "$1" == "--checkonly" ]; then
+    CHECKONLY=1
+fi
+
 PROJECT_NAME=${PROJECT_NAME:-cinder}
 CFGFILE_NAME=${PROJECT_NAME}.conf.sample
 
-if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
-    CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
-elif [ -e etc/${CFGFILE_NAME} ]; then
-    CFGFILE=etc/${CFGFILE_NAME}
-else
-    echo "${0##*/}: can not find config file"
-    exit 1
-fi
 
 TEMPDIR=`mktemp -d /tmp/${PROJECT_NAME}.XXXXXX`
 trap "rm -rf $TEMPDIR" EXIT
 
 tools/config/generate_sample.sh -b ./ -p ${PROJECT_NAME} -o ${TEMPDIR}
 
-if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE}
-then
-   echo "${0##*/}: ${PROJECT_NAME}.conf.sample is not up to date."
-   echo "${0##*/}: Please run ${0%%${0##*/}}generate_sample.sh from within a VENV."
-   echo "  \'source .venv/bin/activate; generate_sample.sh\'"
-   echo "OR simply run tox genconfig"
-   echo "  \'tox -egenconfig\'"
-   exit 1
+# generate_sample.sh may return 0 even when it fails.
+
+if [ $CHECKONLY -eq 1 ]; then
+    # Check whether something was generated.
+    if [ ! -s ${TEMPDIR}/${CFGFILE_NAME} ]; then
+        echo "Failed to generate ${CFGFILE_NAME}."
+        exit 1
+    fi
+else
+    if [ -e etc/${PROJECT_NAME}/${CFGFILE_NAME} ]; then
+        CFGFILE=etc/${PROJECT_NAME}/${CFGFILE_NAME}
+    elif [ -e etc/${CFGFILE_NAME} ]; then
+        CFGFILE=etc/${CFGFILE_NAME}
+    else
+        echo "${0##*/}: can not find config file"
+        exit 1
+    fi
+
+    if ! diff -u ${TEMPDIR}/${CFGFILE_NAME} ${CFGFILE}
+    then
+        echo "${0##*/}: ${PROJECT_NAME}.conf.sample is not up to date."
+        echo "${0##*/}: Please run ${0%%${0##*/}}generate_sample.sh from within a VENV."
+        echo "  \'source .venv/bin/activate; generate_sample.sh\'"
+        echo "OR simply run tox genconfig"
+        echo "  \'tox -egenconfig\'"
+        exit 1
+    fi
 fi
diff --git a/tox.ini b/tox.ini
index dc91a71f5c54c0f0a117bd24a9594cbbbcdf82ca..d74dcc77c8214bca3cda1622f4a5e4bf0129b8c7 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -111,6 +111,7 @@ commands =
   flake8 {posargs} . cinder/common
   # Check that .po and .pot files are valid:
   bash -c "find cinder -type f -regex '.*\.pot?' -print0|xargs -0 -n 1 msgfmt --check-format -o /dev/null"
+  {toxinidir}/tools/config/check_uptodate.sh --checkonly
 
 [testenv:pylint]
 deps = -r{toxinidir}/requirements.txt