Пример #1
0
 def test_create_multiple_clusters_failed(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     check_cluster.side_effect = exc.QuotaException('resource', 'requested',
                                                    'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
Пример #2
0
 def test_create_multiple_clusters_failed(self, check_cluster):
     MULTIPLE_CLUSTERS = SAMPLE_CLUSTER.copy()
     MULTIPLE_CLUSTERS['count'] = 2
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
Пример #3
0
 def test_create_cluster_success(self, check_cluster):
     cluster = api.create_cluster(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)
Пример #4
0
 def test_create_cluster_success(self, check_cluster):
     cluster = api.create_cluster(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)
Пример #5
0
 def test_scale_cluster_success(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     api.scale_cluster(cluster.id, 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)
Пример #6
0
 def test_scale_cluster_success(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     api.scale_cluster(cluster.id, 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)
Пример #7
0
 def test_cluster_update(self):
     with mock.patch('sahara.service.quotas.check_cluster'):
         cluster = api.create_cluster(SAMPLE_CLUSTER)
         updated_cluster = api.update_cluster(cluster.id,
                                              {'description': 'Cluster'})
         self.assertEqual('Cluster', updated_cluster.description)
Пример #8
0
 def test_scale_cluster_failed(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     check_scaling.side_effect = exc.QuotaException('resource', 'requested',
                                                    'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.scale_cluster(cluster.id, {})
Пример #9
0
 def test_create_cluster_failed(self, check_cluster):
     check_cluster.side_effect = exc.QuotaException('resource', 'requested',
                                                    'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
Пример #10
0
 def test_cluster_update(self):
     with mock.patch('sahara.service.quotas.check_cluster'):
         cluster = api.create_cluster(SAMPLE_CLUSTER)
         updated_cluster = api.update_cluster(
             cluster.id, {'description': 'Cluster'})
         self.assertEqual('Cluster', updated_cluster.description)
Пример #11
0
 def test_scale_cluster_failed(self, check_scaling, check_cluster):
     cluster = api.create_cluster(SAMPLE_CLUSTER)
     check_scaling.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.scale_cluster(cluster.id, {})
Пример #12
0
 def test_create_cluster_failed(self, check_cluster):
     check_cluster.side_effect = exc.QuotaException(
         'resource', 'requested', 'available')
     with testtools.ExpectedException(exc.QuotaException):
         api.create_cluster(SAMPLE_CLUSTER)
     self.assertEqual('Error', api.get_clusters()[0].status)
Пример #13
0
def clusters_create(data):
    return u.render(api.create_cluster(data).to_wrapped_dict())
Пример #14
0
def clusters_create(data):
    return u.render(api.create_cluster(data).to_wrapped_dict())