aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick
diff options
context:
space:
mode:
authorStepan Andrushko <stepanx.andrushko@intel.com>2018-10-31 15:58:51 +0200
committerStepan Andrushko <stepanx.andrushko@intel.com>2019-04-19 10:41:24 +0000
commita84cbaaf620fff614a68e0cc95775c45738f14b1 (patch)
tree00dc4a51d90b437d91c2d9eaf73f6e2638f0cf15 /yardstick
parent37b6e13c72a5079fd0b99478a23774d05c21a04f (diff)
Log VM OS version, Sample VNF branch/commit ID
Added debug logs to track VM, Sample VNF details during testing: - Virtual machine OS, kernel version; - Sample VNF branch, commit ID. JIRA: YARDSTICK-1499 Change-Id: I243c435809d4541dfdb8c7c3466f50c5d524ac00 Signed-off-by: Stepan Andrushko <stepanx.andrushko@intel.com>
Diffstat (limited to 'yardstick')
-rw-r--r--yardstick/benchmark/contexts/standalone/model.py11
-rw-r--r--yardstick/common/utils.py45
-rw-r--r--yardstick/tests/unit/common/test_utils.py28
3 files changed, 84 insertions, 0 deletions
diff --git a/yardstick/benchmark/contexts/standalone/model.py b/yardstick/benchmark/contexts/standalone/model.py
index aa5fdd391..a15426872 100644
--- a/yardstick/benchmark/contexts/standalone/model.py
+++ b/yardstick/benchmark/contexts/standalone/model.py
@@ -26,6 +26,7 @@ import xml.etree.ElementTree as ET
from yardstick import ssh
from yardstick.common import constants
from yardstick.common import exceptions
+from yardstick.common import utils as common_utils
from yardstick.common import yaml_loader
from yardstick.network_services.utils import PciAddress
from yardstick.network_services.helpers.cpu import CpuSysCores
@@ -554,6 +555,16 @@ class StandaloneContextHelper(object):
ip = cls.get_mgmt_ip(connection, node["mac"], mgmtip, node)
if ip:
node["ip"] = ip
+ client = ssh.SSH.from_node(node)
+ LOG.debug("OS version: %s",
+ common_utils.get_os_version(client))
+ LOG.debug("Kernel version: %s",
+ common_utils.get_kernel_version(client))
+ vnfs_data = common_utils.get_sample_vnf_info(client)
+ for vnf_name, vnf_data in vnfs_data.items():
+ LOG.debug("VNF name: '%s', commit ID/branch: '%s'",
+ vnf_name, vnf_data["branch_commit"])
+ LOG.debug("%s", vnf_data["md5_result"])
return nodes
@classmethod
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index 9eba896e2..7475f6991 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -19,6 +19,7 @@ import datetime
import errno
import importlib
import ipaddress
+import json
import logging
import os
import pydoc
@@ -629,3 +630,47 @@ def safe_cast(value, type_to_convert, default_value):
return _type(value)
except ValueError:
return default_value
+
+
+def get_os_version(ssh_client):
+ """Return OS version.
+
+ :param ssh_client: SSH
+ :return str: Linux OS versions
+ """
+ os_ver = ssh_client.execute("cat /etc/lsb-release")[1]
+ return os_ver
+
+
+def get_kernel_version(ssh_client):
+ """Return kernel version.
+
+ :param ssh_client: SSH
+ :return str: Linux kernel versions
+ """
+ kernel_ver = ssh_client.execute("uname -a")[1]
+ return kernel_ver
+
+
+def get_sample_vnf_info(ssh_client,
+ json_file='/opt/nsb_bin/yardstick_sample_vnf.json'):
+ """Return sample VNF data.
+
+ :param ssh_client: SSH
+ :param json_file: str
+ :return dict: information about sample VNF
+ """
+ rc, json_str, err = ssh_client.execute("cat %s" % json_file)
+ logger.debug("cat %s: %s, rc: %s, err: %s", json_file, json_str, rc, err)
+
+ if rc:
+ return {}
+ json_data = json.loads(json_str)
+ for vnf_data in json_data.values():
+ out = ssh_client.execute("md5sum %s" % vnf_data["path_vnf"])[1]
+ md5 = out.split()[0].strip()
+ if md5 == vnf_data["md5"]:
+ vnf_data["md5_result"] = "MD5 checksum is valid"
+ else:
+ vnf_data["md5_result"] = "MD5 checksum is invalid"
+ return json_data
diff --git a/yardstick/tests/unit/common/test_utils.py b/yardstick/tests/unit/common/test_utils.py
index 6b8d81907..8fed5ecf1 100644
--- a/yardstick/tests/unit/common/test_utils.py
+++ b/yardstick/tests/unit/common/test_utils.py
@@ -1433,3 +1433,31 @@ class SetupHugepagesTestCase(unittest.TestCase):
self.assertEqual(hp_size_kb, 1024)
self.assertEqual(hp_number, 10)
self.assertEqual(hp_number_set, 5)
+
+
+class GetOSSampleInfoTestCase(unittest.TestCase):
+
+ def test_get_os_version(self, *args):
+ ssh = mock.Mock()
+ ssh.execute.return_value = (0, "18.04", "")
+ utils.get_os_version(ssh)
+ ssh.execute.assert_called_once_with("cat /etc/lsb-release")
+
+ def test_get_kernel_version(self, *args):
+ ssh = mock.Mock()
+ ssh.execute.return_value = (0, "Linux", "")
+ utils.get_kernel_version(ssh)
+ ssh.execute.assert_called_once_with("uname -a")
+
+ def test_get_sample_vnf_info(self, *args):
+ json_out = """
+ {"UDP_Replay": {
+ "branch_commit": "47123bfc1b3c0d0b01884aebbce1a3e09ad7ddb0",
+ "md5": "4577702f6d6848380bd912232a1b9ca5",
+ "path_vnf": "/opt/nsb_bin/UDP_Replay"
+ }
+ }"""
+ json_file = '/opt/nsb_bin/yardstick_sample_vnf.json'
+ ssh = mock.Mock()
+ ssh.execute.return_value = (0, json_out, "")
+ utils.get_sample_vnf_info(ssh, json_file)