+
+ # add test results into the final doc template
+ for report in ${RES_DIR}/${TEST_REPORT_PARTIAL} ; do
+ # modify link to the artifactory with test report and logs
+ if [ -f $report ] ; then
+ sed -i -e "s,$TEST_REPORT_LINK_OLD,$TEST_REPORT_LINK_NEW," "$report"
+ cp $report $TEST_REPORT_DIR
+ echo " $(basename $report)" >> $TEST_REPORT_INDEX
+ fi
+ done
+
+ # copy logs into dedicated directory
+ mkdir ${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}
+ [ -f "$LOG_FILE" ] && cp -a "${LOG_FILE}" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
+ [ -d "$RES_DIR" ] && cp -ar "$RES_DIR" "${TEST_REPORT_LOG_DIR}/${LOG_SUBDIR}" &> /dev/null
+}
+
+# generates final test_report in PDF and HTML formats
+function generate_report() {
+
+ # prepare final tarball with all logs...
+ tar --exclude "${TEST_REPORT_TARBALL}" -czf "${TEST_REPORT_LOG_DIR}/${TEST_REPORT_TARBALL}" $(find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d)
+ # ...and remove original log files
+ find "${TEST_REPORT_LOG_DIR}" -mindepth 1 -maxdepth 1 -type d -exec rm -rf \{\} \;
+
+ # clone releng repository
+ echo "Cloning releng repository..."
+ [ -d releng ] && rm -rf releng
+ git clone https://gerrit.opnfv.org/gerrit/releng &> /dev/null
+
+ # generate final docs with test results
+ echo "Generating test report..."
+ sed -ie 's,python ,python2 ,g' ./releng/utils/docs-build.sh
+ ./releng/utils/docs-build.sh &> /dev/null
+
+ # store PDF with test results into dedicated directory
+ if [ -f $TEST_REPORT_FILE ] ; then
+ cp -a $TEST_REPORT_FILE $TEST_REPORT_LOG_DIR
+ echo "Final test report has been created."
+ else
+ echo "FAILURE: Generation of final test report has failed."
+ fi
+}
+
+# pushes test report and logs collected during test execution into artifactory
+function push_results_to_artifactory() {
+ echo "Pushing results and logs into artifactory..."
+ . ./releng/utils/push-test-logs.sh "$DATE"
+
+ # enter workspace as it could be modified by 3rd party script
+ cd $WORKSPACE
+}
+
+# removes any local changes of repository
+function cleanup() {
+ echo "Cleaning up..."
+ git stash -u
+}
+
+# prepares directory for logs collection and removes old logs
+function initialize_logdir() {
+ if [[ "x$TEST_REPORT_LOG_DIR" == "x" ]] ; then
+ echo "FAILURE: Logging directory is not defined. Logs and report cannot be published!"
+ exit $EXIT_NO_TEST_REPORT_LOG_DIR
+ else
+ # remove TEST_REPORT_LOG_DIR if it exists
+ if [ -e $TEST_REPORT_LOG_DIR ] ; then
+ if [ -f $TEST_REPORT_LOG_DIR ] ; then
+ rm $TEST_REPORT_LOG_DIR
+ else
+ rm -rf ${TEST_REPORT_LOG_DIR}
+ fi
+ fi
+ # create TEST_REPORT_LOG_DIR
+ mkdir -p $TEST_REPORT_LOG_DIR
+ fi