summaryrefslogtreecommitdiffstats
path: root/tools/collectors
diff options
context:
space:
mode:
authorBilly O'Mahony <billy.o.mahony@intel.com>2015-05-29 15:24:03 +0100
committerBilly O'Mahony <billy.o.mahony@intel.com>2015-06-08 13:55:35 +0000
commit8d6777df09c3dc441013a31f21cc50ab3b0f42a3 (patch)
treed00f189e00631c33385122012727dd3c6438f406 /tools/collectors
parentacd2499310f81565c6b1eb11d18528f7372894f5 (diff)
framework: Add reworked framework to repo
This commit adds the vSwitch Integration Test Framework whose design, based off TOIT, is outlined in the HLD previously made availiable to the community for review. The design of this framework allows developers to add different implementations of components, specifically vSwitches, Traffic Generators, Metrics Collectors and VNFs, easily. The goal of this design is that all testcases should run regardless of what is "under the hood". This commit adds support for running the framework for a phy to phy RFC2544 testcase only. More testcases will be added by the community. vSwitches supported at this time: * Intel DPDK (r) accelerated OpenvSwitch Traffic Generators supported at this time: * IxNet - IxNetwork Implementation * Ixia - IxExplorer Implementation * Dummy - Manual Implementation Metrics Collectors supported at this time: * Linux Metrics No VNFs are supported at this time but the framework outlines how they should be integrated and provides APIs for them to adhere to. JIRA: VSPERF-27 Change-Id: I312e1a1199487ffee8f824be06cd97d4f793eee0 Signed-off-by: Stephen Finucane <Stephen.Finucane@intel.com> Signed-off-by: Meghan Halton <Meghan.Halton@intel.com> Signed-off-by: Christopher Nolan <Christopher.Nolan@intel.com> Signed-off-by: Maryam Tahhan <Maryam.Tahhan@intel.com> Signed-off-by: Ciara Loftus <Ciara.Loftus@intel.com> Signed-off-by: Mark Kavanagh <Mark.B.Kavanagh@intel.com> Signed-off-by: Cian Ferriter <Cian.Ferriter@intel.com> Signed-off-by: Timo Puha <TimoX.Puha@intel.com> Signed-off-by: Billy O'Mahony <billy.o.mahony@intel.com> Signed-off-by: Michal Weglicki <MichalX.Weglicki@intel.com> Signed-off-by: Rory Sexton <Rory.Sexton@intel.com> Signed-off-by: Ian Stokes <Ian.Stokes@intel.com> Signed-off-by: Kevin Traynor <Kevin.Traynor@intel.com> Signed-off-by: Dino Simeon Madarang <dino.simeonx.madarang@intel.com> Reviewed-by: Eugene Snider <Eugene.Snider@huawei.com> Reviewed-by: Aihua Li <aihua.li@huawei.com>
Diffstat (limited to 'tools/collectors')
-rw-r--r--tools/collectors/__init__.py18
-rw-r--r--tools/collectors/collector/__init__.py18
-rw-r--r--tools/collectors/collector/collector.py38
-rwxr-xr-xtools/collectors/sysmetrics/__init__.py18
-rw-r--r--tools/collectors/sysmetrics/linuxmetrics.py79
5 files changed, 171 insertions, 0 deletions
diff --git a/tools/collectors/__init__.py b/tools/collectors/__init__.py
new file mode 100644
index 00000000..f2f3adf3
--- /dev/null
+++ b/tools/collectors/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2015 Intel Corporation.
+#
+# 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.
+
+"""Collectors package.
+
+Contains collector interface and its various implementations.
+"""
diff --git a/tools/collectors/collector/__init__.py b/tools/collectors/collector/__init__.py
new file mode 100644
index 00000000..85de5749
--- /dev/null
+++ b/tools/collectors/collector/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2015 Intel Corporation.
+#
+# 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.
+
+"""A collection of functions for automating a system metrics logger.
+"""
+
+from tools.collectors.collector.collector import *
diff --git a/tools/collectors/collector/collector.py b/tools/collectors/collector/collector.py
new file mode 100644
index 00000000..27a07202
--- /dev/null
+++ b/tools/collectors/collector/collector.py
@@ -0,0 +1,38 @@
+# Copyright 2015 Intel Corporation.
+#
+# 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.
+
+"""Abstract "system metrics logger" model.
+"""
+
+CMD_PREFIX = 'metricscmd : '
+
+class ICollector(object):
+ """This is an abstract class for system metrics loggers.
+ """
+
+ def log_mem_stats(self):
+ """Log memory statistics.
+
+ Where implemented, this function should raise an exception on
+ failure.
+ """
+ raise NotImplementedError('Please call an implementation.')
+
+ def log_cpu_stats(self):
+ """Log cpu statistics.
+
+ Where implemented, this function should raise an exception on
+ failure.
+ """
+ raise NotImplementedError('Please call an implementation.')
diff --git a/tools/collectors/sysmetrics/__init__.py b/tools/collectors/sysmetrics/__init__.py
new file mode 100755
index 00000000..9ad1bf29
--- /dev/null
+++ b/tools/collectors/sysmetrics/__init__.py
@@ -0,0 +1,18 @@
+# Copyright 2015 Intel Corporation.
+#
+# 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.
+
+"""Implementation of linux-metrics system metrics logger.
+"""
+
+from tools.collectors.sysmetrics.linuxmetrics import *
diff --git a/tools/collectors/sysmetrics/linuxmetrics.py b/tools/collectors/sysmetrics/linuxmetrics.py
new file mode 100644
index 00000000..fdf30696
--- /dev/null
+++ b/tools/collectors/sysmetrics/linuxmetrics.py
@@ -0,0 +1,79 @@
+# Copyright 2015 Intel Corporation.
+#
+# 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.
+
+"""linux-metrics system statistics model.
+
+Provides linux-metrics system statistics generic "helper" functions.
+
+This requires the following setting in your config:
+
+* SYSMETRICS_LINUX_METRICS_CPU_SAMPLES_INTERVAL
+ Number of seconds in between samples to take for CPU percentages
+
+If this doesn't exist, the application will raise an exception
+(EAFP).
+"""
+
+
+import logging
+import os
+from conf import settings
+from tools.collectors.collector import collector
+from linux_metrics import cpu_stat, mem_stat
+
+_ROOT_DIR = os.path.dirname(os.path.realpath(__file__))
+
+class LinuxMetrics(collector.ICollector):
+ """A logger based on the linux-metrics module.
+
+ Currently it supports the logging of memory and CPU statistics
+ """
+ def __init__(self):
+ self._logger = logging.getLogger(__name__)
+ self._num_samples = settings.getValue(
+ 'SYSMETRICS_LINUX_METRICS_CPU_SAMPLES_INTERVAL')
+ self._mem_stats = []
+ self._cpu_stats = []
+
+ def log_mem_stats(self):
+ """See ICollector for descripion
+ """
+ self._mem_stats = mem_stat.mem_stats()
+ # pylint: disable=unbalanced-tuple-unpacking
+ mem_active, mem_total, mem_cached, mem_free, swap_total, swap_free = \
+ self._mem_stats
+ self._logger.info('%s mem_active: %s, mem_total: %s, mem_cached: %s, '
+ 'mem_free: %s, swap_total: %s, swap_free: %s',
+ collector.CMD_PREFIX,
+ mem_active, mem_total, mem_cached, mem_free,
+ swap_total, swap_free)
+ return self._mem_stats
+
+ def log_cpu_stats(self):
+ """See ICollector for descripion
+ """
+ self._cpu_stats = cpu_stat.cpu_percents(self._num_samples)
+ self._logger.info('%s user: %.2f%%, nice: %.2f%%, system: %.2f%%, '
+ 'idle: %.2f%%, iowait: %.2f%%, irq: %.2f%%, '
+ 'softirq: %.2f%%',
+ collector.CMD_PREFIX,
+ self._cpu_stats['user'],
+ self._cpu_stats['nice'],
+ self._cpu_stats['system'],
+ self._cpu_stats['idle'],
+ self._cpu_stats['iowait'],
+ self._cpu_stats['irq'],
+ self._cpu_stats['softirq'])
+ return self._cpu_stats
+