Beispiel #1
0
 def test_get_cluster_list_cluster_template_not_exist(self):
     utils.create_test_cluster()
     self.assertEqual(1, len(self.dbapi.get_cluster_list(self.context)))
     res = self.dbapi.get_cluster_list(
         self.context,
         filters={'cluster_template_id': uuidutils.generate_uuid()})
     self.assertEqual(0, len(res))
Beispiel #2
0
 def test_get_all_cluster_stats(self):
     utils.create_test_cluster(id=1,
                               name='clusterone',
                               uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(id=2,
                               name='clustertwo',
                               uuid=uuidutils.generate_uuid())
     ret = self.dbapi.get_cluster_stats(self.context)
     self.assertEqual(ret, (2, 12))
Beispiel #3
0
 def test_get_all_cluster_stats(self):
     uuid1 = uuidutils.generate_uuid()
     utils.create_test_cluster(id=1, name='clusterone', uuid=uuid1)
     utils.create_nodegroups_for_cluster(cluster_id=uuid1)
     uuid2 = uuidutils.generate_uuid()
     utils.create_test_cluster(id=2, name='clustertwo', uuid=uuid2)
     utils.create_nodegroups_for_cluster(cluster_id=uuid2)
     ret = self.dbapi.get_cluster_stats(self.context)
     self.assertEqual(ret, (2, 12))
Beispiel #4
0
 def test_get_cluster_by_name_multiple_cluster(self):
     utils.create_test_cluster(id=1,
                               name='clusterone',
                               uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(id=2,
                               name='clusterone',
                               uuid=uuidutils.generate_uuid())
     self.assertRaises(exception.Conflict, self.dbapi.get_cluster_by_name,
                       self.context, 'clusterone')
Beispiel #5
0
 def test_get_all_cluster_stats(self):
     utils.create_test_cluster(
         id=1, name='clusterone',
         uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(
         id=2, name='clustertwo',
         uuid=uuidutils.generate_uuid())
     ret = self.dbapi.get_cluster_stats(self.context)
     self.assertEqual(ret, (2, 12))
Beispiel #6
0
 def test_get_one_tenant_cluster_stats(self):
     utils.create_test_cluster(
         id=1, name='clusterone', project_id='proj1',
         uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(
         id=2, name='clustertwo', project_id='proj2',
         uuid=uuidutils.generate_uuid())
     ret = self.dbapi.get_cluster_stats(self.context, 'proj2')
     self.assertEqual(ret, (1, 6))
Beispiel #7
0
 def test_get_cluster_by_name_multiple_cluster(self):
     utils.create_test_cluster(
         id=1, name='clusterone',
         uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(
         id=2, name='clusterone',
         uuid=uuidutils.generate_uuid())
     self.assertRaises(exception.Conflict,
                       self.dbapi.get_cluster_by_name,
                       self.context, 'clusterone')
Beispiel #8
0
 def test_get_one_tenant_cluster_stats(self):
     utils.create_test_cluster(id=1,
                               name='clusterone',
                               project_id='proj1',
                               uuid=uuidutils.generate_uuid())
     utils.create_test_cluster(id=2,
                               name='clustertwo',
                               project_id='proj2',
                               uuid=uuidutils.generate_uuid())
     ret = self.dbapi.get_cluster_stats(self.context, 'proj2')
     self.assertEqual(ret, (1, 6))
Beispiel #9
0
 def test_get_all_cluster_stats(self):
     uuid1 = uuidutils.generate_uuid()
     utils.create_test_cluster(
         id=1, name='clusterone',
         uuid=uuid1)
     utils.create_nodegroups_for_cluster(cluster_id=uuid1)
     uuid2 = uuidutils.generate_uuid()
     utils.create_test_cluster(
         id=2, name='clustertwo',
         uuid=uuid2)
     utils.create_nodegroups_for_cluster(cluster_id=uuid2)
     ret = self.dbapi.get_cluster_stats(self.context)
     self.assertEqual(ret, (2, 12))
Beispiel #10
0
 def test_get_one_tenant_cluster_stats(self):
     uuid1 = uuidutils.generate_uuid()
     utils.create_test_cluster(
         id=1, name='clusterone', project_id='proj1',
         uuid=uuid1)
     utils.create_nodegroups_for_cluster(
         cluster_id=uuid1, project_id='proj1')
     uuid2 = uuidutils.generate_uuid()
     utils.create_test_cluster(
         id=2, name='clustertwo', project_id='proj2',
         uuid=uuid2)
     utils.create_nodegroups_for_cluster(
         cluster_id=uuid2, project_id='proj2')
     ret = self.dbapi.get_cluster_stats(self.context, 'proj2')
     self.assertEqual(ret, (1, 6))
Beispiel #11
0
 def test_update_cluster(self):
     cluster = utils.create_test_cluster()
     old_nc = cluster.node_count
     new_nc = 5
     self.assertNotEqual(old_nc, new_nc)
     res = self.dbapi.update_cluster(cluster.id, {'node_count': new_nc})
     self.assertEqual(new_nc, res.node_count)
Beispiel #12
0
 def test_update_cluster(self):
     cluster = utils.create_test_cluster()
     old_status = cluster.status
     new_status = 'UPDATE_IN_PROGRESS'
     self.assertNotEqual(old_status, new_status)
     res = self.dbapi.update_cluster(cluster.id, {'status': new_status})
     self.assertEqual(new_status, res.status)
Beispiel #13
0
 def test_update_cluster(self):
     cluster = utils.create_test_cluster()
     old_status = cluster.status
     new_status = 'UPDATE_IN_PROGRESS'
     self.assertNotEqual(old_status, new_status)
     res = self.dbapi.update_cluster(cluster.id, {'status': new_status})
     self.assertEqual(new_status, res.status)
Beispiel #14
0
 def test_update_cluster(self):
     cluster = utils.create_test_cluster()
     old_nc = cluster.node_count
     new_nc = 5
     self.assertNotEqual(old_nc, new_nc)
     res = self.dbapi.update_cluster(cluster.id, {'node_count': new_nc})
     self.assertEqual(new_nc, res.node_count)
Beispiel #15
0
 def test_get_one_tenant_cluster_stats(self):
     uuid1 = uuidutils.generate_uuid()
     utils.create_test_cluster(id=1,
                               name='clusterone',
                               project_id='proj1',
                               uuid=uuid1)
     utils.create_nodegroups_for_cluster(cluster_id=uuid1,
                                         project_id='proj1')
     uuid2 = uuidutils.generate_uuid()
     utils.create_test_cluster(id=2,
                               name='clustertwo',
                               project_id='proj2',
                               uuid=uuid2)
     utils.create_nodegroups_for_cluster(cluster_id=uuid2,
                                         project_id='proj2')
     ret = self.dbapi.get_cluster_stats(self.context, 'proj2')
     self.assertEqual(ret, (1, 6))
Beispiel #16
0
 def test_destroy_cluster_by_uuid(self):
     cluster = utils.create_test_cluster()
     self.assertIsNotNone(
         self.dbapi.get_cluster_by_uuid(self.context, cluster.uuid))
     self.dbapi.destroy_cluster(cluster.uuid)
     self.assertRaises(exception.ClusterNotFound,
                       self.dbapi.get_cluster_by_uuid, self.context,
                       cluster.uuid)
Beispiel #17
0
 def test_get_cluster_list(self):
     uuids = []
     for i in range(1, 6):
         cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
         uuids.append(six.text_type(cluster['uuid']))
     res = self.dbapi.get_cluster_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Beispiel #18
0
 def test_destroy_cluster_by_uuid(self):
     cluster = utils.create_test_cluster()
     self.assertIsNotNone(self.dbapi.get_cluster_by_uuid(self.context,
                                                         cluster.uuid))
     self.dbapi.destroy_cluster(cluster.uuid)
     self.assertRaises(exception.ClusterNotFound,
                       self.dbapi.get_cluster_by_uuid, self.context,
                       cluster.uuid)
Beispiel #19
0
 def test_get_cluster_list(self):
     uuids = []
     for i in range(1, 6):
         cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
         uuids.append(six.text_type(cluster['uuid']))
     res = self.dbapi.get_cluster_list(self.context)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Beispiel #20
0
 def test_destroy_nodegroup_by_uuid(self):
     cluster = utils.create_test_cluster()
     nodegroup = utils.create_test_nodegroup()
     self.assertIsNotNone(self.dbapi.get_nodegroup_by_uuid(self.context,
                                                           cluster.uuid,
                                                           nodegroup.uuid))
     self.dbapi.destroy_nodegroup(cluster.uuid, nodegroup.uuid)
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_uuid, self.context,
                       cluster.uuid, nodegroup.uuid)
Beispiel #21
0
 def test_destroy_nodegroup_by_uuid(self):
     cluster = utils.create_test_cluster()
     nodegroup = utils.create_test_nodegroup()
     self.assertIsNotNone(
         self.dbapi.get_nodegroup_by_uuid(self.context, cluster.uuid,
                                          nodegroup.uuid))
     self.dbapi.destroy_nodegroup(cluster.uuid, nodegroup.uuid)
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_uuid, self.context,
                       cluster.uuid, nodegroup.uuid)
Beispiel #22
0
 def test_get_cluster_list_by_admin_all_tenants(self):
     uuids = []
     for i in range(1, 6):
         cluster = utils.create_test_cluster(
             uuid=uuidutils.generate_uuid(),
             project_id=uuidutils.generate_uuid(),
             user_id=uuidutils.generate_uuid())
         uuids.append(six.text_type(cluster['uuid']))
     ctx = context.make_admin_context(all_tenants=True)
     res = self.dbapi.get_cluster_list(ctx)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Beispiel #23
0
 def test_get_nodegroup_that_does_not_exist(self):
     # Create a cluster with no nodegroups
     cluster = utils.create_test_cluster()
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_id, self.context,
                       cluster.uuid, 100)
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_uuid, self.context,
                       cluster.uuid, '12345678-9999-0000-aaaa-123456789012')
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_name, self.context,
                       cluster.uuid, 'not_found')
