Merge "Adding GS clenaup for Apex"
authorTim Rozet <trozet@redhat.com>
Thu, 28 Apr 2016 19:12:50 +0000 (19:12 +0000)
committerGerrit Code Review <gerrit@172.30.200.206>
Thu, 28 Apr 2016 19:12:50 +0000 (19:12 +0000)
23 files changed:
jjb/apex/apex.yml
jjb/armband/armband-project-jobs.yml [moved from jjb/armband/armband.yml with 76% similarity]
jjb/armband/build.sh [moved from jjb/armband/armband-build.sh with 100% similarity]
jjb/armband/upload-artifacts.sh [new file with mode: 0755]
jjb/bottlenecks/bottlenecks-ci-jobs.yml
jjb/functest/functest-ci-jobs.yml
jjb/opnfv/opnfv-docker.sh
jjb/opnfv/slave-params.yml
jjb/releng-macros.yaml
utils/test/dashboard/js/opnfv_dashboard_tests_conf.js
utils/test/reporting/functest/default.css [moved from utils/test/reporting/default.css with 100% similarity]
utils/test/reporting/functest/img/weather-clear.png [moved from utils/test/reporting/img/weather-clear.png with 100% similarity]
utils/test/reporting/functest/img/weather-few-clouds.png [moved from utils/test/reporting/img/weather-few-clouds.png with 100% similarity]
utils/test/reporting/functest/img/weather-overcast.png [moved from utils/test/reporting/img/weather-overcast.png with 100% similarity]
utils/test/reporting/functest/img/weather-storm.png [moved from utils/test/reporting/img/weather-storm.png with 100% similarity]
utils/test/reporting/functest/index.html [moved from utils/test/reporting/index.html with 100% similarity]
utils/test/reporting/functest/reporting-status.py [moved from utils/test/reporting/reporting-status.py with 67% similarity]
utils/test/reporting/functest/reporting-tempest.py [moved from utils/test/reporting/reporting-tempest.py with 96% similarity]
utils/test/reporting/functest/reporting-vims.py [moved from utils/test/reporting/reporting-vims.py with 95% similarity]
utils/test/reporting/functest/template/index-status-tmpl.html [moved from utils/test/reporting/index-status-tmpl.html with 88% similarity]
utils/test/reporting/functest/template/index-tempest-tmpl.html [moved from utils/test/reporting/index-tempest-tmpl.html with 100% similarity]
utils/test/reporting/functest/template/index-vims-tmpl.html [moved from utils/test/reporting/index-vims-tmpl.html with 100% similarity]
utils/test/result_collection_api/dashboard/functest2Dashboard.py

index 91f76b5..6dbea1a 100644 (file)
             set -o pipefail
 
             # delete everything that is in $WORKSPACE
-            /bin/rm -rf $WORKSPACE
+            sudo /bin/rm -rf $WORKSPACE
 
 - builder:
     name: 'apex-upload-artifact'
                 DEPLOY_CMD="./deploy.sh -c ${WORKSPACE}/build -r ${WORKSPACE}/build/images/"
                 DEPLOY_FILE="${WORKSPACE}/config/deploy/${DEPLOY_SCENARIO}.yaml"
                 NETWORK_FILE="${WORKSPACE}/config/network/network_settings.yaml"
+                # Make sure python34 is installed
+                if ! rpm -q python34 > /dev/null; then
+                    sudo yum install -y epel-release
+                    if ! sudo yum install -y python34; then
+                        echo "Failed to install python34"
+                        exit 1
+                    fi
+                fi
+                if ! rpm -q python34-PyYAML > /dev/null; then
+                    sudo yum install -y epel-release
+                    if ! sudo yum install -y python34-PyYAML; then
+                        echo "Failed to install python34-PyYAML"
+                        exit 1
+                    fi
+                fi
+                if [ -z ${PYTHONPATH:-} ]; then
+                    export PYTHONPATH=${WORKSPACE}/lib/python
+                else
+                    export PYTHONPATH=$PYTHONPATH:${WORKSPACE}/lib/python
+                fi
             else
                 RPM_LIST=$RPM_INSTALL_PATH
                 for pkg in common undercloud opendaylight-sfc; do
similarity index 76%
rename from jjb/armband/armband.yml
rename to jjb/armband/armband-project-jobs.yml
index 75c0e7a..b40949d 100644 (file)
@@ -9,6 +9,7 @@
 
     jobs:
         - 'armband-verify-{stream}'
