[VVP] adding config for test coverage report 33/42833/1
authorstark, steven <ss820f@att.com>
Fri, 13 Apr 2018 22:59:33 +0000 (15:59 -0700)
committerstark, steven <ss820f@att.com>
Fri, 13 Apr 2018 22:59:33 +0000 (15:59 -0700)
modifed tox, pom, and tests to create coverage report

Change-Id: I98321c3d5c205622a3b4f5662566934f323ba70f
Issue-ID: VVP-56
Signed-off-by: stark, steven <ss820f@att.com>
django/engagementmanager/tests/test_expanded_eng.py
django/vvp/settings/tox_settings.py
mvn-phase-script.sh [new file with mode: 0755]
pom.xml
tox.ini

index de2a622..82b1616 100644 (file)
@@ -323,7 +323,7 @@ class testGetExpandedEngsAndSearch(TestBaseEntity):
                 urlStr = self.urlPrefix + 'vf' + str(vf.uuid) + '/vfcs/'
                 vfc_of_x_response = self.c.get(
                     urlStr, **{'HTTP_AUTHORIZATION': "token " + self.token})
-                vfc_list = json.loads(vfc_of_x_response.content)
+                vfc_list = json.loads(vfc_of_x_response.content) or {}
                 for vfc in vfc_list:
                     if (vfc['name'] == self.random_keyword):
                         bool_flag = True
index ff1aabd..e562bc3 100644 (file)
@@ -99,6 +99,7 @@ INSTALLED_APPS = [
     'rest_framework',
     'engagementmanager.apps.EngagementmanagerConfig',
     'validationmanager.apps.ValidationmanagerConfig',
+    'django_jenkins',
 ]
 
 MIDDLEWARE_CLASSES = [
diff --git a/mvn-phase-script.sh b/mvn-phase-script.sh
new file mode 100755 (executable)
index 0000000..77979dc
--- /dev/null
@@ -0,0 +1,60 @@
+#!/bin/bash
+
+# ================================================================================
+# Copyright (c) 2017 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END=========================================================
+#
+# ECOMP is a trademark and service mark of AT&T Intellectual Property.
+
+set -ex
+
+
+echo "running script: [$0] for module [$1] at stage [$2]"
+
+MVN_PROJECT_MODULEID="$1"
+MVN_PHASE="$2"
+PROJECT_ROOT=$(dirname $0)
+
+run_tox_test () {
+  CURDIR=$(pwd)
+  TOXINIS=.
+  for TOXINI in "${TOXINIS[@]}"; do
+    DIR=$(echo "$TOXINI" | rev | cut -f2- -d'/' | rev)
+    cd "${CURDIR}/${DIR}"
+    rm -rf ./venv-tox ./.tox
+    virtualenv ./venv-tox
+    source ./venv-tox/bin/activate
+    pip install --upgrade pip
+    pip install --upgrade tox argparse
+    pip freeze
+    tox
+    deactivate
+    rm -rf ./venv-tox ./.tox
+  done
+}
+
+# Customize the section below for each project
+case $MVN_PHASE in
+test)
+  echo "==> test phase script"
+  run_tox_test
+  ;;
+*)
+  echo "==> unprocessed phase"
+  ;;
+esac
+
+
+
diff --git a/pom.xml b/pom.xml
index 4c8f4e9..7f678af 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <docker.latest.tag>${project.version}-latest</docker.latest.tag>
         <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
         <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+        <!--sonar-->
+        <sonar.sourceEncoding>UTF-8</sonar.sourceEncoding>
+        <sonar.sources>.</sonar.sources>
+        <sonar.python.coverage.reportPath>django/reports/coverage.xml</sonar.python.coverage.reportPath>
+        <sonar.language>py</sonar.language>
+        <sonar.pluginName>python</sonar.pluginName>
+        <sonar.inclusions>django/**.py</sonar.inclusions>
   </properties>
 
   <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>exec-maven-plugin</artifactId>
+            <version>1.2.1</version>
+            <configuration>
+              <executable>${session.executionRootDirectory}/mvn-phase-script.sh</executable>
+            </configuration>
+        </plugin>
+      </plugins>
+    </pluginManagement>
     <plugins>
         <plugin>
             <groupId>org.sonatype.plugins</groupId>
                 </execution>
             </executions>
         </plugin>
+        <plugin>
+          <groupId>org.codehaus.mojo</groupId>
+          <artifactId>exec-maven-plugin</artifactId>
+          <version>1.2.1</version>
+          <executions>
+            <execution>
+              <id>test script</id>
+              <phase>test</phase>
+              <goals>
+                <goal>exec</goal>
+              </goals>
+              <configuration>
+                <arguments>
+                  <argument>__</argument>
+                  <argument>test</argument>
+                </arguments>
+              </configuration>
+            </execution>
+          </executions>
+        </plugin>
     </plugins>
   </build>
   <distributionManagement>
diff --git a/tox.ini b/tox.ini
index f8cb41b..c632928 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -38,8 +38,10 @@ setenv =
 [testenv:py36-django1-10-6]
 basepython = python3.6
 deps = -r{toxinidir}/django/requirements.txt
+    django-jenkins
+    coverage
 commands =  python --version
-            django-admin.py test
+    python {toxinidir}/django/manage.py jenkins --enable-coverage
 
 [testenv:style]
 basepython = python3