Beispiel #24
0
 def test_get_cluster_list_by_admin_all_tenants(self):
     uuids = []
     for i in range(1, 6):
         cluster = utils.create_test_cluster(
             uuid=uuidutils.generate_uuid(),
             project_id=uuidutils.generate_uuid(),
             user_id=uuidutils.generate_uuid())
         uuids.append(six.text_type(cluster['uuid']))
     ctx = context.make_admin_context(all_tenants=True)
     res = self.dbapi.get_cluster_list(ctx)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids), sorted(res_uuids))
Beispiel #25
0
    def test_get_cluster_list_sorted(self):
        uuids = []
        for _ in range(5):
            cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
            uuids.append(six.text_type(cluster.uuid))
        res = self.dbapi.get_cluster_list(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.get_cluster_list,
                          self.context,
                          sort_key='foo')
Beispiel #26
0
    def test_get_cluster_list_sorted(self):
        uuids = []
        for _ in range(5):
            cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
            uuids.append(six.text_type(cluster.uuid))
        res = self.dbapi.get_cluster_list(self.context, sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.get_cluster_list,
                          self.context,
                          sort_key='foo')
Beispiel #27
0
 def test_get_nodegroup_that_does_not_exist(self):
     # Create a cluster with no nodegroups
     cluster = utils.create_test_cluster()
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_id,
                       self.context, cluster.uuid,  100)
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_uuid,
                       self.context, cluster.uuid,
                       '12345678-9999-0000-aaaa-123456789012')
     self.assertRaises(exception.NodeGroupNotFound,
                       self.dbapi.get_nodegroup_by_name,
                       self.context, cluster.uuid, 'not_found')
