def _create_database_structure(cls): mysql_host = settings.DB_HOST mysql_port = settings.DB_PORT or 3306 cls.mysql_endpoint = '{}:{}'.format(mysql_host, mysql_port) cls.engine_type = factory_physical.EngineTypeFactory(name='mysql') cls.engine = factory_physical.EngineFactory( engine_type=cls.engine_type) cls.disk_offering = factory_physical.DiskOfferingFactory( size_kb=524288) cls.plan = factory_physical.PlanFactory( disk_offering=cls.disk_offering, engine=cls.engine) cls.databaseinfra = factory_physical.DatabaseInfraFactory( name="__test__ mysqlinfra2", user="******", password=settings.DB_PASSWORD, endpoint=cls.mysql_endpoint, engine=cls.engine, disk_offering=cls.disk_offering, plan=cls.plan) cls.hostname = factory_physical.HostFactory() cls.instance = factory_physical.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, instance_type=Instance.MYSQL, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=cls.databaseinfra, ) cls.nfsaas_host_attr = factory_physical.NFSaaSHostAttr( host=cls.hostname, # nfsaas_size_kb=cls.database.total_size_in_kb, nfsaas_used_size_kb=cls.database.used_size_in_kb)
def test_can_update_disk_kb(self): nfsaas_host = physical_factory.NFSaaSHostAttr() nfsaas_host.host = self.instance.hostname nfsaas_host.save() old_size = nfsaas_host.nfsaas_size_kb old_used_size = nfsaas_host.nfsaas_used_size_kb self.assertIsNone(self.task.details) is_updated = update_disk(database=self.database, task=self.task, address=self.instance.address, used_size=300, total_size=100) self.assertTrue(is_updated) expected_message = UPDATE_USED_SIZE_SUCCESS.format( nfsaas_host.nfsaas_path_host) self.assertEqual(expected_message, self.task.details) nfsaas_host = HostAttr.objects.get(pk=nfsaas_host.pk) self.assertNotEqual(nfsaas_host.nfsaas_size_kb, old_size) self.assertNotEqual(nfsaas_host.nfsaas_used_size_kb, old_used_size) self.assertEqual(nfsaas_host.nfsaas_size_kb, 100) self.assertEqual(nfsaas_host.nfsaas_used_size_kb, 300)
def setUpClass(cls): cls.databaseinfra = factory.DatabaseInfraFactory( name="__test__ mysqlinfra", user="******", password='******') cls.hostname = factory.HostFactory() cls.instance = factory.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.nfaas_host_attr = factory.NFSaaSHostAttr(host=cls.hostname) cs_offering = factory.CloudStackOfferingFactory(memory_size_mb=9) cls.infra_offering = factory.DatabaseInfraOfferingFactory( databaseinfra=cls.databaseinfra, offering=cs_offering)
def test_can_update_nfsaas_used_disk_size(self): database = factory.DatabaseFactory() database.databaseinfra = self.databaseinfra nfsaas_host = physical_factory.NFSaaSHostAttr() nfsaas_host.host = self.instance.hostname nfsaas_host.save() old_used_size = nfsaas_host.nfsaas_used_size_kb nfsaas_host = database.update_host_disk_used_size( host_address=self.instance.address, used_size_kb=300) self.assertNotEqual(nfsaas_host.nfsaas_used_size_kb, old_used_size) self.assertEqual(nfsaas_host.nfsaas_used_size_kb, 300) old_used_size = nfsaas_host.nfsaas_used_size_kb nfsaas_host = database.update_host_disk_used_size( host_address=self.instance.address, used_size_kb=500) self.assertNotEqual(nfsaas_host.nfsaas_used_size_kb, old_used_size) self.assertEqual(nfsaas_host.nfsaas_used_size_kb, 500)
def setUp(self): host = self.host or '127.0.0.1' port = self.port or 3306 self.infra_endpoint = '{}:{}'.format(host, port) self.databaseinfra = factory_physical.DatabaseInfraFactory( password=self.db_password, endpoint="{}:{}".format(host, port), engine__engine_type__name=self.engine_name, user=self.db_user ) hostname = factory_physical.HostFactory() self.nfsaas_host_attr = factory_physical.NFSaaSHostAttr( host=hostname, nfsaas_used_size_kb=float(40.0/1024.0) ) self.instances = self.instance_helper.create_instances_by_quant( infra=self.databaseinfra, port=self.port, qt=self.instances_quantity, total_size_in_bytes=0, used_size_in_bytes=0, instance_type=self.instance_type, hostname=hostname ) self.instance = self.instances[0] self.instance_endpoint = "{}:{}".format(self.instance.address, self.instance.port) self.driver = self.driver_class(databaseinfra=self.databaseinfra) self._driver_client = None
def _create_database_structure(cls): mysql_host = settings.DB_HOST mysql_port = settings.DB_PORT or 3306 cls.mysql_endpoint = '{}:{}'.format(mysql_host, mysql_port) cls.engine_type = factory_physical.EngineTypeFactory( name=cls.ENGINE ) cls.engine = factory_physical.EngineFactory( engine_type=cls.engine_type ) cls.disk_offering = factory_physical.DiskOfferingFactory( size_kb=524288 ) cls.plan = factory_physical.PlanFactory( disk_offering=cls.disk_offering, engine=cls.engine ) cls.databaseinfra = factory_physical.DatabaseInfraFactory( name="__test__ mysqlinfra2", user="******", password=settings.DB_PASSWORD, endpoint=cls.mysql_endpoint, engine=cls.engine, disk_offering=cls.disk_offering, plan=cls.plan) cls.hostname = factory_physical.HostFactory() cls.instances = cls.instance_helper.create_instances_by_quant( instance_type=Instance.MYSQL, qt=cls.instances_quantity, infra=cls.databaseinfra, hostname=cls.hostname ) cls.instance = cls.instances[0] cls.database = factory_logical.DatabaseFactory( name='test_db_1', databaseinfra=cls.databaseinfra, ) cls.nfsaas_host_attr = factory_physical.NFSaaSHostAttr( host=cls.hostname, nfsaas_used_size_kb=cls.database.used_size_in_kb )
def setUpClass(cls, instances_mock): cls.databaseinfra = factory.DatabaseInfraFactory( name="__test__ mysqlinfra", user="******", password='******') cls.hostname = factory.HostFactory() cls.instance = factory.InstanceFactory( address="new_instance.localinstance", port=123, is_active=True, databaseinfra=cls.databaseinfra, hostname=cls.hostname) cls.nfaas_host_attr = factory.NFSaaSHostAttr(host=cls.hostname) cs_offering = factory.CloudStackOfferingFactory(memory_size_mb=9) cls.infra_offering = factory.DatabaseInfraOfferingFactory( databaseinfra=cls.databaseinfra, offering=cs_offering) instances_mock.return_value = [cls.instance] factory.PlanAttrFactory.create(plan=cls.databaseinfra.plan) cls.instance.hostname.offering = cs_offering cls.instance.hostname.save() offering = cls.databaseinfra.offering offering.memory_size_mb = 9 offering.save() cls.databaseinfra.plan.provider = 1 cls.databaseinfra.plan.save()