vIMS test integration and move "push_results_to_db" method 65/2865/3
authorboucherv <valentin.boucher@orange.com>
Wed, 28 Oct 2015 09:07:04 +0000 (10:07 +0100)
committerboucherv <valentin.boucher@orange.com>
Wed, 28 Oct 2015 11:03:54 +0000 (12:03 +0100)
Move "push_results_to_db" method to functest_util
Updated some files for clearwater vIMS functional testing

Change-Id: I21628b063470963e4e4425a0f89fefa33494e40d
Signed-off-by: boucherv <valentin.boucher@orange.com>
docker/Dockerfile
docker/common.sh
docker/prepare_env.sh
testcases/config_functest.yaml
testcases/functest_utils.py
testcases/vPing/CI/libraries/vPing.py

index 59a262d..836598a 100644 (file)
@@ -29,11 +29,13 @@ ENV repos_dir /home/opnfv/repos
 RUN apt-get update && apt-get install -y \
 ssh \
 sshpass \
+curl \
 git \
 gcc \
 wget \
 python-dev \
 python-pip \
+bundler \
 postgresql \
 build-essential \
 libpq-dev \
@@ -53,7 +55,14 @@ RUN git clone https://gerrit.opnfv.org/gerrit/functest ${repos_dir}/functest
 RUN git clone https://gerrit.opnfv.org/gerrit/releng ${repos_dir}/releng
 RUN git clone https://github.com/openstack/rally.git ${repos_dir}/rally
 RUN git clone https://github.com/opendaylight/integration.git ${repos_dir}/odl_integration
+RUN git clone -b stable https://github.com/boucherv-orange/clearwater-live-test ${repos_dir}/vims-test
 
 RUN pip install -r ${repos_dir}/functest/docker/requirements.pip
 
+RUN gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
+RUN curl -L https://get.rvm.io | bash -s stable
+RUN bash -c 'source /etc/profile.d/rvm.sh ; rvm autolibs enable ; rvm install 1.9.3 ; rvm use 1.9.3'
+RUN bash -c 'source /etc/profile.d/rvm.sh ; cd ${repos_dir}/vims-test ; bundle install'
+
 ADD http://download.cirros-cloud.net/0.3.4/cirros-0.3.4-x86_64-disk.img /home/opnfv/functest/data/
+
index 42b7d3e..8c02d48 100755 (executable)
@@ -33,6 +33,7 @@ REPOS_DIR=$(cat $config_file | grep -w dir_repos | awk 'END {print $NF}')
 FUNCTEST_REPO_DIR=$(cat $config_file | grep -w dir_repo_functest | awk 'END {print $NF}')
 RALLY_REPO_DIR=$(cat $config_file | grep -w dir_repo_rally | awk 'END {print $NF}')
 RELENG_REPO_DIR=$(cat $config_file | grep -w dir_repo_releng | awk 'END {print $NF}')
+VIMS_REPO_DIR=$(cat $config_file | grep -w dir_repo_vims_test | awk 'END {print $NF}')
 
 FUNCTEST_DIR=$(cat $config_file | grep -w dir_functest | awk 'END {print $NF}')
 FUNCTEST_RESULTS_DIR=$(cat $config_file | grep -w dir_results | awk 'END {print $NF}')
