Add support for Python 3
[yardstick.git] / yardstick / vTC / apexlake / tests / common_test.py
1 # Copyright (c) 2015 Intel Research and Development Ireland Ltd.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 from __future__ import absolute_import
16 import unittest
17 import mock
18 import os
19 import logging
20 import six.moves.configparser
21 import experimental_framework.common as common
22 import experimental_framework.constants.conf_file_sections as cf
23 from experimental_framework import APEX_LAKE_ROOT
24
25 __author__ = 'vmricco'
26
27
28 def reset_common():
29     common.LOG = None
30     common.CONF_FILE = None
31     common.DEPLOYMENT_UNIT = None
32     common.ITERATIONS = None
33     common.BASE_DIR = None
34     common.RESULT_DIR = None
35     common.TEMPLATE_DIR = None
36     common.TEMPLATE_NAME = None
37     common.TEMPLATE_FILE_EXTENSION = None
38     common.PKTGEN = None
39     common.PKTGEN_DIR = None
40     common.PKTGEN_DPDK_DIRECTORY = None
41     common.PKTGEN_PROGRAM = None
42     common.PKTGEN_COREMASK = None
43     common.PKTGEN_MEMCHANNEL = None
44     common.PKTGEN_BUS_SLOT_NIC_1 = None
45     common.PKTGEN_BUS_SLOT_NIC_2 = None
46     common.INFLUXDB_IP = None
47     common.INFLUXDB_PORT = None
48     common.INFLUXDB_DB_NAME = None
49
50
51 class DummyConfigurationFile(common.ConfigurationFile):
52
53     def __init__(self, sections, conf_file=''):
54         pass
55
56     def get_variable(self, section, variable_name):
57         return 'vTC.yaml'
58
59     def get_variable_list(self, section):
60         return ['template_base_name']
61
62
63 class DummyConfigurationFile2(common.ConfigurationFile):
64
65     def __init__(self, sections):
66         self.pktgen_counter = 0
67
68     def get_variable(self, section, variable_name):
69         if variable_name == cf.CFSG_TEMPLATE_NAME:
70             return 'vTC.yaml'
71         if variable_name == cf.CFSG_ITERATIONS:
72             return '2'
73         if variable_name == cf.CFSG_DEBUG:
74             return 'True'
75         if variable_name == cf.CFSP_PACKET_GENERATOR:
76             if self.pktgen_counter == 1:
77                 return 'non_supported'
78             self.pktgen_counter += 1
79             return 'dpdk_pktgen'
80         if variable_name == cf.CFSP_DPDK_PKTGEN_DIRECTORY:
81             return APEX_LAKE_ROOT
82         if variable_name == cf.CFSP_DPDK_PROGRAM_NAME:
83             return 'program'
84         if variable_name == cf.CFSP_DPDK_COREMASK:
85             return 'coremask'
86         if variable_name == cf.CFSP_DPDK_MEMORY_CHANNEL:
87             return 'memchannel'
88         if variable_name == cf.CFSP_DPDK_BUS_SLOT_NIC_1:
89             return 'bus_slot_nic_1'
90         if variable_name == cf.CFSP_DPDK_BUS_SLOT_NIC_2:
91             return 'bus_slot_nic_2'
92         if variable_name == cf.CFSP_DPDK_DPDK_DIRECTORY:
93             return APEX_LAKE_ROOT
94
95     def get_variable_list(self, section):
96         if section == cf.CFS_PKTGEN:
97             return [
98                 cf.CFSP_DPDK_NAME_IF_2,
99                 cf.CFSP_DPDK_NAME_IF_1,
100                 cf.CFSP_DPDK_BUS_SLOT_NIC_1,
101                 cf.CFSP_DPDK_BUS_SLOT_NIC_2,
102                 cf.CFSP_DPDK_COREMASK,
103                 cf.CFSP_DPDK_DPDK_DIRECTORY,
104                 cf.CFSP_DPDK_PKTGEN_DIRECTORY,
105                 cf.CFSP_DPDK_MEMORY_CHANNEL,
106                 cf.CFSP_DPDK_PROGRAM_NAME,
107                 cf.CFSP_PACKET_GENERATOR
108             ]
109         else:
110             return [
111                 'template_base_name',
112                 'iterations',
113                 cf.CFSG_DEBUG
114             ]
115
116
117 class TestCommonInit(unittest.TestCase):
118
119     def setUp(self):
120         common.CONF_FILE = DummyConfigurationFile('')
121         self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework/')
122
123     def tearDown(self):
124         reset_common()
125         # common.CONF_FILE = None
126
127     @mock.patch('os.getcwd')
128     @mock.patch('experimental_framework.common.init_conf_file')
129     @mock.patch('experimental_framework.common.init_general_vars')
130     @mock.patch('experimental_framework.common.init_log')
131     @mock.patch('experimental_framework.common.init_pktgen')
132     @mock.patch('experimental_framework.common.CONF_FILE')
133     def test_init_for_success(self, mock_conf_file, init_pkgen, init_log,
134                               init_general_vars, init_conf_file, mock_getcwd):
135         mock_getcwd.return_value = self.dir
136         common.init(True)
137         if common.CONF_FILE.get_variable_list(cf.CFS_PKTGEN):
138             init_pkgen.assert_called_once()
139         init_conf_file.assert_called_once()
140         init_general_vars.assert_called_once()
141         init_log.assert_called_once()
142         expected = self.dir.split('experimental_framework/')[0]
143         self.assertEqual(common.BASE_DIR, expected)
144
145     @mock.patch('experimental_framework.common.InputValidation')
146     @mock.patch('os.path.exists')
147     @mock.patch('os.makedirs')
148     @mock.patch('experimental_framework.common.LOG')
149     def test_init_general_vars_for_success(self, mock_log, mock_makedirs,
150                                            mock_path_exists, mock_val_file):
151         common.BASE_DIR = APEX_LAKE_ROOT
152         mock_path_exists.return_value = False
153         mock_val_file.return_value = True
154         common.init_general_vars()
155         self.assertEqual(common.TEMPLATE_FILE_EXTENSION, '.yaml')
156         self.assertEqual(common.TEMPLATE_DIR, '/tmp/apexlake/heat_templates/')
157         self.assertEqual(common.TEMPLATE_NAME, 'vTC.yaml')
158         self.assertEqual(common.RESULT_DIR, '/tmp/apexlake/results/')
159         self.assertEqual(common.ITERATIONS, 1)
160     # mock_makedirs.assert_called_once_with('/tmp/apexlake/heat_templates/')
161
162
163 class TestCommonInit2(unittest.TestCase):
164
165     def setUp(self):
166         common.CONF_FILE = DummyConfigurationFile2('')
167         self.dir = os.path.join(APEX_LAKE_ROOT, 'experimental_framework')
168
169     def tearDown(self):
170         reset_common()
171         common.CONF_FILE = None
172
173     @mock.patch('experimental_framework.common.InputValidation')
174     @mock.patch('os.path.exists')
175     @mock.patch('os.makedirs')
176     @mock.patch('experimental_framework.common.LOG')
177     def test_init_general_vars_2_for_success(self, mock_log, mock_makedirs,
178                                              mock_path_exists, mock_val_file):
179         common.BASE_DIR = APEX_LAKE_ROOT
180         common.init_general_vars()
181         self.assertEqual(common.TEMPLATE_FILE_EXTENSION, '.yaml')
182         self.assertEqual(common.TEMPLATE_DIR, '/tmp/apexlake/heat_templates/')
183         self.assertEqual(common.TEMPLATE_NAME, 'vTC.yaml')
184         self.assertEqual(common.RESULT_DIR, '/tmp/apexlake/results/')
185         self.assertEqual(common.ITERATIONS, 2)
186
187     def test_init_log_2_for_success(self):
188         common.init_log()
189         self.assertIsInstance(common.LOG, logging.RootLogger)
190
191     def test_init_pktgen_for_success(self):
192         common.init_pktgen()
193         self.assertEqual(common.PKTGEN, 'dpdk_pktgen')
194         directory = self.dir.split('experimental_framework')[0]
195         self.assertEqual(common.PKTGEN_DIR, directory)
196         self.assertEqual(common.PKTGEN_PROGRAM, 'program')
197         self.assertEqual(common.PKTGEN_COREMASK, 'coremask')
198         self.assertEqual(common.PKTGEN_MEMCHANNEL, 'memchannel')
199         self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_1, 'bus_slot_nic_1')
200         self.assertEqual(common.PKTGEN_BUS_SLOT_NIC_2, 'bus_slot_nic_2')
201         # we always add '/' to end of dirs for some reason
202         # probably because we aren't using os.path.join everywhere
203         expected_dir = APEX_LAKE_ROOT + '/'
204         self.assertEqual(common.PKTGEN_DPDK_DIRECTORY, expected_dir)
205
206     def test_init_pktgen_for_failure(self):
207         common.CONF_FILE.get_variable('', cf.CFSP_PACKET_GENERATOR)
208         self.assertRaises(ValueError, common.init_pktgen)
209
210
211 class TestConfFileInitialization(unittest.TestCase):
212
213     def setUp(self):
214         pass
215
216     def tearDown(self):
217         reset_common()
218
219     @mock.patch('experimental_framework.common.ConfigurationFile',
220                 side_effect=DummyConfigurationFile)
221     def test_init_conf_file_for_success(self, conf_file):
222         common.CONF_FILE = None
223         common.init_conf_file(False)
224         self.assertIsInstance(common.CONF_FILE,
225                               DummyConfigurationFile)
226
227         common.CONF_FILE = None
228         common.init_conf_file(True)
229         self.assertIsInstance(common.CONF_FILE,
230                               DummyConfigurationFile)
231
232     @mock.patch('experimental_framework.common.CONF_FILE')
233     def test_init_log_for_success(self, mock_conf_file):
234         mock_conf_file.get_variable_list.return_value = 'value'
235         common.init_log()
236         self.assertIsInstance(common.LOG, logging.RootLogger)
237
238     @mock.patch('experimental_framework.common.CONF_FILE')
239     def test_init_influxdb_for_success(self, mock_conf_file):
240         mock_conf_file.get_variable.return_value = 'value'
241         common.init_influxdb()
242         self.assertEqual(common.INFLUXDB_IP, 'value')
243         self.assertEqual(common.INFLUXDB_PORT, 'value')
244         self.assertEqual(common.INFLUXDB_DB_NAME, 'value')
245
246
247 class DummyConfigurationFile3(common.ConfigurationFile):
248     counter = 0
249
250     def __init__(self, sections, config_file='conf.cfg'):
251         common.ConfigurationFile.__init__(self, sections, config_file)
252
253     @staticmethod
254     def _config_section_map(section, config_file, get_counter=None):
255         if get_counter:
256             return DummyConfigurationFile3.counter
257         else:
258             DummyConfigurationFile3.counter += 1
259             return dict()
260
261
262 class TestConfigFileClass(unittest.TestCase):
263
264     def setUp(self):
265         self.sections = [
266             'General',
267             'OpenStack',
268             'Experiment-VNF',
269             'PacketGen',
270             'Deployment-parameters',
271             'Testcase-parameters'
272         ]
273         c_file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg')
274         common.BASE_DIR = APEX_LAKE_ROOT
275         self.conf_file = common.ConfigurationFile(self.sections, c_file)
276
277     def tearDown(self):
278         reset_common()
279         common.BASE_DIR = None
280
281     @mock.patch('experimental_framework.common.ConfigurationFile.'
282                 '_config_section_map',
283                 side_effect=DummyConfigurationFile3._config_section_map)
284     def test___init___for_success(self, mock_conf_map):
285         sections = ['General', 'OpenStack', 'Experiment-VNF', 'PacketGen',
286                     'Deployment-parameters', 'Testcase-parameters']
287         c = DummyConfigurationFile3(
288             sections, config_file=os.path.join(APEX_LAKE_ROOT,
289                                                'tests/data/common/conf.cfg'))
290         self.assertEqual(
291             DummyConfigurationFile3._config_section_map('', '', True),
292             6)
293         for section in sections:
294             self.assertEqual(getattr(c, section), dict())
295
296     def test__config_section_map_for_success(self):
297         general_section = 'General'
298         # openstack_section = 'OpenStack'
299         config_file = os.path.join(APEX_LAKE_ROOT,
300                                    'tests/data/common/conf.cfg')
301         config = six.moves.configparser.ConfigParser()
302         config.read(config_file)
303
304         expected = {
305             'benchmarks': 'b_marks',
306             'iterations': '1',
307             'template_base_name': 't_name'
308         }
309         output = common.\
310             ConfigurationFile._config_section_map(general_section, config)
311         self.assertEqual(expected, output)
312
313     @mock.patch('experimental_framework.common.'
314                 'ConfigurationFile.get_variable_list')
315     def test_get_variable_for_success(self, mock_get_var_list):
316         section = self.sections[0]
317         variable_name = 'template_base_name'
318         expected = 't_name'
319         mock_get_var_list.return_value = [variable_name]
320         output = self.conf_file.get_variable(section, variable_name)
321         self.assertEqual(expected, output)
322
323     @mock.patch('experimental_framework.common.'
324                 'ConfigurationFile.get_variable_list')
325     def test_get_variable_for_failure(self, mock_get_var_list):
326         section = self.sections[0]
327         variable_name = 'something_else'
328         self.assertRaises(
329             ValueError,
330             self.conf_file.get_variable,
331             section, variable_name
332         )
333
334     def test_get_variable_list_for_success(self):
335         section = self.sections[0]
336         expected = {
337             'benchmarks': 'b_marks',
338             'iterations': '1',
339             'template_base_name': 't_name'
340         }
341         output = self.conf_file.get_variable_list(section)
342         self.assertEqual(expected, output)
343
344     def test_get_variable_list_for_failure(self):
345         section = 'something_else'
346         self.assertRaises(
347             ValueError,
348             self.conf_file.get_variable_list,
349             section)
350
351
352 class DummyConfigurationFile4(common.ConfigurationFile):
353
354     def get_variable(self, section, variable_name):
355         if variable_name == 'vnic2_type':
356             return '"value"'
357         elif variable_name == cf.CFSG_BENCHMARKS:
358             return "BenchmarkClass1, BenchmarkClass2"
359         return '@string "value"'
360
361     # def get_variable_list(self, section):
362     #     return list()
363
364
365 class TestCommonMethods(unittest.TestCase):
366
367     def setUp(self):
368         self.sections = [
369             'General',
370             'OpenStack',
371             'Experiment-VNF',
372             'PacketGen',
373             'Deployment-parameters',
374             'Testcase-parameters'
375         ]
376         config_file = os.path.join(APEX_LAKE_ROOT,
377                                    'tests/data/common/conf.cfg')
378         common.BASE_DIR = APEX_LAKE_ROOT
379         common.CONF_FILE = DummyConfigurationFile4(self.sections, config_file)
380
381     def tearDown(self):
382         reset_common()
383         common.CONF_FILE = None
384
385     def test_get_credentials_for_success(self):
386         expected = {
387             'ip_controller': '@string "value"',
388             'project': '@string "value"',
389             'auth_uri': '@string "value"',
390             'user': '@string "value"',
391             'heat_url': '@string "value"',
392             'password': '@string "value"'
393         }
394         output = common.get_credentials()
395         self.assertEqual(expected, output)
396
397     def test_get_heat_template_params_for_success(self):
398         expected = {
399             'param_1': '@string "value"',
400             'param_2': '@string "value"',
401             'param_3': '@string "value"',
402             'param_4': '@string "value"'
403         }
404         output = common.get_heat_template_params()
405         self.assertEqual(expected, output)
406
407     def test_get_testcase_params_for_success(self):
408         expected = {'test_case_param': '@string "value"'}
409         output = common.get_testcase_params()
410         self.assertEqual(expected, output)
411
412     def test_get_file_first_line_for_success(self):
413         file = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/conf.cfg')
414         expected = '[General]\n'
415         output = common.get_file_first_line(file)
416         self.assertEqual(expected, output)
417
418     def test_replace_in_file_for_success(self):
419         filename = os.path.join(APEX_LAKE_ROOT,
420                                 'tests/data/common/file_replacement.txt')
421         text_to_search = 'replacement of'
422         text_to_replace = '***'
423         common.replace_in_file(filename, text_to_search, text_to_replace)
424         after = open(filename, 'r').readline()
425         self.assertEqual(after, 'Test for the *** strings into a file\n')
426         text_to_search = '***'
427         text_to_replace = 'replacement of'
428         common.replace_in_file(filename, text_to_search, text_to_replace)
429
430     @mock.patch('os.system')
431     @mock.patch('experimental_framework.common.LOG')
432     def test_run_command_for_success(self, mock_log, mock_os_system):
433         command = 'command to be run'
434         common.run_command(command)
435         mock_os_system.assert_called_once_with(command)
436
437     @mock.patch('experimental_framework.common.run_command')
438     def test_push_data_influxdb_for_success(self, mock_run_cmd):
439         data = 'string that describes the data'
440         expected = "curl -i -XPOST 'http://None:None/write?db=None' " \
441                    "--data-binary string that describes the data"
442         common.push_data_influxdb(data)
443         mock_run_cmd.assert_called_once_with(expected)
444
445     def test_get_base_dir_for_success(self):
446         base_dir = common.BASE_DIR
447         common.BASE_DIR = 'base_dir'
448         expected = 'base_dir'
449         output = common.get_base_dir()
450         self.assertEqual(expected, output)
451         common.BASE_DIR = base_dir
452
453     def test_get_template_dir_for_success(self):
454         template_dir = common.TEMPLATE_DIR
455         common.TEMPLATE_DIR = 'base_dir'
456         expected = 'base_dir'
457         output = common.get_template_dir()
458         self.assertEqual(expected, output)
459         common.TEMPLATE_DIR = template_dir
460
461     def test_get_dpdk_pktgen_vars_test(self):
462         # Test 1
463         common.PKTGEN = 'dpdk_pktgen'
464         common.PKTGEN_DIR = 'var'
465         common.PKTGEN_PROGRAM = 'var'
466         common.PKTGEN_COREMASK = 'var'
467         common.PKTGEN_MEMCHANNEL = 'var'
468         common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
469         common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
470         common.PKTGEN_NAME_NIC_1 = 'var'
471         common.PKTGEN_NAME_NIC_2 = 'var'
472         common.PKTGEN_DPDK_DIRECTORY = 'var'
473         expected = {
474             'bus_slot_nic_1': 'var',
475             'bus_slot_nic_2': 'var',
476             'name_if_1': 'var',
477             'name_if_2': 'var',
478             'coremask': 'var',
479             'dpdk_directory': 'var',
480             'memory_channels': 'var',
481             'pktgen_directory': 'var',
482             'program_name': 'var'
483         }
484         output = common.get_dpdk_pktgen_vars()
485         self.assertEqual(expected, output)
486
487         # Test 2
488         common.PKTGEN = 'something_else'
489         common.PKTGEN_DIR = 'var'
490         common.PKTGEN_PROGRAM = 'var'
491         common.PKTGEN_COREMASK = 'var'
492         common.PKTGEN_MEMCHANNEL = 'var'
493         common.PKTGEN_BUS_SLOT_NIC_1 = 'var'
494         common.PKTGEN_BUS_SLOT_NIC_2 = 'var'
495         common.PKTGEN_DPDK_DIRECTORY = 'var'
496         expected = {}
497         output = common.get_dpdk_pktgen_vars()
498         self.assertEqual(expected, output)
499
500     @mock.patch('experimental_framework.common.LOG')
501     def test_get_deployment_configuration_variables_for_success(self,
502                                                                 mock_log):
503         expected = {
504             'vcpu': ['value'],
505             'vnic1_type': ['value'],
506             'ram': ['value'],
507             'vnic2_type': ['value']
508         }
509         output = common.get_deployment_configuration_variables_from_conf_file()
510         self.assertEqual(expected, output)
511
512     def test_get_benchmarks_from_conf_file_for_success(self):
513         expected = ['BenchmarkClass1', 'BenchmarkClass2']
514         output = common.get_benchmarks_from_conf_file()
515         self.assertEqual(expected, output)
516
517
518 class TestinputValidation(unittest.TestCase):
519
520     def setUp(self):
521         pass
522
523     def tearDown(self):
524         reset_common()
525
526     def test_validate_string_for_success(self):
527         output = common.InputValidation.validate_string('string', '')
528         self.assertTrue(output)
529
530     def test_validate_string_for_failure(self):
531         self.assertRaises(
532             ValueError,
533             common.InputValidation.validate_string,
534             list(), ''
535         )
536
537     def test_validate_int_for_success(self):
538         output = common.InputValidation.validate_integer(1111, '')
539         self.assertTrue(output)
540
541     def test_validate_int_for_failure(self):
542         self.assertRaises(
543             ValueError,
544             common.InputValidation.validate_integer,
545             list(), ''
546         )
547
548     def test_validate_dict_for_success(self):
549         output = common.InputValidation.validate_dictionary(dict(), '')
550         self.assertTrue(output)
551
552     def test_validate_dict_for_failure(self):
553         self.assertRaises(
554             ValueError,
555             common.InputValidation.validate_dictionary,
556             list(), ''
557         )
558
559     def test_validate_directory_exist_and_format_for_success(self):
560         directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/common/')
561         output = common.InputValidation.\
562             validate_directory_exist_and_format(directory, '')
563         self.assertTrue(output)
564
565     def test_validate_directory_exist_and_format_for_failure(self):
566         directory = os.path.join(APEX_LAKE_ROOT, 'tests/data/com/')
567         self.assertRaises(
568             ValueError,
569             common.InputValidation.validate_directory_exist_and_format,
570             directory, ''
571         )
572
573     @mock.patch('experimental_framework.common.CONF_FILE')
574     def test_validate_configuration_file_parameter_for_success(self,
575                                                                mock_conf):
576         mock_conf.get_variable_list.return_value = ['param']
577         section = ''
578         parameter = 'param'
579         message = ''
580         output = common.InputValidation.\
581             validate_configuration_file_parameter(section, parameter, message)
582         self.assertTrue(output)
583
584     @mock.patch('experimental_framework.common.CONF_FILE')
585     def test_validate_configuration_file_parameter_for_failure(
586             self, mock_conf_file):
587         section = ''
588         parameter = 'something_else'
589         message = ''
590         mock_conf_file.get_variable_list.return_value(['parameter'])
591         self.assertRaises(
592             ValueError,
593             common.InputValidation.
594             validate_configuration_file_parameter,
595             section, parameter, message
596         )
597
598     def test_validate_configuration_file_section_for_success(self):
599         section = 'General'
600         message = ''
601         output = common.InputValidation.\
602             validate_configuration_file_section(section, message)
603         self.assertTrue(output)
604
605     def test_validate_configuration_file_section_for_failure(self):
606         section = 'Something-Else'
607         message = ''
608         self.assertRaises(
609             ValueError,
610             common.InputValidation.validate_configuration_file_section,
611             section, message
612         )
613
614     def test_validate_boolean_for_success(self):
615         message = ''
616         boolean = True
617         output = common.InputValidation.validate_boolean(boolean, message)
618         self.assertTrue(output)
619
620         boolean = 'True'
621         output = common.InputValidation.validate_boolean(boolean, message)
622         self.assertTrue(output)
623
624         boolean = 'False'
625         output = common.InputValidation.validate_boolean(boolean, message)
626         self.assertFalse(output)
627
628     def test_validate_boolean_for_failure(self):
629         message = ''
630         boolean = 'string'
631         self.assertRaises(
632             ValueError,
633             common.InputValidation.validate_boolean,
634             boolean, message
635         )
636
637     def test_validate_os_credentials_for_failure(self):
638         # Test 1
639         credentials = list()
640         self.assertRaises(ValueError,
641                           common.InputValidation.validate_os_credentials,
642                           credentials)
643
644         # Test 2
645         credentials = dict()
646         credentials['ip_controller'] = ''
647         credentials['heat_url'] = ''
648         credentials['user'] = ''
649         credentials['password'] = ''
650         credentials['auth_uri'] = ''
651         # credentials['project'] = ''
652         self.assertRaises(ValueError,
653                           common.InputValidation.validate_os_credentials,
654                           credentials)
655
656     def test_validate_os_credentials_for_success(self):
657         credentials = dict()
658         credentials['ip_controller'] = ''
659         credentials['heat_url'] = ''
660         credentials['user'] = ''
661         credentials['password'] = ''
662         credentials['auth_uri'] = ''
663         credentials['project'] = ''
664         self.assertTrue(
665             common.InputValidation.validate_os_credentials(credentials))