aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/benchmark/contexts/standalone/test_model.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/tests/unit/benchmark/contexts/standalone/test_model.py b/tests/unit/benchmark/contexts/standalone/test_model.py
index a8c54f193..021c18860 100644
--- a/tests/unit/benchmark/contexts/standalone/test_model.py
+++ b/tests/unit/benchmark/contexts/standalone/test_model.py
@@ -1,5 +1,3 @@
-#!/usr/bin/env python
-
# Copyright (c) 2016-2017 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -16,7 +14,6 @@
# Unittest for yardstick.benchmark.contexts.standalone.model
-from __future__ import absolute_import
import copy
import os
import unittest
@@ -24,9 +21,9 @@ import mock
from xml.etree import ElementTree
+from yardstick.benchmark.contexts.standalone.model import Libvirt
from yardstick.benchmark.contexts.standalone import model
from yardstick.network_services import utils
-from yardstick.network_services.helpers import cpu
XML_SAMPLE = """<?xml version="1.0"?>
@@ -202,21 +199,23 @@ class ModelLibvirtTestCase(unittest.TestCase):
ssh_mock.execute = \
mock.Mock(return_value=(0, "a", ""))
ssh.return_value = ssh_mock
- # NOTE(ralonsoh): this test doesn't cover function execution. This test
- # should also check mocked function calls.
- model.Libvirt.update_interrupts_hugepages_perf(ssh_mock)
-
- @mock.patch.object(cpu.CpuSysCores, 'get_core_socket')
- def test_pin_vcpu_for_perf(self, mock_get_core_socket):
- mock_get_core_socket.return_value = {
- 'cores_per_socket': 1,
- 'thread_per_core': 1,
- '0': [1, 2]
- }
- # NOTE(ralonsoh): this test doesn't cover function execution. This
- # function needs more tests.
- model.Libvirt.pin_vcpu_for_perf(mock.Mock())
-
+ # NOTE(ralonsoh): 'update_interrupts_hugepages_perf' always return
+ # None, this check is trivial.
+ #status = Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+ #self.assertIsNone(status)
+ Libvirt.update_interrupts_hugepages_perf(ssh_mock)
+
+ @mock.patch("yardstick.benchmark.contexts.standalone.model.CpuSysCores")
+ @mock.patch.object(model.Libvirt, 'update_interrupts_hugepages_perf')
+ def test_pin_vcpu_for_perf(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
+ with mock.patch("yardstick.ssh.SSH") as ssh:
+ ssh_mock = mock.Mock(autospec=ssh.SSH)
+ ssh_mock.execute = \
+ mock.Mock(return_value=(0, "a", ""))
+ ssh.return_value = ssh_mock
+ status = Libvirt.pin_vcpu_for_perf(ssh_mock, 4)
+ self.assertIsNotNone(status)
class StandaloneContextHelperTestCase(unittest.TestCase):
@@ -268,8 +267,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
def test_get_nic_details(self, mock_get_kernel_module):
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
- ssh_mock.execute = \
- mock.Mock(return_value=(1, "i40e ixgbe", ""))
+ ssh_mock.execute = mock.Mock(return_value=(1, "i40e ixgbe", ""))
ssh.return_value = ssh_mock
mock_get_kernel_module.return_value = "i40e"
# NOTE(ralonsoh): this test doesn't cover function execution. This test
@@ -317,6 +315,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
@mock.patch('yardstick.ssh.SSH')
def test_get_mgmt_ip(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = mock.Mock(
@@ -330,6 +329,7 @@ class StandaloneContextHelperTestCase(unittest.TestCase):
@mock.patch('yardstick.ssh.SSH')
def test_get_mgmt_ip_no(self, *args):
+ # NOTE(ralonsoh): test mocked methods/variables.
with mock.patch("yardstick.ssh.SSH") as ssh:
ssh_mock = mock.Mock(autospec=ssh.SSH)
ssh_mock.execute = \