@@ -47,6 +48,8 @@ FUNCTEST_BRANCH=$(cat $config_file | grep -w functest_branch | awk 'END {print $
 FUNCTEST_COMMIT=$(cat $config_file | grep -w functest_commit | awk 'END {print $NF}')
 RELENG_BRANCH=$(cat $config_file | grep -w releng_branch | awk 'END {print $NF}')
 RELENG_COMMIT=$(cat $config_file | grep -w releng_commit | awk 'END {print $NF}')
+VIMS_BRANCH=$(cat $config_file | grep -w vims_test_branch | awk 'END {print $NF}')
+VIMS_COMMIT=$(cat $config_file | grep -w vims_test_commit | awk 'END {print $NF}')
 
 echo "_____Parsed needed data from ${config_file}:"
 echo "####### Directories #######"
@@ -54,6 +57,7 @@ echo "REPOS_DIR=${REPOS_DIR}"
 echo "FUNCTEST_REPO_DIR=${FUNCTEST_REPO_DIR}"
 echo "RALLY_REPO_DIR=${RALLY_REPO_DIR}"
 echo "RELENG_REPO_DIR=${RELENG_REPO_DIR}"
+echo "VIMS_REPO_DIR=${VIMS_REPO_DIR}"
 echo "FUNCTEST_DIR=${FUNCTEST_DIR}"
 echo "FUNCTEST_RESULTS_DIR=${FUNCTEST_RESULTS_DIR}"
 echo "FUNCTEST_CONF_DIR=${FUNCTEST_CONF_DIR}"
@@ -66,6 +70,8 @@ echo "RELENG_BRANCH=${RELENG_BRANCH}"
 echo "RELENG_COMMIT=${RELENG_COMMIT}"
 echo "RALLY_BRANCH=${RALLY_BRANCH}"
 echo "RALLY_COMMIT=${RALLY_COMMIT}"
+echo "VIMS_BRANCH=${VIMS_BRANCH}"
+echo "VIMS_COMMIT=${VIMS_COMMIT}"
 echo "############################"
 
 info ()  {
index 42b1e1c..6c77e81 100755 (executable)
@@ -104,6 +104,20 @@ if [ $offline == false ]; then
     cd ${RALLY_REPO_DIR}
     info "Rally repo: pulling to latest..."
     git pull
+
+    info "Updating vIMS test repository...."
+    cd ${VIMS_REPO_DIR}
+    if [ ${VIMS_BRANCH} != "stable" ]; then
+        info "Releng repo: checkout ${VIMS_TEST_BRANCH} branch..."
+        git checkout ${VIMS_BRANCH}
+    fi
+    info "vIMS test repo: pulling to latest..."
+    git pull
+    if [ ${VIMS_COMMIT} != "latest" ]; then
+        info "vIMS test repo: given commit is ${VIMS_TEST_COMMIT}. Reseting..."
+        git reset --hard ${VIMS_COMMIT}
+    fi
+
 fi
 
 # We do this regardless if its online or offline mode.
index 0383515..4603357 100644 (file)
@@ -13,6 +13,7 @@ general:
         dir_repo_functest:  /home/opnfv/repos/functest
         dir_repo_rally:     /home/opnfv/repos/rally
         dir_repo_releng:    /home/opnfv/repos/releng
+        dir_repo_vims_test: /home/opnfv/repos/vims-test
         dir_functest:       /home/opnfv/functest
         dir_results:        /home/opnfv/functest/results
         dir_functest_conf:  /home/opnfv/functest/conf
@@ -29,6 +30,8 @@ general:
         releng_commit:  latest
         rally_branch:   master
         rally_commit:   9a17d8490e7fb4afee2f5629e6db41eabe4bc4d4
+        vims_test_branch:   stable
+        vims_test_commit:   latest
 
     openstack:
         image_name: functest-img
index 59e89a5..262149b 100644 (file)
@@ -13,6 +13,8 @@ import os
 import urllib2
 import subprocess
 import sys
+import requests
+import json
 from git import Repo
 
 
@@ -434,3 +436,19 @@ def get_installer_type(logger=None):
         installer = "Unkown"
 
     return installer
+
+def push_results_to_db(db_url, case_name, logger, pod_name, git_version, payload):
+    url = db_url + "/results"
+    installer = get_installer_type(logger)
+    params = {"project_name": "functest", "case_name": case_name,
+              "pod_name": pod_name, "installer": installer,
+              "version": git_version, "details": payload}
+
+    headers = {'Content-Type': 'application/json'}
+    try:
+        r = requests.post(url, data=json.dumps(params), headers=headers)
+        logger.debug(r)
+        return True
+    except:
+        print "Error:", sys.exc_info()[0]
+        return False
index b51bb62..14671b6 100644 (file)
@@ -242,22 +242,6 @@ def cleanup(nova, neutron, network_dic):
         "Network '%s' deleted successfully" % NEUTRON_PRIVATE_NET_NAME)
     return True
 
-
-def push_results_to_db(payload):
-
-    url = TEST_DB + "/results"
-    installer = functest_utils.get_installer_type(logger)
-    git_version = functest_utils.get_git_branch(args.repo_path)
-    # TODO pod_name hardcoded, info shall come from Jenkins
-    params = {"project_name": "functest", "case_name": "vPing",
-              "pod_name": "opnfv-jump-2", "installer": installer,
-              "version": git_version, "details": payload}
-
-    headers = {'Content-Type': 'application/json'}
-    r = requests.post(url, data=json.dumps(params), headers=headers)
-    logger.debug(r)
-
-
 def main():
 
     creds_nova = functest_utils.get_credentials("nova")
@@ -437,8 +421,10 @@ def main():
         if args.report:
             logger.debug("Push result into DB")
             # TODO check path result for the file
-            push_results_to_db(
-                {'timestart': start_time_ts, 'duration': duration,
+            git_version = functest_utils.get_git_branch(args.repo_path)
+            functest_utils.push_results_to_db(db_url=TEST_DB, case_name="vPing",
+                logger=logger, pod_name="opnfv-jump-2", git_version=git_version,
+                payload={'timestart': start_time_ts, 'duration': duration,
                  'status': test_status})
             # with open("vPing-result.json", "w") as outfile:
             # json.dump({'timestart': start_time_ts, 'duration': duration,