Merge "Adding generic traffic profiles for trex traffic generator"
authorKubi <jean.gaoliang@huawei.com>
Mon, 6 Feb 2017 09:47:50 +0000 (09:47 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Mon, 6 Feb 2017 09:47:50 +0000 (09:47 +0000)
59 files changed:
api/client.py [new file with mode: 0644]
api/resources/testcases.py [new file with mode: 0644]
api/urls.py
api/views.py
tests/opnfv/test_cases/opnfv_yardstick_tc001.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc002.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc005.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc006.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc007.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc008.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc009.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc010.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc011.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc012.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc014.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc019.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc020.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc021.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc025.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc027.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc038.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc040.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc042.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc045.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc046.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc047.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc048.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc049.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc050.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc051.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc052.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc053.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc054.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc055.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc063.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc069.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc070.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc071.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc072.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc073.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc074.yaml
tests/opnfv/test_cases/opnfv_yardstick_tc075.yaml
tests/unit/benchmark/core/test_task.py
tests/unit/benchmark/core/test_testcase.py
tests/unit/cmd/commands/test_testcase.py [new file with mode: 0644]
tests/unit/network_services/nfvi/test_collectd.py
tests/unit/network_services/nfvi/test_resource.py
tox.ini [new file with mode: 0644]
yardstick/benchmark/core/task.py
yardstick/benchmark/core/testcase.py
yardstick/cmd/commands/__init__.py
yardstick/cmd/commands/task.py
yardstick/cmd/commands/testcase.py
yardstick/common/constants.py
yardstick/common/utils.py
yardstick/dispatcher/file.py
yardstick/network_services/utils.py

diff --git a/api/client.py b/api/client.py
new file mode 100644 (file)
index 0000000..167754c
--- /dev/null
@@ -0,0 +1,37 @@
+##############################################################################
+# Copyright (c) 2016 Huawei Technologies Co.,Ltd 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
+##############################################################################
+import logging
+import requests
+
+from oslo_serialization import jsonutils
+
+from yardstick.common import constants as consts
+
+logger = logging.getLogger(__name__)
+
+
+def post(url, data={}):
+    url = '{}{}'.format(consts.BASE_URL, url)
+    data = jsonutils.dumps(data)
+    headers = {'Content-Type': 'application/json'}
+    try:
+        response = requests.post(url, data=data, headers=headers)
+        result = response.json()
+        logger.debug('The result is: %s', result)
+
+        return result
+    except Exception as e:
+        logger.exception('Failed: %s', e)
+        raise
+
+
+def get(url):
+    url = '{}{}'.format(consts.BASE_URL, url)
+    response = requests.get(url)
+    return response.json()
diff --git a/api/resources/testcases.py b/api/resources/testcases.py
new file mode 100644 (file)
index 0000000..6ee15ef
--- /dev/null
@@ -0,0 +1,21 @@
+# ############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd 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
+# ############################################################################
+from yardstick.benchmark.core.testcase import Testcase
+from yardstick.benchmark.core import Param
+from api.utils import common as common_utils
+
+
+def default(args):
+    return listAllTestcases(args)
+
+
+def listAllTestcases(args):
+    param = Param(args)
+    testcase_list = Testcase().list_all(param)
+    return common_utils.result_handler(1, testcase_list)
index 04b7485..3ccb67d 100644 (file)
@@ -13,6 +13,7 @@ from api.utils.common import Url
 
 urlpatterns = [
     Url('/yardstick/asynctask', views.Asynctask, 'asynctask'),
+    Url('/yardstick/testcases', views.Testcases, 'testcases'),
     Url('/yardstick/testcases/release/action', views.ReleaseAction, 'release'),
     Url('/yardstick/testcases/samples/action', views.SamplesAction, 'samples'),
     Url('/yardstick/testsuites/action', views.TestsuitesAction, 'testsuites'),
index 0c39bfa..9fd236f 100644 (file)
@@ -30,6 +30,11 @@ class Asynctask(ApiResource):
         return self._dispatch_get()
 
 
+class Testcases(ApiResource):
+    def get(self):
+        return self._dispatch_get()
+
+
 class ReleaseAction(ApiResource):
     @swag_from(os.getcwd() + '/swagger/docs/release_action.yaml')
     def post(self):
index aa2980f..ceec6cf 100644 (file)
@@ -1,11 +1,11 @@
 ---
-# Yardstick TC001 config file
-# Measure network throughput using pktgen
-# Different amounts of flows are tested with, from 2 up to 1001000
-# All tests are run twice. First twice with the least amount of
-#ports and further on.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC001 config file;
+    Measure network throughput using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run twice. First twice with the least amount of ports and further on.
 
 scenarios:
 {% for num_ports in [1, 10, 50, 100, 500, 1000] %}
index 3c7b988..6830dcd 100644 (file)
@@ -1,7 +1,10 @@
 ---
-# measure network latency using ping
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC002 config file;
+    measure network latency using ping;
+
 {% set image = image or "cirros-0.3.3" %}
 scenarios:
 {% for i in range(2) %}
index f5a2778..82e85db 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Yardstick TC005 config file
-# Measure Storage IOPS, throughput and latency using fio
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC005 config file;
+    Measure Storage IOPS, throughput and latency using fio.
+
 scenarios:
 {% for rw in ['read', 'write', 'randwrite', 'randread', 'rw'] %}
   {% for bs in ['4k', '64k', '1024k'] %}
index 7221518..5dfb29b 100644 (file)
@@ -1,5 +1,8 @@
 ---
+
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC006 config file.
 
 scenarios:
 -
index 6f99ea6..882b3cf 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Sample benchmark task config file
-# vTC
 
 schema: "yardstick:task:0.1"
+description: >
+    Sample benchmark task config file;
+    vTC.
 
 scenarios:
 -
index a2f5f3a..89986f7 100644 (file)
@@ -1,15 +1,16 @@
 ---
-# Yardstick TC008 config file
-# Measure network throughput and packet loss using Pktgen.
-# Different amount of flows, from 2 up to 1001000, in combination
-# with different packet sizes are run in each test.
-# Each combination of packet size and flow amount is run 10 times.
-# First 10 times with the smallest packet size, starting with the
-# least amount of ports/flows, then next amount of ports with same
-# packet size, and so on. The test sequence continues with the next
-# packet size, with same ports/flows sequence as before.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC008 config file;
+    Measure network throughput and packet loss using Pktgen;
+    Different amount of flows, from 2 up to 1001000, in combination
+    with different packet sizes are run in each test.
+    Each combination of packet size and flow amount is run 10 times.
+    First 10 times with the smallest packet size, starting with the
+    least amount of ports/flows, then next amount of ports with same
+    packet size, and so on. The test sequence continues with the next
+    packet size, with same ports/flows sequence as before.
 
 scenarios:
 {% for pkt_size in [64, 128, 256, 512, 1024, 1280, 1518] %}
index f9fa1b7..e18ca78 100644 (file)
@@ -1,12 +1,13 @@
 ---
-# Yardstick TC009 config file
-# Measure network throughput and packet loss using pktgen.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 10 times each. First 10 times with the least
-# amount of ports, then 10 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC009 config file;
+    Measure network throughput and packet loss using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 10 times each. First 10 times with the least
+    amount of ports, then 10 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
 
 scenarios:
 {% for num_ports in [1, 10, 50, 100, 500, 1000] %}
index 6c7f967..ad344e5 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC010 config file
-# measure memory read latency using lmbench
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC010 config file;
+    measure memory read latency using lmbench.
 
 scenarios:
 -
index 4cd3119..5ff31ea 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC011 config file
-# Measure packet delay variation (jitter) using iperf3
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC011 config file;
+    Measure packet delay variation (jitter) using iperf3.
 
 scenarios:
 -
index ba246ff..805f627 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC012 config file
-# Measure memory read and write bandwidth using lmbench
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC012 config file;
+    Measure memory read and write bandwidth using lmbench.
 
 scenarios:
 -
index 1ac0f29..fc14462 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC014 config file
-# Measure Processing speed using unixbench
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC014 config file;
+    Measure Processing speed using unixbench.
 
 scenarios:
 -
index 2e5a4a5..b490196 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Sample test case for the HA of controller node Openstack service
 
 schema: "yardstick:task:0.1"
+description: >
+    Sample test case for the HA of controller node Openstack service.
 
 scenarios:
 -
index cbdaf39..3bcabaa 100644 (file)
@@ -1,5 +1,8 @@
 ---
+
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC020 config file.
 
 scenarios:
 -
index 1724978..263663e 100644 (file)
@@ -1,5 +1,8 @@
 ---
+
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC021 config file.
 
 scenarios:
 -
index b083f6f..0bbc5b8 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Sample test case for the HA of OpenStack Controll Node abnormally shutdown
 
 schema: "yardstick:task:0.1"
+description: >
+    Sample test case for the HA of OpenStack Controll Node abnormally shutdown.
 
 scenarios:
 -
index 5032f3d..036b6e9 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Yardstick TC027 config file
-# Measure IPV6 network latency using ping6
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC027 config file;
+    Measure IPV6 network latency using ping6.
+
 {% set openrc = openrc or "/opt/admin-openrc.sh" %}
 {% set external_network = external_network or "ext-net" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_physical/pod.yaml" %}
index cd42098..0db490a 100644 (file)
@@ -1,15 +1,15 @@
 ---
-# Yardstick TC037 config file
-# Measure network throughput and packet loss using pktgen.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 2 times each. First 2 times with the least
-# amount of ports, then 2 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
-#
-# During the measurements system load and network latency are
-# recorded/measured using ping and mpstat, respectively.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC037 config file;
+    Measure network throughput and packet loss using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 2 times each. First 2 times with the least
+    amount of ports, then 2 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
+    During the measurements system load and network latency are
+    recorded/measured using ping and mpstat, respectively;
 
 scenarios:
 -
index c2e5b40..e6ba0c1 100644 (file)
@@ -1,15 +1,15 @@
 ---
-# Yardstick TC038 config file
-# Measure network throughput and packet loss using pktgen.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 10 times each. First 10 times with the least
-# amount of ports, then 10 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
-#
-# During the measurements system load and network latency are
-# recorded/measured using ping and mpstat, respectively.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC038 config file;
+    Measure network throughput and packet loss using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 10 times each. First 10 times with the least
+    amount of ports, then 10 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
+    During the measurements system load and network latency are
+    recorded/measured using ping and mpstat, respectively;
 
 scenarios:
 -
index 0a6dee6..c609467 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC040 config file
-# Running Parser Yang-to-Tosca module as a tool, validating output against expected outcome
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC040 config file;
+    Running Parser Yang-to-Tosca module as a tool, validating output against expected outcome.
 
 
 scenarios:
index 158f507..c233acb 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC042 config file
-# Measure network latency using testpmd and pktgen-dpdk
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC042 config file;
+    Measure network latency using testpmd and pktgen-dpdk.
 
 scenarios:
 -
index d5754b9..2546b62 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Yardstick TC043 config file
-# Measure latency between NFVI nodes using ping
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC043 config file;
+    Measure latency between NFVI nodes using ping.
+
 {% set host = host or "node1.LF" %}
 {% set target = target or "node2.LF" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_physical/pod.yaml" %}
index 79ad61e..1969945 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Test case for TC045 :Control node Openstack service down - neutron server
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC045 :Control node Openstack service down - neutron server.
 
 scenarios:
 -
index 69cef40..1af5619 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Test case for TC046 :Control node Openstack service down - keystone
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC046 :Control node Openstack service down - keystone.
 
 scenarios:
 -
index f6019f6..24c28f5 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Test case for TC047 :Control node Openstack service down - glance api
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC047 :Control node Openstack service down - glance api.
 
 scenarios:
 -
index 543db97..190084d 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Test case for TC048 :Control node Openstack service down - cinder api
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC048 :Control node Openstack service down - cinder api.
 
 scenarios:
 -
index 759867d..66c1541 100644 (file)
@@ -1,7 +1,8 @@
 ---
-# Test case for TC049 :Control node Openstack service down - swift proxy
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC049 :Control node Openstack service down - swift proxy.
 
 scenarios:
 -
index 0b21f88..a8cb920 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC050 :OpenStack Controller Node Network High Availability
-# This test case is written by new scenario-based HA testing framework
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC050 :OpenStack Controller Node Network High Availability;
+    This test case is written by new scenario-based HA testing framework.
+
 scenarios:
   -
     type: "GeneralHA"
index 8e2e0c7..1115b35 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC051 :OpenStack Controller Node CPU Overload High Availability
-# This test case is written by new scenario-based HA testing framework
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC051 :OpenStack Controller Node CPU Overload High Availability;
+    This test case is written by new scenario-based HA testing framework.
+
 scenarios:
   -
     type: "GeneralHA"
index 7143068..67619d3 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC052 :OpenStack Controller Node Disk I/O Block High Availability
-# This test case is written by new scenario-based HA testing framework
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC052 :OpenStack Controller Node Disk I/O Block High Availability;
+    This test case is written by new scenario-based HA testing framework.
+
 scenarios:
   -
     type: "GeneralHA"
index 696ed3b..16a9711 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC053 :Openstack Controller Load Balance Service High Availability
-# This test case is written by new scenario-based HA testing framework
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC053 :Openstack Controller Load Balance Service High Availability;
+    This test case is written by new scenario-based HA testing framework.
+
 scenarios:
   -
     type: "GeneralHA"
index 7d94e3d..93948d3 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC054 :OpenStack VIP Master Node abnormally shutdown High Availability
-# This test case is written by new scenario-based HA testing framework
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC054 :OpenStack VIP Master Node abnormally shutdown High Availability;
+    This test case is written by new scenario-based HA testing framework.
+
 scenarios:
   -
     type: "GeneralHA"
index 54fc965..405247f 100644 (file)
@@ -1,15 +1,16 @@
 ---
-# Yardstick TC055 config file
-# Collect hardware specification from /proc/cpuinfo /proc/meminfo
-# compute capacity and scale.
-
-# the results have
-# number of CPUs, number of physical cores in a single CPU
-# number of logical cores, total memory size
-# cache size per CPU, total cache size
-# HT (Hyper-Thread) support status, 1 for open, 0 for close
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC055 config file;
+    Collect hardware specification from /proc/cpuinfo /proc/meminfo;
+    compute capacity and scale.
+    the results have,
+    number of CPUs, number of physical cores in a single CPU;
+    number of logical cores, total memory size;
+    cache size per CPU, total cache size;
+    HT (Hyper-Thread) support status, 1 for open, 0 for close.
+
 {% set host = host or "node5.yardstick-TC055" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_virtual/pod.yaml" %}
 scenarios:
index 9817837..f1eb3c6 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Yardstick TC063 config file
-# Measure disk size, block size and disk utilization using fdisk and iostat
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC063 config file;
+    Measure disk size, block size and disk utilization using fdisk and iostat.
+
 {% set host = host or "node5.yardstick-TC063" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_virtual/pod.yaml" %}
 
index dcc34d8..a11337d 100644 (file)
@@ -1,8 +1,9 @@
 ---
-# Yardstick TC069 config file
-# Measure memory read and write bandwidth using ramspeed
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC069 config file;
+    Measure memory read and write bandwidth using ramspeed.
 
 scenarios:
 -
index 931587b..c4ad715 100644 (file)
@@ -1,15 +1,15 @@
 ---
-# Yardstick TC070 config file
-# Measure network throughput and packet loss using pktgen.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 2 times each. First 2 times with the least
-# amount of ports, then 2 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
-#
-# During the measurements memory usage statistics and network latency are
-# recorded/measured using free and ping, respectively.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC070 config file;
+    Measure network throughput and packet loss using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 2 times each. First 2 times with the least
+    amount of ports, then 2 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
+    During the measurements memory usage statistics and network latency are
+    recorded/measured using free and ping, respectively;
 
 scenarios:
 -
index 6f006ee..59bfc24 100644 (file)
@@ -1,15 +1,15 @@
 ---
-# Yardstick TC071 config file
-# Measure cache hit/miss ratio and usage, network throughput and latency.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 2 times each. First 2 times with the least
-# amount of ports, then 2 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
-#
-# During the measurements cache hit/miss ration, cache usage statistics and
-# network latency are recorded/measured using cachestat and ping, respectively.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC071 config file;
+    Measure cache hit/miss ratio and usage, network throughput and latency;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 2 times each. First 2 times with the least
+    amount of ports, then 2 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
+    During the measurements cache hit/miss ration, cache usage statistics and
+    network latency are recorded/measured using cachestat and ping, respectively;
 
 scenarios:
 -
index e1fa331..10db287 100644 (file)
@@ -1,15 +1,15 @@
 ---
-# Yardstick TC072 config file
-# Measure network throughput and packet loss using pktgen.
-# Different amounts of flows are tested with, from 2 up to 1001000.
-# All tests are run 2 times each. First 2 times with the least
-# amount of ports, then 2 times with the next amount of ports,
-# and so on until all packet sizes have been run with.
-#
-# During the measurements network usage statistics and network latency are
-# recorded/measured using sar and ping, respectively.
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC072 config file;
+    Measure network throughput and packet loss using pktgen;
+    Different amounts of flows are tested with, from 2 up to 1001000;
+    All tests are run 2 times each. First 2 times with the least
+    amount of ports, then 2 times with the next amount of ports,
+    and so on until all packet sizes have been run with;
+    During the measurements network usage statistics and network latency are
+    recorded/measured using sar and ping, respectively;
 
 scenarios:
 -
index fd95b8c..99a0ffe 100755 (executable)
@@ -1,13 +1,15 @@
 ---
-# Yardstick TC073 config file
-# measure network latency and throughput using netperf
-# There are two sample scenarios: bulk test and request/response test
-# In bulk test, UDP_STREAM and TCP_STREAM can be used
-# send_msg_size and recv_msg_size are options of bulk test
-# In req/rsp test, TCP_RR TCP_CRR UDP_RR can be used
-# req_rsp_size is option of req/rsp test
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC073 config file;
+    measure network latency and throughput using netperf;
+    There are two sample scenarios: bulk test and request/response test;
+    In bulk test, UDP_STREAM and TCP_STREAM can be used;
+    send_msg_size and recv_msg_size are options of bulk test;
+    In req/rsp test, TCP_RR TCP_CRR UDP_RR can be used;
+    req_rsp_size is option of req/rsp test;
+
 {% set host = host or "node1.LF" %}
 {% set target = target or "node2.LF" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_physical/pod.yaml" %}
index 6dda2d4..3fb3a05 100644 (file)
@@ -1,8 +1,10 @@
 ---
-# Test case for TC074 StorPerf benchmark task config file
-# StorPerf is a tool to measure block and object storage performance in an NFVI
 
 schema: "yardstick:task:0.1"
+description: >
+    Test case for TC074 StorPerf benchmark task config file;
+    StorPerf is a tool to measure block and object storage performance in an NFVI.
+
 {% set public_network = public_network or "ext-net" %}
 {% set StorPerf_ip = StorPerf_ip or "192.168.200.1" %}
 scenarios:
index fb5a12e..1c1a7e4 100644 (file)
@@ -1,9 +1,11 @@
 ---
-# Yardstick TC075 config file
-# Measure network capacity and scale.
-# Measure number of connections, number of frames received
 
 schema: "yardstick:task:0.1"
+description: >
+    Yardstick TC075 config file;
+    Measure network capacity and scale.
+    Measure number of connections, number of frames received;
+
 {% set host = host or "node1.LF" %}
 {% set pod_info = pod_info or "etc/yardstick/nodes/compass_sclab_virtual/pod.yaml" %}
 
index 5dd32ea..c56e210 100644 (file)
@@ -24,6 +24,7 @@ except ImportError:
 
 
 from yardstick.benchmark.core import task
+from yardstick.common import constants as consts
 
 
 class TaskTestCase(unittest.TestCase):
@@ -92,10 +93,10 @@ class TaskTestCase(unittest.TestCase):
         task_files, task_args, task_args_fnames = t.parse_suite()
         print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
                                                 task_args_fnames))
-        self.assertEqual(task_files[0],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
-        self.assertEqual(task_files[1],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+        self.assertEqual(task_files[0], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+        self.assertEqual(task_files[1], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
         self.assertEqual(task_args[0], None)
         self.assertEqual(task_args[1], None)
         self.assertEqual(task_args_fnames[0], None)
@@ -109,10 +110,10 @@ class TaskTestCase(unittest.TestCase):
         task_files, task_args, task_args_fnames = t.parse_suite()
         print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
                                                 task_args_fnames))
-        self.assertEqual(task_files[0],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
-        self.assertEqual(task_files[1],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+        self.assertEqual(task_files[0], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+        self.assertEqual(task_files[1], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
         self.assertEqual(task_args[0], None)
         self.assertEqual(task_args[1],
                          '{"host": "node1.LF","target": "node2.LF"}')
@@ -127,10 +128,10 @@ class TaskTestCase(unittest.TestCase):
         task_files, task_args, task_args_fnames = t.parse_suite()
         print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
                                                 task_args_fnames))
-        self.assertEqual(task_files[0],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
-        self.assertEqual(task_files[1],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+        self.assertEqual(task_files[0], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+        self.assertEqual(task_files[1], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
         self.assertEqual(task_args[0], None)
         self.assertEqual(task_args[1], None)
         self.assertEqual(task_args_fnames[0], None)
@@ -144,10 +145,10 @@ class TaskTestCase(unittest.TestCase):
         task_files, task_args, task_args_fnames = t.parse_suite()
         print("files=%s, args=%s, fnames=%s" % (task_files, task_args,
                                                 task_args_fnames))
-        self.assertEqual(task_files[0],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml')
-        self.assertEqual(task_files[1],
-                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml')
+        self.assertEqual(task_files[0], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc037.yaml'))
+        self.assertEqual(task_files[1], self.change_to_abspath(
+                         'tests/opnfv/test_cases/opnfv_yardstick_tc043.yaml'))
         self.assertEqual(task_args[0], None)
         self.assertEqual(task_args[1],
                          '{"host": "node1.LF","target": "node2.LF"}')
@@ -159,6 +160,9 @@ class TaskTestCase(unittest.TestCase):
         file_path = os.path.join(curr_path, filename)
         return file_path
 
+    def change_to_abspath(self, filepath):
+        return os.path.join(consts.YARDSTICK_ROOT_PATH, filepath)
+
 
 def main():
     unittest.main()
index c7da2de..1f5aad7 100644 (file)
@@ -28,13 +28,13 @@ class TestcaseUT(unittest.TestCase):
     def test_list_all(self):
         t = testcase.Testcase()
         result = t.list_all("")
-        self.assertEqual(result, True)
+        self.assertIsInstance(result, list)
 
     def test_show(self):
         t = testcase.Testcase()
         casename = Arg()
         result = t.show(casename)
-        self.assertEqual(result, True)
+        self.assertTrue(result)
 
 
 def main():
diff --git a/tests/unit/cmd/commands/test_testcase.py b/tests/unit/cmd/commands/test_testcase.py
new file mode 100644 (file)
index 0000000..5157843
--- /dev/null
@@ -0,0 +1,21 @@
+import unittest
+from mock import patch
+
+from yardstick.cmd.commands.testcase import TestcaseCommands
+
+
+class TestcaseCommandsUT(unittest.TestCase):
+    @patch('yardstick.cmd.commands.testcase.TestcaseCommands._format_print')
+    @patch('yardstick.cmd.commands.client')
+    def test_do_list(self, mock_client, mock_print):
+        mock_client.get.return_value = {'result': []}
+        TestcaseCommands().do_list({})
+        self.assertTrue(mock_print.called)
+
+
+def main():
+    unittest.main()
+
+
+if __name__ == '__main__':
+    main()
index 5bd7196..866c31d 100644 (file)
@@ -23,15 +23,12 @@ from yardstick.network_services.nfvi.collectd import AmqpConsumer
 class TestAmqpConsumer(unittest.TestCase):
     def setUp(self):
         self.queue = multiprocessing.Queue()
-        self.url = 'amqp://admin:admin@1.1.1.1:5672/%2F'
+        self.url = 'amqp://admin:admin@127.0.0.1:5672/%2F'
         self.amqp_consumer = AmqpConsumer(self.url, self.queue)
 
     def test___init__(self):
         self.assertEqual(self.url, self.amqp_consumer._url)
 
-    def test_connect(self):
-        self.assertRaises(RuntimeError, self.amqp_consumer.connect)
-
     def test_on_connection_open(self):
         self.amqp_consumer._connection = mock.Mock(autospec=AmqpConsumer)
         self.amqp_consumer._connection.add_on_close_callback = \
index 90910d8..26d1883 100644 (file)
@@ -27,13 +27,13 @@ class TestResourceProfile(unittest.TestCase):
              [{'short-name': 'VpeVnf',
                'vdu':
                [{'routing_table':
-                 [{'network': '152.16.100.20',
+                 [{'network': '172.16.100.20',
                    'netmask': '255.255.255.0',
-                   'gateway': '152.16.100.20',
+                   'gateway': '172.16.100.20',
                    'if': 'xe0'},
-                  {'network': '152.16.40.20',
+                  {'network': '172.16.40.20',
                    'netmask': '255.255.255.0',
-                   'gateway': '152.16.40.20',
+                   'gateway': '172.16.40.20',
                    'if': 'xe1'}],
                  'description': 'VPE approximation using DPDK',
                  'name': 'vpevnf-baremetal',
@@ -51,34 +51,34 @@ class TestResourceProfile(unittest.TestCase):
                  [{'virtual-interface':
                    {'dst_mac': '3c:fd:fe:9e:64:38',
                     'vpci': '0000:05:00.0',
-                    'local_ip': '152.16.100.19',
+                    'local_ip': '172.16.100.19',
                     'type': 'PCI-PASSTHROUGH',
                     'netmask': '255.255.255.0',
                     'dpdk_port_num': '0',
                     'bandwidth': '10 Gbps',
-                    'dst_ip': '152.16.100.20',
+                    'dst_ip': '172.16.100.20',
                     'local_mac': '3c:fd:fe:a1:2b:80'},
                    'vnfd-connection-point-ref': 'xe0',
                    'name': 'xe0'},
                   {'virtual-interface':
                    {'dst_mac': '00:1e:67:d0:60:5c',
                     'vpci': '0000:05:00.1',
-                    'local_ip': '152.16.40.19',
+                    'local_ip': '172.16.40.19',
                     'type': 'PCI-PASSTHROUGH',
                     'netmask': '255.255.255.0',
                     'dpdk_port_num': '1',
                     'bandwidth': '10 Gbps',
-                    'dst_ip': '152.16.40.20',
+                    'dst_ip': '172.16.40.20',
                     'local_mac': '3c:fd:fe:a1:2b:81'},
                    'vnfd-connection-point-ref': 'xe1',
                    'name': 'xe1'}]}],
                'description': 'Vpe approximation using DPDK',
                'mgmt-interface':
                    {'vdu-id': 'vpevnf-baremetal',
-                    'host': '1.1.1.1',
+                    'host': '127.0.0.1',
                     'password': 'r00t',
                     'user': 'root',
-                    'ip': '1.1.1.1'},
+                    'ip': '127.0.0.1'},
                'benchmark':
                    {'kpi': ['packets_in', 'packets_fwd', 'packets_dropped']},
                'connection-point': [{'type': 'VPORT', 'name': 'xe0'},
@@ -103,19 +103,6 @@ class TestResourceProfile(unittest.TestCase):
         self.assertEqual(self.resource_profile.check_if_sa_running("collectd"),
                          [True, {}])
 
-    def test_amqp_collect_nfvi_kpi(self):
-        _queue = multiprocessing.Queue()
-        _queue.put({"cpu/cpu-0/ipc": "ipc:10"})
-        amqp = self.resource_profile.amqp_collect_nfvi_kpi(_queue)
-        _queue.put({"/memory/bandwidth": "local:10"})
-        amqp = self.resource_profile.amqp_collect_nfvi_kpi(_queue)
-        expected = {'timestamp': '', 'cpu': {}, 'memory': {'bandwidth': '10'}}
-        self.assertDictEqual(expected, amqp)
-
-    def test_amqp_collect_nfvi_kpi_exception(self):
-        amqp = self.resource_profile.amqp_collect_nfvi_kpi({})
-        self.assertDictEqual({}, amqp)
-
     def test_get_cpu_data(self):
         reskey = ["", "cpufreq", "cpufreq-0"]
         value = "metric:10"
diff --git a/tox.ini b/tox.ini
new file mode 100644 (file)
index 0000000..3dfb982
--- /dev/null
+++ b/tox.ini
@@ -0,0 +1,22 @@
+[tox]
+minversion = 2.0
+skipsdist = True
+envlist = py27,py3
+
+[testenv]
+usedevelop=True
+deps = -rrequirements.txt
+commands = /bin/bash ./run_tests.sh
+whitelist_externals = /bin/bash
+
+[flake8]
+# E125 is deliberately excluded. See https://github.com/jcrocholl/pep8/issues/126
+# The rest of the ignores are TODOs
+# New from hacking 0.9: E129, E131, H407, H405
+# E251 Skipped due to https://github.com/jcrocholl/pep8/issues/301
+
+# nova flake8 ignores
+#ignore = E121,E122,E123,E124,E125,E126,E127,E128,E129,E131,E251,H405
+# dovetail flake8 ignores
+ignore = E123,E125,H803
+exclude =  .venv,.git,.tox,dist,docs,*egg,build
index 6cfec7b..87d70f4 100644 (file)
@@ -66,8 +66,6 @@ class Task(object):     # pragma: no cover
         if args.parse_only:
             sys.exit(0)
 
-        if os.path.isfile(args.output_file):
-            os.remove(args.output_file)
         # parse task_files
         for i in range(0, len(task_files)):
             one_task_start_time = time.time()
@@ -195,6 +193,8 @@ class TaskParser(object):       # pragma: no cover
         LOG.info("\nStarting scenario:%s", cfg["name"])
 
         test_cases_dir = cfg.get("test_cases_dir", test_cases_dir_default)
+        test_cases_dir = os.path.join(constants.YARDSTICK_ROOT_PATH,
+                                      test_cases_dir)
         if test_cases_dir[-1] != os.sep:
             test_cases_dir += os.sep
 
index 92198bd..7b23b73 100644 (file)
 """ Handler for yardstick command 'testcase' """
 from __future__ import absolute_import
 from __future__ import print_function
+
 import os
 import yaml
-import sys
+import logging
 
-from yardstick.benchmark.core import print_hbar
 from yardstick.common.task_template import TaskTemplate
-from yardstick.definitions import YARDSTICK_ROOT_PATH
+from yardstick.common import constants as consts
+
+LOG = logging.getLogger(__name__)
 
 
 class Testcase(object):
@@ -25,91 +27,80 @@ class Testcase(object):
        Set of commands to discover and display test cases.
     """
 
-    def __init__(self):
-        self.test_case_path = YARDSTICK_ROOT_PATH + 'tests/opnfv/test_cases/'
-        self.testcase_list = []
-
     def list_all(self, args):
         """List existing test cases"""
 
-        try:
-            testcase_files = os.listdir(self.test_case_path)
-        except Exception as e:
-            print("Failed to list dir:\n%(path)s\n%(err)s\n"
-                  % {"path": self.test_case_path, "err": e})
-            raise e
-        testcase_files.sort()
-
-        for testcase_file in testcase_files:
-            record = self._get_record(testcase_file)
-            self.testcase_list.append(record)
-
-        self._format_print(self.testcase_list)
-        return True
+        testcase_files = self._get_testcase_file_list()
+        testcase_list = [self._get_record(f) for f in testcase_files]
 
-    def show(self, args):
-        """Show details of a specific test case"""
-        testcase_name = args.casename[0]
-        testcase_path = self.test_case_path + testcase_name + ".yaml"
+        return testcase_list
+
+    def _get_testcase_file_list(self):
         try:
-            with open(testcase_path) as f:
-                try:
-                    testcase_info = f.read()
-                    print(testcase_info)
-
-                except Exception as e:
-                    print("Failed to load test cases:"
-                          "\n%(testcase_file)s\n%(err)s\n"
-                          % {"testcase_file": testcase_path, "err": e})
-                    raise e
-        except IOError as ioerror:
-            sys.exit(ioerror)
-        return True
+            testcase_files = sorted(os.listdir(consts.TESTCASE_DIR))
+        except OSError:
+            LOG.exception('Failed to list dir:\n%s\n', consts.TESTCASE_DIR)
+            raise
+
+        return testcase_files
 
     def _get_record(self, testcase_file):
 
-        try:
-            with open(self.test_case_path + testcase_file) as f:
-                try:
-                    testcase_info = f.read()
-                except Exception as e:
-                    print("Failed to load test cases:"
-                          "\n%(testcase_file)s\n%(err)s\n"
-                          % {"testcase_file": testcase_file, "err": e})
-                    raise e
-                description, installer, deploy_scenarios = \
-                    self._parse_testcase(testcase_info)
-
-                record = {'Name': testcase_file.split(".")[0],
-                          'Description': description,
-                          'installer': installer,
-                          'deploy_scenarios': deploy_scenarios}
-                return record
-        except IOError as ioerror:
-            sys.exit(ioerror)
+        file_path = os.path.join(consts.TESTCASE_DIR, testcase_file)
+        with open(file_path) as f:
+            try:
+                testcase_info = f.read()
+            except IOError:
+                LOG.exception('Failed to load test case:\n%s\n', testcase_file)
+                raise
+
+        description, installer, deploy_scenarios = self._parse_testcase(
+            testcase_info)
+
+        record = {
+            'Name': testcase_file.split(".")[0],
+            'Description': description,
+            'installer': installer,
+            'deploy_scenarios': deploy_scenarios
+        }
+
+        return record
 
     def _parse_testcase(self, testcase_info):
 
-        kw = {}
-        rendered_testcase = TaskTemplate.render(testcase_info, **kw)
+        rendered_testcase = TaskTemplate.render(testcase_info)
         testcase_cfg = yaml.load(rendered_testcase)
-        test_precondition = testcase_cfg.get('precondition', None)
-        installer_type = 'all'
-        deploy_scenarios = 'all'
-        if test_precondition is not None:
-            installer_type = test_precondition.get('installer_type', 'all')
-            deploy_scenarios = test_precondition.get('deploy_scenarios', 'all')
-
-        description = testcase_info.split("\n")[2][1:].strip()
+
+        test_precondition = testcase_cfg.get('precondition', {})
+        installer_type = test_precondition.get('installer_type', 'all')
+        deploy_scenarios = test_precondition.get('deploy_scenarios', 'all')
+
+        description = self._get_description(testcase_cfg)
+
         return description, installer_type, deploy_scenarios
 
-    def _format_print(self, testcase_list):
-        """format output"""
+    def _get_description(self, testcase_cfg):
+        try:
+            description_list = testcase_cfg['description'].split(';')
+        except KeyError:
+            return ''
+        else:
+            try:
+                return description_list[1].replace(os.linesep, '').strip()
+            except IndexError:
+                return description_list[0].replace(os.linesep, '').strip()
 
-        print_hbar(88)
-        print("| %-21s | %-60s" % ("Testcase Name", "Description"))
-        print_hbar(88)
-        for testcase_record in testcase_list:
-            print("| %-16s | %-60s" % (testcase_record['Name'],
-                                       testcase_record['Description']))
-        print_hbar(88)
+    def show(self, args):
+        """Show details of a specific test case"""
+        testcase_name = args.casename[0]
+        testcase_path = os.path.join(consts.TESTCASE_DIR,
+                                     testcase_name + ".yaml")
+        with open(testcase_path) as f:
+            try:
+                testcase_info = f.read()
+            except IOError:
+                LOG.exception('Failed to load test case:\n%s\n', testcase_path)
+                raise
+
+            print(testcase_info)
+        return True
index 5c53567..9bc0e9f 100644 (file)
@@ -1,10 +1,20 @@
 from __future__ import absolute_import
 from yardstick.benchmark.core import Param
+from api import client
 
 
 def change_osloobj_to_paras(args):
     param = Param({})
-    for k in param.__dict__:
+    for k in vars(param):
         if hasattr(args, k):
             setattr(param, k, getattr(args, k))
     return param
+
+
+class Commands(object):
+    def __init__(self):
+        self.client = client
+
+    def _change_to_dict(self, args):
+        p = Param({})
+        return {k: getattr(args, k) for k in vars(p) if hasattr(args, k)}
index 1c5db1f..20ab086 100644 (file)
@@ -1,4 +1,4 @@
-##############################################################################
+#############################################################################
 # Copyright (c) 2015 Ericsson AB and others.
 #
 # All rights reserved. This program and the accompanying materials
@@ -9,10 +9,12 @@
 
 """ Handler for yardstick command 'task' """
 from __future__ import print_function
-
 from __future__ import absolute_import
+
 from yardstick.benchmark.core.task import Task
 from yardstick.common.utils import cliargs
+from yardstick.common.utils import write_json_to_file
+from yardstick.common import constants as consts
 from yardstick.cmd.commands import change_osloobj_to_paras
 
 output_file_default = "/tmp/yardstick.out"
@@ -42,4 +44,18 @@ class TaskCommands(object):
              action="store_true")
     def do_start(self, args, **kwargs):
         param = change_osloobj_to_paras(args)
-        Task().start(param)
+
+        self._init_result_file()
+
+        try:
+            Task().start(param)
+        except Exception as e:
+            self._write_error_data(e)
+
+    def _init_result_file(self):
+        data = {'status': 0, 'result': []}
+        write_json_to_file(consts.DEFAULT_OUTPUT_FILE, data)
+
+    def _write_error_data(self, error):
+        data = {'status': 2, 'result': str(error)}
+        write_json_to_file(consts.DEFAULT_OUTPUT_FILE, data)
index bd17b1a..a151871 100644 (file)
@@ -9,14 +9,16 @@
 
 """ Handler for yardstick command 'testcase' """
 from __future__ import print_function
-
 from __future__ import absolute_import
+
 from yardstick.benchmark.core.testcase import Testcase
+from yardstick.benchmark.core import print_hbar
 from yardstick.common.utils import cliargs
 from yardstick.cmd.commands import change_osloobj_to_paras
+from yardstick.cmd.commands import Commands
 
 
-class TestcaseCommands(object):
+class TestcaseCommands(Commands):
     """Testcase commands.
 
        Set of commands to discover and display test cases.
@@ -24,11 +26,22 @@ class TestcaseCommands(object):
 
     def do_list(self, args):
         """List existing test cases"""
-        param = change_osloobj_to_paras(args)
-        Testcase().list_all(param)
+        testcase_list = self.client.get('/yardstick/testcases')['result']
+        self._format_print(testcase_list)
 
     @cliargs("casename", type=str, help="test case name", nargs=1)
     def do_show(self, args):
         """Show details of a specific test case"""
         param = change_osloobj_to_paras(args)
         Testcase().show(param)
+
+    def _format_print(self, testcase_list):
+        """format output"""
+
+        print_hbar(88)
+        print("| %-21s | %-60s" % ("Testcase Name", "Description"))
+        print_hbar(88)
+        for testcase_record in testcase_list:
+            print("| %-16s | %-60s" % (testcase_record['Name'],
+                                       testcase_record['Description']))
+        print_hbar(88)
index ffca4b3..e6faf68 100644 (file)
@@ -31,6 +31,8 @@ INSTALLERS = ['apex', 'compass', 'fuel', 'joid']
 
 YARDSTICK_ROOT_PATH = dirname(dirname(dirname(abspath(__file__)))) + sep
 
+TESTCASE_DIR = join(YARDSTICK_ROOT_PATH, 'tests/opnfv/test_cases/')
+
 YARDSTICK_REPOS_DIR = '/home/opnfv/repos/yardstick'
 
 YARDSTICK_CONFIG_DIR = '/etc/yardstick/'
@@ -57,3 +59,5 @@ ENV_ACTION_API = BASE_URL + '/yardstick/env/action'
 ASYNC_TASK_API = BASE_URL + '/yardstick/asynctask'
 
 SQLITE = 'sqlite:////tmp/yardstick.db'
+
+DEFAULT_OUTPUT_FILE = '/tmp/yardstick.out'
index 57ace14..473bbf5 100644 (file)
@@ -30,6 +30,7 @@ from keystoneauth1 import identity
 from keystoneauth1 import session
 from neutronclient.v2_0 import client
 from oslo_utils import importutils
+from oslo_serialization import jsonutils
 
 import yardstick
 
@@ -145,3 +146,12 @@ def get_neutron_client():
     sess = get_openstack_session()
     neutron_client = client.Client(session=sess)
     return neutron_client
+
+
+def write_json_to_file(path, data, mode='w'):
+    write_file(path, jsonutils.dump_as_bytes(data), mode)
+
+
+def write_file(path, data, mode='w'):
+    with open(path, mode) as f:
+        f.write(data)
index 9c728e9..8d3c369 100644 (file)
 
 from __future__ import absolute_import
 
-import logging
-import logging.handlers
-
-from oslo_serialization import jsonutils
-from oslo_config import cfg
-
 from yardstick.dispatcher.base import Base as DispatchBase
-
-CONF = cfg.CONF
-OPTS = [
-    cfg.StrOpt('file_path',
-               default='/tmp/yardstick.out',
-               help='Name and the location of the file to record '
-                    'data.'),
-    cfg.IntOpt('max_bytes',
-               default=0,
-               help='The max size of the file.'),
-    cfg.IntOpt('backup_count',
-               default=0,
-               help='The max number of the files to keep.'),
-]
-CONF.register_opts(OPTS, group="dispatcher_file")
+from yardstick.common import constants as consts
+from yardstick.common import utils
 
 
 class FileDispatcher(DispatchBase):
@@ -50,29 +31,13 @@ class FileDispatcher(DispatchBase):
 
     def __init__(self, conf):
         super(FileDispatcher, self).__init__(conf)
-        self.log = None
-
-        # if the directory and path are configured, then log to the file
-        if CONF.dispatcher_file.file_path:
-            dispatcher_logger = logging.Logger('dispatcher.file')
-            dispatcher_logger.setLevel(logging.INFO)
-            # create rotating file handler which logs result
-            rfh = logging.handlers.RotatingFileHandler(
-                self.conf.get('file_path', CONF.dispatcher_file.file_path),
-                maxBytes=CONF.dispatcher_file.max_bytes,
-                backupCount=CONF.dispatcher_file.backup_count,
-                encoding='utf8')
-
-            rfh.setLevel(logging.INFO)
-            # Only wanted the data to be saved in the file, not the
-            # project root logger.
-            dispatcher_logger.propagate = False
-            dispatcher_logger.addHandler(rfh)
-            self.log = dispatcher_logger
+        self.result = []
 
     def record_result_data(self, data):
-        if self.log:
-            self.log.info(jsonutils.dump_as_bytes(data))
+        self.result.append(data)
 
     def flush_result_data(self):
-        pass
+        file_path = self.conf.get('file_path', consts.DEFAULT_OUTPUT_FILE)
+
+        data = {'status': 1, 'result': self.result}
+        utils.write_json_to_file(file_path, data)
index 80e0a63..b750913 100644 (file)
@@ -53,7 +53,7 @@ def provision_tool(connection, tool_path):
     bin_path = get_nsb_option("bin_path")
     exit_status, stdout = connection.execute("which %s" % tool_path)[:2]
     if exit_status == 0:
-        return encodeutils.safe_encode(stdout, incoming='utf-8').rstrip()
+        return encodeutils.safe_decode(stdout, incoming='utf-8').rstrip()
 
     logging.warning("%s not found on %s, will try to copy from localhost",
                     tool_path, connection.host)