+        - 'armband-build-daily-{stream}'
 
     stream:
         - master:
             max-per-node: 1
 
     parameters:
-        - project-parameters:
+        - project-parameter:
             project: '{project}'
         - 'arm-build1-defaults'
-        - choice:
-            name: FORCE_BUILD
-            choices:
-                - 'false'
-                - 'true'
-            description: 'Force build even if there are no changes in the armband repo. Default false'
+        - armband-project-parameter:
+            gs-pathname: '{gs-pathname}'
 
     scm:
         - git-scm:
             branch: '{branch}'
 
     triggers:
-        -pollscm:
+        - pollscm:
             cron: '0 H/4 * * *'
 
     wrappers:
-        -timeout:
+        - timeout:
             timeout: 360
             fail: true
 
     builders:
         - shell:
-            !include-raw-escape: ./armband-build.sh
+            !include-raw-escape: ./build.sh
+        - shell:
+            !include-raw-escape: ./upload-artifacts.sh
 
     publishers:
         - email:
             recipients: josep.puigdemont@enea.com armband@enea.com
+
+########################
+# parameter macros
+########################
+- parameter:
+    name: armband-project-parameter
+    parameters:
+        - string:
+            name: BUILD_DIRECTORY
+            default: $WORKSPACE/build_output
+            description: "Directory where the build artifact will be located upon the completion of the build."
+        - string:
+            name: GS_URL
+            default: artifacts.opnfv.org/$PROJECT{gs-pathname}
+            description: "URL to Google Storage."
+        - choice:
+            name: FORCE_BUILD
+            choices:
+                - 'false'
+                - 'true'
+            description: 'Force build even if there are no changes in the armband repo. Default false'
diff --git a/jjb/armband/upload-artifacts.sh b/jjb/armband/upload-artifacts.sh
new file mode 100755 (executable)
index 0000000..f4e84e9
--- /dev/null
@@ -0,0 +1,86 @@
+#!/bin/bash
+# SPDX-license-identifier: Apache-2.0
+##############################################################################
+# Copyright (c) 2016 Ericsson AB and others.
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+set -o pipefail
+
+# check if we built something
+if [ -f $WORKSPACE/.noupload ]; then
+    echo "Nothing new to upload. Exiting."
+    /bin/rm -f $WORKSPACE/.noupload
+    exit 0
+fi
+
+# source the opnfv.properties to get ARTIFACT_VERSION
+source $WORKSPACE/opnfv.properties
+
+# storing ISOs for verify & merge jobs will be done once we get the disk array
+if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
+    # store ISO locally on NFS first
+    ISOSTORE="/home/jenkins/opnfv/iso_store"
+    if [[ -d "$ISOSTORE" ]]; then
+        # remove all but most recent 3 ISOs first to keep iso_mount clean & tidy
+        cd $ISOSTORE
+        ls -tp | grep -v '/' | tail -n +4 | xargs -d '\n' /bin/rm -f --
+
+        # store ISO
+        echo "Storing latest ISO in local storage"
+        touch .storing
+        /bin/cp -f $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso \
+            $ISOSTORE/opnfv-$OPNFV_ARTIFACT_VERSION.iso
+        rm .storing
+    fi
+fi
+
+# log info to console
+echo "Uploading armband artifacts. This could take some time..."
+echo
+
+echo "Started at $(date)"
+cd $WORKSPACE
+# upload artifact and additional files to google storage
+gsutil cp $BUILD_DIRECTORY/opnfv-$OPNFV_ARTIFACT_VERSION.iso \
+    gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > gsutil.iso.log 2>&1
+gsutil cp $WORKSPACE/opnfv.properties \
+    gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > gsutil.properties.log 2>&1
+if [[ ! "$JOB_NAME" =~ (verify|merge) ]]; then
+    gsutil cp $WORKSPACE/opnfv.properties \
+    gs://$GS_URL/latest.properties > gsutil.latest.log 2>&1
+elif [[ "$JOB_NAME" =~ "merge" ]]; then
+    echo "Uploaded Armband Fuel ISO for a merged change"
+fi
+echo "Ended at $(date)"
+
+gsutil -m setmeta \
+    -h "Content-Type:text/html" \
+    -h "Cache-Control:private, max-age=0, no-transform" \
+    gs://$GS_URL/latest.properties \
+    gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.properties > /dev/null 2>&1
+
+gsutil -m setmeta \
+    -h "Cache-Control:private, max-age=0, no-transform" \
+    gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > /dev/null 2>&1
+
+# disabled errexit due to gsutil setmeta complaints
+#   BadRequestException: 400 Invalid argument
+# check if we uploaded the file successfully to see if things are fine
+gsutil ls gs://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso > /dev/null 2>&1
+if [[ $? -ne 0 ]]; then
+    echo "Problem while uploading artifact!"
+    echo "Check log $WORKSPACE/gsutil.iso.log on the machine where this build is done."
+    exit 1
+fi
+
+echo "Done!"
+echo
+echo "--------------------------------------------------------"
+echo
+echo "Artifact is available as http://$GS_URL/opnfv-$OPNFV_ARTIFACT_VERSION.iso"
+echo
+echo "--------------------------------------------------------"
+echo
index cd1d89a..9d88123 100644 (file)
 
     builders:
         - 'bottlenecks-env-cleanup'