Beispiel #28
0
    def test_get_cluster_list_sorted(self):
        uuids = []
        cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
        for i in range(5):
            ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                             name='test%(id)s' % {'id': i},
                                             cluster_id=cluster.uuid)
            uuids.append(ng.uuid)
        res = self.dbapi.list_cluster_nodegroups(self.context, cluster.uuid,
                                                 sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.list_cluster_nodegroups,
                          self.context,
                          cluster.uuid,
                          sort_key='not-there')
Beispiel #29
0
    def test_get_cluster_list_sorted(self):
        uuids = []
        cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
        for i in range(5):
            ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                             name='test%(id)s' % {'id': i},
                                             cluster_id=cluster.uuid)
            uuids.append(ng.uuid)
        res = self.dbapi.list_cluster_nodegroups(self.context,
                                                 cluster.uuid,
                                                 sort_key='uuid')
        res_uuids = [r.uuid for r in res]
        self.assertEqual(sorted(uuids), res_uuids)

        self.assertRaises(exception.InvalidParameterValue,
                          self.dbapi.list_cluster_nodegroups,
                          self.context,
                          cluster.uuid,
                          sort_key='not-there')
Beispiel #30
0
 def test_get_nodegroups_in_cluster(self):
     uuids_in_cluster = []
     uuids_not_in_cluster = []
     cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
     for i in range(2):
         ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                          name='test%(id)s' % {'id': i},
                                          cluster_id=cluster.uuid)
         uuids_in_cluster.append(ng.uuid)
     for i in range(2):
         ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                          name='test%(id)s' % {'id': i},
                                          cluster_id='fake_cluster')
         uuids_not_in_cluster.append(ng.uuid)
     res = self.dbapi.list_cluster_nodegroups(self.context, cluster.uuid)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids_in_cluster), sorted(res_uuids))
     for uuid in uuids_not_in_cluster:
         self.assertNotIn(uuid, res_uuids)
