aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-05-16 16:37:10 +0100
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-06-14 07:15:55 +0000
commitdeca2856353603b6ac8a016a4a2aedab465953e9 (patch)
tree4064e49cbb8a2ebee0b5cc3daeaa51dd403b3970
parent9c19d2dc2ca9057d5d27b3e1b77e40fee2fcc6d4 (diff)
Change "KubernetesObject" class name to "ReplicationController"
The class name "KubernetesObject" is not accurate. This class holds the definition of a Kubernetes replication controller. The suggested name is therefore "ReplicationControllerObject". JIRA: YARDSTICK-1180 Change-Id: I9ee9228f9528cb779e54a9bc178760b6e24c85c2 Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
-rw-r--r--yardstick/orchestrator/kubernetes.py11
-rw-r--r--yardstick/tests/unit/orchestrator/test_kubernetes.py30
2 files changed, 22 insertions, 19 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py
index 231a03b13..120c40b9f 100644
--- a/yardstick/orchestrator/kubernetes.py
+++ b/yardstick/orchestrator/kubernetes.py
@@ -61,12 +61,12 @@ class ContainerObject(object):
return container
-class KubernetesObject(object):
+class ReplicationControllerObject(object):
SSHKEY_DEFAULT = 'yardstick_key'
def __init__(self, name, **kwargs):
- super(KubernetesObject, self).__init__()
+ super(ReplicationControllerObject, self).__init__()
parameters = copy.deepcopy(kwargs)
self.name = name
self.node_selector = parameters.pop('nodeSelector', {})
@@ -360,10 +360,9 @@ class KubernetesTemplate(object):
self.ssh_key = '{}-key'.format(name)
self.rcs = [self._get_rc_name(rc) for rc in servers_cfg]
- self.k8s_objs = [KubernetesObject(self._get_rc_name(rc),
- ssh_key=self.ssh_key,
- **cfg)
- for rc, cfg in servers_cfg.items()]
+ self.k8s_objs = [ReplicationControllerObject(
+ self._get_rc_name(rc), ssh_key=self.ssh_key, **cfg)
+ for rc, cfg in servers_cfg.items()]
self.service_objs = [ServiceObject(s) for s in self.rcs]
self.crd = [CustomResourceDefinitionObject(self.name, **crd)
for crd in crd_cfg]
diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py
index fe9e2fd2b..e8d5abf67 100644
--- a/yardstick/tests/unit/orchestrator/test_kubernetes.py
+++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py
@@ -80,7 +80,8 @@ service ssh restart;while true ; do sleep 10000; done'],
'volumes': []
}
name = 'host-k8s-86096c30'
- output_r = kubernetes.KubernetesObject(name, **input_s).get_template()
+ output_r = kubernetes.ReplicationControllerObject(
+ name, **input_s).get_template()
self.assertEqual(output_r, output_t)
@@ -108,14 +109,14 @@ service ssh restart;while true ; do sleep 10000; done']
self.assertEqual(pods, [])
-class KubernetesObjectTestCase(base.BaseUnitTestCase):
+class ReplicationControllerObjectTestCase(base.BaseUnitTestCase):
def test__init_one_container(self):
pod_name = 'pod_name'
_kwargs = {'args': ['arg1', 'arg2'],
'image': 'fake_image',
'command': 'fake_command'}
- k8s_obj = kubernetes.KubernetesObject(pod_name, **_kwargs)
+ k8s_obj = kubernetes.ReplicationControllerObject(pod_name, **_kwargs)
self.assertEqual(1, len(k8s_obj._containers))
container = k8s_obj._containers[0]
self.assertEqual(['arg1', 'arg2'], container._args)
@@ -131,7 +132,7 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
'image': 'fake_image_%s' % i,
'command': 'fake_command_%s' % i})
_kwargs = {'containers': containers}
- k8s_obj = kubernetes.KubernetesObject(pod_name, **_kwargs)
+ k8s_obj = kubernetes.ReplicationControllerObject(pod_name, **_kwargs)
self.assertEqual(5, len(k8s_obj._containers))
for i in range(5):
container = k8s_obj._containers[i]
@@ -145,8 +146,8 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
'configMap': {'name': 'fake_sshkey'}}
volume2 = {'name': 'volume2',
'configMap': 'data'}
- k8s_obj = kubernetes.KubernetesObject('name', ssh_key='fake_sshkey',
- volumes=[volume2])
+ k8s_obj = kubernetes.ReplicationControllerObject(
+ 'name', ssh_key='fake_sshkey', volumes=[volume2])
k8s_obj._add_volumes()
volumes = k8s_obj.template['spec']['template']['spec']['volumes']
self.assertEqual(sorted([volume1, volume2], key=lambda k: k['name']),
@@ -155,7 +156,8 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
def test__add_volumes_no_volumes(self):
volume1 = {'name': 'fake_sshkey',
'configMap': {'name': 'fake_sshkey'}}
- k8s_obj = kubernetes.KubernetesObject('name', ssh_key='fake_sshkey')
+ k8s_obj = kubernetes.ReplicationControllerObject(
+ 'name', ssh_key='fake_sshkey')
k8s_obj._add_volumes()
volumes = k8s_obj.template['spec']['template']['spec']['volumes']
self.assertEqual([volume1], volumes)
@@ -163,7 +165,8 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
def test__create_ssh_key_volume(self):
expected = {'name': 'fake_sshkey',
'configMap': {'name': 'fake_sshkey'}}
- k8s_obj = kubernetes.KubernetesObject('name', ssh_key='fake_sshkey')
+ k8s_obj = kubernetes.ReplicationControllerObject(
+ 'name', ssh_key='fake_sshkey')
self.assertEqual(expected, k8s_obj._create_ssh_key_volume())
def test__create_volume_item(self):
@@ -172,16 +175,17 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
vol_type: 'data'}
self.assertEqual(
volume,
- kubernetes.KubernetesObject._create_volume_item(volume))
+ kubernetes.ReplicationControllerObject.
+ _create_volume_item(volume))
def test__create_volume_item_invalid_type(self):
volume = {'name': 'vol_name',
'invalid_type': 'data'}
with self.assertRaises(exceptions.KubernetesTemplateInvalidVolumeType):
- kubernetes.KubernetesObject._create_volume_item(volume)
+ kubernetes.ReplicationControllerObject._create_volume_item(volume)
def test__add_security_context(self):
- k8s_obj = kubernetes.KubernetesObject('pod_name')
+ k8s_obj = kubernetes.ReplicationControllerObject('pod_name')
self.assertNotIn('securityContext',
k8s_obj.template['spec']['template']['spec'])
@@ -198,7 +202,7 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
{'securityContext': {'key%s' % i: 'value%s' % i}})
_kwargs = {'containers': containers,
'securityContext': {'key_pod': 'value_pod'}}
- k8s_obj = kubernetes.KubernetesObject('pod_name', **_kwargs)
+ k8s_obj = kubernetes.ReplicationControllerObject('pod_name', **_kwargs)
self.assertEqual(
{'key_pod': 'value_pod'},
k8s_obj.template['spec']['template']['spec']['securityContext'])
@@ -209,7 +213,7 @@ class KubernetesObjectTestCase(base.BaseUnitTestCase):
container['securityContext'])
def test__add_networks(self):
- k8s_obj = kubernetes.KubernetesObject(
+ k8s_obj = kubernetes.ReplicationControllerObject(
'name', networks=['network1', 'network2', 'network3'])
k8s_obj._add_networks()
networks = k8s_obj.\