Пример #1
0
    def test_create_duplicate_leases(self):
        """Create two leases with same names, and checks it raises an error."""

        db_api.lease_create(_get_fake_phys_lease_values())
        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create,
                          _get_fake_phys_lease_values())
Пример #2
0
    def test_create_duplicate_leases(self):
        """Create two leases with same names, and checks it raises an error.
        """

        db_api.lease_create(_get_fake_phys_lease_values())
        self.assertRaises(RuntimeError, db_api.lease_create,
                          _get_fake_phys_lease_values())
Пример #3
0
    def test_create_duplicate_leases(self):
        """Create two leases with same names, and checks it raises an error.
        """

        db_api.lease_create(_get_fake_phys_lease_values())
        self.assertRaises(RuntimeError, db_api.lease_create,
                          _get_fake_phys_lease_values())
Пример #4
0
 def test_model_query(self):
     db_api.lease_create(_get_fake_virt_lease_values())
     query = db_api.model_query(models.Lease, project_only=None)
     self.assertEqual(1, len(query.all()))
     query = db_api.model_query(models.Lease, project_only=True)
     self.assertEqual(1, len(query.all()))
     self.set_context(context.ClimateContext(user_id="fake", tenant_id="wrong"))
     query = db_api.model_query(models.Lease, project_only=True)
     self.assertEqual(0, len(query.all()))
Пример #5
0
    def test_create_leases_with_duplicated_reservation(self):
        """Check duplicated reservation create

        Create two leases with a duplicated reservation,
        and checks it raises an error.
        """
        lease_values = _get_fake_phys_lease_values()

        db_api.lease_create(lease_values)

        lease_values['id'] = _get_fake_random_uuid()
        lease_values['name'] = 'duplicated_reservation'

        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create, lease_values)
Пример #6
0
    def test_create_leases_with_duplicated_reservation(self):
        """Check duplicated reservation create

        Create two leases with a duplicated reservation,
        and checks it raises an error.
        """
        lease_values = _get_fake_phys_lease_values()

        db_api.lease_create(lease_values)

        lease_values['id'] = _get_fake_random_uuid()
        lease_values['name'] = 'duplicated_reservation'

        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create,
                          lease_values)
Пример #7
0
def _create_physical_lease(values=_get_fake_phys_lease_values(),
                           random=False):
    """Creating fake lease having a single physical resource."""
    if random is True:
        values = _get_fake_phys_lease_values(id=_get_fake_random_uuid(),
                                             name=_get_fake_random_uuid())
    lease = db_api.lease_create(values)
    phys_res = _get_fake_phys_reservation_values()
    for reservation in db_api.reservation_get_all_by_lease_id(lease['id']):
        allocation_values = {
            'id': _get_fake_random_uuid(),
            'compute_host_id': values['reservations'][0]['resource_id'],
            'reservation_id': reservation['id']
        }
        db_api.host_allocation_create(allocation_values)
        computehost_reservations = {
            'id': _get_fake_random_uuid(),
            'reservation_id': values['reservations'][0]['id'],
            'resource_properties': phys_res['resource_properties'],
            'hypervisor_properties': phys_res['hypervisor_properties'],
            'count_range': "{0} - {1}".format(phys_res['min'],
                                              phys_res['max'])
        }
        db_api.host_reservation_create(computehost_reservations)
    return lease
Пример #8
0
def _create_physical_lease(values=_get_fake_phys_lease_values(),
                           random=False):
    """Creating fake lease having a single physical resource."""
    if random is True:
        values = _get_fake_phys_lease_values(id=_get_fake_random_uuid(),
                                             name=_get_fake_random_uuid())
    return db_api.lease_create(values)
Пример #9
0
    def test_create_lease_with_event(self):
        """Create a lease including a fake event and check all tables."""

        lease = _get_fake_phys_lease_values()
        lease["events"].append(_get_fake_event_values(lease_id=lease["id"]))
        result = db_api.lease_create(lease)
        self.assertEqual(result["name"], _get_fake_phys_lease_values()["name"])
        self.assertEqual(1, len(db_api.event_get_all()))
Пример #10
0
    def test_create_lease_with_event(self):
        """Create a lease including a fake event and check all tables."""

        lease = _get_fake_phys_lease_values()
        lease['events'].append(_get_fake_event_values(lease_id=lease['id']))
        result = db_api.lease_create(lease)
        self.assertEqual(result['name'], _get_fake_phys_lease_values()['name'])
        self.assertEqual(1, len(db_api.event_get_all()))
Пример #11
0
    def test_create_leases_with_duplicated_event(self):
        """Check duplicated event create

        Create two leases with a duplicated event,
        and checks it raises an error.
        """
        lease_values = _get_fake_phys_lease_values()
        lease_values['events'] = [_get_fake_event_values()]

        db_api.lease_create(lease_values)

        lease_values['id'] = _get_fake_random_uuid()
        lease_values['name'] = 'duplicated_event'
        lease_values['reservations'][0]['id'] = _get_fake_random_uuid()

        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create, lease_values)