Beispiel #31
0
 def test_get_nodegroups_in_cluster(self):
     uuids_in_cluster = []
     uuids_not_in_cluster = []
     cluster = utils.create_test_cluster(uuid=uuidutils.generate_uuid())
     for i in range(2):
         ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                          name='test%(id)s' % {'id': i},
                                          cluster_id=cluster.uuid)
         uuids_in_cluster.append(ng.uuid)
     for i in range(2):
         ng = utils.create_test_nodegroup(uuid=uuidutils.generate_uuid(),
                                          name='test%(id)s' % {'id': i},
                                          cluster_id='fake_cluster')
         uuids_not_in_cluster.append(ng.uuid)
     res = self.dbapi.list_cluster_nodegroups(self.context, cluster.uuid)
     res_uuids = [r.uuid for r in res]
     self.assertEqual(sorted(uuids_in_cluster), sorted(res_uuids))
     for uuid in uuids_not_in_cluster:
         self.assertNotIn(uuid, res_uuids)
Beispiel #32
0
 def test_create_cluster_already_exists(self):
     utils.create_test_cluster()
     self.assertRaises(exception.ClusterAlreadyExists,
                       utils.create_test_cluster)
Beispiel #33
0
 def test_create_cluster_nullable_cluster_template_id(self):
     utils.create_test_cluster(cluster_template_id=None)
Beispiel #34
0
 def test_create_cluster(self):
     utils.create_test_cluster()
Beispiel #35
0
 def test_update_cluster_uuid(self):
     cluster = utils.create_test_cluster()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_cluster, cluster.id,
                       {'uuid': ''})
Beispiel #36
0
    def test_get_cluster_list_with_filters(self):
        ct1 = utils.get_test_cluster_template(id=1,
                                              uuid=uuidutils.generate_uuid())
        ct2 = utils.get_test_cluster_template(id=2,
                                              uuid=uuidutils.generate_uuid())
        self.dbapi.create_cluster_template(ct1)
        self.dbapi.create_cluster_template(ct2)

        cluster1 = utils.create_test_cluster(
            name='cluster-one',
            uuid=uuidutils.generate_uuid(),
            cluster_template_id=ct1['uuid'],
            status=cluster_status.CREATE_IN_PROGRESS)
        cluster2 = utils.create_test_cluster(
            name='cluster-two',
            uuid=uuidutils.generate_uuid(),
            cluster_template_id=ct2['uuid'],
            node_count=1,
            master_count=1,
            status=cluster_status.UPDATE_IN_PROGRESS)
        cluster3 = utils.create_test_cluster(
            name='cluster-three',
            node_count=2,
            master_count=5,
            status=cluster_status.DELETE_IN_PROGRESS)

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct1['uuid']})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct2['uuid']})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'cluster-one'})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'bad-cluster'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        filters = {
            'status': [
                cluster_status.CREATE_IN_PROGRESS,
                cluster_status.DELETE_IN_PROGRESS
            ]
        }
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual([cluster1.id, cluster3.id], [r.id for r in res])
Beispiel #37
0
 def test_create_cluster(self):
     utils.create_test_cluster()
