From b5cafe95acef8a14def98192b6de96b92b574cef Mon Sep 17 00:00:00 2001 From: John O Loughlin Date: Tue, 15 May 2018 11:43:05 +0100 Subject: Add "resources" parameter in Kubernetes context This new parameter, "resources", will allow the user to automatically add resources in a pod definition per container. Example of yaml definition in Kubernetes: apiVersion: v1 kind: Pod metadata: name: frontend spec: containers: - name: db image: mysql resources: requests: memory: "64Mi" cpu: "250m" limits: memory: "128Mi" cpu: "500m" Example of definition in a Yardstick context: context: type: Kubernetes servers: host: resources: # There are two possible keys in this dict: # "requests" and "limits". limits: requests: Resources in containers [1]. [1] https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/ JIRA:YARDSTICK-1171 Change-Id: I163d72d9d3e88b538fca73eb4dbf38613aa23ff4 Signed-off-by: John O Loughlin --- yardstick/tests/unit/orchestrator/test_kubernetes.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'yardstick/tests/unit/orchestrator/test_kubernetes.py') diff --git a/yardstick/tests/unit/orchestrator/test_kubernetes.py b/yardstick/tests/unit/orchestrator/test_kubernetes.py index 5eba1a02a..2451518a4 100644 --- a/yardstick/tests/unit/orchestrator/test_kubernetes.py +++ b/yardstick/tests/unit/orchestrator/test_kubernetes.py @@ -302,6 +302,24 @@ class ContainerObjectTestCase(base.BaseUnitTestCase): 'value': 'fake_var_value'}]} self.assertEqual(expected, container_obj.get_container_item()) + def test_get_container_item_with_resources(self): + volume_mount = {'name': 'fake_name', + 'mountPath': 'fake_path'} + args = ['arg1', 'arg2'] + resources = {'requests': {'key1': 'val1'}, + 'limits': {'key2': 'val2'}, + 'other_key': {'key3': 'val3'}} + container_obj = kubernetes.ContainerObject( + 'cname', ssh_key='fake_sshkey', volumeMount=[volume_mount], + args=args, resources=resources) + expected = {'args': args, + 'command': [kubernetes.ContainerObject.COMMAND_DEFAULT], + 'image': kubernetes.ContainerObject.IMAGE_DEFAULT, + 'name': 'cname-container', + 'volumeMounts': container_obj._create_volume_mounts(), + 'resources': {'requests': {'key1': 'val1'}, + 'limits': {'key2': 'val2'}}} + self.assertEqual(expected, container_obj.get_container_item()) class CustomResourceDefinitionObjectTestCase(base.BaseUnitTestCase): -- cgit 1.2.3-korg