def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor='23') data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "node_group_template_id": '%s' % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "jobtracker", "datanode", "tasktracker" ] }, ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } with self.assertRaises(exceptions.InvalidException): try: patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) except exceptions.InvalidException as e: self.assertEqual("Requested flavor '23' not found", six.text_type(e)) raise e
def test_cluster_create_cluster_tmpl_node_group_mixin(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000', "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "jobtracker", "datanode", "tasktracker" ] } ] } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers)
def test_cluster_create_cluster_tmpl_node_group_mixin(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000', "node_groups": [{ "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"] }] } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers)
def test_cluster_create_v_invalid_flavor(self): ng_id = self._create_node_group_template(flavor="10") ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": "%s" % ctmpl_id, "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } data1 = { "name": "testwithnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "10", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"], } ], "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } for values in [data, data1]: with self.assertRaises(exceptions.InvalidException): try: patchers = u.start_patch(False) c.check_cluster_create(values) u.stop_patch(patchers) except exceptions.InvalidException as e: self.assertEqual("Requested flavor '10' not found", e.message) raise e
def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor="23") data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "node_group_template_id": "%s" % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"], } ], "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } with self.assertRaises(exceptions.InvalidException): try: patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) except exceptions.InvalidException as e: self.assertEqual("Requested flavor '23' not found", e.message) raise e
def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor='23') data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "node_group_template_id": '%s' % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "jobtracker", "datanode", "tasktracker" ] }, ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } with testtools.ExpectedException(exceptions.InvalidException): try: patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) except exceptions.InvalidException as e: self.assertEqual("Requested flavor '23' not found", six.text_type(e)) raise e
def test_cluster_create_v_correct_flavor(self): ng_id = self._create_node_group_template(flavor="42") ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": "%s" % ctmpl_id, "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) data1 = { "name": "testwithnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"], } ], "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } patchers = u.start_patch(False) c.check_cluster_create(data1) u.stop_patch(patchers)
def test_cluster_create_cluster_tmpl_node_group_mixin(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testtmplnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "cluster_template_id": '%s' % ctmpl_id, "neutron_management_network": "d9a3bebc-f788-4b81-" "9a93-aa048022c1ca", 'default_image_id': '550e8400-e29b-41d4-a716-446655440000', "node_groups": [{ "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "resourcemanager", "datanode", "nodemanager"] }] } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers)
def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor='23') data = { "name": "testtmplnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "node_groups": [ { "node_group_template_id": '%s' % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "resourcemanager", "datanode", "nodemanager" ] }, ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } with testtools.ExpectedException(exceptions.NotFoundException): patchers = u.start_patch(False) try: c.check_cluster_create(data) except exceptions.NotFoundException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '23' not found", message) raise e finally: u.stop_patch(patchers)
def test_cluster_create_cluster_tmpl_node_group_mixin(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testtmplnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "cluster_template_id": '%s' % ctmpl_id, "neutron_management_network": "d9a3bebc-f788-4b81-" "9a93-aa048022c1ca", 'default_image_id': '550e8400-e29b-41d4-a716-446655440000', "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "resourcemanager", "datanode", "nodemanager" ] } ] } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers)
def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor="23") data = { "name": "testtmplnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "node_group_template_id": "%s" % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"], } ], "default_image_id": "550e8400-e29b-41d4-a716-446655440000", } with testtools.ExpectedException(exceptions.NotFoundException): patchers = u.start_patch(False) try: c.check_cluster_create(data) except exceptions.NotFoundException as e: message = six.text_type(e).split("\n")[0] self.assertEqual("Requested flavor '23' not found", message) raise e finally: u.stop_patch(patchers)
def test_check_cluster_scaling_add_ng(self, ops): ops.get_engine_type_and_version.return_value = "direct.1.1" ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1) cluster = tu.create_cluster("test-cluster", "tenant", "vanilla", "1.2.1", [ng1], status='Active', id='12321') data = { 'add_node_groups': [{ 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] }, { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] }] } self._assert_check_scaling(data=data, cluster=cluster, expected_message='Duplicates in node ' 'group names are detected', expected_exception=ex.InvalidDataException) data = { 'add_node_groups': [ { 'name': 'ng', 'flavor_id': '42', 'node_processes': ['namenode'] }, ] } self._assert_check_scaling(data=data, cluster=cluster, expected_message="Can't add new nodegroup. " "Cluster already has nodegroup " "with name 'ng'") data = { 'add_node_groups': [ { 'name': 'very-very-very-very-very-very-long-ng-name', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 10 }, ] } patchers = u.start_patch() self._assert_check_scaling( data=data, cluster=cluster, expected_message="Composite hostname test-cluster-very-" "very-very-very-very-very-long-ng-name-" "010.novalocal in provisioned cluster exceeds " "maximum limit 64 characters", expected_exception=ex.InvalidDataException) u.stop_patch(patchers)
def test_check_cluster_scaling_add_ng(self, ops): ops.get_engine_type_and_version.return_value = "direct.1.1" ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1) cluster = tu.create_cluster("test-cluster", "tenant1", "fake", "0.1", [ng1], status=c_u.CLUSTER_STATUS_ACTIVE, id='12321') data = { 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] }, { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] } ] } self._assert_check_scaling( data=data, cluster=cluster, expected_message=self.duplicates_detected, expected_exception=ex.InvalidDataException) data = { 'add_node_groups': [ { 'name': 'ng', 'flavor_id': '42', 'node_processes': ['namenode'] }, ] } self._assert_check_scaling( data=data, cluster=cluster, expected_message="Can't add new nodegroup. " "Cluster already has nodegroup " "with name 'ng'") data = { 'add_node_groups': [ { 'name': 'very-very-very-very-very-very-long-ng-name', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 10 }, ] } patchers = u.start_patch() self._assert_check_scaling( data=data, cluster=cluster, expected_message="Composite hostname test-cluster-very-" "very-very-very-very-very-long-ng-name-" "010.novalocal in provisioned cluster exceeds " "maximum limit 64 characters", expected_exception=ex.InvalidDataException) u.stop_patch(patchers)
def test_check_cluster_scaling_add_ng(self, ops): ops.get_engine_type_and_version.return_value = "direct.1.1" ng1 = tu.make_ng_dict('ng', '42', ['namenode'], 1) cluster = tu.create_cluster("test-cluster", "tenant", "vanilla", "1.2.1", [ng1], status='Active', id='12321') data = { 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] }, { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'] } ] } self._assert_check_scaling( data=data, cluster=cluster, expected_message='Duplicates in node ' 'group names are detected') data = { 'add_node_groups': [ { 'name': 'ng', 'flavor_id': '42', 'node_processes': ['namenode'] }, ] } self._assert_check_scaling( data=data, cluster=cluster, expected_message="Can't add new nodegroup. " "Cluster already has nodegroup " "with name 'ng'") data = { 'add_node_groups': [ { 'name': 'very-very-very-very-very-very-long-ng-name', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 10 }, ] } patchers = u.start_patch() self._assert_check_scaling( data=data, cluster=cluster, expected_message="Composite hostname test-cluster-very-" "very-very-very-very-very-long-ng-name-" "010.novalocal in provisioned cluster exceeds " "maximum limit 64 characters") u.stop_patch(patchers)
def test_cluster_create_v_invalid_flavor(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "fake", "hadoop_version": "0.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } data1 = { "name": "testwithnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "neutron_management_network": "d9a3bebc-f788-4b81-" "9a93-aa048022c1ca", "node_groups": [{ "name": "allinone", "count": 1, "flavor_id": "10", "node_processes": ["namenode", "resourcemanager", "datanode", "nodemanager"] }], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } for values in [data, data1]: with testtools.ExpectedException(exceptions.NotFoundException): patchers = u.start_patch(False) try: c.check_cluster_create(values) except exceptions.NotFoundException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '10' not found", message) raise e finally: u.stop_patch(patchers)
def test_cluster_create_v_invalid_flavor(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "fake", "hadoop_version": "0.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } data1 = { "name": "testwithnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "neutron_management_network": "d9a3bebc-f788-4b81-" "9a93-aa048022c1ca", "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "10", "node_processes": [ "namenode", "resourcemanager", "datanode", "nodemanager" ] } ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } for values in [data, data1]: with testtools.ExpectedException( exceptions.NotFoundException): patchers = u.start_patch(False) try: c.check_cluster_create(values) except exceptions.NotFoundException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '10' not found", message) raise e finally: u.stop_patch(patchers)
def test_cluster_create_v_invalid_flavor(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } data1 = { "name": "testwithnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [{ "name": "allinone", "count": 1, "flavor_id": "10", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"] }], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } for values in [data, data1]: with testtools.ExpectedException(exceptions.InvalidException): patchers = u.start_patch(False) try: c.check_cluster_create(values) except exceptions.InvalidException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '10' not found", message) raise e finally: u.stop_patch(patchers)
def test_cluster_create_v_invalid_flavor(self): ng_id = self._create_node_group_template(flavor='10') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } data1 = { "name": "testwithnodegroups", "plugin_name": "vanilla", "hadoop_version": "1.2.1", "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "10", "node_processes": [ "namenode", "jobtracker", "datanode", "tasktracker" ] } ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } for values in [data, data1]: with testtools.ExpectedException(exceptions.InvalidException): patchers = u.start_patch(False) try: c.check_cluster_create(values) except exceptions.InvalidException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '10' not found", message) raise e finally: u.stop_patch(patchers)
def test_cluster_scaling_v_right_data(self): self._create_object_fun = c_s.check_cluster_scaling data = { 'resize_node_groups': [{ 'name': 'ng', 'count': 4 }], 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 3 }, ] } patchers = u.start_patch() self._assert_cluster_scaling_validation(data=data) u.stop_patch(patchers)
def test_cluster_scaling_v_right_data(self, ops): ops.get_engine_type_and_version.return_value = "direct.1.1" self._create_object_fun = c_s.check_cluster_scaling data = { 'resize_node_groups': [{ 'name': 'ng', 'count': 4 }], 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 3 }, ] } patchers = u.start_patch() self._assert_cluster_scaling_validation(data=data) u.stop_patch(patchers)
def test_cluster_scaling_v_right_data(self): self._create_object_fun = c_s.check_cluster_scaling data = { 'resize_node_groups': [ { 'name': 'ng', 'count': 4 } ], 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 3 }, ] } patchers = u.start_patch() self._assert_cluster_scaling_validation(data=data) u.stop_patch(patchers)
def test_cluster_create_v_correct_flavor(self): ng_id = self._create_node_group_template(flavor='42') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "fake", "hadoop_version": "0.1", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) data1 = { "name": "testwithnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "node_groups": [{ "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "jobtracker", "datanode", "tasktracker"] }], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } patchers = u.start_patch(False) c.check_cluster_create(data1) u.stop_patch(patchers)
def test_cluster_scaling_v_right_data(self, ops): ops.get_engine_type_and_version.return_value = "direct.1.1" self._create_object_fun = c_s.check_cluster_scaling data = { 'resize_node_groups': [ { 'name': 'ng', 'count': 4 } ], 'add_node_groups': [ { 'name': 'a', 'flavor_id': '42', 'node_processes': ['namenode'], 'count': 3 }, ] } patchers = u.start_patch() self._assert_cluster_scaling_validation(data=data) u.stop_patch(patchers)
def test_cluster_create_v_correct_flavor(self): ng_id = self._create_node_group_template(flavor='42') ctmpl_id = self._create_cluster_template(ng_id) data = { "name": "testname", "plugin_name": "vanilla", "hadoop_version": "2.6.0", "cluster_template_id": '%s' % ctmpl_id, 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } patchers = u.start_patch(False) c.check_cluster_create(data) u.stop_patch(patchers) data1 = { "name": "testwithnodegroups", "plugin_name": "vanilla", "hadoop_version": "2.6.0", "node_groups": [ { "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": [ "namenode", "resourcemanager", "datanode", "nodemanager" ] } ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } patchers = u.start_patch(False) c.check_cluster_create(data1) u.stop_patch(patchers)
def test_cluster_create_node_group_tmpl_mixin(self): ng_id = self._create_node_group_template(flavor='23') data = { "name": "testtmplnodegroups", "plugin_name": "fake", "hadoop_version": "0.1", "node_groups": [ { "node_group_template_id": '%s' % ng_id, "name": "allinone", "count": 1, "flavor_id": "42", "node_processes": ["namenode", "resourcemanager", "datanode", "nodemanager"] }, ], 'default_image_id': '550e8400-e29b-41d4-a716-446655440000' } with testtools.ExpectedException(exceptions.NotFoundException): patchers = u.start_patch(False) try: c.check_cluster_create(data) except exceptions.NotFoundException as e: message = six.text_type(e).split('\n')[0] self.assertEqual("Requested flavor '23' not found", message) raise e finally: u.stop_patch(patchers)
def tearDown(self): u.stop_patch(self.patchers) super(TestClusterCreateFlavorValidation, self).tearDown()