Beispiel #38
0
 def test_create_cluster_already_exists(self):
     utils.create_test_cluster()
     self.assertRaises(exception.ClusterAlreadyExists,
                       utils.create_test_cluster)
Beispiel #39
0
    def test_get_cluster_list_with_filters(self):
        ct1 = utils.get_test_cluster_template(id=1,
                                              uuid=uuidutils.generate_uuid())
        ct2 = utils.get_test_cluster_template(id=2,
                                              uuid=uuidutils.generate_uuid())
        self.dbapi.create_cluster_template(ct1)
        self.dbapi.create_cluster_template(ct2)

        cluster1 = utils.create_test_cluster(
            name='cluster-one',
            uuid=uuidutils.generate_uuid(),
            cluster_template_id=ct1['uuid'],
            status=cluster_status.CREATE_IN_PROGRESS)
        cluster2 = utils.create_test_cluster(
            name='cluster-two',
            uuid=uuidutils.generate_uuid(),
            cluster_template_id=ct2['uuid'],
            node_count=1,
            master_count=1,
            status=cluster_status.UPDATE_IN_PROGRESS)
        cluster3 = utils.create_test_cluster(
            name='cluster-three',
            node_count=2,
            master_count=5,
            status=cluster_status.DELETE_IN_PROGRESS)

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct1['uuid']})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct2['uuid']})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'cluster-one'})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'bad-cluster'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        filters = {'status': [cluster_status.CREATE_IN_PROGRESS,
                              cluster_status.DELETE_IN_PROGRESS]}
        res = self.dbapi.get_cluster_list(self.context,
                                          filters=filters)
        self.assertEqual([cluster1.id, cluster3.id], [r.id for r in res])
Beispiel #40
0
 def test_get_cluster_by_uuid(self):
     cluster = utils.create_test_cluster()
     res = self.dbapi.get_cluster_by_uuid(self.context, cluster.uuid)
     self.assertEqual(cluster.id, res.id)
     self.assertEqual(cluster.uuid, res.uuid)
Beispiel #41
0
    def test_get_cluster_list_with_filters(self):
        ct1 = utils.get_test_cluster_template(id=1,
                                              uuid=uuidutils.generate_uuid())
        ct2 = utils.get_test_cluster_template(id=2,
                                              uuid=uuidutils.generate_uuid())
        self.dbapi.create_cluster_template(ct1)
        self.dbapi.create_cluster_template(ct2)

        uuid1 = uuidutils.generate_uuid()
        cluster1 = utils.create_test_cluster(
            name='cluster-one',
            uuid=uuid1,
            cluster_template_id=ct1['uuid'],
            status=cluster_status.CREATE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(cluster_id=uuid1)
        uuid2 = uuidutils.generate_uuid()
        cluster2 = utils.create_test_cluster(
            name='cluster-two',
            uuid=uuid2,
            cluster_template_id=ct2['uuid'],
            status=cluster_status.UPDATE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(cluster_id=uuid2,
                                            node_count=1,
                                            master_count=1)
        cluster3 = utils.create_test_cluster(
            name='cluster-three', status=cluster_status.DELETE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(node_count=2, master_count=5)

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct1['uuid']})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct2['uuid']})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'cluster-one'})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'bad-cluster'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        # Check that both filters have to be valid
        filters = {'master_count': 1, 'node_count': 1}
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual([cluster2.id], [r.id for r in res])

        filters = {'master_count': 1, 'node_count': 2}
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual(0, len(res))

        filters = {
            'status': [
                cluster_status.CREATE_IN_PROGRESS,
                cluster_status.DELETE_IN_PROGRESS
            ]
        }
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual([cluster1.id, cluster3.id], [r.id for r in res])
Beispiel #42
0
 def test_update_cluster_uuid(self):
     cluster = utils.create_test_cluster()
     self.assertRaises(exception.InvalidParameterValue,
                       self.dbapi.update_cluster, cluster.id, {'uuid': ''})
 def test_destroy_cluster_template_that_referenced_by_clusters(self):
     ct = utils.create_test_cluster_template()
     cluster = utils.create_test_cluster(cluster_template_id=ct['uuid'])
     self.assertEqual(ct['uuid'], cluster.cluster_template_id)
     self.assertRaises(exception.ClusterTemplateReferenced,
                       self.dbapi.destroy_cluster_template, ct['id'])
