3 ##############################################################################
4 # Copyright (c) 2017 Intel Corporation
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Unittest for yardstick.benchmark.orchestrator.heat
16 from yardstick.orchestrator.kubernetes import KubernetesObject
17 from yardstick.orchestrator.kubernetes import KubernetesTemplate
20 class GetTemplateTestCase(unittest.TestCase):
22 def test_get_template(self):
25 "kind": "ReplicationController",
27 "name": "host-k8s-86096c30"
34 "app": "host-k8s-86096c30"
42 "chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
43 service ssh restart;while true ; do sleep 10000; done"
48 "image": "openretriever/yardstick",
49 "name": "host-k8s-86096c30-container",
52 "mountPath": "/root/.ssh/",
53 "name": "k8s-86096c30-key"
61 "name": "k8s-86096c30-key"
63 "name": "k8s-86096c30-key"
67 "kubernetes.io/hostname": "node-01"
74 'command': '/bin/bash',
75 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
76 service ssh restart;while true ; do sleep 10000; done'],
77 'ssh_key': 'k8s-86096c30-key',
78 'nodeSelector': { 'kubernetes.io/hostname': 'node-01'}
80 name = 'host-k8s-86096c30'
81 output_r = KubernetesObject(name, **input_s).get_template()
82 self.assertEqual(output_r, output_t)
85 class GetRcPodsTestCase(unittest.TestCase):
87 @mock.patch('yardstick.orchestrator.kubernetes.k8s_utils.get_pod_list')
88 def test_get_rc_pods(self, mock_get_pod_list):
91 'image': 'openretriever/yardstick',
92 'command': '/bin/bash',
93 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
94 service ssh restart;while true ; do sleep 10000; done']
97 'image': 'openretriever/yardstick',
98 'command': '/bin/bash',
99 'args': ['-c', 'chmod 700 ~/.ssh; chmod 600 ~/.ssh/*; \
100 service ssh restart;while true ; do sleep 10000; done']
103 k8s_template = KubernetesTemplate('k8s-86096c30', servers)
104 mock_get_pod_list.return_value.items = []
105 pods = k8s_template.get_rc_pods()
106 self.assertEqual(pods, [])
113 if __name__ == '__main__':