1 ##############################################################################
2 # Copyright (c) 2017 Intel Corporation
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 # Unittest for yardstick.benchmark.orchestrator.heat
14 from yardstick.orchestrator.kubernetes import KubernetesObject
15 from yardstick.orchestrator.kubernetes import KubernetesTemplate
18 class GetTemplateTestCase(unittest.TestCase):
20 def test_get_template(self):
23 "kind": "ReplicationController",
25 "name": "host-k8s-86096c30"
32 "app": "host-k8s-86096c30"
40 "chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
41 service ssh restart;while true ; do sleep 10000; done"
46 "image": "openretriever/yardstick",
47 "name": "host-k8s-86096c30-container",
50 "mountPath": "/tmp/.ssh/",
51 "name": "k8s-86096c30-key"
59 "name": "k8s-86096c30-key"
61 "name": "k8s-86096c30-key"
65 "kubernetes.io/hostname": "node-01"
72 'command': '/bin/bash',
73 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
74 service ssh restart;while true ; do sleep 10000; done'],
75 'ssh_key': 'k8s-86096c30-key',
76 'nodeSelector': {'kubernetes.io/hostname': 'node-01'}
78 name = 'host-k8s-86096c30'
79 output_r = KubernetesObject(name, **input_s).get_template()
80 self.assertEqual(output_r, output_t)
83 class GetRcPodsTestCase(unittest.TestCase):
85 @mock.patch('yardstick.orchestrator.kubernetes.k8s_utils.get_pod_list')
86 def test_get_rc_pods(self, mock_get_pod_list):
89 'image': 'openretriever/yardstick',
90 'command': '/bin/bash',
91 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
92 service ssh restart;while true ; do sleep 10000; done']
95 'image': 'openretriever/yardstick',
96 'command': '/bin/bash',
97 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
98 service ssh restart;while true ; do sleep 10000; done']
101 k8s_template = KubernetesTemplate('k8s-86096c30', servers)
102 mock_get_pod_list.return_value.items = []
103 pods = k8s_template.get_rc_pods()
104 self.assertEqual(pods, [])