diff options
author | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-18 17:14:24 +0100 |
---|---|---|
committer | Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com> | 2018-07-19 13:42:54 +0000 |
commit | 5b37f2eb188c390ce6942940e0ad9f33900dafd5 (patch) | |
tree | 567a2a471ca1031d8f5172cb7bfb5579bdaf0d0e | |
parent | 5c8add8e51f3cbc5f6949e890f13785502005576 (diff) |
Add "stdin" and "tty" parameters to Kubernetes container
JIRA: YARDSTICK-1330
Change-Id: I05303a1d0783421472883806f97441dd63f7f740
Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
-rw-r--r-- | yardstick/orchestrator/kubernetes.py | 6 | ||||
-rw-r--r-- | yardstick/tests/unit/orchestrator/test_kubernetes.py | 13 |
2 files changed, 19 insertions, 0 deletions
diff --git a/yardstick/orchestrator/kubernetes.py b/yardstick/orchestrator/kubernetes.py index 3e2572fcc..8d9fc41c9 100644 --- a/yardstick/orchestrator/kubernetes.py +++ b/yardstick/orchestrator/kubernetes.py @@ -41,6 +41,8 @@ class ContainerObject(object): self._resources = kwargs.get('resources', {}) self._ports = kwargs.get('ports', []) self._image_pull_policy = kwargs.get('imagePullPolicy') + self._tty = kwargs.get('tty') + self._stdin = kwargs.get('stdin') @staticmethod def _parse_commands(command): @@ -99,6 +101,10 @@ class ContainerObject(object): if self._image_pull_policy not in self.IMAGE_PULL_POLICY: raise exceptions.KubernetesContainerWrongImagePullPolicy() container['imagePullPolicy'] = self._image_pull_policy + if self._stdin is not None: + container['stdin'] = self._stdin + if self._tty is not None: + container['tty'] = self._tty return container diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py index be9c2ae24..a73a4a132 100644 --- a/yardstick/tests/unit/orchestrator/test_kubernetes.py +++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py @@ -405,6 +405,19 @@ class ContainerObjectTestCase(base.BaseUnitTestCase): 'imagePullPolicy':'Always'} self.assertEqual(expected, container_obj.get_container_item()) + def test_get_container_item_with_tty_stdin(self): + args = ['arg1', 'arg2'] + container_obj = kubernetes.ContainerObject( + 'cname', 'fake_sshkey', args=args, tty=False, stdin=True) + expected = {'args': args, + 'command': kubernetes.ContainerObject.COMMAND_DEFAULT, + 'image': kubernetes.ContainerObject.IMAGE_DEFAULT, + 'name': 'cname-container', + 'volumeMounts': container_obj._create_volume_mounts(), + 'tty': False, + 'stdin': True} + self.assertEqual(expected, container_obj.get_container_item()) + def test__parse_commands_string(self): container_obj = kubernetes.ContainerObject('cname', 'fake_sshkey') self.assertEqual(['fake command'], |