Add run_tempest.sh
We need to have own method to run tests for our pipeline
Change-Id: I17da3ba3c46f9277c880320f2dfc3fe2430c6c41
diff --git a/Dockerfile b/Dockerfile
index a26565c..20a1f76 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -77,6 +77,8 @@
pip install --constraint /var/lib/openstack_requirements/upper-constraints.txt -r requirements.txt ; \
pip install . ; popd;
+RUN pip install junitxml
+
# Cleanup.
RUN apt-get -y purge libx11-data xauth libxmuu1 libxcb1 libx11-6 libxext6 \
ppp pppconfig pppoeconf popularity-contest cpp gcc g++ libssl-doc
@@ -85,6 +87,9 @@
RUN rm -rf /var/lib/apt/lists/*
#
COPY bin/entrypoint.sh /usr/bin/entrypoint.sh
+COPY bin/run_tempest.sh /usr/bin/run-tempest
+
+ENV LOG_DIR='/root/tempest'
WORKDIR /var/lib/tempest/
ENTRYPOINT ["/usr/bin/entrypoint.sh"]
diff --git a/bin/run_tempest.sh b/bin/run_tempest.sh
new file mode 100755
index 0000000..f9852f6
--- /dev/null
+++ b/bin/run_tempest.sh
@@ -0,0 +1,27 @@
+#!/bin/bash -xe
+
+if [ ! -f /etc/tempest/tempest.conf ]
+then
+ echo "Please put your tempest.conf file to /etc/tempest/"
+ exit 1
+fi
+
+if [ -n "${REPORT_SUFFIX}" ]
+then
+ report="report_${REPORT_SUFFIX}"
+else
+ report='report_'`date +%F_%H-%M`
+fi
+
+log=$LOG_DIR/$report.log
+
+cd $LOG_DIR
+rm -rf env
+tempest init env | tee -a $log
+cd env
+tempest run $PATTERN | tee -a $log
+
+if [[ "$PATTERN" =~ '-r ' || "$PATTERN" =~ '--regex' || "$PATTERN" =~ '-s' ]]; then
+ stestr last --subunit | subunit2junitxml > $LOG_DIR/$report.xml
+fi
+