Пример #12
0
    def test_create_leases_with_duplicated_event(self):
        """Check duplicated event create

        Create two leases with a duplicated event,
        and checks it raises an error.
        """
        lease_values = _get_fake_phys_lease_values()
        lease_values['events'] = [_get_fake_event_values()]

        db_api.lease_create(lease_values)

        lease_values['id'] = _get_fake_random_uuid()
        lease_values['name'] = 'duplicated_event'
        lease_values['reservations'][0]['id'] = _get_fake_random_uuid()

        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create,
                          lease_values)
Пример #13
0
    def test_create_phys_lease(self):
        """Create a physical lease and verify that all tables have been
        populated.
        """

        result = db_api.lease_create(_get_fake_phys_lease_values())
        self.assertEqual(result["name"], _get_fake_phys_lease_values()["name"])
        self.assertEqual(0, len(db_api.event_get_all()))
        self.assertEqual(1, len(db_api.reservation_get_all()))
Пример #14
0
    def test_create_phys_lease(self):
        """Create a physical lease and verify that all tables have been
        populated.
        """

        result = db_api.lease_create(_get_fake_phys_lease_values())
        self.assertEquals(result['name'],
                          _get_fake_phys_lease_values()['name'])
        self.assertEqual(0, len(db_api.event_get_all()))
        self.assertEqual(1, len(db_api.reservation_get_all()))
Пример #15
0
    def test_create_virt_lease(self):
        """Check virtual lease create

        Create a virtual lease and verify that all tables have been
        populated.
        """

        result = db_api.lease_create(_get_fake_virt_lease_values())
        self.assertEqual(result['name'],
                         _get_fake_virt_lease_values()['name'])
        self.assertEqual(0, len(db_api.event_get_all()))
        self.assertEqual(1, len(db_api.reservation_get_all()))
Пример #16
0
def _create_physical_lease(values=_get_fake_phys_lease_values(),
                           random=False):
    """Creating fake lease having a single physical resource."""
    if random is True:
        values = _get_fake_phys_lease_values(id=_get_fake_random_uuid(),
                                             name=_get_fake_random_uuid())
    lease = db_api.lease_create(values)
    for reservation in db_api.reservation_get_all_by_lease_id(lease['id']):
        allocation_values = {
            'id': _get_fake_random_uuid(),
            'compute_host_id': values['reservations'][0]['resource_id'],
            'reservation_id': reservation['id']
        }
        db_api.host_allocation_create(allocation_values)
    return lease
Пример #17
0
def _create_physical_lease(values=_get_fake_phys_lease_values(), random=False):
    """Creating fake lease having a single physical resource."""
    if random is True:
        values = _get_fake_phys_lease_values(id=_get_fake_random_uuid(),
                                             name=_get_fake_random_uuid())
    lease = db_api.lease_create(values)
    phys_res = _get_fake_phys_reservation_values()
    for reservation in db_api.reservation_get_all_by_lease_id(lease['id']):
        allocation_values = {
            'id': _get_fake_random_uuid(),
            'compute_host_id': values['reservations'][0]['resource_id'],
            'reservation_id': reservation['id']
        }
        db_api.host_allocation_create(allocation_values)
        computehost_reservations = {
            'id': _get_fake_random_uuid(),
            'reservation_id': values['reservations'][0]['id'],
            'resource_properties': phys_res['resource_properties'],
            'hypervisor_properties': phys_res['hypervisor_properties'],
            'count_range': "{0} - {1}".format(phys_res['min'], phys_res['max'])
        }
        db_api.host_reservation_create(computehost_reservations)
    return lease
Пример #18
0
 def test_model_query(self):
     lease = db_api.lease_create(_get_fake_virt_lease_values())
     query = db_api.model_query(models.Lease)
     self.assertEqual([lease.to_dict()], [l.to_dict() for l in query.all()])
Пример #19
0
def _create_virtual_lease(values=_get_fake_virt_lease_values(),
                          random=False):
    """Creating fake lease having a single virtual resource."""
    return db_api.lease_create(values)
Пример #20
0
    def test_create_duplicate_leases(self):
        """Create two leases with same names, and checks it raises an error."""

        db_api.lease_create(_get_fake_phys_lease_values())
        self.assertRaises(db_exceptions.ClimateDBDuplicateEntry,
                          db_api.lease_create, _get_fake_phys_lease_values())
Пример #21
0
def _create_virtual_lease(values=_get_fake_virt_lease_values(), random=False):
    """Creating fake lease having a single virtual resource."""
    return db_api.lease_create(values)
Пример #22
0
def _create_physical_lease(values=_get_fake_phys_lease_values(), random=False):
    """Creating fake lease having a single physical resource."""
    if random is True:
        values = _get_fake_phys_lease_values(id=_get_fake_random_uuid(),
                                             name=_get_fake_random_uuid())
    return db_api.lease_create(values)
Пример #23
0
 def test_model_query(self):
     lease = db_api.lease_create(_get_fake_virt_lease_values())
     query = db_api.model_query(models.Lease)
     self.assertEqual([lease.to_dict()], [l.to_dict() for l in query.all()])