-        - 'bottlenecks-fetch-os-creds'
         - 'bottlenecks-run-suite'
 
     publishers:
 ########################
 # builder macros
 ########################
-- builder:
-    name: bottlenecks-fetch-os-creds
-    builders:
-        - shell:
-            !include-raw ../../utils/fetch_os_creds.sh
-
 - builder:
     name: bottlenecks-env-cleanup
     builders:
             set -e
             [[ $GERRIT_REFSPEC_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
 
-            echo "Bottlenecks: ${SUITE_NAME} running now..."
-
-            # pull latest image
-            docker pull opnfv/bottlenecks:$DOCKER_TAG >$redirect
+            echo "Bottlenecks: to pull image opnfv/bottlenecks:${DOCKER_TAG}"
+            docker pull opnfv/bottlenecks:$DOCKER_TAG >${redirect}
 
-            # run tests by using docker
-            opts="--privileged=true --rm"
+            echo "Bottlenecks: docker start running"
+            opts="--privileged=true -id"
             envs="-e INSTALLER_TYPE=${INSTALLER_TYPE} -e INSTALLER_IP=${INSTALLER_IP} \
                   -e NODE_NAME=${NODE_NAME} -e EXTERNAL_NET=${EXTERNAL_NETWORK} \
                   -e BOTTLENECKS_BRANCH=${BOTTLENECKS_BRANCH} -e GERRIT_REFSPEC_DEBUG=${GERRIT_REFSPEC_DEBUG} \
                   -e BOTTLENECKS_DB_TARGET=${BOTTLENECKS_DB_TARGET} -e PACKAGE_URL=${PACKAGE_URL}"
+            cmd="sudo docker run ${opts} ${envs} opnfv/bottlenecks:${DOCKER_TAG} /bin/bash"
+            echo "Bottlenecks: docker cmd running ${cmd}"
+            ${cmd} >${redirect}
+
+            echo "Bottlenecks: obtain docker id"
+            container_id=$(docker ps | grep "opnfv/bottlenecks:${DOCKER_TAG}" | awk '{print $1}' | head -1)
+            if [ -z ${container_id} ]; then
+                echo "Cannot find opnfv/bottlenecks container ID ${container_id}. Please check if it exists."
+                docker ps -a
+                exit 1
+            fi
+
+            echo "Bottlenecks: to prepare openstack environment"
+            prepare_env="${REPO_DIR}/ci/prepare_env.sh"
+            echo "Bottlenecks: docker cmd running: ${prepare_env}"
+            sudo docker exec ${container_id} ${prepare_env}
+
+            echo "Bottlenecks: to run testsuite ${SUITE_NAME}"
             run_testsuite="${REPO_DIR}/run_tests.sh -s ${SUITE_NAME}"
-            cmd="sudo docker run ${opts} ${envs} opnfv/bottlenecks ${run_testsuite}"
-            echo "Bottlenecks: docker cmd running: ${cmd}"
-            ${cmd}
+            echo "Bottlenecks: docker cmd running: ${run_testsuite}"
+            sudo docker exec ${container_id} ${run_testsuite}
 
 ####################
 # parameter macros
index d691140..a0a1326 100644 (file)
@@ -94,6 +94,9 @@
         - nokia-pod1:
             installer: apex
             <<: *master
+        - arm-pod1:
+            installer: fuel
+            <<: *master
 #--------------------------------
 
     testsuite:
             branch: '{branch}'
 
     builders:
-        - 'functest-cleanup'
-        - 'set-functest-env'
         - 'functest-{testsuite}-builder'
 
 ########################
     builders:
         - shell: |
             #!/bin/bash
-            set +e
-            flags="-s"
-            [[ "$PUSH_RESULTS_TO_DB" == "true" ]] && flags+=" -r"
+            set -e
             echo "Functest: run $FUNCTEST_SUITE_NAME"
-            cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME ${flags}"
+            cmd="${FUNCTEST_REPO_DIR}/docker/run_tests.sh --test $FUNCTEST_SUITE_NAME"
             container_id=$(docker ps -a | grep opnfv/functest | awk '{print $1}' | head -1)
             docker exec $container_id $cmd
 
     builders:
         - shell: |
             #!/bin/bash
-            set +e
+            set -e
             [[ $CI_DEBUG == true ]] && redirect="/dev/stdout" || redirect="/dev/null"
             # labconfig is used only for joid
             labconfig=""
             if [[ ${INSTALLER_TYPE} == 'apex' ]]; then
-                if virsh list | grep instack; then
+                if sudo virsh list | grep instack; then
                     instack_mac=$(sudo virsh domiflist instack | grep default | \
                                   grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
-                elif virsh list | grep undercloud; then
+                elif sudo virsh list | grep undercloud; then
                     instack_mac=$(sudo virsh domiflist undercloud | grep default | \
                                   grep -Eo "[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+")
                 else
                 fi
                 INSTALLER_IP=$(/usr/sbin/arp -e | grep ${instack_mac} | awk {'print $1'})
                 sshkey="-v /root/.ssh/id_rsa:/root/.ssh/id_rsa"
-                sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
-                sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
+                if sudo iptables -C FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
+                    sudo iptables -D FORWARD -o virbr0 -j REJECT --reject-with icmp-port-unreachable
+                fi
+                if sudo iptables -C FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable 2> ${redirect}; then
+                    sudo iptables -D FORWARD -i virbr0 -j REJECT --reject-with icmp-port-unreachable
+                fi
             elif [[ ${INSTALLER_TYPE} == 'joid' ]]; then
                 # If production lab then creds may be retrieved dynamically
                 # creds are on the jumphost, always in the same folder
             cmd="sudo docker run --privileged=true -id ${envs} ${labconfig} ${sshkey} ${res_volume} opnfv/functest:${DOCKER_TAG} /bin/bash"
             echo "Functest: Running docker run command: ${cmd}"
             ${cmd} >${redirect}
-            docker ps -a
+            docker ps -a >${redirect}
             sleep 5
             container_id=$(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | awk '{print $1}' | head -1)
             echo "Container ID=${container_id}"
             echo "Starting the container: docker start ${container_id}"
             docker start ${container_id}
             sleep 5
-            docker ps
+            docker ps >${redirect}
             if [ $(docker ps | grep "opnfv/functest:${DOCKER_TAG}" | wc -l) == 0 ]; then
                 echo "The container opnfv/functest with ID=${container_id} has not been properly started. Exiting..."
                 exit 1
             # Remove existing images if exist
             if [[ ! -z $(docker images | grep opnfv/functest) ]]; then
                 echo "Docker images to remove:"
-                docker images | head -1 && docker images | grep opnfv/functest
+                docker images | head -1 && docker images | grep opnfv/functest >${redirect}
                 image_tags=($(docker images | grep opnfv/functest | awk '{print $2}'))
                 for tag in "${image_tags[@]}"; do
                     echo "Removing docker image opnfv/functest:$tag..."
index 8f44268..702c0ce 100644 (file)
@@ -17,6 +17,14 @@ echo "--------------------------------------------------------"
 echo
 
 
+if [[ -n $(ps -ef|grep 'docker build'|grep -v grep) ]]; then
+    echo "There is already another build process in progress:"
+    echo $(ps -ef|grep 'docker build'|grep -v grep)
+    # Abort this job since it will colide and might mess up the current one.
+    echo "Aborting..."
+    exit 1
+fi
+
 # Remove previous running containers if exist
 if [[ -n "$(docker ps -a | grep $DOCKER_REPO_NAME)" ]]; then
     echo "Removing existing $DOCKER_REPO_NAME containers..."
index 2431ade..2ca4459 100644 (file)
             name: GIT_BASE
             default: https://gerrit.opnfv.org/gerrit/$PROJECT
             description: 'Git URL to use on this Jenkins Slave'
+
+- parameter:
+    name: 'arm-pod1-defaults'
+    parameters:
+        - node:
+            name: SLAVE_NAME
+            description: 'Slave name on Jenkins'
+            allowed-slaves:
+                - arm-pod1
+            default-slaves:
+                - arm-pod1
+        - string:
+            name: GIT_BASE
+            default: https://gerrit.opnfv.org/gerrit/$PROJECT
+            description: 'Git URL to use on this Jenkins Slave'
index 23d174a..7fb4d65 100644 (file)
             # generate and upload lint log
             echo "Running flake8 code on $PROJECT ..."
 
-            echo -e "Flake8 Violations\n-----------------" >> lint.log
-            find . \
+            # Get number of flake8 violations. If none, this will be an
+            # empty string: ""
+            FLAKE_COUNT="$(find . \
                 -path './releng_flake8' -prune -o \
                 -type f -name "*.py" -print | \
-                xargs flake8 --exit-zero --first >> lint.log
+                xargs flake8 --exit-zero -qq --count 2>&1)"
+
+            if [ ! -z $FLAKE_COUNT ]; then
+              echo "Flake8 Violations: $FLAKE_COUNT" >> lint.log
+              find . \
+                  -path './releng_flake8' -prune -o \
+                  -type f -name "*.py" -print | \
+                  xargs flake8 --exit-zero --first >> violation.log
+              SHOWN=$(wc -l violation.log | cut -d' ' -f1)
+              echo -e "First $SHOWN shown\n---" >> lint.log
+              cat violation.log >> lint.log
+              sed -r -i '4,$s/^/ /g' lint.log
+              rm violation.log
+            else
+              echo -e "Flake8 Violations: 0" > lint.log
+            fi
 
             deactivate
 
             set -o xtrace
             export PATH=$PATH:/usr/local/bin/
             if [[ -e lint.log ]] ; then
-                sed -r -i 's/^/ /g' lint.log
                 echo -e "\nposting linting report to gerrit...\n"
                 cat lint.log
                 echo
index 6778332..4d909c8 100644 (file)
@@ -56,13 +56,13 @@ var opnfv_dashboard_testcases = {
 var opnfv_dashboard_installers_pods = {};\r
 opnfv_dashboard_installers_pods['apex'] = ['all','intel-pod7','opnfv-jump-1'];\r
 opnfv_dashboard_installers_pods['compass'] = ['all','huawei-us-deploy-bare-1','huawei-us-deploy-vm-1','huawei-us-deploy-vm2','intel-pod8'];\r
-opnfv_dashboard_installers_pods['fuel'] = ['all','ericsson-pod2','opnfv-jump-2'];\r
+opnfv_dashboard_installers_pods['fuel'] = ['all','ericsson-pod2','opnfv-jump-2','arm-pod1'];\r
 opnfv_dashboard_installers_pods['joid'] = ['all','intel-pod5','intel-pod6','orange-fr-pod2'];\r
 \r
 var opnfv_dashboard_installers_pods_print = {};\r
 opnfv_dashboard_installers_pods_print['apex'] = ['all','intelpod7','opnfvjump1'];\r
 opnfv_dashboard_installers_pods_print['compass'] = ['all','hwusbare1','hwusvm1','hwusvm2','intelpod8'];\r
-opnfv_dashboard_installers_pods_print['fuel'] = ['all','ericssonpod2','opnfvjump2'];\r
+opnfv_dashboard_installers_pods_print['fuel'] = ['all','ericssonpod2','opnfvjump2','armpod1'];\r
 opnfv_dashboard_installers_pods_print['joid'] = ['all','intelpod5','intelpod6','orangefrpod2'];\r
 \r
 var opnfv_dashboard_file_directory = 'res-test';\r
similarity index 67%
rename from utils/test/reporting/reporting-status.py
rename to utils/test/reporting/functest/reporting-status.py
index e15bac9..2eb0f50 100644 (file)
@@ -4,6 +4,7 @@ import jinja2
 import os
 import re
 import requests
+import sys
 import time
 import yaml
 
@@ -12,11 +13,12 @@ functest_test_list = ['vPing', 'vPing_userdata',
                       'Tempest', 'Rally',
                       'ODL', 'ONOS', 'vIMS']
 # functest_test_list = ['vPing']
-# functest_test_list = []
 companion_test_list = ['doctor/doctor-notification', 'promise/promise']
 # companion_test_list = []
 installers = ["apex", "compass", "fuel", "joid"]
-# installers = ["apex"]
+# installers = ["fuel"]
+versions = ["brahmaputra", "master"]
+# versions = ["master"]
 PERIOD = 10
 
 # Correspondance between the name of the test case and the name in the DB
@@ -100,7 +102,7 @@ class TestCase(object):
         self.isRunnable = is_runnable
 
 
-def getApiResults(case, installer, scenario):
+def getApiResults(case, installer, scenario, version):
     case = case.getName()
     results = json.dumps([])
     # to remove proxy (to be removed at the end for local test only)
@@ -109,9 +111,9 @@ def getApiResults(case, installer, scenario):
     # urllib2.install_opener(opener)
     # url = "http://127.0.0.1:8000/results?case=" + case + \
     #       "&period=30&installer=" + installer
-    url = "http://testresults.opnfv.org/testapi/results?case=" + case + \
-          "&period=" + str(PERIOD) + "&installer=" + installer + \
-          "&scenario=" + scenario
+    url = ("http://testresults.opnfv.org/testapi/results?case=" + case +
+           "&period=" + str(PERIOD) + "&installer=" + installer +
+           "&scenario=" + scenario + "&version=" + version)
     request = Request(url)
 
     try:
@@ -124,11 +126,12 @@ def getApiResults(case, installer, scenario):
     return results
 
 
-def getScenarios(case, installer):
+def getScenarios(case, installer, version):
 
     case = case.getName()
     url = "http://testresults.opnfv.org/testapi/results?case=" + case + \
-          "&period=" + str(PERIOD) + "&installer=" + installer
+          "&period=" + str(PERIOD) + "&installer=" + installer + \
+          "&version=" + version
     request = Request(url)
 
     try:
@@ -147,9 +150,9 @@ def getScenarios(case, installer):
 
         for r in test_results:
             # Retrieve all the scenarios per installer
-            if not r['version'] in scenario_results.keys():
-                scenario_results[r['version']] = []
-            scenario_results[r['version']].append(r)
+            if not r['scenario'] in scenario_results.keys():
+                scenario_results[r['scenario']] = []
+            scenario_results[r['scenario']].append(r)
 
     return scenario_results
 
@@ -174,10 +177,10 @@ def getNbtestOk(results):
     return nb_test_ok
 
 
-def getResult(testCase, installer, scenario):
+def getResult(testCase, installer, scenario, version):
 
     # retrieve raw results
-    results = getApiResults(testCase, installer, scenario)
+    results = getApiResults(testCase, installer, scenario, version)
     # let's concentrate on test results only
     test_results = results['test_results']
 
@@ -230,77 +233,79 @@ def getResult(testCase, installer, scenario):
 # ******************************************************************************
 # ******************************************************************************
 
-# as the criteria are all difference, we shall use a common way to indicate
-# the criteria
-# 100 = 100% = all the test must be OK
-# 90 = 90% = all the test must be above 90% of success rate
-# TODO harmonize success criteria
-# some criteria could be the duration, the success rate, the packet loss,...
-# to be done case by case
-# TODo create TestCriteria Object
-
-
 # init just tempest to get the list of scenarios
 # as all the scenarios run Tempest
 tempest = TestCase("Tempest", "functest", -1)
 
 # Retrieve the Functest configuration to detect which tests are relevant
 # according to the installer, scenario
-response = requests.get('https://git.opnfv.org/cgit/functest/plain/testcases/config_functest.yaml')
+cf = "https://git.opnfv.org/cgit/functest/plain/testcases/config_functest.yaml"
+response = requests.get(cf)
 functest_yaml_config = yaml.load(response.text)
 
 print "****************************************"
 print "*   Generating reporting.....          *"
 print "****************************************"
-# For all the installers
-for installer in installers:
-    # get scenarios
-    scenario_results = getScenarios(tempest, installer)
-    scenario_stats = getScenarioStats(scenario_results)
-
-    items = {}
-    # For all the scenarios get results
-    for s, s_result in scenario_results.items():
-        testCases = []
-        # For each scenario declare the test cases
-        # Functest cases
-        for test_case in functest_test_list:
-            testCases.append(TestCase(test_case, "functest"))
-
-        # project/case
-        for test_case in companion_test_list:
-            test_split = test_case.split("/")
-            test_project = test_split[0]
-            test_case = test_split[1]
-            testCases.append(TestCase(test_case, test_project))
-
-        # Check if test case is runnable according to the installer, scenario
-        for test_case in testCases:
-            test_case.checkRunnable(installer, s, functest_yaml_config)
-            # print "testcase %s is %s" % (test_case.getName(),
-            #                              test_case.isRunnable)
-
-        print "--------------------------"
-        print "%s / %s:" % (installer, s)
-        for testCase in testCases:
-            time.sleep(1)
-            if testCase.isRunnable:
-                print "    Searching results for case %s " % testCase.getName()
-                result = getResult(testCase, installer, s)
-                testCase.setCriteria(result)
-                items[s] = testCases
-        print "--------------------------"
-    print "****************************************"
-    templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
-    templateEnv = jinja2.Environment(loader=templateLoader)
-
-    TEMPLATE_FILE = "index-status-tmpl.html"
-    template = templateEnv.get_template(TEMPLATE_FILE)
-
-    outputText = template.render(scenario_stats=scenario_stats,
-                                 items=items,
-                                 installer=installer,
-                                 period=PERIOD)
-
-    with open("index-status-" + installer + ".html", "wb") as fh:
-        fh.write(outputText)
+# For all the versions
+for version in versions:
+    # For all the installers
+    for installer in installers:
+        # get scenarios
+        scenario_results = getScenarios(tempest, installer, version)
+        scenario_stats = getScenarioStats(scenario_results)
+
+        items = {}
+        # For all the scenarios get results
+        for s, s_result in scenario_results.items():
+            testCases = []
+            # For each scenario declare the test cases
+            # Functest cases
+            for test_case in functest_test_list:
+                testCases.append(TestCase(test_case, "functest"))
+
+            # project/case
+            for test_case in companion_test_list:
+                test_split = test_case.split("/")
+                test_project = test_split[0]
+                test_case = test_split[1]
+                testCases.append(TestCase(test_case, test_project))
+
+            # Check if test case is runnable / installer, scenario
+            try:
+                for test_case in testCases:
+                    test_case.checkRunnable(installer, s, functest_yaml_config)
+                    # print "testcase %s is %s" % (test_case.getName(),
+                    #                              test_case.isRunnable)
+                print "--------------------------"
+                print ("installer %s, version %s, scenario %s:" %
+                       (installer, version, s))
+                for testCase in testCases:
+                    time.sleep(1)
+                    if testCase.isRunnable:
+                        print (" Searching results for case %s " %
+                               (testCase.getName()))
+                        result = getResult(testCase, installer, s, version)
+                        testCase.setCriteria(result)
+                        items[s] = testCases
+                print "--------------------------"
+            except:
+                print ("installer %s, version %s, scenario %s" %
+                       (installer, version, s))
+                print "No data available , error %s " % (sys.exc_info()[0])
+
+        print "****************************************"
+        templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
+        templateEnv = jinja2.Environment(loader=templateLoader)
+
+        TEMPLATE_FILE = "./template/index-status-tmpl.html"
+        template = templateEnv.get_template(TEMPLATE_FILE)
+
+        outputText = template.render(scenario_stats=scenario_stats,
+                                     items=items,
+                                     installer=installer,
+                                     period=PERIOD,
+                                     version=version)
+
+        with open("./release/" + version +
+                  "/index-status-" + installer + ".html", "wb") as fh:
+            fh.write(outputText)
@@ -88,12 +88,12 @@ for installer in installers:
     templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
     templateEnv = jinja2.Environment(loader=templateLoader)
 
-    TEMPLATE_FILE = "index-tempest-tmpl.html"
+    TEMPLATE_FILE = "./template/index-tempest-tmpl.html"
     template = templateEnv.get_template(TEMPLATE_FILE)
 
     outputText = template.render(scenario_results=scenario_results,
                                  items=items,
                                  installer=installer)
 
-    with open("index-tempest-" + installer + ".html", "wb") as fh:
+    with open("./release/index-tempest-" + installer + ".html", "wb") as fh:
         fh.write(outputText)
similarity index 95%
rename from utils/test/reporting/reporting-vims.py
rename to utils/test/reporting/functest/reporting-vims.py
index cf43f3e..78ca9f5 100644 (file)
@@ -72,12 +72,12 @@ for installer in installers:
     templateLoader = jinja2.FileSystemLoader(os.path.dirname(os.path.abspath(__file__)))
     templateEnv = jinja2.Environment( loader=templateLoader )
 
-    TEMPLATE_FILE = "index-vims-tmpl.html"
+    TEMPLATE_FILE = "./template/index-vims-tmpl.html"
     template = templateEnv.get_template( TEMPLATE_FILE )
 
     outputText = template.render( scenario_results = scenario_results, step_order = step_order, installer = installer)
 
-    with open("index-vims" + installer + ".html", "wb") as fh:
+    with open("./release/index-vims" + installer + ".html", "wb") as fh:
         fh.write(outputText)
 
 
@@ -18,7 +18,7 @@
     <body>
     <div class="container">
       <div class="masthead">
-        <h3 class="text-muted">Functest status page</h3>
+        <h3 class="text-muted">Functest status page ({{version}})</h3>
         <nav>
           <ul class="nav nav-justified">
             <li class="active"><a href="index.html">Home</a></li>
@@ -37,7 +37,7 @@
         </div>
 
         <div class="scenario-overview">
-            <div class="panel-heading"><h4><b>List of last scenarios run over the last {{period}} days </b></h4></div>
+            <div class="panel-heading"><h4><b>List of last scenarios ({{version}}) run over the last {{period}} days </b></h4></div>
                 <table class="table">
                     <tr>
                         <th width="80%">Scenario</th>
                             {% if test.isRunnable is sameas false -%}
                                 <td>N.R</td>
                             {% elif test.getCriteria() > 2 -%}
-                                <td><img src="./img/weather-clear.png"></td>
+                                <td><img src="../../img/weather-clear.png"></td>
                             {%- elif test.getCriteria() > 1 -%}
-                                <td><img src="./img/weather-few-clouds.png"></td>
+                                <td><img src="../../img/weather-few-clouds.png"></td>
                             {%- elif test.getCriteria() > 0 -%}
-                                <td><img src="./img/weather-overcast.png"></td>
+                                <td><img src="../../img/weather-overcast.png"></td>
                             {%- else -%}
-                                <td><img src="./img/weather-storm.png"></td>
+                                <td><img src="../../img/weather-storm.png"></td>
                             {%- endif %}
                             {%- endfor %}
                         </tr>
index a2ed308..379b932 100644 (file)
@@ -117,12 +117,15 @@ def format_vIMS_for_dashboard(results):
             # Calculate nb of tests run and nb of tests failed
             # vIMS_results = get_vIMSresults(vIMS_test)
             # print vIMS_results
-            if data_test['result'] == "Passed":
-                nbTests += 1
-            elif data_test['result'] == "Failed":
-                nbFailures += 1
-            elif data_test['result'] == "Skipped":
-                nbSkipped += 1
+            try:
+                if data_test['result'] == "Passed":
+                    nbTests += 1
+                elif data_test['result'] == "Failed":
+                    nbFailures += 1
+                elif data_test['result'] == "Skipped":
+                    nbSkipped += 1
+            except:
+                nbTests = 0
 
         new_element.append({'x': data['creation_date'],
                             'y1': nbTests,
@@ -149,10 +152,13 @@ def format_vIMS_for_dashboard(results):
             nbTestsOK = 0
             nbTestsKO = 0
 
-            if data_test['result'] == "Passed":
-                nbTestsOK += 1
-            elif data_test['result'] == "Failed":
-                nbTestsKO += 1
+            try:
+                if data_test['result'] == "Passed":
+                    nbTestsOK += 1
+                elif data_test['result'] == "Failed":
+                    nbTestsKO += 1
+            except:
+                nbTestsOK = 0
 
             nbTests += nbTestsOK + nbTestsKO
             nbFailures += nbTestsKO
@@ -366,7 +372,7 @@ def format_Rally_for_dashboard(results):
     # ********************************
     new_element = []
     for data in results:
-        summary_cursor = len(data)
+        summary_cursor = len(data['details']) - 1
         new_element.append({'x': data['creation_date'],
                             'y': int(data['details'][summary_cursor]['summary']['duration'])})