aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit/benchmark/contexts/test_kubernetes.py
diff options
context:
space:
mode:
authorDeepak S <deepak.s@linux.intel.com>2017-06-20 14:31:19 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-08-08 08:54:23 -0700
commit5ce3b6f8c8b3217091e51a6041455738603d90b8 (patch)
treeca34e15a85d69e2b23ce498fead47761624ae42c /tests/unit/benchmark/contexts/test_kubernetes.py
parent72778951d6b8968f562fb8fefa02a57159ea1b83 (diff)
NSB update
Refactored main NSB VNF classes accroding to class diagram https://wiki.opnfv.org/display/yardstick/NSB+class+diagram All the SampleVNFs have been separated and placed under the SampleVNF class. Added AutoConnectSSH to automatically create SSH conneciton on demand. Added VnfdHelper class to wrap the VNFD dictionary in prepartion for class-based modeling. Extracted DpdkVnfSetupEnvHelper for DPDK based VNF setup. Extracted Stats and other client config to ResourceHelper Had to replace dict_key_flatten with deepgetitem due to Python 2.7 Jinja2 infinite recursion. Change-Id: Ia8840e9c44cdbdf39aab6b02e6d2176b31937dc9 Signed-off-by: Deepak S <deepak.s@linux.intel.com> Signed-off-by: Edward MacGillivray <edward.s.macgillivray@intel.com> Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
Diffstat (limited to 'tests/unit/benchmark/contexts/test_kubernetes.py')
-rw-r--r--tests/unit/benchmark/contexts/test_kubernetes.py34
1 files changed, 8 insertions, 26 deletions
diff --git a/tests/unit/benchmark/contexts/test_kubernetes.py b/tests/unit/benchmark/contexts/test_kubernetes.py
index f47c07a67..b0ee792db 100644
--- a/tests/unit/benchmark/contexts/test_kubernetes.py
+++ b/tests/unit/benchmark/contexts/test_kubernetes.py
@@ -15,6 +15,7 @@ from __future__ import absolute_import
import unittest
import mock
+from yardstick.benchmark.contexts.base import Context
from yardstick.benchmark.contexts.kubernetes import KubernetesContext
@@ -40,7 +41,11 @@ service ssh restart;while true ; do sleep 10000; done']
prefix = 'yardstick.benchmark.contexts.kubernetes'
-class UndeployTestCase(unittest.TestCase):
+class KubernetesTestCase(unittest.TestCase):
+
+ def tearDown(self):
+ # clear kubernetes contexts from global list so we don't break other tests
+ Context.list = []
@mock.patch('{}.KubernetesContext._delete_ssh_key'.format(prefix))
@mock.patch('{}.KubernetesContext._delete_rcs'.format(prefix))
@@ -57,9 +62,6 @@ class UndeployTestCase(unittest.TestCase):
self.assertTrue(mock_delete_rcs.called)
self.assertTrue(mock_delete_pods.called)
-
-class DeployTestCase(unittest.TestCase):
-
@mock.patch('{}.KubernetesContext._wait_until_running'.format(prefix))
@mock.patch('{}.KubernetesTemplate.get_rc_pods'.format(prefix))
@mock.patch('{}.KubernetesContext._create_rcs'.format(prefix))
@@ -72,15 +74,13 @@ class DeployTestCase(unittest.TestCase):
k8s_context = KubernetesContext()
k8s_context.init(context_cfg)
- k8s_context.deploy()
+ with mock.patch("yardstick.benchmark.contexts.kubernetes.time"):
+ k8s_context.deploy()
self.assertTrue(mock_set_ssh_key.called)
self.assertTrue(mock_create_rcs.called)
self.assertTrue(mock_get_rc_pods.called)
self.assertTrue(mock_wait_until_running.called)
-
-class SSHKeyTestCase(unittest.TestCase):
-
@mock.patch('{}.k8s_utils.delete_config_map'.format(prefix))
@mock.patch('{}.k8s_utils.create_config_map'.format(prefix))
def test_ssh_key(self, mock_create, mock_delete):
@@ -92,9 +92,6 @@ class SSHKeyTestCase(unittest.TestCase):
self.assertTrue(mock_create.called)
self.assertTrue(mock_delete.called)
-
-class WaitUntilRunningTestCase(unittest.TestCase):
-
@mock.patch('{}.k8s_utils.read_pod_status'.format(prefix))
def test_wait_until_running(self, mock_read_pod_status):
@@ -104,9 +101,6 @@ class WaitUntilRunningTestCase(unittest.TestCase):
mock_read_pod_status.return_value = 'Running'
k8s_context._wait_until_running()
-
-class GetServerTestCase(unittest.TestCase):
-
@mock.patch('{}.k8s_utils.get_pod_list'.format(prefix))
def test_get_server(self, mock_get_pod_list):
k8s_context = KubernetesContext()
@@ -116,9 +110,6 @@ class GetServerTestCase(unittest.TestCase):
server = k8s_context._get_server('server')
self.assertIsNone(server)
-
-class CreateRcsTestCase(unittest.TestCase):
-
@mock.patch('{}.KubernetesContext._create_rc'.format(prefix))
def test_create_rcs(self, mock_create_rc):
k8s_context = KubernetesContext()
@@ -126,9 +117,6 @@ class CreateRcsTestCase(unittest.TestCase):
k8s_context._create_rcs()
self.assertTrue(mock_create_rc.called)
-
-class CreateRcTestCase(unittest.TestCase):
-
@mock.patch('{}.k8s_utils.create_replication_controller'.format(prefix))
def test_create_rc(self, mock_create_replication_controller):
k8s_context = KubernetesContext()
@@ -136,9 +124,6 @@ class CreateRcTestCase(unittest.TestCase):
k8s_context._create_rc({})
self.assertTrue(mock_create_replication_controller.called)
-
-class DeleteRcsTestCases(unittest.TestCase):
-
@mock.patch('{}.KubernetesContext._delete_rc'.format(prefix))
def test_delete_rcs(self, mock_delete_rc):
k8s_context = KubernetesContext()
@@ -146,9 +131,6 @@ class DeleteRcsTestCases(unittest.TestCase):
k8s_context._delete_rcs()
self.assertTrue(mock_delete_rc.called)
-
-class DeleteRcTestCase(unittest.TestCase):
-
@mock.patch('{}.k8s_utils.delete_replication_controller'.format(prefix))
def test_delete_rc(self, mock_delete_replication_controller):
k8s_context = KubernetesContext()