def test_create_multiple_clusters_failed(self, check_cluster): MULTIPLE_CLUSTERS = api_base.SAMPLE_CLUSTER.copy() MULTIPLE_CLUSTERS['count'] = 2 check_cluster.side_effect = exc.QuotaException( 'resource', 'requested', 'available') with testtools.ExpectedException(exc.QuotaException): api.create_cluster(api_base.SAMPLE_CLUSTER) self.assertEqual('Error', api.get_clusters()[0].status)
def test_create_multiple_clusters_failed(self, check_cluster): MULTIPLE_CLUSTERS = api_base.SAMPLE_CLUSTER.copy() MULTIPLE_CLUSTERS['count'] = 2 check_cluster.side_effect = exc.QuotaException( 'resource', 'requested', 'available') with testtools.ExpectedException(exc.QuotaException): api.create_cluster(api_base.SAMPLE_CLUSTER) self.assertEqual('Error', api.get_clusters()[0].status)
def test_scale_cluster_specific_and_non_specific(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) cluster = api.get_cluster(cluster.id) api.scale_cluster(cluster.id, api_base.SCALE_DATA_SPECIFIC_INSTANCE) result_cluster = api.get_cluster(cluster.id) self.assertEqual('Scaled', result_cluster.status) expected_count = { 'ng_1': 3, 'ng_2': 1, 'ng_3': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(1, result_cluster.node_groups[1].count) self.assertNotIn('ng_2_0', self._get_instances_ids( result_cluster.node_groups[1])) self.assertEqual(3, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'get_open_ports', 'recommend_configs', 'validate_scaling', 'ops.provision_scaled_cluster', 'ops.terminate_cluster'], self.calls_order)
def test_scale_cluster_n_specific_instances_success(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) cluster = api.get_cluster(cluster.id) api.scale_cluster(cluster.id, api_base.SCALE_DATA_N_SPECIFIC_INSTANCE) result_cluster = api.get_cluster(cluster.id) self.assertEqual('Scaled', result_cluster.status) expected_count = { 'ng_1': 3, 'ng_2': 1, 'ng_3': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(1, result_cluster.node_groups[1].count) self.assertNotIn('ng_2_0', self._get_instances_ids( result_cluster.node_groups[1])) self.assertNotIn('ng_2_2', self._get_instances_ids( result_cluster.node_groups[1])) self.assertEqual(3, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'get_open_ports', 'recommend_configs', 'validate_scaling', 'ops.provision_scaled_cluster', 'ops.terminate_cluster'], self.calls_order)
def clusters_create(data): # renaming hadoop_version -> plugin_version # this can be removed once APIv1 is deprecated data['hadoop_version'] = data['plugin_version'] del data['plugin_version'] if data.get('count', None) is not None: return u.render(api.create_multiple_clusters(data)) else: return u.render(api.create_cluster(data).to_wrapped_dict())
def clusters_create(data): # renaming hadoop_version -> plugin_version # this can be removed once APIv1 is deprecated data['hadoop_version'] = data['plugin_version'] del data['plugin_version'] if data.get('count', None) is not None: result = api.create_multiple_clusters(data) for c in result['clusters']: u._replace_hadoop_version_plugin_version(c['cluster']) return u.render(result) else: result = api.create_cluster(data).to_wrapped_dict() u._replace_hadoop_version_plugin_version(result['cluster']) return u.render(result)
def clusters_create(data): # renaming hadoop_version -> plugin_version # this can be removed once APIv1 is deprecated data['hadoop_version'] = data['plugin_version'] del data['plugin_version'] if data.get('count', None) is not None: result = api.create_multiple_clusters(data) for c in result['clusters']: u._replace_hadoop_version_plugin_version(c['cluster']) u._replace_tenant_id_project_id(c['cluster']) return u.render(result) else: result = api.create_cluster(data).to_wrapped_dict() u._replace_hadoop_version_plugin_version(result['cluster']) u._replace_tenant_id_project_id(result['cluster']) return u.render(result)
def test_create_cluster_success(self, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) self.assertEqual(1, check_cluster.call_count) result_cluster = api.get_cluster(cluster.id) self.assertEqual(c_u.CLUSTER_STATUS_ACTIVE, result_cluster.status) expected_count = { 'ng_1': 1, 'ng_2': 3, 'ng_3': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(3, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'ops.terminate_cluster'], self.calls_order)
def test_create_cluster_success(self, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) self.assertEqual(1, check_cluster.call_count) result_cluster = api.get_cluster(cluster.id) self.assertEqual(c_u.CLUSTER_STATUS_ACTIVE, result_cluster.status) expected_count = { 'ng_1': 1, 'ng_2': 3, 'ng_3': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(3, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'ops.terminate_cluster'], self.calls_order)
def test_scale_cluster_success(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) api.scale_cluster(cluster.id, api_base.SCALE_DATA) result_cluster = api.get_cluster(cluster.id) self.assertEqual('Scaled', result_cluster.status) expected_count = { 'ng_1': 3, 'ng_2': 2, 'ng_3': 1, 'ng_4': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(4, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'get_open_ports', 'get_open_ports', 'recommend_configs', 'validate_scaling', 'ops.provision_scaled_cluster', 'ops.terminate_cluster'], self.calls_order)
def test_scale_cluster_success(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) cluster = api.get_cluster(cluster.id) api.scale_cluster(cluster.id, api_base.SCALE_DATA) result_cluster = api.get_cluster(cluster.id) self.assertEqual('Scaled', result_cluster.status) expected_count = { 'ng_1': 3, 'ng_2': 2, 'ng_3': 1, 'ng_4': 1, } ng_count = 0 for ng in result_cluster.node_groups: self.assertEqual(expected_count[ng.name], ng.count) ng_count += 1 self.assertEqual(4, ng_count) api.terminate_cluster(result_cluster.id) self.assertEqual( ['get_open_ports', 'recommend_configs', 'validate', 'ops.provision_cluster', 'get_open_ports', 'get_open_ports', 'recommend_configs', 'validate_scaling', 'ops.provision_scaled_cluster', 'ops.terminate_cluster'], self.calls_order)
def clusters_create(data): return u.render(api.create_cluster(data).to_wrapped_dict())
def test_cluster_update(self): with mock.patch('sahara.service.quotas.check_cluster'): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) updated_cluster = api.update_cluster( cluster.id, {'description': 'Cluster'}) self.assertEqual('Cluster', updated_cluster.description)
def test_scale_cluster_failed(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) check_scaling.side_effect = exc.QuotaException( 'resource', 'requested', 'available') with testtools.ExpectedException(exc.QuotaException): api.scale_cluster(cluster.id, {})
def test_scale_cluster_failed(self, check_scaling, check_cluster): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) check_scaling.side_effect = exc.QuotaException( 'resource', 'requested', 'available') with testtools.ExpectedException(exc.QuotaException): api.scale_cluster(cluster.id, {})
def clusters_create(data): # renaming hadoop_version -> plugin_version # this can be removed once APIv1 is deprecated data['hadoop_version'] = data['plugin_version'] del data['plugin_version'] return u.render(api.create_cluster(data).to_wrapped_dict())
def test_cluster_update(self): with mock.patch('sahara.service.quotas.check_cluster'): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) updated_cluster = api.update_cluster( cluster.id, {'description': 'Cluster'}) self.assertEqual('Cluster', updated_cluster.description)
def clusters_create(data): return u.render(api.create_cluster(data).to_wrapped_dict())
def test_cluster_keypair_update(self): with mock.patch('sahara.service.quotas.check_cluster'): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) api.update_cluster(cluster.id, {'update_keypair': True})
def test_cluster_keypair_update(self): with mock.patch('sahara.service.quotas.check_cluster'): cluster = api.create_cluster(api_base.SAMPLE_CLUSTER) api.update_cluster(cluster.id, {'update_keypair': True})