aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-10-02 23:41:37 +0000
committerGerrit Code Review <gerrit@opnfv.org>2017-10-02 23:41:37 +0000
commitdd3cbc21dfb505ea70dd3574869c1fb33b7de956 (patch)
treec0501384c36e70832fa9c8e82749aa7a62a11a54 /yardstick
parent570cb78d5906143d19d95bf2d7fe1764e52cf68b (diff)
parent0eccf0cb46496b4a0fc1865f2c2c40d226697853 (diff)
Merge "add collectd resource node capability"
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py12
-rw-r--r--yardstick/network_services/collector/subscriber.py59
-rw-r--r--yardstick/network_services/nfvi/resource.py16
3 files changed, 71 insertions, 16 deletions
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 3f61116bc..d9cc0eac1 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -607,7 +607,7 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
traffic_gen.listen_traffic(self.traffic_profile)
# register collector with yardstick for KPI collection.
- self.collector = Collector(self.vnfs, self.traffic_profile)
+ self.collector = Collector(self.vnfs, self.context_cfg["nodes"], self.traffic_profile)
self.collector.start()
# Start the actual traffic
@@ -623,11 +623,11 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
:return: None
"""
- for vnf in self.vnfs:
- # Result example:
- # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
- LOG.debug("collect KPI for %s", vnf.name)
- result.update(self.collector.get_kpi(vnf))
+ # this is the only method that is check from the runner
+ # so if we have any fatal error it must be raised via these methods
+ # otherwise we will not terminate
+
+ result.update(self.collector.get_kpi())
def teardown(self):
""" Stop the collector and terminate VNF & TG instance
diff --git a/yardstick/network_services/collector/subscriber.py b/yardstick/network_services/collector/subscriber.py
index 3bcb20876..db52e0b45 100644
--- a/yardstick/network_services/collector/subscriber.py
+++ b/yardstick/network_services/collector/subscriber.py
@@ -12,28 +12,73 @@
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module implements stub for publishing results in yardstick format."""
+import logging
+
+from yardstick.network_services.nfvi.resource import ResourceProfile
+from yardstick.network_services.utils import get_nsb_option
+
+LOG = logging.getLogger(__name__)
class Collector(object):
"""Class that handles dictionary of results in yardstick-plot format."""
- def __init__(self, traffic_profile, vnfs):
+ @staticmethod
+ def make_resource_profile(node, timeout):
+ # node dict works as mgmt dict
+ # don't need port names, there is no way we can
+ # tell what port is used on the compute node
+ collectd_options = node["collectd"]
+ plugins = collectd_options.get("plugins", {})
+ interval = collectd_options.get("interval")
+
+ # use default cores = None to MatchAllCores
+ return ResourceProfile(node, plugins=plugins, interval=interval, timeout=timeout)
+
+ def __init__(self, vnfs, nodes, traffic_profile, timeout=3600):
super(Collector, self).__init__()
self.traffic_profile = traffic_profile
- self.service = vnfs
+ self.vnfs = vnfs
+ self.nodes = nodes
+ self.timeout = timeout
+ self.bin_path = get_nsb_option('bin_path', '')
+ self.resource_profiles = {node_name: self.make_resource_profile(node, self.timeout)
+ for node_name, node in self.nodes.items()
+ if node.get("collectd")}
def start(self):
"""Nothing to do, yet"""
- pass
+ for resource in self.resource_profiles.values():
+ resource.initiate_systemagent(self.bin_path)
+ resource.start()
+ resource.amqp_process_for_nfvi_kpi()
def stop(self):
"""Nothing to do, yet"""
- pass
+ for resource in self.resource_profiles.values():
+ resource.stop()
- @classmethod
- def get_kpi(cls, vnf):
+ def get_kpi(self):
"""Returns dictionary of results in yardstick-plot format
:return:
"""
- return {vnf.name: vnf.collect_kpi()}
+ results = {}
+ for vnf in self.vnfs:
+ # Result example:
+ # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
+ LOG.debug("collect KPI for %s", vnf.name)
+ results[vnf.name] = vnf.collect_kpi()
+
+ for node_name, resource in self.resource_profiles.items():
+ # Result example:
+ # {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
+ LOG.debug("collect KPI for %s", node_name)
+ if not resource.check_if_sa_running("collectd")[0]:
+ continue
+
+ try:
+ results[node_name] = {"core": resource.amqp_collect_nfvi_kpi()}
+ except Exception:
+ LOG.exception("")
+ return results
diff --git a/yardstick/network_services/nfvi/resource.py b/yardstick/network_services/nfvi/resource.py
index d807f5e46..7e8334c73 100644
--- a/yardstick/network_services/nfvi/resource.py
+++ b/yardstick/network_services/nfvi/resource.py
@@ -51,16 +51,26 @@ class ResourceProfile(object):
COLLECTD_CONF = "collectd.conf"
AMPQ_PORT = 5672
DEFAULT_INTERVAL = 25
+ DEFAULT_TIMEOUT = 3600
+
+ def __init__(self, mgmt, port_names=None, cores=None, plugins=None,
+ interval=None, timeout=None):
- def __init__(self, mgmt, port_names=None, cores=None, plugins=None, interval=None):
if plugins is None:
self.plugins = {}
else:
self.plugins = plugins
+
if interval is None:
self.interval = self.DEFAULT_INTERVAL
else:
self.interval = interval
+
+ if timeout is None:
+ self.timeout = self.DEFAULT_TIMEOUT
+ else:
+ self.timeout = timeout
+
self.enable = True
self.cores = validate_non_string_sequence(cores, default=[])
self._queue = multiprocessing.Queue()
@@ -73,8 +83,8 @@ class ResourceProfile(object):
def check_if_sa_running(self, process):
""" verify if system agent is running """
- err, pid, _ = self.connection.execute("pgrep -f %s" % process)
- return [err == 0, pid]
+ status, pid, _ = self.connection.execute("pgrep -f %s" % process)
+ return status == 0, pid
def run_collectd_amqp(self):
""" run amqp consumer to collect the NFVi data """