Beispiel #44
0
 def test_get_cluster_by_uuid(self):
     cluster = utils.create_test_cluster()
     res = self.dbapi.get_cluster_by_uuid(self.context, cluster.uuid)
     self.assertEqual(cluster.id, res.id)
     self.assertEqual(cluster.uuid, res.uuid)
Beispiel #45
0
 def test_get_cluster_list_cluster_template_not_exist(self):
     utils.create_test_cluster()
     self.assertEqual(1, len(self.dbapi.get_cluster_list(self.context)))
     res = self.dbapi.get_cluster_list(self.context, filters={
         'cluster_template_id': uuidutils.generate_uuid()})
     self.assertEqual(0, len(res))
Beispiel #46
0
 def test_create_cluster_nullable_cluster_template_id(self):
     utils.create_test_cluster(cluster_template_id=None)
 def test_destroy_cluster_template_that_referenced_by_clusters(self):
     ct = utils.create_test_cluster_template()
     cluster = utils.create_test_cluster(cluster_template_id=ct['uuid'])
     self.assertEqual(ct['uuid'], cluster.cluster_template_id)
     self.assertRaises(exception.ClusterTemplateReferenced,
                       self.dbapi.destroy_cluster_template, ct['id'])
Beispiel #48
0
    def test_get_cluster_list_with_filters(self):
        ct1 = utils.get_test_cluster_template(id=1,
                                              uuid=uuidutils.generate_uuid())
        ct2 = utils.get_test_cluster_template(id=2,
                                              uuid=uuidutils.generate_uuid())
        self.dbapi.create_cluster_template(ct1)
        self.dbapi.create_cluster_template(ct2)

        uuid1 = uuidutils.generate_uuid()
        cluster1 = utils.create_test_cluster(
            name='cluster-one',
            uuid=uuid1,
            cluster_template_id=ct1['uuid'],
            status=cluster_status.CREATE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(cluster_id=uuid1)
        uuid2 = uuidutils.generate_uuid()
        cluster2 = utils.create_test_cluster(
            name='cluster-two',
            uuid=uuid2,
            cluster_template_id=ct2['uuid'],
            status=cluster_status.UPDATE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(
            cluster_id=uuid2, node_count=1, master_count=1)
        cluster3 = utils.create_test_cluster(
            name='cluster-three',
            status=cluster_status.DELETE_IN_PROGRESS)
        utils.create_nodegroups_for_cluster(
            node_count=2, master_count=5)

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct1['uuid']})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(
            self.context, filters={'cluster_template_id': ct2['uuid']})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'cluster-one'})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'name': 'bad-cluster'})
        self.assertEqual([], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'node_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 3})
        self.assertEqual([cluster1.id], [r.id for r in res])

        res = self.dbapi.get_cluster_list(self.context,
                                          filters={'master_count': 1})
        self.assertEqual([cluster2.id], [r.id for r in res])

        # Check that both filters have to be valid
        filters = {'master_count': 1, 'node_count': 1}
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual([cluster2.id], [r.id for r in res])

        filters = {'master_count': 1, 'node_count': 2}
        res = self.dbapi.get_cluster_list(self.context, filters=filters)
        self.assertEqual(0, len(res))

        filters = {'status': [cluster_status.CREATE_IN_PROGRESS,
                              cluster_status.DELETE_IN_PROGRESS]}
        res = self.dbapi.get_cluster_list(self.context,
                                          filters=filters)
        self.assertEqual([cluster1.id, cluster3.id], [r.id for r in res])