Home | Trees | Indices | Help |
|
---|
|
1 import os 2 import sys 3 import unittest 4 import tempfile 5 from starcluster import exception 6 from starcluster.logger import log 7 from starcluster.tests import StarClusterTest 8 from starcluster.tests.templates.config import config_test_template, default_config 91114813 ec2 = self.config.get_easy_ec2() 14 cluster = self.config.get_cluster_template('c1') 15 try: 16 cluster._validate_credentials() 17 except exception.ClusterValidationError,e: 18 pass 19 else: 20 raise Exception("cluster allows invalid aws credentials")2123 # default test template should have valid plugins by default 24 cluster = self.config.get_cluster_template('c1') 25 # make them invalid 26 cases = [ 27 {'p1_class': 'None'}, 28 {'p1_class':'unittest.TestCase'}, 29 ] 30 for case in cases: 31 cfg = self.get_custom_config(**case) 32 try: 33 cluster = cfg.get_cluster_template('c1') 34 except exception.PluginError,e: 35 pass 36 else: 37 raise Exception( 38 'cluster allows non-valid plugin setup class (case: %s)' % 39 case)4042 cases = [ 43 {'c1_size': -1}, 44 {'c1_size': 0} 45 ] 46 for case in cases: 47 cfg = self.get_custom_config(**case) 48 try: 49 cluster = cfg.get_cluster_template('c1') 50 cluster._validate_cluster_size() 51 except exception.ClusterValidationError,e: 52 pass 53 else: 54 raise Exception('cluster allows invalid cluster size (case: %s)' 55 % case)5658 cases = [ 59 {'c1_shell': ''}, 60 {'c1_shell': 'nosh'}, 61 {'c1_shell': 2} 62 ] 63 for case in cases: 64 cfg = self.get_custom_config(**case) 65 try: 66 cluster = cfg.get_cluster_template('c1') 67 cluster._validate_shell_setting() 68 except exception.ClusterValidationError,e: 69 pass 70 else: 71 raise Exception('cluster allows invalid cluster shell (case: %s)' 72 % case)7375 tmpfile = tempfile.NamedTemporaryFile() 76 tmp_file = tmpfile.name 77 tmpfile.close() 78 tmpdir = tempfile.mkdtemp() 79 cases = [{'k1_location': tmp_file}, {'k1_location':tmpdir}] 80 for case in cases: 81 cfg = self.get_custom_config(**case) 82 cluster = cfg.get_cluster_template('c1') 83 try: 84 cluster._validate_keypair() 85 except exception.ClusterValidationError,e: 86 pass 87 else: 88 raise Exception('cluster allows invalid key_location') 89 os.rmdir(tmpdir)9092 failed = [] 93 for case in cases: 94 cfg = self.get_custom_config(**case) 95 cluster = cfg.get_cluster_template(cluster_name) 96 try: 97 getattr(cluster,test)() 98 except exception.ClusterValidationError,e: 99 continue 100 else: 101 failed.append(case) 102 return failed103105 cases = [ 106 {'c1_node_type': None}, 107 {'c1_master_type': None}, 108 {'c1_node_type': 'asdfa'}, 109 {'c1_master_type': 'asdfa'}, 110 {'c1_zone': None}, 111 ] 112 failed = self.__test_for_validation_error(cases, '_validate_instance_types') 113 if failed: 114 raise Exception( 115 'cluster allows invalid instance type settings (cases: %s)' % \ 116 failed)117119 cases = [ 120 {'v1_mount_path': 'home'}, 121 ] 122 failed = self.__test_for_validation_error(cases, '_validate_ebs_settings') 123 if failed: 124 raise Exception('cluster allows invalid ebs settings (cases: %s)' % failed) 125 try: 126 failed = self.__test_for_validation_error( \ 127 [{'v1_device': '/dev/asd'}],'_validate_ebs_settings') 128 raise Exception('cluster allows invalid ebs settings (cases: %s)' % \ 129 failed) 130 except exception.InvalidDevice,e: 131 pass 132 try: 133 failed = self.__test_for_validation_error( \ 134 [{'v1_partition': -1}],'_validate_ebs_settings') 135 raise Exception('cluster allows invalid ebs settings (cases: %s)' % \ 136 failed) 137 except exception.InvalidPartition,e: 138 pass139 142 145
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri May 14 13:53:41 2010 | http://epydoc.sourceforge.net |