aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/tests/unit/orchestrator/test_kubernetes.py
diff options
context:
space:
mode:
authorJohn O'Loughlin <john.oloughlin@intel.com>2018-05-17 15:06:53 +0000
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-07-10 10:31:30 +0100
commitff3cd7a245840606b09322c7705f8a64cf1868f2 (patch)
tree59a2cb213e0991cb2ea4184ef961882e1dc1e660 /yardstick/tests/unit/orchestrator/test_kubernetes.py
parent028e92b1b2dcbaffd4a80061cc3d387877b59d62 (diff)
Add "ports" parameters in Kubernetes context
This new parameter, "ports", will allow the user to automatically to add port variables in a pod definition: context: type: Kubernetes servers: host: image: ... commands: ... ports: - containerPort: <port value> # Mandatory hostIP: <host IP> # Optional hostPort: <host port> # Optional name: <port name> # Optional protocol: <protocol name> # Optional The port type and the definition must be one of the supported ones in Kubernetes [1]. Container port definition, V1 API, Kubernetes Python library v6.0.0 [2] [1] https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/ [2] https://github.com/kubernetes-client/python/blob/6.0.0/kubernetes/client/models/v1_container_port.py JIRA: YARDSTICK-1183 Change-Id: I3673dbeec8d380cb2f8b1dacf6c25c7cdbc37e28 Signed-off-by: John O Loughlin <john.oloughlin@intel.com>
Diffstat (limited to 'yardstick/tests/unit/orchestrator/test_kubernetes.py')
-rw-r--r--yardstick/tests/unit/orchestrator/test_kubernetes.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py
index e9c3c9751..afadf748a 100644
--- a/yardstick/tests/unit/orchestrator/test_kubernetes.py
+++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py
@@ -311,6 +311,44 @@ class ContainerObjectTestCase(base.BaseUnitTestCase):
'value': 'fake_var_value'}]}
self.assertEqual(expected, container_obj.get_container_item())
+ def test_get_container_item_with_ports_multi_parameter(self):
+ volume_mount = {'name': 'fake_name',
+ 'mountPath': 'fake_path'}
+ args = ['arg1', 'arg2']
+ container_obj = kubernetes.ContainerObject(
+ 'cname', ssh_key='fake_sshkey', volumeMount=[volume_mount],
+ args=args, ports=[{'containerPort': 'fake_port_name',
+ 'hostPort': 'fake_host_port',
+ 'name': 'fake_name',
+ 'protocol': 'fake_protocol',
+ 'invalid_varible': 'fakeinvalid_varible',
+ 'hostIP': 'fake_port_number'}])
+ expected = {'args': args,
+ 'command': [
+ kubernetes.ContainerObject.COMMAND_DEFAULT],
+ 'image': kubernetes.ContainerObject.IMAGE_DEFAULT,
+ 'name': 'cname-container',
+ 'volumeMounts': container_obj._create_volume_mounts(),
+ 'ports': [{'containerPort': 'fake_port_name',
+ 'hostPort': 'fake_host_port',
+ 'name': 'fake_name',
+ 'protocol': 'fake_protocol',
+ 'hostIP': 'fake_port_number'}]}
+ self.assertEqual(expected, container_obj.get_container_item())
+
+ def test_get_container_item_with_ports_no_container_port(self):
+ with self.assertRaises(exceptions.KubernetesContainerPortNotDefined):
+ volume_mount = {'name': 'fake_name',
+ 'mountPath': 'fake_path'}
+ args = ['arg1', 'arg2']
+ container_obj = kubernetes.ContainerObject(
+ 'cname', ssh_key='fake_sshkey', volumeMount=[volume_mount],
+ args=args, ports=[{'hostPort': 'fake_host_port',
+ 'name': 'fake_name',
+ 'protocol': 'fake_protocol',
+ 'hostIP': 'fake_port_number'}])
+ container_obj.get_container_item()
+
def test_get_container_item_with_resources(self):
volume_mount = {'name': 'fake_name',
'mountPath': 'fake_path'}